Browse Source

HDFS-5565. CacheAdmin help should match against non-dashed commands (wang via cmccabe)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1545850 13f79535-47bb-0310-9956-ffa450edef68
Colin McCabe 11 years ago
parent
commit
05a9a80bd4

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -405,6 +405,9 @@ Trunk (Unreleased)
     HDFS-5543. Fix narrow race condition in TestPathBasedCacheRequests
     (cmccabe)
 
+    HDFS-5565. CacheAdmin help should match against non-dashed commands
+    (wang via cmccabe)
+
 Release 2.3.0 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 4 - 3
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java

@@ -822,14 +822,15 @@ public class CacheAdmin extends Configured implements Tool {
         return 0;
       }
       String commandName = args.get(0);
-      Command command = determineCommand(commandName);
+      // prepend a dash to match against the command names
+      Command command = determineCommand("-"+commandName);
       if (command == null) {
         System.err.print("Sorry, I don't know the command '" +
           commandName + "'.\n");
-        System.err.print("Valid command names are:\n");
+        System.err.print("Valid help command names are:\n");
         String separator = "";
         for (Command c : COMMANDS) {
-          System.err.print(separator + c.getName());
+          System.err.print(separator + c.getName().substring(1));
           separator = ", ";
         }
         System.err.print("\n");

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testCacheAdminConf.xml

@@ -387,7 +387,7 @@
     <test>
       <description>Testing the help usage</description>
       <test-commands>
-        <cache-admin-command>-help -addPool</cache-admin-command>
+        <cache-admin-command>-help addPool</cache-admin-command>
       </test-commands>
       <cleanup-commands>
       </cleanup-commands>