hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z..@apache.org
Subject [29/50] [abbrv] hadoop git commit: YARN-3164. RMAdmin command usage prints incorrect command name. Contributed by Bibin A Chundatt
Date Mon, 23 Feb 2015 19:36:26 GMT
YARN-3164. RMAdmin command usage prints incorrect command name.
Contributed by Bibin A Chundatt


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

Branch: refs/heads/HDFS-EC
Commit: ac5497c48b33b2cf89720070ef94a51aac7357bd
Parents: 7367700
Author: Xuan <xgong@apache.org>
Authored: Thu Feb 12 21:39:16 2015 -0800
Committer: Zhe Zhang <zhz@apache.org>
Committed: Mon Feb 16 10:29:49 2015 -0800

----------------------------------------------------------------------
 .../main/java/org/apache/hadoop/ha/HAAdmin.java   |  4 ++--
 hadoop-yarn-project/CHANGES.txt                   |  3 +++
 .../apache/hadoop/yarn/client/cli/RMAdminCLI.java | 10 ++++++++++
 .../hadoop/yarn/client/cli/TestRMAdminCLI.java    | 18 +++++++++++++++++-
 4 files changed, 32 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac5497c4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAAdmin.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAAdmin.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAAdmin.java
index f72df77..9c28eb9 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAAdmin.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAAdmin.java
@@ -125,12 +125,12 @@ public abstract class HAAdmin extends Configured implements Tool {
     ToolRunner.printGenericCommandUsage(errOut);    
   }
   
-  private static void printUsage(PrintStream errOut, String cmd) {
+  private void printUsage(PrintStream errOut, String cmd) {
     UsageInfo usage = USAGE.get(cmd);
     if (usage == null) {
       throw new RuntimeException("No usage for cmd " + cmd);
     }
-    errOut.println("Usage: HAAdmin [" + cmd + " " + usage.args + "]");
+    errOut.println(getUsageString() + " [" + cmd + " " + usage.args + "]");
   }
 
   private int transitionToActive(final CommandLine cmd)

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac5497c4/hadoop-yarn-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index 0e8a8e4..cd9b467 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -590,6 +590,9 @@ Release 2.7.0 - UNRELEASED
     YARN-3191. Log object should be initialized with its own class. (Rohith via
     aajisaka)
 
+    YARN-3164. RMAdmin command usage prints incorrect command name. 
+    (Bibin A Chundatt via xgong)
+
 Release 2.6.0 - 2014-11-18
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac5497c4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java
index d29f674..4642add 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java
@@ -19,6 +19,7 @@
 package org.apache.hadoop.yarn.client.cli;
 
 import java.io.IOException;
+import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -127,6 +128,10 @@ public class RMAdminCLI extends HAAdmin {
     super(conf);
   }
 
+  protected void setErrOut(PrintStream errOut) {
+    this.errOut = errOut;
+  }
+
   private static void appendHAUsage(final StringBuilder usageBuilder) {
     for (Map.Entry<String,UsageInfo> cmdEntry : USAGE.entrySet()) {
       if (cmdEntry.getKey().equals("-help")) {
@@ -639,6 +644,11 @@ public class RMAdminCLI extends HAAdmin {
           "Could not connect to RM HA Admin for node " + rmId);
     }
   }
+  
+  @Override
+  protected String getUsageString() {
+    return "Usage: rmadmin";
+  }
 
   public static void main(String[] args) throws Exception {
     int result = ToolRunner.run(new RMAdminCLI(), args);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ac5497c4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestRMAdminCLI.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestRMAdminCLI.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestRMAdminCLI.java
index d448090..c22494c 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestRMAdminCLI.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestRMAdminCLI.java
@@ -58,6 +58,7 @@ import org.mockito.ArgumentMatcher;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 
+import com.google.common.base.Charsets;
 import com.google.common.collect.ImmutableSet;
 
 public class TestRMAdminCLI {
@@ -561,5 +562,20 @@ public class TestRMAdminCLI {
         data.toString().contains(template));
     data.reset();
   }
-  
+
+  @Test
+  public void testRMHAErrorUsage() throws Exception {
+    ByteArrayOutputStream errOutBytes = new ByteArrayOutputStream();
+    rmAdminCLIWithHAEnabled.setErrOut(new PrintStream(errOutBytes));
+    try {
+      String[] args = { "-failover" };
+      assertEquals(-1, rmAdminCLIWithHAEnabled.run(args));
+      String errOut = new String(errOutBytes.toByteArray(), Charsets.UTF_8);
+      errOutBytes.reset();
+      assertTrue(errOut.contains("Usage: rmadmin"));
+    } finally {
+      rmAdminCLIWithHAEnabled.setErrOut(System.err);
+    }
+  }
+
 }


Mime
View raw message