hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjs...@apache.org
Subject [35/50] [abbrv] hadoop git commit: YARN-2797. Add -help to yarn logs and nodes CLI command. Contributed by Jagadesh Kiran N.
Date Wed, 25 Feb 2015 17:24:18 GMT
YARN-2797. Add -help to yarn logs and nodes CLI command. Contributed by
Jagadesh Kiran N.


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

Branch: refs/heads/YARN-2928
Commit: b610c68d4423a5a1ab342dc490cd0064f8983c07
Parents: 1dba572
Author: Devaraj K <devaraj@apache.org>
Authored: Tue Feb 24 12:04:06 2015 +0530
Committer: Devaraj K <devaraj@apache.org>
Committed: Tue Feb 24 12:04:06 2015 +0530

----------------------------------------------------------------------
 hadoop-yarn-project/CHANGES.txt                          |  3 +++
 .../java/org/apache/hadoop/yarn/client/cli/LogsCLI.java  | 11 +++++++++--
 .../java/org/apache/hadoop/yarn/client/cli/NodeCLI.java  |  4 ++++
 .../org/apache/hadoop/yarn/client/cli/TestLogsCLI.java   |  1 +
 .../org/apache/hadoop/yarn/client/cli/TestYarnCLI.java   |  1 +
 5 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/b610c68d/hadoop-yarn-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index 3507420..36bc707 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -321,6 +321,9 @@ Release 2.7.0 - UNRELEASED
     YARN-2797. TestWorkPreservingRMRestart should use ParametrizedSchedulerTestBase
     (Karthik Kambatla via xgong)
 
+    YARN-2797. Add -help to yarn logs and nodes CLI command. 
+    (Jagadesh Kiran N via devaraj)
+
   OPTIMIZATIONS
 
     YARN-2990. FairScheduler's delay-scheduling always waits for node-local and 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b610c68d/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java
index 0b34a46..d3b44a7 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java
@@ -51,12 +51,15 @@ public class LogsCLI extends Configured implements Tool {
   private static final String APPLICATION_ID_OPTION = "applicationId";
   private static final String NODE_ADDRESS_OPTION = "nodeAddress";
   private static final String APP_OWNER_OPTION = "appOwner";
+  public static final String HELP_CMD = "help";
 
   @Override
   public int run(String[] args) throws Exception {
 
     Options opts = new Options();
-    Option appIdOpt = new Option(APPLICATION_ID_OPTION, true, "ApplicationId (required)");
+    opts.addOption(HELP_CMD, false, "Displays help for all commands.");
+    Option appIdOpt =
+        new Option(APPLICATION_ID_OPTION, true, "ApplicationId (required)");
     appIdOpt.setRequired(true);
     opts.addOption(appIdOpt);
     opts.addOption(CONTAINER_ID_OPTION, true,
@@ -71,6 +74,7 @@ public class LogsCLI extends Configured implements Tool {
     opts.getOption(APP_OWNER_OPTION).setArgName("Application Owner");
 
     Options printOpts = new Options();
+    printOpts.addOption(opts.getOption(HELP_CMD));
     printOpts.addOption(opts.getOption(CONTAINER_ID_OPTION));
     printOpts.addOption(opts.getOption(NODE_ADDRESS_OPTION));
     printOpts.addOption(opts.getOption(APP_OWNER_OPTION));
@@ -79,7 +83,10 @@ public class LogsCLI extends Configured implements Tool {
       printHelpMessage(printOpts);
       return -1;
     }
-
+    if (args[0].equals("-help")) {
+      printHelpMessage(printOpts);
+      return 0;
+    }
     CommandLineParser parser = new GnuParser();
     String appIdStr = null;
     String containerIdStr = null;

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b610c68d/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/NodeCLI.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/NodeCLI.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/NodeCLI.java
index a6ed9b5..ce1c0fd 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/NodeCLI.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/NodeCLI.java
@@ -69,6 +69,7 @@ public class NodeCLI extends YarnCLI {
   public int run(String[] args) throws Exception {
 
     Options opts = new Options();
+    opts.addOption(HELP_CMD, false, "Displays help for all commands.");
     opts.addOption(STATUS_CMD, true, "Prints the status report of the node.");
     opts.addOption(LIST_CMD, false, "List all running nodes. " +
         "Supports optional use of -states to filter nodes " +
@@ -120,6 +121,9 @@ public class NodeCLI extends YarnCLI {
         nodeStates.add(NodeState.RUNNING);
       }
       listClusterNodes(nodeStates);
+    } else if (cliParser.hasOption(HELP_CMD)) {
+      printUsage(opts);
+      return 0;
     } else {
       syserr.println("Invalid Command Usage : ");
       printUsage(opts);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b610c68d/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java
index ef9439d..7ee918e 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java
@@ -149,6 +149,7 @@ public class TestLogsCLI {
     pw.println("                                 not specified)");
     pw.println(" -containerId <Container ID>     ContainerId (must be specified if
node");
     pw.println("                                 address is specified)");
+    pw.println(" -help                           Displays help for all commands.");
     pw.println(" -nodeAddress <Node Address>     NodeAddress in the format nodename:port");
     pw.println("                                 (must be specified if container id is");
     pw.println("                                 specified)");

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b610c68d/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
index fa81f14..088969f 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
@@ -1500,6 +1500,7 @@ public class TestYarnCLI {
     PrintWriter pw = new PrintWriter(baos);
     pw.println("usage: node");
     pw.println(" -all               Works with -list to list all nodes.");
+    pw.println(" -help              Displays help for all commands.");
     pw.println(" -list              List all running nodes. Supports optional use of");
     pw.println("                    -states to filter nodes based on node state, all -all");
     pw.println("                    to list all nodes.");


Mime
View raw message