incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aaven...@apache.org
Subject [11/11] git commit: BLUR-356 cache most calls to blur for a few seconds
Date Fri, 15 Aug 2014 03:25:22 GMT
BLUR-356 cache most calls to blur for a few seconds


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/04261d3c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/04261d3c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/04261d3c

Branch: refs/heads/master
Commit: 04261d3cbd605718f609370234f85bd726791427
Parents: 00c9bf9
Author: Andrew Avenoso <andrew.va@gmail.com>
Authored: Thu Aug 14 23:23:20 2014 -0400
Committer: Andrew Avenoso <andrew.va@gmail.com>
Committed: Thu Aug 14 23:23:20 2014 -0400

----------------------------------------------------------------------
 .../org/apache/blur/console/JettyServer.java    |  17 +-
 .../blur/console/filters/LoggedInFilter.java    |   2 +-
 .../console/servlets/JavascriptServlet.java     |  35 +++
 .../blur/console/util/CachingBlurClient.java    | 281 +++++++++++++++++++
 .../org/apache/blur/console/util/Config.java    |  38 ++-
 .../org/apache/blur/console/util/NodeUtil.java  |   2 +
 .../org/apache/blur/console/util/QueryUtil.java |  12 +-
 .../org/apache/blur/console/util/TableUtil.java |  20 +-
 blur-console/src/main/webapp/Gruntfile.js       |   2 +-
 blur-console/src/main/webapp/index.html         |   1 +
 .../src/main/webapp/js/blurconsole.model.js     |   8 +-
 blur-console/src/main/webapp/public/index.html  |   3 +-
 ...rconsole.2a826151959859ac6ba1bdd17da01ee1.js |  27 ++
 ...rconsole.4cb08879ff9d1303a1e4e10f29a09c14.js |  27 --
 ...rconsole.b3b55f3b66f68d99a652d8034e0d53a4.js |  27 --
 .../src/main/webapp/public/js/blurconsole.js    |   6 +-
 ...sole.js.2d04b49d3f00a8ce62d30d6b682d3561.map |   1 -
 ...sole.js.581ce85b04ad8d3441a0a291e9a3aac4.map |   1 +
 ...sole.js.73b9e36b2f0e79be60aa19df31137f02.map |   1 -
 .../main/webapp/public/js/blurconsole.js.map    |   2 +-
 .../apache/blur/console/ConsoleTestBase.java    |   1 +
 .../apache/blur/console/util/QueryUtilTest.java |   8 +-
 .../apache/blur/console/util/TableUtilTest.java |  10 +-
 23 files changed, 416 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/04261d3c/blur-console/src/main/java/org/apache/blur/console/JettyServer.java
