Author: vinodkv
Date: Sat Mar 8 04:50:20 2014
New Revision: 1575483
URL: http://svn.apache.org/r1575483
Log:
YARN-1787. Fixed help messages for applicationattempt and container
sub-commands in bin/yarn. Contributed by Zhijie Shen.
svn merge --ignore-ancestry -c 1575482 ../../trunk/
Modified:
hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt
hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/ApplicationCLI.java
hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt?rev=1575483&r1=1575482&r2=1575483&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt Sat Mar 8
04:50:20 2014
@@ -413,6 +413,9 @@ Release 2.4.0 - UNRELEASED
completed container statuses when NodeManager is forced to resync by the
ResourceManager. (Jian He via vinodkv)
+ YARN-1787. Fixed help messages for applicationattempt and container
+ sub-commands in bin/yarn. (Zhijie Shen via vinodkv)
+
Release 2.3.1 - UNRELEASED
INCOMPATIBLE CHANGES
Modified:
hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/ApplicationCLI.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/ApplicationCLI.java?rev=1575483&r1=1575482&r2=1575483&view=diff
==============================================================================
---
hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/ApplicationCLI.java
(original)
+++
hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/ApplicationCLI.java
Sat Mar 8 04:50:20 2014
@@ -80,47 +80,59 @@ public class ApplicationCLI extends Yarn
@Override
public int run(String[] args) throws Exception {
-
Options opts = new Options();
- opts.addOption(STATUS_CMD, true,
- "Prints the status of the application.");
- if (args.length > 0
- && args[0].compareToIgnoreCase(APPLICATION_ATTEMPT) == 0) {
- opts.addOption(LIST_CMD, true,
- "List application attempts for aplication from AHS. ");
- } else if (args.length > 0 && args[0].compareToIgnoreCase("container") ==
0) {
- opts.addOption(LIST_CMD, true,
- "List containers for application attempts from AHS. ");
- } else {
- opts.addOption(LIST_CMD, false, "List applications from the RM. "
+ String title = null;
+ if (args.length > 0 && args[0].equalsIgnoreCase(APPLICATION)) {
+ title = APPLICATION;
+ opts.addOption(STATUS_CMD, true,
+ "Prints the status of the application.");
+ opts.addOption(LIST_CMD, false, "List applications. "
+ "Supports optional use of -appTypes to filter applications "
+ "based on application type, "
- + "and -appStates to filter applications based on application
state");
+ + "and -appStates to filter applications based on application
state.");
+ opts.addOption(KILL_CMD, true, "Kills the application.");
+ opts.addOption(MOVE_TO_QUEUE_CMD, true, "Moves the application to a "
+ + "different queue.");
+ opts.addOption(QUEUE_CMD, true, "Works with the movetoqueue command to"
+ + " specify which queue to move an application to.");
+ opts.addOption(HELP_CMD, false, "Displays help for all commands.");
+ Option appTypeOpt = new Option(APP_TYPE_CMD, true, "Works with -list to "
+ + "filter applications based on "
+ + "input comma-separated list of application types.");
+ appTypeOpt.setValueSeparator(',');
+ appTypeOpt.setArgs(Option.UNLIMITED_VALUES);
+ appTypeOpt.setArgName("Types");
+ opts.addOption(appTypeOpt);
+ Option appStateOpt = new Option(APP_STATE_CMD, true, "Works with -list "
+ + "to filter applications based on input comma-separated list of "
+ + "application states. " + getAllValidApplicationStates());
+ appStateOpt.setValueSeparator(',');
+ appStateOpt.setArgs(Option.UNLIMITED_VALUES);
+ appStateOpt.setArgName("States");
+ opts.addOption(appStateOpt);
+ opts.getOption(KILL_CMD).setArgName("Application ID");
+ opts.getOption(MOVE_TO_QUEUE_CMD).setArgName("Application ID");
+ opts.getOption(QUEUE_CMD).setArgName("Queue Name");
+ opts.getOption(STATUS_CMD).setArgName("Application ID");
+ } else if (args.length > 0 &&
args[0].equalsIgnoreCase(APPLICATION_ATTEMPT)) {
+ title = APPLICATION_ATTEMPT;
+ opts.addOption(STATUS_CMD, true,
+ "Prints the status of the application attempt.");
+ opts.addOption(LIST_CMD, true,
+ "List application attempts for aplication.");
+ opts.addOption(HELP_CMD, false, "Displays help for all commands.");
+ opts.getOption(STATUS_CMD).setArgName("Application Attempt ID");
+ opts.getOption(LIST_CMD).setArgName("Application ID");
+ } else if (args.length > 0 && args[0].equalsIgnoreCase(CONTAINER)) {
+ title = CONTAINER;
+ opts.addOption(STATUS_CMD, true,
+ "Prints the status of the container.");
+ opts.addOption(LIST_CMD, true,
+ "List containers for application attempt.");
+ opts.addOption(HELP_CMD, false, "Displays help for all commands.");
+ opts.getOption(STATUS_CMD).setArgName("Container ID");
+ opts.getOption(LIST_CMD).setArgName("Application Attempt ID");
}
- opts.addOption(KILL_CMD, true, "Kills the application.");
- opts.addOption(MOVE_TO_QUEUE_CMD, true, "Moves the application to a "
- + "different queue.");
- opts.addOption(QUEUE_CMD, true, "Works with the movetoqueue command to"
- + " specify which queue to move an application to.");
- opts.addOption(HELP_CMD, false, "Displays help for all commands.");
- Option appTypeOpt = new Option(APP_TYPE_CMD, true, "Works with -list to "
- + "filter applications based on "
- + "input comma-separated list of application types.");
- appTypeOpt.setValueSeparator(',');
- appTypeOpt.setArgs(Option.UNLIMITED_VALUES);
- appTypeOpt.setArgName("Types");
- opts.addOption(appTypeOpt);
- Option appStateOpt = new Option(APP_STATE_CMD, true, "Works with -list "
- + "to filter applications based on input comma-separated list of "
- + "application states. " + getAllValidApplicationStates());
- appStateOpt.setValueSeparator(',');
- appStateOpt.setArgs(Option.UNLIMITED_VALUES);
- appStateOpt.setArgName("States");
- opts.addOption(appStateOpt);
- opts.getOption(KILL_CMD).setArgName("Application ID");
- opts.getOption(MOVE_TO_QUEUE_CMD).setArgName("Application ID");
- opts.getOption(QUEUE_CMD).setArgName("Queue Name");
- opts.getOption(STATUS_CMD).setArgName("Application ID");
int exitCode = -1;
CommandLine cliParser = null;
@@ -128,43 +140,24 @@ public class ApplicationCLI extends Yarn
cliParser = new GnuParser().parse(opts, args);
} catch (MissingArgumentException ex) {
sysout.println("Missing argument for options");
- printUsage(opts);
+ printUsage(title, opts);
return exitCode;
}
if (cliParser.hasOption(STATUS_CMD)) {
- if ((args[0].compareToIgnoreCase(APPLICATION) == 0)
- || (args[0].compareToIgnoreCase(APPLICATION_ATTEMPT) == 0)
- || (args[0].compareToIgnoreCase(CONTAINER) == 0)) {
- if (args.length != 3) {
- printUsage(opts);
- return exitCode;
- }
- } else if (args.length != 2) {
- printUsage(opts);
+ if (args.length != 3) {
+ printUsage(title, opts);
return exitCode;
}
- if (args[0].compareToIgnoreCase(APPLICATION_ATTEMPT) == 0) {
+ if (args[0].equalsIgnoreCase(APPLICATION)) {
+ printApplicationReport(cliParser.getOptionValue(STATUS_CMD));
+ } else if (args[0].equalsIgnoreCase(APPLICATION_ATTEMPT)) {
printApplicationAttemptReport(cliParser.getOptionValue(STATUS_CMD));
- } else if (args[0].compareToIgnoreCase(CONTAINER) == 0) {
+ } else if (args[0].equalsIgnoreCase(CONTAINER)) {
printContainerReport(cliParser.getOptionValue(STATUS_CMD));
- } else {
- printApplicationReport(cliParser.getOptionValue(STATUS_CMD));
}
} else if (cliParser.hasOption(LIST_CMD)) {
- if (args[0].compareToIgnoreCase(APPLICATION_ATTEMPT) == 0) {
- if (args.length != 3) {
- printUsage(opts);
- return exitCode;
- }
- listApplicationAttempts(cliParser.getOptionValue(LIST_CMD));
- } else if (args[0].compareToIgnoreCase(CONTAINER) == 0) {
- if (args.length != 3) {
- printUsage(opts);
- return exitCode;
- }
- listContainers(cliParser.getOptionValue(LIST_CMD));
- } else {
+ if (args[0].equalsIgnoreCase(APPLICATION)) {
allAppStates = false;
Set<String> appTypes = new HashSet<String>();
if (cliParser.hasOption(APP_TYPE_CMD)) {
@@ -203,10 +196,22 @@ public class ApplicationCLI extends Yarn
}
}
listApplications(appTypes, appStates);
+ } else if (args[0].equalsIgnoreCase(APPLICATION_ATTEMPT)) {
+ if (args.length != 3) {
+ printUsage(title, opts);
+ return exitCode;
+ }
+ listApplicationAttempts(cliParser.getOptionValue(LIST_CMD));
+ } else if (args[0].equalsIgnoreCase(CONTAINER)) {
+ if (args.length != 3) {
+ printUsage(title, opts);
+ return exitCode;
+ }
+ listContainers(cliParser.getOptionValue(LIST_CMD));
}
} else if (cliParser.hasOption(KILL_CMD)) {
if (args.length != 3) {
- printUsage(opts);
+ printUsage(title, opts);
return exitCode;
}
try{
@@ -216,17 +221,17 @@ public class ApplicationCLI extends Yarn
}
} else if (cliParser.hasOption(MOVE_TO_QUEUE_CMD)) {
if (!cliParser.hasOption(QUEUE_CMD)) {
- printUsage(opts);
+ printUsage(title, opts);
return exitCode;
}
moveApplicationAcrossQueues(cliParser.getOptionValue(MOVE_TO_QUEUE_CMD),
cliParser.getOptionValue(QUEUE_CMD));
} else if (cliParser.hasOption(HELP_CMD)) {
- printUsage(opts);
+ printUsage(title, opts);
return 0;
} else {
syserr.println("Invalid Command Usage : ");
- printUsage(opts);
+ printUsage(title, opts);
}
return 0;
}
@@ -237,8 +242,8 @@ public class ApplicationCLI extends Yarn
* @param opts
*/
@VisibleForTesting
- void printUsage(Options opts) {
- new HelpFormatter().printHelp("application", opts);
+ void printUsage(String title, Options opts) {
+ new HelpFormatter().printHelp(title, opts);
}
/**
Modified:
hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java?rev=1575483&r1=1575482&r2=1575483&view=diff
==============================================================================
---
hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
(original)
+++
hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
Sat Mar 8 04:50:20 2014
@@ -94,7 +94,7 @@ public class TestYarnCLI {
FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.53789f, "YARN", null);
when(client.getApplicationReport(any(ApplicationId.class))).thenReturn(
newApplicationReport);
- int result = cli.run(new String[] { "-status", applicationId.toString() });
+ int result = cli.run(new String[] { "application", "-status",
applicationId.toString() });
assertEquals(0, result);
verify(client).getApplicationReport(applicationId);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -289,7 +289,7 @@ public class TestYarnCLI {
new ApplicationNotFoundException("History file for application"
+ applicationId + " is not found"));
try {
- cli.run(new String[] { "-status", applicationId.toString() });
+ cli.run(new String[] { "application", "-status",
applicationId.toString() });
Assert.fail();
} catch (Exception ex) {
Assert.assertTrue(ex instanceof ApplicationNotFoundException);
@@ -368,7 +368,7 @@ public class TestYarnCLI {
appState1.add(YarnApplicationState.SUBMITTED);
when(client.getApplications(appType1, appState1)).thenReturn(
getApplicationReports(applicationReports, appType1, appState1, false));
- int result = cli.run(new String[] { "-list" });
+ int result = cli.run(new String[] { "application", "-list" });
assertEquals(0, result);
verify(client).getApplications(appType1, appState1);
@@ -423,8 +423,8 @@ public class TestYarnCLI {
when(client.getApplications(appType2, appState2)).thenReturn(
getApplicationReports(applicationReports, appType2, appState2, false));
result =
- cli.run(new String[] { "-list", "-appTypes", "YARN, ,, NON-YARN",
- " ,, ,," });
+ cli.run(new String[] { "application", "-list", "-appTypes",
+ "YARN, ,, NON-YARN", " ,, ,," });
assertEquals(0, result);
verify(client).getApplications(appType2, appState2);
baos = new ByteArrayOutputStream();
@@ -458,8 +458,8 @@ public class TestYarnCLI {
when(client.getApplications(appType3, appState3)).thenReturn(
getApplicationReports(applicationReports, appType3, appState3, false));
result =
- cli.run(new String[] { "-list", "--appStates", "FINISHED ,, , FAILED",
- ",,FINISHED" });
+ cli.run(new String[] { "application", "-list", "--appStates",
+ "FINISHED ,, , FAILED", ",,FINISHED" });
assertEquals(0, result);
verify(client).getApplications(appType3, appState3);
baos = new ByteArrayOutputStream();
@@ -501,8 +501,8 @@ public class TestYarnCLI {
when(client.getApplications(appType4, appState4)).thenReturn(
getApplicationReports(applicationReports, appType4, appState4, false));
result =
- cli.run(new String[] { "-list", "--appTypes", "YARN,NON-YARN",
- "--appStates", "FINISHED ,, , FAILED" });
+ cli.run(new String[] { "application", "-list", "--appTypes",
+ "YARN,NON-YARN", "--appStates", "FINISHED ,, , FAILED" });
assertEquals(0, result);
verify(client).getApplications(appType2, appState2);
baos = new ByteArrayOutputStream();
@@ -527,7 +527,8 @@ public class TestYarnCLI {
//Test command yarn application -list --appStates with invalid appStates
sysOutStream.reset();
result =
- cli.run(new String[] { "-list", "--appStates", "FINISHED ,, , INVALID"
});
+ cli.run(new String[] { "application", "-list", "--appStates",
+ "FINISHED ,, , INVALID" });
assertEquals(-1, result);
baos = new ByteArrayOutputStream();
pw = new PrintWriter(baos);
@@ -555,7 +556,8 @@ public class TestYarnCLI {
when(client.getApplications(appType5, appState5)).thenReturn(
getApplicationReports(applicationReports, appType5, appState5, true));
result =
- cli.run(new String[] { "-list", "--appStates", "FINISHED ,, , ALL" });
+ cli.run(new String[] { "application", "-list", "--appStates",
+ "FINISHED ,, , ALL" });
assertEquals(0, result);
verify(client).getApplications(appType5, appState5);
baos = new ByteArrayOutputStream();
@@ -614,8 +616,8 @@ public class TestYarnCLI {
when(client.getApplications(appType6, appState6)).thenReturn(
getApplicationReports(applicationReports, appType6, appState6, false));
result =
- cli.run(new String[] { "-list", "-appTypes", "YARN, ,, NON-YARN",
- "--appStates", "finished" });
+ cli.run(new String[] { "application", "-list", "-appTypes",
+ "YARN, ,, NON-YARN", "--appStates", "finished" });
assertEquals(0, result);
verify(client).getApplications(appType6, appState6);
baos = new ByteArrayOutputStream();
@@ -672,28 +674,88 @@ public class TestYarnCLI {
public void testAppsHelpCommand() throws Exception {
ApplicationCLI cli = createAndGetAppCLI();
ApplicationCLI spyCli = spy(cli);
- int result = spyCli.run(new String[] { "-help" });
+ int result = spyCli.run(new String[] { "application", "-help" });
Assert.assertTrue(result == 0);
- verify(spyCli).printUsage(any(Options.class));
+ verify(spyCli).printUsage(any(String.class), any(Options.class));
Assert.assertEquals(createApplicationCLIHelpMessage(),
sysOutStream.toString());
sysOutStream.reset();
ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
- result =
- cli.run(new String[] {"application", "-kill",
applicationId.toString(), "args" });
- verify(spyCli).printUsage(any(Options.class));
+ result = cli.run(
+ new String[] {"application", "-kill", applicationId.toString(), "args"
});
+ verify(spyCli).printUsage(any(String.class), any(Options.class));
Assert.assertEquals(createApplicationCLIHelpMessage(),
sysOutStream.toString());
sysOutStream.reset();
NodeId nodeId = NodeId.newInstance("host0", 0);
- result = cli.run(new String[] { "-status", nodeId.toString(), "args" });
- verify(spyCli).printUsage(any(Options.class));
+ result = cli.run(
+ new String[] { "application", "-status", nodeId.toString(), "args" });
+ verify(spyCli).printUsage(any(String.class), any(Options.class));
Assert.assertEquals(createApplicationCLIHelpMessage(),
sysOutStream.toString());
}
+ @Test (timeout = 10000)
+ public void testAppAttemptsHelpCommand() throws Exception {
+ ApplicationCLI cli = createAndGetAppCLI();
+ ApplicationCLI spyCli = spy(cli);
+ int result = spyCli.run(new String[] { "applicationattempt", "-help" });
+ Assert.assertTrue(result == 0);
+ verify(spyCli).printUsage(any(String.class), any(Options.class));
+ Assert.assertEquals(createApplicationAttemptCLIHelpMessage(),
+ sysOutStream.toString());
+
+ sysOutStream.reset();
+ ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
+ result = cli.run(
+ new String[] {"applicationattempt", "-list", applicationId.toString(),
+ "args" });
+ verify(spyCli).printUsage(any(String.class), any(Options.class));
+ Assert.assertEquals(createApplicationAttemptCLIHelpMessage(),
+ sysOutStream.toString());
+
+ sysOutStream.reset();
+ ApplicationAttemptId appAttemptId =
+ ApplicationAttemptId.newInstance(applicationId, 6);
+ result = cli.run(
+ new String[] { "applicationattempt", "-status",
appAttemptId.toString(),
+ "args" });
+ verify(spyCli).printUsage(any(String.class), any(Options.class));
+ Assert.assertEquals(createApplicationAttemptCLIHelpMessage(),
+ sysOutStream.toString());
+ }
+
+ @Test (timeout = 10000)
+ public void testContainersHelpCommand() throws Exception {
+ ApplicationCLI cli = createAndGetAppCLI();
+ ApplicationCLI spyCli = spy(cli);
+ int result = spyCli.run(new String[] { "container", "-help" });
+ Assert.assertTrue(result == 0);
+ verify(spyCli).printUsage(any(String.class), any(Options.class));
+ Assert.assertEquals(createContainerCLIHelpMessage(),
+ sysOutStream.toString());
+
+ sysOutStream.reset();
+ ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
+ ApplicationAttemptId appAttemptId =
+ ApplicationAttemptId.newInstance(applicationId, 6);
+ result = cli.run(
+ new String[] {"container", "-list", appAttemptId.toString(), "args" });
+ verify(spyCli).printUsage(any(String.class), any(Options.class));
+ Assert.assertEquals(createContainerCLIHelpMessage(),
+ sysOutStream.toString());
+
+ sysOutStream.reset();
+ ContainerId containerId = ContainerId.newInstance(appAttemptId, 7);
+ result = cli.run(
+ new String[] { "container", "-status", containerId.toString(), "args"
});
+ verify(spyCli).printUsage(any(String.class), any(Options.class));
+ Assert.assertEquals(createContainerCLIHelpMessage(),
+ sysOutStream.toString());
+ }
+
@Test (timeout = 5000)
public void testNodesHelpCommand() throws Exception {
NodeCLI nodeCLI = new NodeCLI();
@@ -765,8 +827,8 @@ public class TestYarnCLI {
FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.53789f, "YARN", null);
when(client.getApplicationReport(any(ApplicationId.class))).thenReturn(
newApplicationReport2);
- int result = cli.run(new String[] { "-movetoqueue",
applicationId.toString(),
- "-queue", "targetqueue"});
+ int result = cli.run(new String[] { "application", "-movetoqueue",
+ applicationId.toString(), "-queue", "targetqueue"});
assertEquals(0, result);
verify(client, times(0)).moveApplicationAcrossQueues(
any(ApplicationId.class), any(String.class));
@@ -780,8 +842,8 @@ public class TestYarnCLI {
FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.53789f, "YARN", null);
when(client.getApplicationReport(any(ApplicationId.class))).thenReturn(
newApplicationReport);
- result = cli.run(new String[] { "-movetoqueue", applicationId.toString(),
- "-queue", "targetqueue"});
+ result = cli.run(new String[] { "application", "-movetoqueue",
+ applicationId.toString(), "-queue", "targetqueue"});
assertEquals(0, result);
verify(client).moveApplicationAcrossQueues(any(ApplicationId.class),
any(String.class));
@@ -793,8 +855,8 @@ public class TestYarnCLI {
.moveApplicationAcrossQueues(applicationId, "targetqueue");
cli = createAndGetAppCLI();
try {
- result = cli.run(new String[] { "-movetoqueue", applicationId.toString(),
- "-queue", "targetqueue"});
+ result = cli.run(new String[] { "application", "-movetoqueue",
+ applicationId.toString(), "-queue", "targetqueue"});
Assert.fail();
} catch (Exception ex) {
Assert.assertTrue(ex instanceof ApplicationNotFoundException);
@@ -1095,12 +1157,24 @@ public class TestYarnCLI {
@Test
public void testMissingArguments() throws Exception {
ApplicationCLI cli = createAndGetAppCLI();
- int result = cli.run(new String[] { "-status" });
+ int result = cli.run(new String[] { "application", "-status" });
Assert.assertEquals(result, -1);
Assert.assertEquals(String.format("Missing argument for options%n%1s",
createApplicationCLIHelpMessage()), sysOutStream.toString());
sysOutStream.reset();
+ result = cli.run(new String[] { "applicationattempt", "-status" });
+ Assert.assertEquals(result, -1);
+ Assert.assertEquals(String.format("Missing argument for options%n%1s",
+ createApplicationAttemptCLIHelpMessage()), sysOutStream.toString());
+
+ sysOutStream.reset();
+ result = cli.run(new String[] { "container", "-status" });
+ Assert.assertEquals(result, -1);
+ Assert.assertEquals(String.format("Missing argument for options%n%1s",
+ createContainerCLIHelpMessage()), sysOutStream.toString());
+
+ sysOutStream.reset();
NodeCLI nodeCLI = new NodeCLI();
nodeCLI.setClient(client);
nodeCLI.setSysOutPrintStream(sysOut);
@@ -1113,7 +1187,7 @@ public class TestYarnCLI {
private void verifyUsageInfo(YarnCLI cli) throws Exception {
cli.setSysErrPrintStream(sysErr);
- cli.run(new String[0]);
+ cli.run(new String[] { "application" });
verify(sysErr).println("Invalid Command Usage : ");
}
@@ -1152,11 +1226,11 @@ public class TestYarnCLI {
pw.println(" application types.");
pw.println(" -help Displays help for all
commands.");
pw.println(" -kill <Application ID> Kills the application.");
- pw.println(" -list List applications from the
RM. Supports");
- pw.println(" optional use of -appTypes to
filter");
- pw.println(" applications based on
application type,");
- pw.println(" and -appStates to filter
applications");
- pw.println(" based on application state");
+ pw.println(" -list List applications. Supports
optional use");
+ pw.println(" of -appTypes to filter
applications based");
+ pw.println(" on application type, and
-appStates to");
+ pw.println(" filter applications based on
application");
+ pw.println(" state.");
pw.println(" -movetoqueue <Application ID> Moves the application to a
different");
pw.println(" queue.");
pw.println(" -queue <Queue Name> Works with the movetoqueue
command to");
@@ -1168,6 +1242,32 @@ public class TestYarnCLI {
return appsHelpStr;
}
+ private String createApplicationAttemptCLIHelpMessage() throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintWriter pw = new PrintWriter(baos);
+ pw.println("usage: applicationattempt");
+ pw.println(" -help Displays help for all
commands.");
+ pw.println(" -list <Application ID> List application attempts
for");
+ pw.println(" aplication.");
+ pw.println(" -status <Application Attempt ID> Prints the status of the
application");
+ pw.println(" attempt.");
+ pw.close();
+ String appsHelpStr = baos.toString("UTF-8");
+ return appsHelpStr;
+ }
+
+ private String createContainerCLIHelpMessage() throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintWriter pw = new PrintWriter(baos);
+ pw.println("usage: container");
+ pw.println(" -help Displays help for all
commands.");
+ pw.println(" -list <Application Attempt ID> List containers for
application attempt.");
+ pw.println(" -status <Container ID> Prints the status of the
container.");
+ pw.close();
+ String appsHelpStr = baos.toString("UTF-8");
+ return appsHelpStr;
+ }
+
private String createNodeCLIHelpMessage() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(baos);