cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject svn commit: r1146923 - /cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/tools/NodeCmd.java
Date Thu, 14 Jul 2011 23:42:12 GMT
Author: brandonwilliams
Date: Thu Jul 14 23:42:11 2011
New Revision: 1146923

URL: http://svn.apache.org/viewvc?rev=1146923&view=rev
Log:
Do not allow extra params to nodetool commands to prevent confusion.
Patch by Jon Hermes, reviewed by brandonwilliams for CASSANDRA-2740

Modified:
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/tools/NodeCmd.java

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/tools/NodeCmd.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/tools/NodeCmd.java?rev=1146923&r1=1146922&r2=1146923&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/tools/NodeCmd.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/tools/NodeCmd.java Thu
Jul 14 23:42:11 2011
@@ -539,19 +539,19 @@ public class NodeCmd
 
         switch (command)
         {
-            case RING            : nodeCmd.printRing(System.out); break;
-            case INFO            : nodeCmd.printInfo(System.out); break;
-            case CFSTATS         : nodeCmd.printColumnFamilyStats(System.out); break;
-            case DECOMMISSION    : probe.decommission(); break;
-            case LOADBALANCE     : probe.loadBalance(); break;
-            case CLEARSNAPSHOT   : probe.clearSnapshot(); break;
-            case TPSTATS         : nodeCmd.printThreadPoolStats(System.out); break;
-            case VERSION         : nodeCmd.printReleaseVersion(System.out); break;
-            case COMPACTIONSTATS : nodeCmd.printCompactionStats(System.out); break;
-            case DISABLEGOSSIP   : probe.stopGossiping(); break;
-            case ENABLEGOSSIP    : probe.startGossiping(); break;
-            case DISABLETHRIFT   : probe.stopThriftServer(); break;
-            case ENABLETHRIFT    : probe.startThriftServer(); break;
+            case RING            : complainNonzeroArgs(arguments, command); nodeCmd.printRing(System.out);
break;
+            case INFO            : complainNonzeroArgs(arguments, command); nodeCmd.printInfo(System.out);
break;
+            case CFSTATS         : complainNonzeroArgs(arguments, command); nodeCmd.printColumnFamilyStats(System.out);
break;
+            case DECOMMISSION    : complainNonzeroArgs(arguments, command); probe.decommission();
break;
+            case LOADBALANCE     : complainNonzeroArgs(arguments, command); probe.loadBalance();
break;
+            case CLEARSNAPSHOT   : complainNonzeroArgs(arguments, command); probe.clearSnapshot();
break;
+            case TPSTATS         : complainNonzeroArgs(arguments, command); nodeCmd.printThreadPoolStats(System.out);
break;
+            case VERSION         : complainNonzeroArgs(arguments, command); nodeCmd.printReleaseVersion(System.out);
break;
+            case COMPACTIONSTATS : complainNonzeroArgs(arguments, command); nodeCmd.printCompactionStats(System.out);
break;
+            case DISABLEGOSSIP   : complainNonzeroArgs(arguments, command); probe.stopGossiping();
break;
+            case ENABLEGOSSIP    : complainNonzeroArgs(arguments, command); probe.startGossiping();
break;
+            case DISABLETHRIFT   : complainNonzeroArgs(arguments, command); probe.stopThriftServer();
break;
+            case ENABLETHRIFT    : complainNonzeroArgs(arguments, command); probe.startThriftServer();
break;
 
             case DRAIN :
                 try { probe.drain(); }
@@ -647,6 +647,15 @@ public class NodeCmd
         System.exit(3);
     }
 
+    private static void complainNonzeroArgs(String[] args, NodeCommand cmd)
+    {
+        if (args.length > 0) {
+            System.err.println("Too many arguments for command '"+cmd.toString()+"'.");
+            printUsage();
+            System.exit(1);
+        }
+    }
+
     private static void optionalKSandCFs(NodeCommand nc, String[] cmdArgs, NodeProbe probe)
throws InterruptedException, IOException
     {
         // if there is one additional arg, it's the keyspace; more are columnfamilies



Mime
View raw message