cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbros...@apache.org
Subject git commit: Allow nodetool issued w/o commands or with help to run even if no server is active patch by mmainali reviewed by dbrosius for cassandra 5734
Date Wed, 10 Jul 2013 04:56:04 GMT
Updated Branches:
  refs/heads/trunk db4da73e5 -> 626b0783c


Allow nodetool issued w/o commands or with help to run even if no server is active
patch by mmainali reviewed by dbrosius for cassandra 5734


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/626b0783
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/626b0783
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/626b0783

Branch: refs/heads/trunk
Commit: 626b0783c70f69e35861cfbbd523632d8d91537c
Parents: db4da73
Author: Dave Brosius <dbrosius@apache.org>
Authored: Wed Jul 10 00:50:51 2013 -0400
Committer: Dave Brosius <dbrosius@apache.org>
Committed: Wed Jul 10 00:52:59 2013 -0400

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 +-
 .../org/apache/cassandra/tools/NodeCmd.java     | 58 +++++++++++---------
 2 files changed, 33 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/626b0783/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index deb37ba..4ede198 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -73,7 +73,7 @@
  * Auto paging in binary protocol (CASSANDRA-4415, 5714)
  * Don't tie client side use of AbstractType to JDBC (CASSANDRA-4495)
  * Adds new TimestampType to replace DateType (CASSANDRA-5723, CASSANDRA-5729)
-
+ * Allow nodetool with no args, and with help to run without a server (CASSANDRA-5734)
 
 1.2.7
  * make starting native protocol server idempotent (CASSANDRA-5728)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/626b0783/src/java/org/apache/cassandra/tools/NodeCmd.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeCmd.java b/src/java/org/apache/cassandra/tools/NodeCmd.java
index 825c8d1..57c641a 100644
--- a/src/java/org/apache/cassandra/tools/NodeCmd.java
+++ b/src/java/org/apache/cassandra/tools/NodeCmd.java
@@ -969,46 +969,53 @@ public class NodeCmd
             }
         }
 
-        String username = cmd.getOptionValue(USERNAME_OPT.left);
-        String password = cmd.getOptionValue(PASSWORD_OPT.left);
+        NodeCommand command = null;
 
-        NodeProbe probe = null;
         try
         {
-            probe = username == null ? new NodeProbe(host, port) : new NodeProbe(host, port,
username, password);
+            command = cmd.getCommand();
         }
-        catch (IOException ioe)
+        catch (IllegalArgumentException e)
         {
-            Throwable inner = findInnermostThrowable(ioe);
-            if (inner instanceof ConnectException)
-            {
-                System.err.printf("Failed to connect to '%s:%d': %s%n", host, port, inner.getMessage());
-                System.exit(1);
-            }
-            else if (inner instanceof UnknownHostException)
-            {
-                System.err.printf("Cannot resolve '%s': unknown host%n", host);
-                System.exit(1);
-            }
-            else
-            {
-                err(ioe, "Error connecting to remote JMX agent!");
-            }
+            badUse(e.getMessage());
+        }
+
+        if(NodeCommand.HELP.equals(command))
+        {
+            printUsage();
+            System.exit(0);
         }
+
+        NodeProbe probe = null;
+
         try
         {
-            NodeCommand command = null;
+            String username = cmd.getOptionValue(USERNAME_OPT.left);
+            String password = cmd.getOptionValue(PASSWORD_OPT.left);
 
             try
             {
-                command = cmd.getCommand();
+                probe = username == null ? new NodeProbe(host, port) : new NodeProbe(host,
port, username, password);
             }
-            catch (IllegalArgumentException e)
+            catch (IOException ioe)
             {
-                badUse(e.getMessage());
+                Throwable inner = findInnermostThrowable(ioe);
+                if (inner instanceof ConnectException)
+                {
+                    System.err.printf("Failed to connect to '%s:%d': %s%n", host, port, inner.getMessage());
+                    System.exit(1);
+                }
+                else if (inner instanceof UnknownHostException)
+                {
+                    System.err.printf("Cannot resolve '%s': unknown host%n", host);
+                    System.exit(1);
+                }
+                else
+                {
+                    err(ioe, "Error connecting to remote JMX agent!");
+                }
             }
 
-
             NodeCmd nodeCmd = new NodeCmd(probe);
 
             // Execute the requested command.
@@ -1018,7 +1025,6 @@ public class NodeCmd
 
             switch (command)
             {
-                case HELP : printUsage(); break;
                 case RING :
                     if (arguments.length > 0) { nodeCmd.printRing(System.out, arguments[0]);
}
                     else                      { nodeCmd.printRing(System.out, null); };


Mime
View raw message