----------------------------------------------------------------------
diff --git a/blur-console/src/main/java/org/apache/blur/console/JettyServer.java b/blur-console/src/main/java/org/apache/blur/console/JettyServer.java
index bb9ac0a..41c772b 100644
--- a/blur-console/src/main/java/org/apache/blur/console/JettyServer.java
+++ b/blur-console/src/main/java/org/apache/blur/console/JettyServer.java
@@ -73,13 +73,16 @@ public class JettyServer {
     server.setHandler(new WebAppContext(warUrlString, CONTEXTPATH));
 
     // for localhost:port/service/dashboard, etc.
-    final Context context = new Context(server, "/service", Context.SESSIONS);
-    context.addServlet(AuthServlet.class, "/auth/*");
-    context.addServlet(NodesServlet.class, "/nodes/*");
-    context.addServlet(TablesServlet.class, "/tables/*");
-    context.addServlet(QueriesServlet.class, "/queries/*");
-    context.addServlet(SearchServlet.class, "/search/*");
-    context.addFilter(LoggedInFilter.class, "/*", Handler.REQUEST);
+    Context serviceContext = new Context(server, "/service", Context.SESSIONS);
+    serviceContext.addServlet(AuthServlet.class, "/auth/*");
+    serviceContext.addServlet(NodesServlet.class, "/nodes/*");
+    serviceContext.addServlet(TablesServlet.class, "/tables/*");
+    serviceContext.addServlet(QueriesServlet.class, "/queries/*");
+    serviceContext.addServlet(SearchServlet.class, "/search/*");
+    serviceContext.addServlet(JavascriptServlet.class, "/config.js");
+    serviceContext.addFilter(LoggedInFilter.class, "/*", Handler.REQUEST);
+
+
 
     System.out.println("started server on http://localhost:" + port + CONTEXTPATH);
     try {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/04261d3c/blur-console/src/main/java/org/apache/blur/console/filters/LoggedInFilter.java
----------------------------------------------------------------------
diff --git a/blur-console/src/main/java/org/apache/blur/console/filters/LoggedInFilter.java
b/blur-console/src/main/java/org/apache/blur/console/filters/LoggedInFilter.java
index bc2f4dc..52372f3 100644
--- a/blur-console/src/main/java/org/apache/blur/console/filters/LoggedInFilter.java
+++ b/blur-console/src/main/java/org/apache/blur/console/filters/LoggedInFilter.java
@@ -39,7 +39,7 @@ public class LoggedInFilter implements Filter {
     HttpSession session = request.getSession();
     String path = request.getServletPath();
     User user = (User) session.getAttribute("user");
-    if(path.startsWith("/auth") || user != null) {
+    if(path.startsWith("/auth") || path.startsWith("/config.js") || user != null) {
       try {
         filterChain.doFilter(servletRequest, servletResponse);
       } catch(UnauthorizedException e) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/04261d3c/blur-console/src/main/java/org/apache/blur/console/servlets/JavascriptServlet.java
----------------------------------------------------------------------
diff --git a/blur-console/src/main/java/org/apache/blur/console/servlets/JavascriptServlet.java
b/blur-console/src/main/java/org/apache/blur/console/servlets/JavascriptServlet.java
new file mode 100644
index 0000000..ef99ee3
--- /dev/null
+++ b/blur-console/src/main/java/org/apache/blur/console/servlets/JavascriptServlet.java
@@ -0,0 +1,35 @@
+package org.apache.blur.console.servlets;
+
+import org.apache.blur.console.util.Config;
+import org.apache.blur.console.util.HttpUtil;
+import org.codehaus.jackson.map.ObjectMapper;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class JavascriptServlet  extends BaseConsoleServlet {
+  @Override
+  protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,
IOException {
+    String javascript = "blurconsole.config = {refreshtime: " + Config.getInt("blur.console.refreshtime",
Config.DEFAULT_REFRESH_TIME) + "}";
+    HttpUtil.sendResponse(res, javascript, HttpUtil.TEXT);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/04261d3c/blur-console/src/main/java/org/apache/blur/console/util/CachingBlurClient.java
----------------------------------------------------------------------
diff --git a/blur-console/src/main/java/org/apache/blur/console/util/CachingBlurClient.java
b/blur-console/src/main/java/org/apache/blur/console/util/CachingBlurClient.java
new file mode 100644
index 0000000..c2a9d63
--- /dev/null
+++ b/blur-console/src/main/java/org/apache/blur/console/util/CachingBlurClient.java
@@ -0,0 +1,281 @@
+package org.apache.blur.console.util;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.blur.thirdparty.thrift_0_9_0.TException;
+import org.apache.blur.thrift.BlurClient;
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.BlurQueryStatus;
+import org.apache.blur.thrift.generated.Schema;
+import org.apache.blur.thrift.generated.TableDescriptor;
+import org.apache.blur.thrift.generated.TableStats;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.*;
+
+public class CachingBlurClient {
+
+  private final int timeout;
+  private final Log log = LogFactory.getLog(CachingBlurClient.class);
+
+  private Map<String, Item> clusterListCache = new HashMap<String, Item>(1);
+  private Map<String, Item> tableListCache = new HashMap<String, Item>();
+  private Map<String, Item> queryListCache = new HashMap<String, Item>();
+  private Map<String, Item> queryStatusCache = new HashMap<String, Item>();
+  private Map<String, Item> tableDescriptionCache = new HashMap<String, Item>();
+  private Map<String, Item> tableStatsCache = new HashMap<String, Item>();
+  private Map<String, Item> schemaCache = new HashMap<String, Item>();
+
+  private long cacheHits;
+  private long cacheMisses;
+
+  public CachingBlurClient(int timeout) {
+    this.timeout = timeout;
+    if(this.timeout > 0) {
+      startCleanup();
+    }
+  }
+
+  public List<String> shardClusterList() throws TException {
+    return getFromCache(null, clusterListCache, new Retriever<List<String>>()
{
+      @Override
+      public List<String> retrieve() throws TException {
+        return getClient().shardClusterList();
+      }
+    });
+  }
+
+  private void startCleanup() {
+    Thread t = new Thread(new Runnable() {
+      @Override
+      public void run() {
+        boolean run = true;
+          while (run) {
+            cleanup(clusterListCache);
+            cleanup(tableListCache);
+            cleanup(queryListCache);
+            cleanup(queryStatusCache);
+            cleanup(tableDescriptionCache);
+            cleanup(tableStatsCache);
+            cleanup(schemaCache);
+            log.info("Cache: " + cacheHits + " hits, " + cacheMisses + " misses");
+            try {
+              Thread.sleep(timeout * 2);
+            } catch (InterruptedException e) {
+              run = false;
+            }
+          }
+
+      }
+    });
+    t.setDaemon(true);
+    t.start();
+  }
+
+  private void cleanup(Map<String, Item> cache) {
+    if (cache != null) {
+      synchronized (cache) {
+        Iterator<Map.Entry<String, Item>> iterator = cache.entrySet().iterator();
+        while (iterator.hasNext()) {
+          Map.Entry<String, Item> entry = iterator.next();
+          if (entry.getValue().expired(timeout)) {
+            iterator.remove();
+          }
+        }
+      }
+    }
+  }
+
+  private Iface getClient() {
+    return BlurClient.getClient(Config.getConnectionString());
+  }
+
+  private <T extends Object> T getFromCache(String key, Map<String, Item> cache,
Retriever<T> retriever) throws TException {
+    synchronized (cache) {
+      if(this.timeout <= 0) {
+        return retriever.retrieve();
+      }
+      Item item = cache.get(key);
+      if (item == null || item.expired(timeout)) {
+        cacheMisses++;
+        item = new Item(retriever.retrieve());
+        cache.put(key, item);
+      } else {
+        cacheHits++;
+      }
+      return (T) item.value;
+    }
+  }
+
+  public void cancelQuery(String table, String uuid) throws TException {
+    getClient().cancelQuery(table, uuid);
+    invalidateQuery(table, uuid);
+  }
+
+  private void invalidateQuery(String table, String uuid) {
+    synchronized (queryListCache) {
+      Item item = queryListCache.get(null);
+      if(item != null && item.getValue() != null) {
+        ((List<String>)(item.getValue())).remove(uuid);
+      }
+    }
+    synchronized (queryStatusCache) {
+      queryStatusCache.remove(queryKey(table,uuid));
+    }
+  }
+
+  private void invalidateTable(String table) {
+    synchronized (tableListCache) {
+      for(Item item: tableListCache.values()) {
+        if(item != null && item.getValue() != null) {
+          ((List<String>)(item.getValue())).remove(table);
+        }
+      }
+    }
+  }
+
+  private String queryKey(String table, String uuid) {
+    return table + ":" + uuid;
+  }
+
+  public List<String> enabledTables() throws TException {
+    List<String> tables = tableList();
+    List<String> enabledTables = new ArrayList<String>(tables.size());
+    for (String table : tables) {
+      try {
+        TableDescriptor descriptor = describe(table);
+        if (descriptor != null && descriptor.isEnabled()) {
+          enabledTables.add(table);
+        }
+      } catch(TException e) {
+        log.warn("error getting descriptor for " + table, e);
+      }
+    }
+    return enabledTables;
+  }
+
+  public List<String> tableList() throws TException {
+    return getFromCache(null, tableListCache, new Retriever<List<String>>() {
+      @Override
+      public List<String> retrieve() throws TException {
+        return getClient().tableList();
+      }
+    });
+  }
+
+  public List<String> queryStatusIdList(final String table) throws TException {
+    return getFromCache(table, queryListCache, new Retriever<List<String>>()
{
+      @Override
+      public List<String> retrieve() throws TException {
+        return getClient().queryStatusIdList(table);
+      }
+    });
+  }
+
+  public BlurQueryStatus queryStatusById(final String table, final String id) throws TException
{
+    return getFromCache(queryKey(table,id), queryStatusCache, new Retriever<BlurQueryStatus>()
{
+      @Override
+      public BlurQueryStatus retrieve() throws TException {
+        return getClient().queryStatusById(table, id);
+      }
+    });
+
+  }
+
+  public List<String> tableListByCluster(final String cluster) throws TException {
+    return getFromCache(cluster, tableListCache, new Retriever<List<String>>()
{
+      @Override
+      public List<String> retrieve() throws TException {
+        return getClient().tableListByCluster(cluster);
+      }
+    });
+  }
+
+  public TableDescriptor describe(final String table) throws TException {
+    return getFromCache(table, tableDescriptionCache, new Retriever<TableDescriptor>()
{
+      @Override
+      public TableDescriptor retrieve() throws TException {
+        return getClient().describe(table);
+      }
+    });
+  }
+
+  public TableStats tableStats(final String table) throws TException {
+    return getFromCache(table, tableStatsCache, new Retriever<TableStats>() {
+      @Override
+      public TableStats retrieve() throws TException {
+        return getClient().tableStats(table);
+      }
+    });
+  }
+
+  public Schema schema(final String table) throws TException {
+    return getFromCache(table, schemaCache, new Retriever<Schema>() {
+      @Override
+      public Schema retrieve() throws TException {
+        return getClient().schema(table);
+      }
+    });
+  }
+
+  public List<String> terms(String table, String family, String column, String startWith,
short i) throws TException {
+    TableDescriptor descriptor = describe(table);
+    if (descriptor != null && descriptor.isEnabled()) {
+      return getClient().terms(table, family, column, startWith, i);
+    }
+    return new ArrayList<String>(0);
+  }
+
+  public void disableTable(String table) throws TException {
+    getClient().disableTable(table);
+    invalidateTable(table);
+  }
+
+  public void enableTable(String table) throws TException {
+    getClient().enableTable(table);
+    invalidateTable(table);
+  }
+
+  public void removeTable(String table, boolean includeFiles) throws TException {
+    getClient().removeTable(table, includeFiles);
+    invalidateTable(table);
+  }
+
+  private static class Item {
+    private Object value;
+    private long insertionTime;
+
+    public Item(Object value) {
+      this.value = value;
+      insertionTime = System.currentTimeMillis();
+    }
+
+    public boolean expired(long timeout) {
+      return insertionTime < System.currentTimeMillis() - timeout;
+    }
+
+    public Object getValue() {
+      return value;
+    }
+  }
+
+  private abstract static class Retriever<T> {
+    public abstract T retrieve() throws TException;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/04261d3c/blur-console/src/main/java/org/apache/blur/console/util/Config.java
----------------------------------------------------------------------
diff --git a/blur-console/src/main/java/org/apache/blur/console/util/Config.java b/blur-console/src/main/java/org/apache/blur/console/util/Config.java
index 7abd3c6..a9dc634 100644
--- a/blur-console/src/main/java/org/apache/blur/console/util/Config.java
+++ b/blur-console/src/main/java/org/apache/blur/console/util/Config.java
@@ -32,20 +32,21 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.codehaus.jackson.JsonFactory;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.type.TypeReference;
 
 import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Method;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
 
 public class Config {
 
   private static final File TMPDIR = new File(System.getProperty("blur.tmp.dir", "./target/mini-cluster"));
   private static final Log log = LogFactory.getLog(Config.class);
   private static final int DEFAULT_PORT = 8080;
+  public static final int DEFAULT_REFRESH_TIME = 5000;
 
   private static int port;
   private static BlurConfiguration blurConfig;
@@ -54,6 +55,7 @@ public class Config {
   private static Object cluster;
   private static IAuthenticationProvider authenticationProvider;
   private static IAuthorizationProvider authorizationProvider;
+  private static CachingBlurClient cachingBlurClient;
 
   public static int getConsolePort() {
     return port;
@@ -74,6 +76,7 @@ public class Config {
     zk = new ZookeeperClusterStatus(blurConfig.get("blur.zookeeper.connection"), blurConfig);
     blurConnection = buildConnectionString();
     port = blurConfig.getInt("blur.console.port", DEFAULT_PORT);
+    cachingBlurClient = new CachingBlurClient(blurConfig.getInt("blur.console.refreshtime",
DEFAULT_REFRESH_TIME));
     setupProviders();
   }
 
@@ -111,15 +114,15 @@ public class Config {
     } else {
       authenticationProvider = (IAuthenticationProvider) authenticationProviderClass.newInstance();
       log.info("Using " + authenticationProviderClassName + " for authentication");
-      if(authenticationProviderClassName.equals(authorizationProviderClassName)) {
+      if (authenticationProviderClassName.equals(authorizationProviderClassName)) {
         log.info("authentication and authorization providers are the same, reusing");
         authorizationProvider = (IAuthorizationProvider) authenticationProvider;
       }
     }
     authenticationProvider.setupProvider(blurConfig);
 
-    if(authorizationProvider == null) {
-      if(authorizationProviderClassName != null) {
+    if (authorizationProvider == null) {
+      if (authorizationProviderClassName != null) {
         Class authorizationProviderClass = Class.forName(authorizationProviderClassName,
false, Config.class.getClassLoader());
         if (authorizationProviderClass == null) {
           log.error("Error in blur.console.authorization.provider: EmptyAuthorization");
@@ -135,7 +138,7 @@ public class Config {
     }
   }
 
-  public static String getConnectionString() throws IOException {
+  public static String getConnectionString() {
     return blurConnection;
   }
 
@@ -178,6 +181,10 @@ public class Config {
         cluster = clusterClass.newInstance();
         Method startBlurCluster = clusterClass.getDeclaredMethod("startBlurCluster", String.class,
int.class, int.class, boolean.class);
         startBlurCluster.invoke(cluster, new File(testDirectory, "cluster").getAbsolutePath(),
2, 3, true);
+        Method getControllerConnectionStr = clusterClass.getDeclaredMethod("getControllerConnectionStr");
+        String controllerConnectionStr = (String) getControllerConnectionStr.invoke(cluster);
+        System.out.println("MiniCluster started at " + controllerConnectionStr);
+
       }
     } catch (Exception e) {
       log.fatal("Unable to start in dev mode because MiniCluster isn't in classpath", e);
@@ -188,13 +195,24 @@ public class Config {
   public static Iface getClient(org.apache.blur.console.model.User user, String securityUser)
throws IOException {
     Iface client = BlurClient.getClient(getConnectionString());
     Map<String, String> securityAttributes = user.getSecurityAttributes(securityUser);
-    if(securityAttributes != null) {
+    if (securityAttributes != null) {
       UserContext.setUser(new User(user.getName(), securityAttributes));
     }
-
     return client;
   }
 
+  public static int getInt(String name, int defaultValue) {
+    return blurConfig.getInt(name, defaultValue);
+  }
+
+  public static Iface getClient() {
+    return BlurClient.getClient(getConnectionString());
+  }
+
+  public static CachingBlurClient getCachingBlurClient() {
+    return cachingBlurClient;
+  }
+
   public static boolean isClusterSetup() {
     return cluster != null;
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/04261d3c/blur-console/src/main/java/org/apache/blur/console/util/NodeUtil.java
----------------------------------------------------------------------
diff --git a/blur-console/src/main/java/org/apache/blur/console/util/NodeUtil.java b/blur-console/src/main/java/org/apache/blur/console/util/NodeUtil.java
index 2ee9cfa..3a1bb1a 100644
--- a/blur-console/src/main/java/org/apache/blur/console/util/NodeUtil.java
+++ b/blur-console/src/main/java/org/apache/blur/console/util/NodeUtil.java
@@ -19,6 +19,7 @@ package org.apache.blur.console.util;
 
 import org.apache.blur.manager.clusterstatus.ZookeeperClusterStatus;
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.blur.thrift.generated.Blur.Iface;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -33,6 +34,7 @@ public class NodeUtil {
 
   @SuppressWarnings("unchecked")
   public static Map<String, Object> getControllerStatus() throws IOException {
+    Iface client = Config.getClient();
     ZookeeperClusterStatus zk = Config.getZookeeper();
 
     List<String> allControllers = new ArrayList<String>();

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/04261d3c/blur-console/src/main/java/org/apache/blur/console/util/QueryUtil.java
----------------------------------------------------------------------
diff --git a/blur-console/src/main/java/org/apache/blur/console/util/QueryUtil.java b/blur-console/src/main/java/org/apache/blur/console/util/QueryUtil.java
index 363e07e..9eae4b5 100644
--- a/blur-console/src/main/java/org/apache/blur/console/util/QueryUtil.java
+++ b/blur-console/src/main/java/org/apache/blur/console/util/QueryUtil.java
@@ -18,8 +18,6 @@
 package org.apache.blur.console.util;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
-import org.apache.blur.thrift.BlurClient;
-import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.BlurQueryStatus;
 import org.apache.blur.thrift.generated.Status;
 
@@ -32,10 +30,10 @@ import java.util.Map;
 public class QueryUtil {
 
   public static int getCurrentQueryCount() throws IOException, TException {
-    Iface client = BlurClient.getClient(Config.getConnectionString());
+    CachingBlurClient client = Config.getCachingBlurClient();
 
     int count = 0;
-    List<String> tableList = client.tableList();
+    List<String> tableList = client.enabledTables();
     for (String table : tableList) {
       List<String> queries = client.queryStatusIdList(table);
       count += queries.size();
@@ -51,8 +49,8 @@ public class QueryUtil {
 
     List<Map<String, Object>> queries = new ArrayList<Map<String, Object>>();
 
-    Iface client = BlurClient.getClient(Config.getConnectionString());
-    List<String> tableList = client.tableList();
+    CachingBlurClient client = Config.getCachingBlurClient();
+    List<String> tableList = client.enabledTables();
 
     for (String table : tableList) {
       List<String> queriesForTable = client.queryStatusIdList(table);
@@ -87,7 +85,7 @@ public class QueryUtil {
   }
 
   public static void cancelQuery(String table, String uuid) throws IOException, TException
{
-    Iface client = BlurClient.getClient(Config.getConnectionString());
+    CachingBlurClient client = Config.getCachingBlurClient();
 
     client.cancelQuery(table, uuid);
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/04261d3c/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
----------------------------------------------------------------------
diff --git a/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java b/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
index 1e754bb..50be7eb 100644
--- a/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
+++ b/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
@@ -18,8 +18,6 @@
 package org.apache.blur.console.util;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
-import org.apache.blur.thrift.BlurClient;
-import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.ColumnDefinition;
 import org.apache.blur.thrift.generated.Schema;
 import org.apache.blur.thrift.generated.TableDescriptor;
@@ -32,7 +30,7 @@ public class TableUtil {
 
   @SuppressWarnings("rawtypes")
   public static Map<String, List> getTableSummaries() throws IOException, TException
{
-    Iface client = BlurClient.getClient(Config.getConnectionString());
+    CachingBlurClient client = Config.getCachingBlurClient();
 
     List<Map<String, Object>> summaries = new ArrayList<Map<String, Object>>();
 
@@ -73,7 +71,7 @@ public class TableUtil {
   }
 
   public static Map<String, Map<String, Map<String, Object>>> getSchema(String
table) throws IOException, TException {
-    Iface client = BlurClient.getClient(Config.getConnectionString());
+    CachingBlurClient client = Config.getCachingBlurClient();
 
     Schema schema = client.schema(table);
 
@@ -95,26 +93,20 @@ public class TableUtil {
   }
 
   public static List<String> getTerms(String table, String family, String column, String
startWith) throws IOException, TException {
-    Iface client = BlurClient.getClient(Config.getConnectionString());
+    CachingBlurClient client = Config.getCachingBlurClient();
 
     return client.terms(table, family, column, startWith, (short) 10);
   }
 
   public static void disableTable(String table) throws TException, IOException {
-    Iface client = BlurClient.getClient(Config.getConnectionString());
-
-    client.disableTable(table);
+    Config.getCachingBlurClient().disableTable(table);
   }
 
   public static void enableTable(String table) throws TException, IOException {
-    Iface client = BlurClient.getClient(Config.getConnectionString());
-
-    client.enableTable(table);
+    Config.getCachingBlurClient().enableTable(table);
   }
 
   public static void deleteTable(String table, boolean includeFiles) throws TException, IOException
{
-    Iface client = BlurClient.getClient(Config.getConnectionString());
-
-    client.removeTable(table, includeFiles);
+    Config.getCachingBlurClient().removeTable(table, includeFiles);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/04261d3c/blur-console/src/main/webapp/Gruntfile.js
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/Gruntfile.js b/blur-console/src/main/webapp/Gruntfile.js
index 876c40d..5280cb0 100644
--- a/blur-console/src/main/webapp/Gruntfile.js
+++ b/blur-console/src/main/webapp/Gruntfile.js
@@ -233,7 +233,7 @@ module.exports = function (grunt) {
     grunt.registerTask('development', 'Build for development', ['clean', 'less:development',
'uglify:js', 'copy:main', 'version-assets']);
     grunt.registerTask('production', 'Build for production', ['clean', 'less:production',
'uglify:js', 'copy:main', 'version-assets']);
     grunt.registerTask('serve', 'Run development server', ['clean','development', 'connect:livereload','watch']);
-    grunt.registerTask('default', ['clean', 'style:development', 'development', 'watch']);
+    grunt.registerTask('default', ['clean', 'development', 'watch']);
     grunt.registerTask('version-assets-css-map', function() {
         var Version = require("node-version-assets");
         var versionInstance = new Version({

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/04261d3c/blur-console/src/main/webapp/index.html
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/index.html b/blur-console/src/main/webapp/index.html
index f6a8e91..c00ca69 100644
--- a/blur-console/src/main/webapp/index.html
+++ b/blur-console/src/main/webapp/index.html
@@ -65,6 +65,7 @@ under the License.
     </nav>
     <div id="blurconsole"></div>
     <script src="js/blurconsole.js"></script>
+    <script src="/service/config.js"></script>
     <script type="text/javascript">
       $(function () { blurconsole.initModule( $('#blurconsole') ); });
     </script>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/04261d3c/blur-console/src/main/webapp/js/blurconsole.model.js
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/js/blurconsole.model.js b/blur-console/src/main/webapp/js/blurconsole.model.js
index ec8323f..0bf5071 100644
--- a/blur-console/src/main/webapp/js/blurconsole.model.js
+++ b/blur-console/src/main/webapp/js/blurconsole.model.js
@@ -515,7 +515,7 @@ blurconsole.model = (function() {
       stateMap.nodeMap = nodes;
       $.gevent.publish('node-status-updated');
     }
-    setTimeout(_nodePoller, 5000);
+    setTimeout(_nodePoller, blurconsole.config.refreshtime);
   }
 
   function _updateTables(data) {
@@ -527,7 +527,7 @@ blurconsole.model = (function() {
         $.gevent.publish('tables-updated');
       }
     }
-    setTimeout(_tablePoller, 5000);
+    setTimeout(_tablePoller, blurconsole.config.refreshtime);
   }
 
   function _updateQueryPerformance(performanceMetric) {
@@ -539,7 +539,7 @@ blurconsole.model = (function() {
       stateMap.queryPerformance.push(performanceMetric);
       $.gevent.publish('query-perf-updated');
     }
-    setTimeout(_queryPerformancePoller, 5000);
+    setTimeout(_queryPerformancePoller, blurconsole.config.refreshtime);
   }
 
   function _updateQueries(queries) {
@@ -547,7 +547,7 @@ blurconsole.model = (function() {
       stateMap.queries = queries;
       $.gevent.publish('queries-updated');
     }
-    setTimeout(_queryPoller, 5000);
+    setTimeout(_queryPoller, blurconsole.config.refreshtime);
   }
 
   //----------------------- Public API ------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/04261d3c/blur-console/src/main/webapp/public/index.html
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/public/index.html b/blur-console/src/main/webapp/public/index.html
index 6eafdf6..528e9d2 100644
--- a/blur-console/src/main/webapp/public/index.html
+++ b/blur-console/src/main/webapp/public/index.html
@@ -64,7 +64,8 @@ under the License.
       </ul>
     </nav>
     <div id="blurconsole"></div>
-    <script src="js/blurconsole.b3b55f3b66f68d99a652d8034e0d53a4.js"></script>
+    <script src="js/blurconsole.2a826151959859ac6ba1bdd17da01ee1.js"></script>
+    <script src="/service/config.js"></script>
     <script type="text/javascript">
       $(function () { blurconsole.initModule( $('#blurconsole') ); });
     </script>


Mime
View raw message