incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [1/3] git commit: Updates to the blur shell.
Date Fri, 07 Jun 2013 17:31:35 GMT
Updated Branches:
  refs/heads/0.1.5 ae49a010a -> bca9cafc2


Updates to the blur shell.


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

Branch: refs/heads/0.1.5
Commit: 0bb1028467b70b871f230b05a48d75d7e74dc1bf
Parents: ae49a01
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Fri Jun 7 13:29:09 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Fri Jun 7 13:29:09 2013 -0400

----------------------------------------------------------------------
 .../main/java/org/apache/blur/shell/Command.java   |    5 +-
 .../apache/blur/shell/ControllersEchoCommand.java  |    4 +-
 .../org/apache/blur/shell/CreateTableCommand.java  |    4 +-
 .../apache/blur/shell/DescribeTableCommand.java    |    4 +-
 .../blur/shell/EnableDisableTableCommand.java      |    4 +-
 .../java/org/apache/blur/shell/GetRowCommand.java  |    4 +-
 .../apache/blur/shell/IndexAccessLogCommand.java   |    4 +-
 .../org/apache/blur/shell/ListTablesCommand.java   |    4 +-
 .../src/main/java/org/apache/blur/shell/Main.java  |  201 ++++++++-------
 .../org/apache/blur/shell/MutateRowCommand.java    |    4 +-
 .../java/org/apache/blur/shell/QueryCommand.java   |    4 +-
 .../org/apache/blur/shell/RemoveTableCommand.java  |    4 +-
 .../org/apache/blur/shell/SchemaTableCommand.java  |    4 +-
 .../apache/blur/shell/ShardClusterListCommand.java |    4 +-
 .../blur/shell/ShardServerLayoutCommand.java       |    4 +-
 .../org/apache/blur/shell/ShardsEchoCommand.java   |   65 +++++
 .../org/apache/blur/shell/TableStatsCommand.java   |    4 +-
 distribution/src/main/scripts/bin/blur             |    7 +-
 18 files changed, 208 insertions(+), 126 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/Command.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/Command.java b/blur-shell/src/main/java/org/apache/blur/shell/Command.java
index 36da1ec..a12883f 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/Command.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/Command.java
@@ -20,10 +20,9 @@ package org.apache.blur.shell;
 
 import java.io.PrintWriter;
 
-
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
+import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.BlurException;
-import org.apache.blur.thrift.generated.Blur.Client;
 
 public abstract class Command {
   @SuppressWarnings("serial")
@@ -32,7 +31,7 @@ public abstract class Command {
       super(msg);
     }
   }
