Updated Branches: refs/heads/master 3cedeb543 -> 8691ee015
BLUR-259 Subtask(1), implement a method to fetch all the registerd controllers Signed-off-by: Aaron McCurry <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/8691ee01 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/8691ee01 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/8691ee01 Branch: refs/heads/master Commit: 8691ee015c14917b0ee3eacfb563065c3391211e Parents: 3cedeb5 Author: Vikrant Navalgund <[email protected]> Authored: Mon Oct 14 01:04:57 2013 +1100 Committer: Aaron McCurry <[email protected]> Committed: Sun Oct 13 21:09:56 2013 -0400 ---------------------------------------------------------------------- .../blur/manager/clusterstatus/ClusterStatus.java | 6 ++++-- .../clusterstatus/ZookeeperClusterStatus.java | 18 +++++++++++++++++- .../clusterstatus/ZookeeperPathConstants.java | 4 ++++ .../apache/blur/thrift/BlurControllerServer.java | 17 +++++++++++++++-- .../org/apache/blur/manager/IndexManagerTest.java | 5 +++++ 5 files changed, 45 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/8691ee01/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ClusterStatus.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ClusterStatus.java b/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ClusterStatus.java index f14ef11..32110ff 100644 --- a/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ClusterStatus.java +++ b/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ClusterStatus.java @@ -27,10 +27,12 @@ public abstract class ClusterStatus { public abstract List<String> getOnlineShardServers(boolean useCache, String cluster); - public abstract List<String> getControllerServerList(); - public abstract List<String> getShardServerList(String cluster); + public abstract List<String> getOnlineControllerList(); + + public abstract List<String> getControllerServerList(); + public abstract List<String> getClusterList(boolean useCache); public abstract TableDescriptor getTableDescriptor(boolean useCache, String cluster, String table); http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/8691ee01/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperClusterStatus.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperClusterStatus.java b/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperClusterStatus.java index f51f19a..6615f91 100644 --- a/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperClusterStatus.java +++ b/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperClusterStatus.java @@ -252,7 +252,7 @@ public class ZookeeperClusterStatus extends ClusterStatus { } @Override - public List<String> getControllerServerList() { + public List<String> getOnlineControllerList() { long s = System.nanoTime(); try { checkIfOpen(); @@ -263,6 +263,22 @@ public class ZookeeperClusterStatus extends ClusterStatus { throw new RuntimeException(e); } finally { long e = System.nanoTime(); + LOG.debug("trace getOnlineControllerList [" + (e - s) / 1000000.0 + " ms]"); + } + } + + @Override + public List<String> getControllerServerList() { + long s = System.nanoTime(); + try { + checkIfOpen(); + return _zk.getChildren(ZookeeperPathConstants.getControllersPath(), false); + } catch (KeeperException e) { + throw new RuntimeException(e); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + long e = System.nanoTime(); LOG.debug("trace getControllerServerList [" + (e - s) / 1000000.0 + " ms]"); } } http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/8691ee01/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperPathConstants.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperPathConstants.java b/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperPathConstants.java index 3e1f619..5278aca 100644 --- a/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperPathConstants.java +++ b/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperPathConstants.java @@ -35,6 +35,10 @@ public class ZookeeperPathConstants { return getBasePath() + "/online-controller-nodes"; } + public static String getControllersPath() { + return getBasePath() + "/controller-nodes"; + } + public static String getTableEnabledPath(String cluster, String table) { return getTablePath(cluster, table) + "/enabled"; } http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/8691ee01/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 1ec7c6a..6e4a75f 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 @@ -162,6 +162,7 @@ public class BlurControllerServer extends TableAdmin implements Iface { private void setupZookeeper() throws KeeperException, InterruptedException { BlurUtil.createIfMissing(_zookeeper, "/blur"); BlurUtil.createIfMissing(_zookeeper, ZookeeperPathConstants.getOnlineControllersPath()); + BlurUtil.createIfMissing(_zookeeper, ZookeeperPathConstants.getControllersPath()); BlurUtil.createIfMissing(_zookeeper, ZookeeperPathConstants.getClustersPath()); } @@ -280,19 +281,31 @@ public class BlurControllerServer extends TableAdmin implements Iface { private void registerMyself() { try { + String version = BlurUtil.getVersion(); String onlineControllerPath = ZookeeperPathConstants.getOnlineControllersPath() + "/" + _nodeName; while (_zookeeper.exists(onlineControllerPath, false) != null) { LOG.info("Node [{0}] already registered, waiting for path [{1}] to be released", _nodeName, onlineControllerPath); Thread.sleep(3000); } - String version = BlurUtil.getVersion(); _zookeeper.create(onlineControllerPath, version.getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL); } catch (KeeperException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } + + try { + String controllerPath = ZookeeperPathConstants.getControllersPath() + "/" + _nodeName; + if (_zookeeper.exists(controllerPath, false) == null) { + //Don't set the version for the registered nodes but only to the online nodes. + _zookeeper.create(controllerPath, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); + } + } catch (KeeperException e) { + throw new RuntimeException(e); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } } public synchronized void close() { @@ -1050,4 +1063,4 @@ public class BlurControllerServer extends TableAdmin implements Iface { return connections; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/8691ee01/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java ---------------------------------------------------------------------- diff --git a/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java b/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java index b7639cd..1573363 100644 --- a/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java +++ b/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java @@ -166,6 +166,11 @@ public class IndexManagerTest { } @Override + public List<String> getOnlineControllerList() { + throw new RuntimeException("Not impl"); + } + + @Override public List<String> getControllerServerList() { throw new RuntimeException("Not impl"); }
