incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [9/9] git commit: Status pages now work with random port assignment for the http status port being randomly assigned.
Date Wed, 04 Mar 2015 14:38:50 GMT
Status pages now work with random port assignment for the http status port being randomly assigned.


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

Branch: refs/heads/master
Commit: df0e889e1aefa9b7a5258a2a61354a9b5641597e
Parents: c46eb88
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Wed Mar 4 09:38:37 2015 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Wed Mar 4 09:38:37 2015 -0500

----------------------------------------------------------------------
 .../apache/blur/server/FilteredBlurServer.java  |  5 +++++
 .../blur/thrift/BlurControllerServer.java       |  5 -----
 .../java/org/apache/blur/thrift/TableAdmin.java | 23 ++++++++++++++++++++
 .../blur/thrift/ThriftBlurControllerServer.java |  2 ++
 .../blur/thrift/ThriftBlurShardServer.java      |  3 +++
 .../server/cache/ThriftCacheServerTest.java     |  6 +++++
 .../src/main/resources/webapp/index.html        | 13 ++++++-----
 .../org/apache/blur/utils/BlurConstants.java    |  1 +
 .../apache/blur/utils/BlurConstantsTest.java    |  2 +-
 9 files changed, 49 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/df0e889e/blur-core/src/main/java/org/apache/blur/server/FilteredBlurServer.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/server/FilteredBlurServer.java b/blur-core/src/main/java/org/apache/blur/server/FilteredBlurServer.java
index 6a7eb17..1bff212 100644
--- a/blur-core/src/main/java/org/apache/blur/server/FilteredBlurServer.java
+++ b/blur-core/src/main/java/org/apache/blur/server/FilteredBlurServer.java
@@ -312,4 +312,9 @@ public class FilteredBlurServer implements Iface {
     _iface.bulkMutateAddMultiple(bulkId, rowMutations);
   }
 
