incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cr...@apache.org
Subject [3/3] git commit: Cleaned up some code
Date Sat, 12 Oct 2013 18:05:48 GMT
Cleaned up some code


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

Branch: refs/heads/blur-console-v2
Commit: 79df6ba8cb2c9cee66197df6a8f75063ac354317
Parents: 1676142
Author: Chris Rohr <crohr@nearinfinity.com>
Authored: Sat Oct 12 14:05:26 2013 -0400
Committer: Chris Rohr <crohr@nearinfinity.com>
Committed: Sat Oct 12 14:05:26 2013 -0400

----------------------------------------------------------------------
 .../blur/console/servlets/DashboardServlet.java |   134 +-
 .../org/apache/blur/console/util/Config.java    |    99 +-
 .../org/apache/blur/console/util/HttpUtil.java  |    35 +
 .../org/apache/blur/console/util/NodeUtil.java  |   187 +
 .../org/apache/blur/console/util/TableUtil.java |    97 +
 .../apache/blur/console/webapp/css/console.css  |     4 +
 .../org/apache/blur/console/webapp/index.html   |    28 +-
 .../apache/blur/console/webapp/js/angular.js    | 13122 ++++++++++-------
 .../apache/blur/console/webapp/js/dashboard.js  |    30 +-
 .../console/webapp/partials/dashboard.tpl.html  |    44 +
 10 files changed, 8437 insertions(+), 5343 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/79df6ba8/contrib/blur-console/src/main/java/org/apache/blur/console/servlets/DashboardServlet.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/java/org/apache/blur/console/servlets/DashboardServlet.java
b/contrib/blur-console/src/main/java/org/apache/blur/console/servlets/DashboardServlet.java
index 74dcb6d..9e4001c 100644
--- a/contrib/blur-console/src/main/java/org/apache/blur/console/servlets/DashboardServlet.java
+++ b/contrib/blur-console/src/main/java/org/apache/blur/console/servlets/DashboardServlet.java
@@ -18,22 +18,17 @@ package org.apache.blur.console.servlets;
  */
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.blur.console.util.Config;
-import org.apache.blur.manager.clusterstatus.ZookeeperClusterStatus;
-import org.apache.blur.thrift.BlurClient;
-import org.apache.blur.thrift.generated.Blur.Iface;
-import org.apache.commons.collections.CollectionUtils;
+import org.apache.blur.console.util.HttpUtil;
+import org.apache.blur.console.util.NodeUtil;
+import org.apache.blur.console.util.TableUtil;
 import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
