asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mb...@apache.org
Subject asterixdb git commit: Extensibility, Cleanup For Client Helper
Date Wed, 31 Aug 2016 20:31:58 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 6214f6fca -> 9b5405a68


Extensibility, Cleanup For Client Helper

Change-Id: Ifa24e952c1b49d7d3a5b971906915ae1560086c8
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1133
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/9b5405a6
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/9b5405a6
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/9b5405a6

Branch: refs/heads/master
Commit: 9b5405a684bf86d62ff45f64a9c4e3bfaf3b5224
Parents: 6214f6f
Author: Michael Blow <mblow@apache.org>
Authored: Wed Aug 31 15:39:39 2016 -0400
Committer: Michael Blow <mblow@apache.org>
Committed: Wed Aug 31 13:30:27 2016 -0700

----------------------------------------------------------------------
 .../clienthelper/AsterixHelperExecution.java       | 17 +++++++++++++----
 .../clienthelper/commands/ClientCommand.java       |  6 +++---
 .../clienthelper/commands/RemoteCommand.java       |  2 +-
 3 files changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/9b5405a6/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/AsterixHelperExecution.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/AsterixHelperExecution.java
b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/AsterixHelperExecution.java
index 82e8386..419e660 100644
--- a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/AsterixHelperExecution.java
+++ b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/AsterixHelperExecution.java
@@ -33,6 +33,7 @@ import org.kohsuke.args4j.ParserProperties;
 public class AsterixHelperExecution {
 
     public static final String ASTERIX_HELPER = "asterixhelper";
+    public static final int COMMAND_USAGE_ALIGNMENT = 20;
 
     protected AsterixHelperExecution() {
     }
@@ -41,7 +42,7 @@ public class AsterixHelperExecution {
             "squid:S106", // use of System.err
             "squid:S1166" // rethrow or log exception
     })
-    protected int execute(String [] argArray) throws IOException {
+    public int execute(String [] argArray) throws IOException {
         Args args = createArgs();
         CmdLineParser parser = createParser(args);
         try {
@@ -59,7 +60,7 @@ public class AsterixHelperExecution {
             System.err.println("ERROR: " + e.getMessage() + "\n\n"
                     + "Usage: " + getHelperCommandName() + " [options] <command>\n\n"
                     + "Commands:");
-            printCommandUsage(System.err);
+            printCommandsUsage(System.err);
             System.err.println("Options:");
             parser.printUsage(System.err);
             System.err.flush();
@@ -71,12 +72,20 @@ public class AsterixHelperExecution {
         return ASTERIX_HELPER;
     }
 
-    protected void printCommandUsage(PrintStream out) {
+    protected void printCommandsUsage(PrintStream out) {
         for (Command command : Command.values()) {
-            out.println("  " + command.name().toLowerCase() + " " + command.usage());
+            printCommandUsage(out, command.name(), command.usage());
         }
     }
 
+    protected void printCommandUsage(PrintStream out, String name, String usage) {
+        StringBuilder padding = new StringBuilder();
+        for (int i = name.length(); i < COMMAND_USAGE_ALIGNMENT; i++) {
+            padding.append(' ');
+        }
+        out.println("  " + name.toLowerCase() + padding.toString() + " : " + usage);
+    }
+
     protected CmdLineParser createParser(Args args) {
         return new CmdLineParser(args, ParserProperties.defaults().withUsageWidth(120));
     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/9b5405a6/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/ClientCommand.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/ClientCommand.java
b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/ClientCommand.java
index 734d87b..8f0cac0 100644
--- a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/ClientCommand.java
+++ b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/ClientCommand.java
@@ -28,9 +28,9 @@ import org.apache.asterix.clienthelper.Args;
 public abstract class ClientCommand {
 
     public enum Command {
-        GET_CLUSTER_STATE("- Get state of cluster (errorcode 0 = UP, non-zero = DOWN)"),
-        WAIT_FOR_CLUSTER(" - Wait for cluster to be ready (errorcode 0 = UP, non-zero = UNKNOWN)\")"),
-        SHUTDOWN_CLUSTER(" - Instructs the cluster to shut down"),;
+        GET_CLUSTER_STATE("Get state of cluster (errorcode 0 = UP, non-zero = DOWN)"),
+        WAIT_FOR_CLUSTER("Wait for cluster to be ready (errorcode 0 = UP, non-zero = UNKNOWN)"),
+        SHUTDOWN_CLUSTER("Instructs the cluster to shut down"),;
 
         private final String usage;
         private static final Map<String, Command> nameMap = new HashMap<>();

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/9b5405a6/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/RemoteCommand.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/RemoteCommand.java
b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/RemoteCommand.java
index 1440b70..77ccbb4 100644
--- a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/RemoteCommand.java
+++ b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/RemoteCommand.java
@@ -26,7 +26,7 @@ import java.net.URL;
 import org.apache.asterix.clienthelper.Args;
 
 public abstract class RemoteCommand extends ClientCommand {
-    enum Method {
+    protected enum Method {
         GET,
         POST
     }


Mime
View raw message