incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cr...@apache.org
Subject [58/58] git commit: Got Controllers and Shards working
Date Tue, 08 Oct 2013 18:00:06 GMT
Got Controllers and Shards working


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

Branch: refs/heads/blur-console-v2
Commit: c6e64403a72f0e15489c2c3e4806aaa82485338c
Parents: 7b205b3
Author: Chris Rohr <crohr@nearinfinity.com>
Authored: Tue Oct 8 13:57:52 2013 -0400
Committer: Chris Rohr <crohr@nearinfinity.com>
Committed: Tue Oct 8 13:57:52 2013 -0400

----------------------------------------------------------------------
 contrib/blur-console/pom.xml                    |  7 ++-
 .../blur/console/servlets/DashboardServlet.java | 55 ++++++++++++++++++--
 .../org/apache/blur/console/util/Config.java    | 29 +++++++----
 .../org/apache/blur/console/webapp/index.html   |  9 ++--
 .../apache/blur/console/webapp/js/dashboard.js  | 15 ++++--
 5 files changed, 95 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/c6e64403/contrib/blur-console/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/blur-console/pom.xml b/contrib/blur-console/pom.xml
index 1653c9c..e7b9483 100644
--- a/contrib/blur-console/pom.xml
+++ b/contrib/blur-console/pom.xml
@@ -25,7 +25,7 @@ under the License.
     <parent>
     	<groupId>org.apache.blur</groupId>
     	<artifactId>blur</artifactId>
-    	<version>0.2.0-incubating-SNAPSHOT</version>
+    	<version>0.3.0-incubating-SNAPSHOT</version>
     	<relativePath>../../pom.xml</relativePath>
     </parent>
 
@@ -41,6 +41,11 @@ under the License.
        		<version>${project.version}</version>
        	</dependency>
     	<dependency>
+       		<groupId>org.apache.blur</groupId>
+       		<artifactId>blur-core</artifactId>
+       		<version>${project.version}</version>
+       	</dependency>
+    	<dependency>
        		<groupId>com.sun.jersey</groupId>
        		<artifactId>jersey-grizzly</artifactId>
        		<version>1.8</version>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/c6e64403/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 dc24194..0c18c1a 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
@@ -10,6 +10,7 @@ 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;
@@ -26,6 +27,8 @@ public class DashboardServlet extends HttpServlet {
 		String path = request.getPathInfo();
 		if ("/controllers/status".equalsIgnoreCase(path)) {
 			sendControllerStatus(response);
+		} else if ("/clusters/status".equalsIgnoreCase(path)) {
+			sendClusterStatus(response);
 		} else {
 			response.setStatus(404);
 			IOUtils.write("Route [" + path + "] doesn't exist", response.getOutputStream());
@@ -33,14 +36,20 @@ public class DashboardServlet extends HttpServlet {
 	}
 
 	private void sendControllerStatus(HttpServletResponse response) throws IOException {
-		Iface client = BlurClient.getClient(StringUtils.join(Config.getControllers(), ","));
+		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(Config.getControllers(), controllersFromBlur).size();
-		int offlineControllers = CollectionUtils.subtract(Config.getControllers(), controllersFromBlur).size();
+		
+		int onlineControllers = CollectionUtils.intersection(allControllers, controllersFromBlur).size();
+		int offlineControllers = CollectionUtils.subtract(allControllers, controllersFromBlur).size();
 		
 		JSONArray data = new JSONArray();
 		
@@ -63,4 +72,44 @@ public class DashboardServlet extends HttpServlet {
 		response.setStatus(200);
 		IOUtils.write(body, response.getOutputStream());
 	}
+	
+	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();
+		
+		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) {}
+		
+		
+		String body = data.toString();
+		response.setContentType("application/json");
+		response.setContentLength(body.getBytes().length);
+		response.setStatus(200);
+		IOUtils.write(body, response.getOutputStream());
+	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/c6e64403/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 5b797f0..d059eaf 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
@@ -2,6 +2,7 @@ package org.apache.blur.console.util;
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -10,6 +11,7 @@ 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;
@@ -26,6 +28,8 @@ public class Config {
 	private static boolean foundSite = false;
 	private static int port = 8080;
 	
+	private static BlurConfiguration blurConfig;
+	
 	public static Collection<String> getControllers() {
 		return ImmutableList.copyOf(controllers);
 	}
@@ -41,18 +45,23 @@ public class Config {
 	public static int getConsolePort() {
 		return port;
 	}
+	public static BlurConfiguration getBlurConfig() {
+		return blurConfig;
+	}
 	
-	public static void setupConfig() {
-		String blurHome = System.getenv("BLUR_HOME");
+	public static void setupConfig() throws IOException {
+		blurConfig = new BlurConfiguration();
 		
-		if (StringUtils.isNotBlank(blurHome)) {
-			File blurHomeDir = new File(blurHome + "/conf/blur-site.properties");
-			if (blurHomeDir.exists()) {
-				foundSite = true;
-			}
-			
-			startTimer(blurHome);
-		}
+//		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) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/c6e64403/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 603806d..641d300 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
@@ -1,4 +1,3 @@
-<html>
 	<head>
 		<title>Blur Console</title>
 		<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
@@ -22,10 +21,14 @@
                         <div class="row">
                             <div class="col-md-4">
                                 <h4>Controllers</h4>
-                                <canvas doughnutchart data="controllerData" width="200"
height="200"></canvas>
+                                <canvas doughnutchart data="controllerData" width="100"
height="100" options="chartOptions"></canvas>
                             </div>
                             <div class="col-md-4">
-                                <h3>Shards</h3>
+                                <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">
                                 <h3>Tables</h3>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/c6e64403/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/dashboard.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/dashboard.js
b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/dashboard.js
index b651ee7..52f8ac7 100644
--- a/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/dashboard.js
+++ b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/dashboard.js
@@ -1,11 +1,20 @@
 blurApp.controller('DashboardCtrl', function($scope, $http, $timeout) {
+	$scope.chartOptions = {
+		animation: false	
+	};
     $scope.controllerData = [];
-    //$scope.shard
+    $scope.clusters = [];
 
-    (function tick() {
+    (function controller_tick() {
         $http.get('/service/dashboard/controllers/status').success(function (data) {
             $scope.controllerData = data;
-            $timeout(tick, 10000);
+            $timeout(controller_tick, 10000);
         });
     })();
+    (function cluster_tick() {
+    	$http.get('/service/dashboard/clusters/status').success(function (data) {
+    		$scope.clusters = data;
+    		$timeout(cluster_tick, 10000);
+    	});
+    })();
 })
\ No newline at end of file


Mime
View raw message