incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Fixed BLUR-111
Date Thu, 30 May 2013 12:29:51 GMT
Updated Branches:
  refs/heads/0.1.5 d61fd212b -> ff4827f93


Fixed BLUR-111


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

Branch: refs/heads/0.1.5
Commit: ff4827f93ace1dc38504a30bd1b5c4f19dac12fc
Parents: d61fd21
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Thu May 30 08:29:29 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Thu May 30 08:29:29 2013 -0400

----------------------------------------------------------------------
 .../apache/blur/shell/ControllersEchoCommand.java  |   61 +++++++++++++++
 .../src/main/java/org/apache/blur/shell/Main.java  |    1 +
 2 files changed, 62 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ff4827f9/src/blur-shell/src/main/java/org/apache/blur/shell/ControllersEchoCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/ControllersEchoCommand.java
b/src/blur-shell/src/main/java/org/apache/blur/shell/ControllersEchoCommand.java
new file mode 100644
index 0000000..5d82874
--- /dev/null
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/ControllersEchoCommand.java
@@ -0,0 +1,61 @@
+package org.apache.blur.shell;
+
+import java.io.PrintWriter;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.List;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.TException;
+import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.BlurException;
+
+public class ControllersEchoCommand extends Command {
+
+  @Override
+  public void doit(PrintWriter out, Client client, String[] args) throws CommandException,
TException, BlurException {
+    List<String> controllerServerList = client.controllerServerList();
+    String nodeName = getNodeName();
+    for (String controller : controllerServerList) {
+      if (isSameServer(controller, nodeName)) {
+        out.println(controller + "*");
+      } else {
+        out.println(controller);
+      }
+    }
+  }
+
+  private boolean isSameServer(String controller, String nodeName) {
+    if (nodeName == null || controller == null) {
+      return false;
+    } else {
+      int i = controller.lastIndexOf(':');
+      if (i < 0) {
+        return false;
+      }
+      if (nodeName.equals(controller.substring(0, i))) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  @Override
+  public String help() {
+    return "list controllers";
+  }
+
+  public static String getNodeName() {
+    try {
+      return InetAddress.getLocalHost().getHostName();
+    } catch (UnknownHostException e) {
+      String message = e.getMessage();
+      int index = message.indexOf(':');
+      if (index < 0) {
+        return null;
+      }
+      String nodeName = message.substring(0, index);
+      return nodeName;
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ff4827f9/src/blur-shell/src/main/java/org/apache/blur/shell/Main.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/Main.java b/src/blur-shell/src/main/java/org/apache/blur/shell/Main.java
index 614f60d..b74a766 100644
--- a/src/blur-shell/src/main/java/org/apache/blur/shell/Main.java
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/Main.java
@@ -152,6 +152,7 @@ public class Main {
         .put("indexaccesslog", new IndexAccessLogCommand())
         .put("shardclusterlist", new ShardClusterListCommand())
         .put("shardserverlayout", new ShardServerLayoutCommand())
+        .put("controllers", new ControllersEchoCommand())
         .build();
 
     try {


Mime
View raw message