-  abstract public void doit(PrintWriter out, Client client, String[] args)
+  abstract public void doit(PrintWriter out, Blur.Iface client, String[] args)
       throws CommandException, TException, BlurException;
   abstract public String help();
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/ControllersEchoCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/ControllersEchoCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/ControllersEchoCommand.java
index 5d82874..32df28e 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/ControllersEchoCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/ControllersEchoCommand.java
@@ -6,13 +6,13 @@ 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.Blur;
 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 {
+  public void doit(PrintWriter out, Blur.Iface client, String[] args) throws CommandException,
TException, BlurException {
     List<String> controllerServerList = client.controllerServerList();
     String nodeName = getNodeName();
     for (String controller : controllerServerList) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/CreateTableCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/CreateTableCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/CreateTableCommand.java
index a22b427..4a7f4d3 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/CreateTableCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/CreateTableCommand.java
@@ -22,13 +22,13 @@ import java.io.PrintWriter;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
 import org.apache.blur.thrift.generated.AnalyzerDefinition;
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.TableDescriptor;
 
 public class CreateTableCommand extends Command {
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
+  public void doit(PrintWriter out, Blur.Iface client, String[] args)
       throws CommandException, TException, BlurException {
     if (args.length != 4) {
       throw new CommandException("Invalid args: " + help());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/DescribeTableCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/DescribeTableCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/DescribeTableCommand.java
index 15e9a5b..32e563f 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/DescribeTableCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/DescribeTableCommand.java
@@ -21,12 +21,12 @@ package org.apache.blur.shell;
 import java.io.PrintWriter;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.BlurException;
 
 public class DescribeTableCommand extends Command {
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
+  public void doit(PrintWriter out, Blur.Iface client, String[] args)
       throws CommandException, TException, BlurException {
     if (args.length != 2) {
       throw new CommandException("Invalid args: " + help());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/EnableDisableTableCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/EnableDisableTableCommand.java
b/blur-shell/src/main/java/org/apache/blur/shell/EnableDisableTableCommand.java
index d3ab60e..0938889 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/EnableDisableTableCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/EnableDisableTableCommand.java
@@ -21,12 +21,12 @@ package org.apache.blur.shell;
 import java.io.PrintWriter;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.BlurException;
 
 public class EnableDisableTableCommand extends Command {
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
+  public void doit(PrintWriter out, Blur.Iface client, String[] args)
       throws CommandException, TException, BlurException {
     if (args.length != 2) {
       throw new CommandException("Invalid args: " + help());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/GetRowCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/GetRowCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/GetRowCommand.java
index 287fe4e..bf8be51 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/GetRowCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/GetRowCommand.java
@@ -21,7 +21,7 @@ package org.apache.blur.shell;
 import java.io.PrintWriter;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.FetchResult;
 import org.apache.blur.thrift.generated.FetchRowResult;
@@ -30,7 +30,7 @@ import org.apache.blur.thrift.generated.Selector;
 
 public class GetRowCommand extends Command {
   @Override
-  public void doit(PrintWriter out, Client client, String[] args) throws CommandException,
TException, BlurException {
+  public void doit(PrintWriter out, Blur.Iface client, String[] args) throws CommandException,
TException, BlurException {
     if (args.length != 3) {
       throw new CommandException("Invalid args: " + help());
     }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/IndexAccessLogCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/IndexAccessLogCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/IndexAccessLogCommand.java
index 10c434b..858c9f1 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/IndexAccessLogCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/IndexAccessLogCommand.java
@@ -30,7 +30,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.Column;
 import org.apache.blur.thrift.generated.Record;
@@ -43,7 +43,7 @@ import com.google.common.collect.Lists;
 
 public class IndexAccessLogCommand extends Command {
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
+  public void doit(PrintWriter out, Blur.Iface client, String[] args)
       throws CommandException, TException, BlurException {
     if (args.length < 6) {
       throw new CommandException("Invalid args: " + help());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/ListTablesCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/ListTablesCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/ListTablesCommand.java
index 06de2dd..ef418e6 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/ListTablesCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/ListTablesCommand.java
@@ -21,12 +21,12 @@ package org.apache.blur.shell;
 import java.io.PrintWriter;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.BlurException;
 
 public class ListTablesCommand extends Command {
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
+  public void doit(PrintWriter out, Blur.Iface client, String[] args)
       throws CommandException, TException, BlurException {
     out.println("tables: " + client.tableList());
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/Main.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/Main.java b/blur-shell/src/main/java/org/apache/blur/shell/Main.java
index b74a766..d97472f 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/Main.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/Main.java
@@ -18,6 +18,10 @@
 
 package org.apache.blur.shell;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.PrintWriter;
 import java.util.LinkedList;
 import java.util.List;
@@ -33,15 +37,12 @@ import jline.console.completer.StringsCompleter;
 import org.apache.blur.shell.Command.CommandException;
 import org.apache.blur.shell.Main.QuitCommand.QuitCommandException;
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
-import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TBinaryProtocol;
-import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol;
-import org.apache.blur.thirdparty.thrift_0_9_0.transport.TFramedTransport;
-import org.apache.blur.thirdparty.thrift_0_9_0.transport.TSocket;
-import org.apache.blur.thirdparty.thrift_0_9_0.transport.TTransport;
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.BlurClient;
+import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.BlurException;
 
 import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
 
 public class Main {
   /** is debugging enabled - off by default */
@@ -50,17 +51,16 @@ public class Main {
   static boolean timed = false;
 
   private static Map<String, Command> commands;
-  
+
   public static void usage() {
-    System.out.println("Usage: java " + Main.class.getName()
-        + " controller:port");
+    System.out.println("Usage: java " + Main.class.getName() + " controller1:port,controller2:port,...");
   }
 
   private static class DebugCommand extends Command {
 
     @Override
-    public void doit(PrintWriter out, Client client, String[] args)
-        throws CommandException, TException, BlurException {
+    public void doit(PrintWriter out, Blur.Iface client, String[] args) throws CommandException,
TException,
+        BlurException {
       if (debug == true) {
         debug = false;
       } else {
@@ -73,14 +73,14 @@ public class Main {
     public String help() {
       return "toggle debugging on/off";
     }
-    
+
   }
 
   private static class TimedCommand extends Command {
 
     @Override
-    public void doit(PrintWriter out, Client client, String[] args)
-        throws CommandException, TException, BlurException {
+    public void doit(PrintWriter out, Blur.Iface client, String[] args) throws CommandException,
TException,
+        BlurException {
       if (timed == true) {
         timed = false;
       } else {
@@ -93,15 +93,15 @@ public class Main {
     public String help() {
       return "toggle timing of commands on/off";
     }
-    
+
   }
 
   private static class HelpCommand extends Command {
     @Override
-    public void doit(PrintWriter out, Client client, String[] args)
-        throws CommandException, TException, BlurException {
+    public void doit(PrintWriter out, Blur.Iface client, String[] args) throws CommandException,
TException,
+        BlurException {
       out.println("Available commands:");
-      for (Entry<String, Command> e: commands.entrySet()) {
+      for (Entry<String, Command> e : commands.entrySet()) {
         out.println("  " + e.getKey() + " - " + e.getValue().help());
       }
     }
@@ -121,8 +121,8 @@ public class Main {
     }
 
     @Override
-    public void doit(PrintWriter out, Client client, String[] args)
-        throws CommandException, TException, BlurException {
+    public void doit(PrintWriter out, Blur.Iface client, String[] args) throws CommandException,
TException,
+        BlurException {
       throw new QuitCommandException();
     }
 
@@ -133,43 +133,45 @@ public class Main {
   }
 
   public static void main(String[] args) throws Throwable {
-    commands = new ImmutableMap.Builder<String,Command>()
-        .put("help", new HelpCommand())
-        .put("debug", new DebugCommand())
-        .put("timed", new TimedCommand())
-        .put("quit", new QuitCommand())
-        .put("listtables", new ListTablesCommand())
-        .put("createtable", new CreateTableCommand())
-        .put("enabletable", new EnableDisableTableCommand())
-        .put("disabletable", new EnableDisableTableCommand())
-        .put("removetable", new RemoveTableCommand())
-        .put("describetable", new DescribeTableCommand())
-        .put("tablestats", new TableStatsCommand())
-        .put("schema", new SchemaTableCommand())
-        .put("query", new QueryCommand())
-        .put("getrow", new GetRowCommand())
-        .put("mutaterow", new MutateRowCommand())
-        .put("indexaccesslog", new IndexAccessLogCommand())
-        .put("shardclusterlist", new ShardClusterListCommand())
-        .put("shardserverlayout", new ShardServerLayoutCommand())
-        .put("controllers", new ControllersEchoCommand())
-        .build();
+    Builder<String, Command> builder = new ImmutableMap.Builder<String, Command>();
+    builder.put("help", new HelpCommand());
+    builder.put("debug", new DebugCommand());
+    builder.put("timed", new TimedCommand());
+    builder.put("quit", new QuitCommand());
+    builder.put("list", new ListTablesCommand());
+    builder.put("create", new CreateTableCommand());
+    builder.put("enable", new EnableDisableTableCommand());
+    builder.put("disable", new EnableDisableTableCommand());
+    builder.put("remove", new RemoveTableCommand());
+    builder.put("describe", new DescribeTableCommand());
+    builder.put("tablestats", new TableStatsCommand());
+    builder.put("schema", new SchemaTableCommand());
+    builder.put("query", new QueryCommand());
+    builder.put("getrow", new GetRowCommand());
+    builder.put("mutaterow", new MutateRowCommand());
+    builder.put("indexaccesslog", new IndexAccessLogCommand());
+    builder.put("shardclusterlist", new ShardClusterListCommand());
+    builder.put("shardserverlayout", new ShardServerLayoutCommand());
+    builder.put("controllers", new ControllersEchoCommand());
+    builder.put("shards", new ShardsEchoCommand());
+    commands = builder.build();
 
     try {
       ConsoleReader reader = new ConsoleReader();
 
       reader.setPrompt("blur> ");
 
-      if ((args == null) || (args.length != 1)) {
-        usage();
-        return;
-      }
+      String controllerConnectionString = null;
 
-      String[] hostport = args[0].split(":"); 
+      if ((args == null) || (args.length != 1)) {
+        controllerConnectionString = loadControllerConnectionString();
+        if (controllerConnectionString == null) {
+          usage();
+          return;
+        }
+      } else {
+        controllerConnectionString = args[0];
 
-      if (hostport.length != 2) {
-        usage();
-        return;
       }
 
       List<Completer> completors = new LinkedList<Completer>();
@@ -181,61 +183,74 @@ public class Main {
         reader.addCompleter(c);
       }
 
-      TTransport trans = new TSocket(hostport[0], Integer.parseInt(hostport[1]));
-      TProtocol proto = new TBinaryProtocol(new TFramedTransport(trans));
-      Client client = new Client(proto);
+      Blur.Iface client = BlurClient.getClient(controllerConnectionString);
+
+      String line;
+      PrintWriter out = new PrintWriter(reader.getOutput());
       try {
-          trans.open();
-
-          String line;
-          PrintWriter out = new PrintWriter(reader.getOutput());
-          try {
-            while ((line = reader.readLine()) != null) {
-              line = line.trim();
-              // ignore empty lines and comments
-              if (line.length() == 0 || line.startsWith("#")) {
-                continue;
+        while ((line = reader.readLine()) != null) {
+          line = line.trim();
+          // ignore empty lines and comments
+          if (line.length() == 0 || line.startsWith("#")) {
+            continue;
+          }
+          String[] commandArgs = line.split("\\s");
+          Command command = commands.get(commandArgs[0]);
+          if (command == null) {
+            out.println("unknown command \"" + commandArgs[0] + "\"");
+          } else {
+            long start = System.nanoTime();
+            try {
+              command.doit(out, client, commandArgs);
+            } catch (QuitCommandException e) {
+              // exit gracefully
+              System.exit(0);
+            } catch (CommandException e) {
+              out.println(e.getMessage());
+              if (debug) {
+                e.printStackTrace(out);
+              }
+            } catch (BlurException e) {
+              out.println(e.getMessage());
+              if (debug) {
+                e.printStackTrace(out);
               }
-              String[] commandArgs = line.split("\\s");
-              Command command = commands.get(commandArgs[0]);
-              if (command == null) {
-                out.println("unknown command \"" + commandArgs[0] + "\"");
-              } else {
-                long start = System.nanoTime();
-                try {
-                  command.doit(out, client, commandArgs);
-                } catch (QuitCommandException e) {
-                  // exit gracefully
-                  System.exit(0);
-                } catch (CommandException e) {
-                  out.println(e.getMessage());
-                  if (debug) {
-                    e.printStackTrace(out);
-                  }
-                } catch (BlurException e) {
-                  out.println(e.getMessage());
-                  if (debug) {
-                    e.printStackTrace(out);
-                  }
-                } finally {
-                  if (timed) {
-                    out.println("Last command took "
-                        + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start)
-                        + "ms");
-                  }
-                }
+            } finally {
+              if (timed) {
+                out.println("Last command took " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime()
- start) + "ms");
               }
             }
-          } finally {
-            out.close();
           }
+        }
       } finally {
-          trans.close();
+        out.close();
       }
+
     } catch (Throwable t) {
       t.printStackTrace();
       throw t;
     }
   }
 
+  private static String loadControllerConnectionString() throws IOException {
+    StringBuilder builder = new StringBuilder();
+    InputStream inputStream = Main.class.getResourceAsStream("/controllers");
+    if (inputStream == null) {
+      return null;
+    }
+    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+    String line;
+    while ((line = bufferedReader.readLine()) != null) {
+      if (builder.length() != 0) {
+        builder.append(',');
+      }
+      String trim = line.trim();
+      if (trim.startsWith("#")) {
+        continue;
+      }
+      builder.append(trim).append(":40010");
+    }
+    bufferedReader.close();
+    return builder.toString();
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/MutateRowCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/MutateRowCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/MutateRowCommand.java
index 86dcf05..27cd560 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/MutateRowCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/MutateRowCommand.java
@@ -23,7 +23,7 @@ import java.util.ArrayList;
 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.Blur;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.Column;
 import org.apache.blur.thrift.generated.Record;
@@ -34,7 +34,7 @@ import org.apache.blur.thrift.generated.RowMutationType;
 
 public class MutateRowCommand extends Command {
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
+  public void doit(PrintWriter out, Blur.Iface client, String[] args)
       throws CommandException, TException, BlurException {
     if (args.length != 7) {
       throw new CommandException("Invalid args: " + help());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/QueryCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/QueryCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/QueryCommand.java
index 5599e0b..0e98a20 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/QueryCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/QueryCommand.java
@@ -21,7 +21,7 @@ package org.apache.blur.shell;
 import java.io.PrintWriter;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurQuery;
 import org.apache.blur.thrift.generated.BlurResult;
@@ -31,7 +31,7 @@ import org.apache.blur.thrift.generated.SimpleQuery;
 
 public class QueryCommand extends Command {
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
+  public void doit(PrintWriter out, Blur.Iface client, String[] args)
       throws CommandException, TException, BlurException {
     if (args.length < 3) {
       throw new CommandException("Invalid args: " + help());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/RemoveTableCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/RemoveTableCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/RemoveTableCommand.java
index 7690686..df562be 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/RemoveTableCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/RemoveTableCommand.java
@@ -21,12 +21,12 @@ package org.apache.blur.shell;
 import java.io.PrintWriter;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.BlurException;
 
 public class RemoveTableCommand extends Command {
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
+  public void doit(PrintWriter out, Blur.Iface client, String[] args)
       throws CommandException, TException, BlurException {
     if (args.length != 2) {
       throw new CommandException("Invalid args: " + help());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/SchemaTableCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/SchemaTableCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/SchemaTableCommand.java
index a2609c2..b8421a0 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/SchemaTableCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/SchemaTableCommand.java
@@ -21,12 +21,12 @@ package org.apache.blur.shell;
 import java.io.PrintWriter;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.BlurException;
 
 public class SchemaTableCommand extends Command {
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
+  public void doit(PrintWriter out, Blur.Iface client, String[] args)
       throws CommandException, TException, BlurException {
     if (args.length != 2) {
       throw new CommandException("Invalid args: " + help());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/ShardClusterListCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/ShardClusterListCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/ShardClusterListCommand.java
index 3ccc6f3..a1f590f 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/ShardClusterListCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/ShardClusterListCommand.java
@@ -21,12 +21,12 @@ package org.apache.blur.shell;
 import java.io.PrintWriter;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.BlurException;
 
 public class ShardClusterListCommand extends Command {
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
+  public void doit(PrintWriter out, Blur.Iface client, String[] args)
       throws CommandException, TException, BlurException {
     if (args.length != 1) {
       throw new CommandException("Invalid args: " + help());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/ShardServerLayoutCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/ShardServerLayoutCommand.java
b/blur-shell/src/main/java/org/apache/blur/shell/ShardServerLayoutCommand.java
index 21e75ef..1b66f4d 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/ShardServerLayoutCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/ShardServerLayoutCommand.java
@@ -21,12 +21,12 @@ package org.apache.blur.shell;
 import java.io.PrintWriter;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.BlurException;
 
 public class ShardServerLayoutCommand extends Command {
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
+  public void doit(PrintWriter out, Blur.Iface client, String[] args)
       throws CommandException, TException, BlurException {
     if (args.length != 2) {
       throw new CommandException("Invalid args: " + help());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/ShardsEchoCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/ShardsEchoCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/ShardsEchoCommand.java
new file mode 100644
index 0000000..c12b945
--- /dev/null
+++ b/blur-shell/src/main/java/org/apache/blur/shell/ShardsEchoCommand.java
@@ -0,0 +1,65 @@
+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;
+import org.apache.blur.thrift.generated.BlurException;
+
+public class ShardsEchoCommand extends Command {
+
+  @Override
+  public void doit(PrintWriter out, Blur.Iface client, String[] args) throws CommandException,
TException, BlurException {
+    if (args.length != 2) {
+      throw new CommandException("Invalid args: " + help());
+    }
+    String cluster = args[1];
+    List<String> shardServerList = client.shardServerList(cluster);
+    String nodeName = getNodeName();
+    for (String shards : shardServerList) {
+      if (isSameServer(shards, nodeName)) {
+        out.println(shards + "*");
+      } else {
+        out.println(shards);
+      }
+    }
+  }
+
+  private boolean isSameServer(String shard, String nodeName) {
+    if (nodeName == null || shard == null) {
+      return false;
+    } else {
+      int i = shard.lastIndexOf(':');
+      if (i < 0) {
+        return false;
+      }
+      if (nodeName.equals(shard.substring(0, i))) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  @Override
+  public String help() {
+    return "list shards, args; clustername";
+  }
+
+  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/0bb10284/blur-shell/src/main/java/org/apache/blur/shell/TableStatsCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/TableStatsCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/TableStatsCommand.java
index f8d7d18..5d20ec3 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/TableStatsCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/TableStatsCommand.java
@@ -21,12 +21,12 @@ package org.apache.blur.shell;
 import java.io.PrintWriter;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.BlurException;
 
 public class TableStatsCommand extends Command {
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
+  public void doit(PrintWriter out, Blur.Iface client, String[] args)
       throws CommandException, TException, BlurException {
     if (args.length != 2) {
       throw new CommandException("Invalid args: " + help());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0bb10284/distribution/src/main/scripts/bin/blur
----------------------------------------------------------------------
diff --git a/distribution/src/main/scripts/bin/blur b/distribution/src/main/scripts/bin/blur
index afe5ebb..ec4be88 100755
--- a/distribution/src/main/scripts/bin/blur
+++ b/distribution/src/main/scripts/bin/blur
@@ -20,7 +20,10 @@ bin=`cd "$bin"; pwd`
 
 . "$bin"/blur-config.sh
 PROC_NAME=$1
-"$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH $BLUR_COMMAND
-Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=$PROC_NAME.log -cp $BLUR_CLASSPATH $@
-
+if [ $1 = "shell" ]; then
+  "$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH $BLUR_COMMAND
-Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=$PROC_NAME.log -cp $BLUR_CLASSPATH org.apache.blur.shell.Main
$2
+else
+  "$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH $BLUR_COMMAND
-Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=$PROC_NAME.log -cp $BLUR_CLASSPATH $@
+fi
 
 


Mime
View raw message