YARN-2797. Add -help to yarn logs and nodes CLI command. Contributed by

Jagadesh Kiran N.

(cherry picked from commit b610c68d44)
This commit is contained in:
Devaraj K 2015-02-24 12:04:06 +05:30
parent 62e0e67d49
commit b9e82e27f5
5 changed files with 18 additions and 2 deletions

View File

@ -285,6 +285,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

View File

@ -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;

View File

@ -68,6 +68,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 " +
@ -118,6 +119,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);

View File

@ -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)");

View File

@ -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.");