+  @Override
+  public String configurationPerServer(String thriftServerPlusPort, String configName) throws
BlurException, TException {
+    return _iface.configurationPerServer(thriftServerPlusPort, configName);
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/df0e889e/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java b/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java
index 4c45a90..8bc8da4 100644
--- a/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java
+++ b/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java
@@ -179,7 +179,6 @@ public class BlurControllerServer extends TableAdmin implements Iface
{
   private AtomicBoolean _closed = new AtomicBoolean();
   private Map<String, Integer> _tableShardCountMap = new ConcurrentHashMap<String,
Integer>();
   private BlurPartitioner _blurPartitioner = new BlurPartitioner();
-  private String _nodeName;
   private int _remoteFetchCount = 100;
   private BlurQueryChecker _queryChecker;
   private AtomicBoolean _running = new AtomicBoolean();
@@ -1387,10 +1386,6 @@ public class BlurControllerServer extends TableAdmin implements Iface
{
     }
   }
 
-  public void setNodeName(String nodeName) {
-    _nodeName = nodeName;
-  }
-
   public int getRemoteFetchCount() {
     return _remoteFetchCount;
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/df0e889e/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java b/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java
index 69f74a2..2dd7f53 100644
--- a/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java
+++ b/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java
@@ -46,6 +46,7 @@ import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.ColumnDefinition;
 import org.apache.blur.thrift.generated.CommandDescriptor;
+import org.apache.blur.thrift.generated.ErrorType;
 import org.apache.blur.thrift.generated.Level;
 import org.apache.blur.thrift.generated.Metric;
 import org.apache.blur.thrift.generated.Schema;
@@ -68,6 +69,7 @@ public abstract class TableAdmin implements Iface {
   protected ClusterStatus _clusterStatus;
   protected BlurConfiguration _configuration;
   protected int _maxRecordsPerRowFetchRequest = 1000;
+  protected String _nodeName;
 
   protected void checkSelectorFetchSize(Selector selector) {
     if (selector == null) {
@@ -733,4 +735,25 @@ public abstract class TableAdmin implements Iface {
   // throw new RuntimeException("Not implemented.");
   // }
 
+  @Override
+  public String configurationPerServer(String thriftServerPlusPort, String configName) throws
BlurException, TException {
+    if (thriftServerPlusPort == null || thriftServerPlusPort.equals(_nodeName)) {
+      String s = _configuration.get(configName);
+      if (s == null) {
+        throw new BlurException("NOT_FOUND", null, ErrorType.UNKNOWN);
+      }
+      return s;
+    }
+    Iface client = BlurClient.getClient(thriftServerPlusPort);
+    return client.configurationPerServer(thriftServerPlusPort, configName);
+  }
+
+  public String getNodeName() {
+    return _nodeName;
+  }
+
+  public void setNodeName(String nodeName) {
+    _nodeName = nodeName;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/df0e889e/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurControllerServer.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurControllerServer.java
b/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurControllerServer.java
index 3279d0c..a3e2c90 100644
--- a/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurControllerServer.java
+++ b/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurControllerServer.java
@@ -42,6 +42,7 @@ import static org.apache.blur.utils.BlurConstants.BLUR_GC_BACK_PRESSURE_HEAP_RAT
 import static org.apache.blur.utils.BlurConstants.BLUR_GUI_CONTROLLER_PORT;
 import static org.apache.blur.utils.BlurConstants.BLUR_HTTP_STATUS_RUNNING_PORT;
 import static org.apache.blur.utils.BlurConstants.BLUR_MAX_RECORDS_PER_ROW_FETCH_REQUEST;
+import static org.apache.blur.utils.BlurConstants.BLUR_NODENAME;
 import static org.apache.blur.utils.BlurConstants.BLUR_THRIFT_DEFAULT_MAX_FRAME_SIZE;
 import static org.apache.blur.utils.BlurConstants.BLUR_THRIFT_MAX_FRAME_SIZE;
 import static org.apache.blur.utils.BlurConstants.BLUR_TMP_PATH;
@@ -124,6 +125,7 @@ public class ThriftBlurControllerServer extends ThriftServer {
 
     String nodeName = getNodeName(configuration, BLUR_CONTROLLER_HOSTNAME);
     nodeName = nodeName + ":" + instanceBindPort;
+    configuration.set(BLUR_NODENAME, nodeName);
     String zkConnectionStr = isEmpty(configuration.get(BLUR_ZOOKEEPER_CONNECTION), BLUR_ZOOKEEPER_CONNECTION);
 
     BlurQueryChecker queryChecker = new BlurQueryChecker(configuration);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/df0e889e/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java b/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java
index 5a7346d..5cdbe77 100644
--- a/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java
+++ b/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java
@@ -29,6 +29,7 @@ import static org.apache.blur.utils.BlurConstants.BLUR_INDEXMANAGER_SEARCH_THREA
 import static org.apache.blur.utils.BlurConstants.BLUR_MAX_CLAUSE_COUNT;
 import static org.apache.blur.utils.BlurConstants.BLUR_MAX_HEAP_PER_ROW_FETCH;
 import static org.apache.blur.utils.BlurConstants.BLUR_MAX_RECORDS_PER_ROW_FETCH_REQUEST;
+import static org.apache.blur.utils.BlurConstants.BLUR_NODENAME;
 import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_BIND_ADDRESS;
 import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_BIND_PORT;
 import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_BLOCK_CACHE_TOTAL_SIZE;
@@ -188,6 +189,7 @@ public class ThriftBlurShardServer extends ThriftServer {
 
     String nodeNameHostName = getNodeName(configuration, BLUR_SHARD_HOSTNAME);
     String nodeName = nodeNameHostName + ":" + instanceBindPort;
+    configuration.set(BLUR_NODENAME, nodeName);
     String zkConnectionStr = isEmpty(configuration.get(BLUR_ZOOKEEPER_CONNECTION), BLUR_ZOOKEEPER_CONNECTION);
 
     BlurQueryChecker queryChecker = new BlurQueryChecker(configuration);
@@ -264,6 +266,7 @@ public class ThriftBlurShardServer extends ThriftServer {
     });
 
     final BlurShardServer shardServer = new BlurShardServer();
+    shardServer.setNodeName(nodeName);
     shardServer.setCommandManager(commandManager);
     shardServer.setIndexServer(indexServer);
     shardServer.setIndexManager(indexManager);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/df0e889e/blur-core/src/test/java/org/apache/blur/server/cache/ThriftCacheServerTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/server/cache/ThriftCacheServerTest.java
b/blur-core/src/test/java/org/apache/blur/server/cache/ThriftCacheServerTest.java
index 587f1fb..f01a665 100644
--- a/blur-core/src/test/java/org/apache/blur/server/cache/ThriftCacheServerTest.java
+++ b/blur-core/src/test/java/org/apache/blur/server/cache/ThriftCacheServerTest.java
@@ -509,6 +509,12 @@ public class ThriftCacheServerTest {
           TException {
         throw new RuntimeException("Not implemented.");
       }
+
+      @Override
+      public String configurationPerServer(String thriftServerPlusPort, String configName)
throws BlurException,
+          TException {
+        throw new RuntimeException("Not implemented.");
+      }
     };
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/df0e889e/blur-status/src/main/resources/webapp/index.html
----------------------------------------------------------------------
diff --git a/blur-status/src/main/resources/webapp/index.html b/blur-status/src/main/resources/webapp/index.html
index 0a6f1b8..bf944c5 100644
--- a/blur-status/src/main/resources/webapp/index.html
+++ b/blur-status/src/main/resources/webapp/index.html
@@ -37,6 +37,7 @@ function displayPage() {
     try {
 	  var clusters = client.shardClusterList();
 	  var body = $("#page_body");
+      body.append("<h2>Current Node [" + getNodeName(client) + "]</h2>");
 	  for (var i = 0; i < clusters.length; i++) {
         var cluster = clusters[i];
         body.append("<h2>Tables [" + cluster + "]</h2>");
@@ -66,7 +67,7 @@ s += "<tr><th>Name</th><th>Enabled</th><th>Totals
Shards</th><th>Online Shards</
         var l = "<ul>";
 	    for (var t = 0; t < cservers.length; t++) {
 		  var server = cservers[t];
-		  var hostname = getHostName(server);
+		  var hostname = getHttpName(client, server);
 		  l += "<li><a href=\"http://"+hostname+"\">" + server + "</a></li>";
 		}
 		body.append(l + "</ul>");
@@ -77,7 +78,7 @@ s += "<tr><th>Name</th><th>Enabled</th><th>Totals
Shards</th><th>Online Shards</
         var l = "<ul>";
 	    for (var t = 0; t < servers.length; t++) {
 		  var server = servers[t];
-		  var hostname = getHostName(server);
+		  var hostname = getHttpName(client, server);
 		  l += "<li><a href=\"http://"+hostname+"\">" + server + "</a></li>";
 		}
 		body.append(l + "</ul>");
@@ -86,10 +87,12 @@ s += "<tr><th>Name</th><th>Enabled</th><th>Totals
Shards</th><th>Online Shards</
 alert (ouch);
     }
 }
-function getHostName(hostnamePlusPort) {
+function getNodeName(client) {
+  return client.configurationPerServer(null, "blur.nodename");
+}
+function getHttpName(client,hostnamePlusPort) {
   var indexOf = hostnamePlusPort.indexOf("\:");
-  var port = parseInt(hostnamePlusPort.substring(indexOf+1));
-  port+=70;
+  var port = client.configurationPerServer(hostnamePlusPort, "blur.http.status.running.port");
   return hostnamePlusPort.substring(0,indexOf) + ":" + port;
 }
 $(window).bind("load", displayPage);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/df0e889e/blur-util/src/main/java/org/apache/blur/utils/BlurConstants.java
----------------------------------------------------------------------
diff --git a/blur-util/src/main/java/org/apache/blur/utils/BlurConstants.java b/blur-util/src/main/java/org/apache/blur/utils/BlurConstants.java
index 0c4f8ec..6dbe515 100644
--- a/blur-util/src/main/java/org/apache/blur/utils/BlurConstants.java
+++ b/blur-util/src/main/java/org/apache/blur/utils/BlurConstants.java
@@ -162,6 +162,7 @@ public class BlurConstants {
   public static final String BLUR_CONTROLLER_COMMAND_WORKER_THREADS = "blur.controller.command.worker.threads";
   public static final String BLUR_COMMAND_LIB_PATH = "blur.command.lib.path";
   public static final String BLUR_TMP_PATH = "blur.tmp.path";
+  public static final String BLUR_NODENAME = "blur.nodename";
 
   public static final String BLUR_SECURITY_SASL_TYPE = "blur.security.sasl.type";
   public static final String BLUR_SECURITY_SASL_ENABLED = "blur.security.sasl.enabled";

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/df0e889e/blur-util/src/test/java/org/apache/blur/utils/BlurConstantsTest.java
----------------------------------------------------------------------
diff --git a/blur-util/src/test/java/org/apache/blur/utils/BlurConstantsTest.java b/blur-util/src/test/java/org/apache/blur/utils/BlurConstantsTest.java
index da4d350..04a1a34 100644
--- a/blur-util/src/test/java/org/apache/blur/utils/BlurConstantsTest.java
+++ b/blur-util/src/test/java/org/apache/blur/utils/BlurConstantsTest.java
@@ -42,7 +42,7 @@ public class BlurConstantsTest {
         "ROW_ID", "RECORD_ID", "FIELDS", "FAMILY", "DEFAULT_FAMILY", "SUPER", "SEP", "BLUR_HOME",
         "DELETE_MARKER_VALUE", "DELETE_MARKER", "BLUR_ZOOKEEPER_TIMEOUT_DEFAULT", "BLUR_THRIFT_DEFAULT_MAX_FRAME_SIZE",
         "ZK_WAIT_TIME", "ACL_DISCOVER", "ACL_READ", "FAST_DECOMPRESSION", "FAST", "HIGH_COMPRESSION",
"DEFAULT_VALUE",
-        "OFF_HEAP", "DEFAULT", "BLUR_CLUSTER", "BLUR_HTTP_STATUS_RUNNING_PORT", "SHARED_MERGE_SCHEDULER_PREFIX"));
+        "OFF_HEAP", "DEFAULT", "BLUR_CLUSTER", "BLUR_NODENAME", "BLUR_HTTP_STATUS_RUNNING_PORT",
"SHARED_MERGE_SCHEDULER_PREFIX"));
     _emptyDefaultProperties = new HashSet<String>();
     _emptyDefaultProperties.addAll(Arrays.asList("BLUR_HDFS_TRACE_PATH", "BLUR_SHARD_HOSTNAME",
         "BLUR_SHARD_BLOCK_CACHE_TOTAL_SIZE", "BLUR_CONTROLLER_HOSTNAME", "BLUR_SHARD_READ_INTERCEPTOR",


Mime
View raw message