-import org.json.JSONArray;
+import org.json.JSONException;
 import org.json.JSONObject;
 
 public class DashboardServlet extends HttpServlet {
@@ -42,91 +37,66 @@ public class DashboardServlet extends HttpServlet {
 	@Override
 	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
 		String path = request.getPathInfo();
-		if ("/controllers/status".equalsIgnoreCase(path)) {
-			sendControllerStatus(response);
-		} else if ("/clusters/status".equalsIgnoreCase(path)) {
-			sendClusterStatus(response);
+		if ("/node/status".equalsIgnoreCase(path)) {
+			sendNodeStatus(response);
+		} else if ("/table/status".equalsIgnoreCase(path)) {
+			sendTableStatus(response);
+		} else if ("query/status".equalsIgnoreCase(path)) {
+			sendQueryStatus(response);
 		} else {
 			response.setStatus(404);
 			IOUtils.write("Route [" + path + "] doesn't exist", response.getOutputStream());
 		}
 	}
-
-	private void sendControllerStatus(HttpServletResponse response) throws IOException {
-		ZookeeperClusterStatus zk = new ZookeeperClusterStatus(Config.getBlurConfig().get("blur.zookeeper.connection"),
Config.getBlurConfig());
-		
-		//TODO: Fix with another call, this will return online only every time
-		List<String> allControllers = zk.getControllerServerList();
-		
-		Iface client = BlurClient.getClient(StringUtils.join(allControllers, ","));
-		List<String> controllersFromBlur = new ArrayList<String>();
-		try {
-			controllersFromBlur = client.controllerServerList();
-		} catch (Exception e) {}
-		
-		
-		int onlineControllers = CollectionUtils.intersection(allControllers, controllersFromBlur).size();
-		int offlineControllers = CollectionUtils.subtract(allControllers, controllersFromBlur).size();
-		
-		JSONArray data = new JSONArray();
-		
-		try {
-			JSONObject online = new JSONObject();
-			online.put("value", onlineControllers);
-			online.put("color", "#7DC77D");
-			
-			JSONObject offline = new JSONObject();
-			offline.put("value", offlineControllers);
-			offline.put("color", "#FF1919");
-			
-			data.put(online);
-			data.put(offline);
-		} catch (Exception e) {}
-		
-		String body = data.toString();
+	
+	private void sendError(HttpServletResponse response, Exception e) throws IOException {
+		String body = e.getMessage();
 		response.setContentType("application/json");
 		response.setContentLength(body.getBytes().length);
-		response.setStatus(200);
+		response.setStatus(500);
 		IOUtils.write(body, response.getOutputStream());
 	}
+
+	private void sendNodeStatus(HttpServletResponse response) throws IOException {
+		JSONObject nodeData = new JSONObject();
+
+		try {
+			nodeData.put("zookeepers", NodeUtil.getZookeeperStatus());
+			nodeData.put("controllers", NodeUtil.getControllerStatus());
+			nodeData.put("clusters", NodeUtil.getClusterStatus());
+		} catch (JSONException e) {
+			sendError(response, e);
+			return;
+		}
+
+		HttpUtil.sendResponse(response, nodeData.toString(), HttpUtil.JSON);
+	}
 	
-	private void sendClusterStatus(HttpServletResponse response) throws IOException {
-		ZookeeperClusterStatus zk = new ZookeeperClusterStatus(Config.getBlurConfig().get("blur.zookeeper.connection"),
Config.getBlurConfig());
-		
-		List<String> clusters = zk.getClusterList(false);
-		JSONArray data = new JSONArray();
-		
+	private void sendTableStatus(HttpServletResponse response) throws IOException {
+		JSONObject tableData = new JSONObject();
+
 		try {
-			for (String cluster : clusters) {
-				JSONObject clusterObj = new JSONObject();
-				clusterObj.put("name", cluster);
-				
-				List<String> offlineShardServers = zk.getOfflineShardServers(false, cluster);
-				List<String> onlineShardServers = zk.getOnlineShardServers(false, cluster);
-				
-				JSONArray clusterData = new JSONArray();
-				
-				JSONObject online = new JSONObject();
-				online.put("value", onlineShardServers.size());
-				online.put("color", "#7DC77D");
-				
-				JSONObject offline = new JSONObject();
-				offline.put("value", offlineShardServers.size());
-				offline.put("color", "#FF1919");
-				
-				clusterData.put(online);
-				clusterData.put(offline);
-				clusterObj.put("data", clusterData);
-				
-				data.put(clusterObj);
-			}
-		} catch (Exception e) {}
+			tableData = TableUtil.getTableStatus();
+		} catch (IOException e) {
+			throw new IOException(e);
+		} catch (Exception e) {
+			sendError(response, e);
+			return;
+		}
+
+		HttpUtil.sendResponse(response, tableData.toString(), HttpUtil.JSON);
+	}
+	
+	private void sendQueryStatus(HttpServletResponse response) throws IOException {
+		JSONObject nodeData = new JSONObject();
 		
+		try {
+			nodeData.put("fill", "me");
+		} catch (JSONException e) {
+			sendError(response, e);
+			return;
+		}
 		
-		String body = data.toString();
-		response.setContentType("application/json");
-		response.setContentLength(body.getBytes().length);
-		response.setStatus(200);
-		IOUtils.write(body, response.getOutputStream());
+		HttpUtil.sendResponse(response, nodeData.toString(), HttpUtil.JSON);
 	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/79df6ba8/contrib/blur-console/src/main/java/org/apache/blur/console/util/Config.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/java/org/apache/blur/console/util/Config.java b/contrib/blur-console/src/main/java/org/apache/blur/console/util/Config.java
index 5e55bd4..563ea14 100644
--- a/contrib/blur-console/src/main/java/org/apache/blur/console/util/Config.java
+++ b/contrib/blur-console/src/main/java/org/apache/blur/console/util/Config.java
@@ -17,48 +17,18 @@ package org.apache.blur.console.util;
  * limitations under the License.
  */
 
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
-import java.util.Properties;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.blur.BlurConfiguration;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.Predicate;
-import org.apache.commons.collections.Transformer;
-import org.apache.commons.io.IOUtils;
+import org.apache.blur.manager.clusterstatus.ZookeeperClusterStatus;
 import org.apache.commons.lang.StringUtils;
 
-import com.google.common.collect.ImmutableList;
-
 public class Config {
-	private static List<String> controllers = new ArrayList<String>();
-	private static List<String> shards = new ArrayList<String>();
-	private static List<String> zookeepers = new ArrayList<String>();
-	
-	private static boolean foundSite = false;
 	private static int port = 8080;
 	
 	private static BlurConfiguration blurConfig;
-	
-	public static Collection<String> getControllers() {
-		return ImmutableList.copyOf(controllers);
-	}
-	public static Collection<String> getShards() {
-		return ImmutableList.copyOf(shards);
-	}
-	public static Collection<String> getZookeepers() {
-		return ImmutableList.copyOf(zookeepers);
-	}
-	public static boolean isBlurConfigured() {
-		return foundSite;
-	}
+
 	public static int getConsolePort() {
 		return port;
 	}
@@ -68,68 +38,11 @@ public class Config {
 	
 	public static void setupConfig() throws IOException {
 		blurConfig = new BlurConfiguration();
-		
-//		String blurHome = System.getenv("BLUR_HOME");
-//		
-//		if (StringUtils.isNotBlank(blurHome)) {
-//			File blurHomeDir = new File(blurHome + "/conf/blur-site.properties");
-//			if (blurHomeDir.exists()) {
-//				foundSite = true;
-//			}
-//			
-//			startTimer(blurHome);
-//		}
 	}
 	
-	private static void startTimer(final String blurHome) {
-		Timer timer = new Timer("BlurSiteReader", true);
-		timer.scheduleAtFixedRate(new TimerTask() {
-			@Override
-			public void run() {
-				try {
-					List<String> tmpControllers = IOUtils.readLines(new FileInputStream(blurHome +
"/conf/controllers"));
-					List<String> tmpShards = IOUtils.readLines(new FileInputStream(blurHome + "/conf/shards"));
-					List<String> tmpZookeepers = IOUtils.readLines(new FileInputStream(blurHome +
"/conf/zookeepers"));
-					
-					removeComments(tmpControllers);
-					removeComments(tmpShards);
-					removeComments(tmpZookeepers);
-					
-					tmpControllers = new ArrayList<String>(fixPorts(tmpControllers, 40010));
-					
-					controllers = tmpControllers;
-					shards = tmpShards;
-					zookeepers = tmpZookeepers;
-					
-					Properties props = new Properties();
-					props.load(new FileInputStream(blurHome + "/conf/blur-site.properties"));
-					
-					port = Integer.parseInt(props.getProperty("blur.console.port", "8080"));
-				} catch (Exception e) {}
-				
-			}
-			
-			private void removeComments(List<String> list) {
-				CollectionUtils.filter(list, new Predicate() {
-					@Override
-					public boolean evaluate(Object line) {
-						return !StringUtils.startsWith((String) line, "#");
-					}
-				});
-			}
-			
-			@SuppressWarnings("unchecked")
-			private Collection<String> fixPorts(List<String> list, final int port) {
-				return CollectionUtils.collect(list, new Transformer() {
-					@Override
-					public Object transform(Object input) {
-						if (((String) input).indexOf(":") > 0) {
-							return input;
-						}
-						return input + ":" + port;
-					}
-				});
-			}
-		}, 0, TimeUnit.MINUTES.toMillis(2));
+	public static String getConnectionString() throws IOException {
+		ZookeeperClusterStatus zk = new ZookeeperClusterStatus(blurConfig.get("blur.zookeeper.connection"),
blurConfig);
+		List<String> allControllers = zk.getControllerServerList();
+		return StringUtils.join(allControllers, ",");
 	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/79df6ba8/contrib/blur-console/src/main/java/org/apache/blur/console/util/HttpUtil.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/java/org/apache/blur/console/util/HttpUtil.java
b/contrib/blur-console/src/main/java/org/apache/blur/console/util/HttpUtil.java
new file mode 100644
index 0000000..6b502b5
--- /dev/null
+++ b/contrib/blur-console/src/main/java/org/apache/blur/console/util/HttpUtil.java
@@ -0,0 +1,35 @@
+/**
+ * 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.
+ */
+
+package org.apache.blur.console.util;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.io.IOUtils;
+
+public class HttpUtil {
+	public static String JSON = "application/json";
+	
+	public static void sendResponse(HttpServletResponse response, String body, String contentType)
throws IOException {
+		response.setContentType(contentType);
+		response.setContentLength(body.getBytes().length);
+		response.setStatus(200);
+		IOUtils.write(body, response.getOutputStream());
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/79df6ba8/contrib/blur-console/src/main/java/org/apache/blur/console/util/NodeUtil.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/java/org/apache/blur/console/util/NodeUtil.java
b/contrib/blur-console/src/main/java/org/apache/blur/console/util/NodeUtil.java
new file mode 100644
index 0000000..aa16bef
--- /dev/null
+++ b/contrib/blur-console/src/main/java/org/apache/blur/console/util/NodeUtil.java
@@ -0,0 +1,187 @@
+/**
+ * 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.
+ */
+
+package org.apache.blur.console.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.URI;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.blur.manager.clusterstatus.ZookeeperClusterStatus;
+import org.apache.blur.thrift.BlurClient;
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+public class NodeUtil {
+	@SuppressWarnings("unchecked")
+	public static JSONObject getControllerStatus() throws JSONException, IOException {
+		ZookeeperClusterStatus zk = new ZookeeperClusterStatus(Config.getBlurConfig().get("blur.zookeeper.connection"),
+				Config.getBlurConfig());
+
+		// TODO: Fix with another call, this will return online only every time
+		List<String> allControllers = zk.getControllerServerList();
+		zk.close();
+
+		Iface client = BlurClient.getClient(StringUtils.join(allControllers, ","));
+		List<String> controllersFromBlur = new ArrayList<String>();
+		try {
+			controllersFromBlur = client.controllerServerList();
+		} catch (Exception e) {
+		}
+		
+		Collection<String> onlineControllers = CollectionUtils.intersection(allControllers,
controllersFromBlur);
+		Collection<String> offlineControllers = CollectionUtils.subtract(allControllers,
controllersFromBlur);
+
+		JSONObject data = new JSONObject();
+
+		data.put("online", new JSONArray(onlineControllers));
+		data.put("offline", new JSONArray(offlineControllers));
+
+		JSONArray chartData = new JSONArray();
+
+		JSONObject online = new JSONObject();
+		online.put("value", onlineControllers.size());
+		online.put("color", "#7DC77D");
+
+		JSONObject offline = new JSONObject();
+		offline.put("value", offlineControllers.size());
+		offline.put("color", "#FF1919");
+
+		chartData.put(online);
+		chartData.put(offline);
+
+		data.put("chart", chartData);
+		
+		return data;
+	}
+
+	public static JSONArray getClusterStatus() throws IOException, JSONException {
+		ZookeeperClusterStatus zk = new ZookeeperClusterStatus(Config.getBlurConfig().get("blur.zookeeper.connection"),
+				Config.getBlurConfig());
+
+		List<String> clusters = zk.getClusterList(false);
+		JSONArray data = new JSONArray();
+
+		for (String cluster : clusters) {
+			JSONObject clusterObj = new JSONObject();
+			clusterObj.put("name", cluster);
+
+			List<String> offlineShardServers = zk.getOfflineShardServers(false, cluster);
+			List<String> onlineShardServers = zk.getOnlineShardServers(false, cluster);
+
+			clusterObj.put("online", new JSONArray(onlineShardServers));
+			clusterObj.put("offline", new JSONArray(offlineShardServers));
+
+			JSONArray clusterData = new JSONArray();
+
+			JSONObject online = new JSONObject();
+			online.put("value", onlineShardServers.size());
+			online.put("color", "#7DC77D");
+
+			JSONObject offline = new JSONObject();
+			offline.put("value", offlineShardServers.size());
+			offline.put("color", "#FF1919");
+
+			clusterData.put(online);
+			clusterData.put(offline);
+			clusterObj.put("chart", clusterData);
+
+			data.put(clusterObj);
+		}
+		zk.close();
+
+		return data;
+	}
+
+	public static JSONObject getZookeeperStatus() throws IOException, JSONException {
+		String[] connections = Config.getBlurConfig().get("blur.zookeeper.connection").split(",");
+		Set<String> onlineZookeepers = new HashSet<String>();
+		Set<String> offlineZookeepers = new HashSet<String>();
+		
+		for (String connection : connections) {
+			try {
+				URI parsedConnection = new URI("my://" + connection);
+				String host = parsedConnection.getHost();
+				int port = parsedConnection.getPort() >= 0 ? parsedConnection.getPort() : 2181;
+				byte[] reqBytes = new byte[4];
+				ByteBuffer req = ByteBuffer.wrap(reqBytes);
+				req.putInt(ByteBuffer.wrap("ruok".getBytes()).getInt());
+				Socket socket = new Socket();
+				socket.setSoLinger(false, 10);
+				socket.setSoTimeout(20000);
+				parsedConnection.getPort();
+				socket.connect(new InetSocketAddress(host, port));
+
+				InputStream response = socket.getInputStream();
+				OutputStream question = socket.getOutputStream();
+
+				question.write(reqBytes);
+
+				byte[] resBytes = new byte[4];
+
+				response.read(resBytes);
+				String status = new String(resBytes);
+				if (status.equals("imok")) {
+					onlineZookeepers.add(connection);
+				} else {
+					offlineZookeepers.add(connection);
+				}
+				socket.close();
+				response.close();
+				question.close();
+			} catch (Exception e) {
+				offlineZookeepers.add(connection);
+				//log.error("A connection to " + connection + " could not be made.", e);
+			}
+		}
+		
+		JSONObject data = new JSONObject();
+		
+		data.put("online", new JSONArray(onlineZookeepers));
+		data.put("offline", new JSONArray(offlineZookeepers));
+		
+		JSONArray chartData = new JSONArray();
+
+		JSONObject online = new JSONObject();
+		online.put("value", onlineZookeepers.size());
+		online.put("color", "#7DC77D");
+
+		JSONObject offline = new JSONObject();
+		offline.put("value", offlineZookeepers.size());
+		offline.put("color", "#FF1919");
+
+		chartData.put(online);
+		chartData.put(offline);
+
+		data.put("chart", chartData);
+		
+		return data;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/79df6ba8/contrib/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
b/contrib/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
new file mode 100644
index 0000000..ab29f59
--- /dev/null
+++ b/contrib/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
@@ -0,0 +1,97 @@
+/**
+ * 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.
+ */
+
+package org.apache.blur.console.util;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+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.BlurException;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+public class TableUtil {
+	public static JSONObject getTableStatus() throws IOException, BlurException, TException,
JSONException {
+		//TODO: Change this to a stacked bar chart when chart.js supports it
+		
+		Iface client = BlurClient.getClient(Config.getConnectionString());
+		
+		List<String> clusters = client.shardClusterList();
+		
+		JSONObject data = new JSONObject();
+		JSONArray clusterInfo = new JSONArray();
+		
+		List<Integer> enabledCounts = new ArrayList<Integer>();
+		List<Integer> disabledCounts = new ArrayList<Integer>();
+
+		for (String cluster : clusters) {
+			JSONObject clusterObj = new JSONObject();
+			clusterObj.put("name", cluster);
+
+			List<String> tables = client.tableListByCluster(cluster);
+			
+			List<String> enabledTables = new ArrayList<String>();
+			List<String> disabledTables = new ArrayList<String>();
+			
+			for (String table : tables) {
+				boolean enabled = client.describe(table).isEnabled();
+				
+				if (enabled) {
+					enabledTables.add(table);
+				} else {
+					disabledTables.add(table);
+				}
+			}
+			
+			clusterObj.put("enabled", new JSONArray(enabledTables));
+			clusterObj.put("disabled", new JSONArray(disabledTables));
+			
+			enabledCounts.add(enabledTables.size());
+			disabledCounts.add(disabledTables.size());
+
+			clusterInfo.put(clusterObj);
+		}
+		
+		JSONObject clusterData = new JSONObject();
+		
+		clusterData.put("labels", new JSONArray(clusters));
+		
+		JSONArray datasets = new JSONArray();
+
+		JSONObject enabled = new JSONObject();
+		enabled.put("data", new JSONArray(enabledCounts));
+		enabled.put("fillColor", "#7DC77D");
+
+		JSONObject disabled = new JSONObject();
+		disabled.put("data", new JSONArray(disabledCounts));
+		disabled.put("fillColor", "#FF1919");
+
+		datasets.put(enabled);
+		datasets.put(disabled);
+		clusterData.put("datasets", datasets);
+		
+		data.put("tables", clusterInfo);
+		data.put("chart", clusterData);
+
+		return data;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/79df6ba8/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/css/console.css
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/css/console.css
b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/css/console.css
index c90a8ac..b7fc785 100644
--- a/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/css/console.css
+++ b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/css/console.css
@@ -61,3 +61,7 @@ body { padding-top: 70px; }
     border-color: #ddd transparent #ddd #ddd;
     *border-right-color: #fff;
 }
+
+.center {
+    text-align: center;
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/79df6ba8/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/index.html
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/index.html
b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/index.html
index 3ca5cf9..1e23bf0 100644
--- a/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/index.html
+++ b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/index.html
@@ -37,33 +37,7 @@ Licensed to the Apache Software Foundation (ASF) under one
             <tabset vertical="true" class="tabs-left">
                 <tab>
                     <tab-heading><i class="icon icon-dashboard" title="Dashboard"></i>
Dashboard</tab-heading>
-                    <div ng-controller="DashboardCtrl">
-                        <div id="slow-query-warnings" class="alert alert-danger hidden">Warning</div>
-                        <div class="row">
-                            <div class="col-md-4 well">
-                                <h4>Controllers</h4>
-                                <canvas doughnutchart data="controllerData" width="100"
height="100" options="chartOptions"></canvas>
-                            </div>
-                            <div class="col-md-4 well">
-                                <h4>Shards</h4>
-                                <div ng-repeat="cluster in clusters">
-                                	<h5>{{cluster.name}}</h5>
-                                	<canvas doughnutchart data="cluster.data" width="75"
height="75" options="chartOptions"></canvas>
-                                </div>
-                            </div>
-                            <div class="col-md-4 well">
-                                <h3>Tables</h3>
-                            </div>
-                        </div>
-                        <div class="row">
-                            <div class="col-md-6">
-                                <h3>Queries By Cluster By Minute</h3>
-                            </div>
-                            <div class="col-md-6">
-                                <h3>Average Query Performance By Cluster By Minute</h3>
-                            </div>
-                        </div>
-                    </div>
+                    <ng-include src="'partials/dashboard.tpl.html'"></ng-include>
                 </tab>
                 <tab>
                     <tab-heading><i class="icon icon-table" title="Tables"></i>
Tables</tab-heading>


Mime
View raw message