YARN-1768. Fixed error message being too verbose when killing a non-existent application. Contributed by Tsuyoshi Ozawa
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1574403 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4cc5a8dbdb
commit
b5e010ca0d
|
@ -379,6 +379,9 @@ Release 2.4.0 - UNRELEASED
|
||||||
|
|
||||||
YARN-1766. Fixed a bug in ResourceManager to use configuration loaded from the
|
YARN-1766. Fixed a bug in ResourceManager to use configuration loaded from the
|
||||||
configuration-provider when booting up. (Xuan Gong via vinodkv)
|
configuration-provider when booting up. (Xuan Gong via vinodkv)
|
||||||
|
|
||||||
|
YARN-1768. Fixed error message being too verbose when killing a non-existent
|
||||||
|
application
|
||||||
|
|
||||||
|
|
||||||
Release 2.3.1 - UNRELEASED
|
Release 2.3.1 - UNRELEASED
|
||||||
|
|
|
@ -40,6 +40,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationId;
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationReport;
|
import org.apache.hadoop.yarn.api.records.ApplicationReport;
|
||||||
import org.apache.hadoop.yarn.api.records.ContainerReport;
|
import org.apache.hadoop.yarn.api.records.ContainerReport;
|
||||||
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
|
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
|
||||||
|
import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException;
|
||||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||||
import org.apache.hadoop.yarn.util.ConverterUtils;
|
import org.apache.hadoop.yarn.util.ConverterUtils;
|
||||||
|
|
||||||
|
@ -208,7 +209,11 @@ public class ApplicationCLI extends YarnCLI {
|
||||||
printUsage(opts);
|
printUsage(opts);
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
killApplication(cliParser.getOptionValue(KILL_CMD));
|
try{
|
||||||
|
killApplication(cliParser.getOptionValue(KILL_CMD));
|
||||||
|
} catch (ApplicationNotFoundException e) {
|
||||||
|
return exitCode;
|
||||||
|
}
|
||||||
} else if (cliParser.hasOption(MOVE_TO_QUEUE_CMD)) {
|
} else if (cliParser.hasOption(MOVE_TO_QUEUE_CMD)) {
|
||||||
if (!cliParser.hasOption(QUEUE_CMD)) {
|
if (!cliParser.hasOption(QUEUE_CMD)) {
|
||||||
printUsage(opts);
|
printUsage(opts);
|
||||||
|
@ -370,7 +375,15 @@ public class ApplicationCLI extends YarnCLI {
|
||||||
private void killApplication(String applicationId) throws YarnException,
|
private void killApplication(String applicationId) throws YarnException,
|
||||||
IOException {
|
IOException {
|
||||||
ApplicationId appId = ConverterUtils.toApplicationId(applicationId);
|
ApplicationId appId = ConverterUtils.toApplicationId(applicationId);
|
||||||
ApplicationReport appReport = client.getApplicationReport(appId);
|
ApplicationReport appReport = null;
|
||||||
|
try {
|
||||||
|
appReport = client.getApplicationReport(appId);
|
||||||
|
} catch (ApplicationNotFoundException e) {
|
||||||
|
sysout.println("Application with id '" + applicationId +
|
||||||
|
"' doesn't exist in RM.");
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
if (appReport.getYarnApplicationState() == YarnApplicationState.FINISHED
|
if (appReport.getYarnApplicationState() == YarnApplicationState.FINISHED
|
||||||
|| appReport.getYarnApplicationState() == YarnApplicationState.KILLED
|
|| appReport.getYarnApplicationState() == YarnApplicationState.KILLED
|
||||||
|| appReport.getYarnApplicationState() == YarnApplicationState.FAILED) {
|
|| appReport.getYarnApplicationState() == YarnApplicationState.FAILED) {
|
||||||
|
@ -380,7 +393,7 @@ public class ApplicationCLI extends YarnCLI {
|
||||||
client.killApplication(appId);
|
client.killApplication(appId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the application with the given ID to the given queue.
|
* Moves the application with the given ID to the given queue.
|
||||||
*/
|
*/
|
||||||
|
@ -470,12 +483,12 @@ public class ApplicationCLI extends YarnCLI {
|
||||||
* @throws YarnException
|
* @throws YarnException
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private void listApplicationAttempts(String appId) throws YarnException,
|
private void listApplicationAttempts(String applicationId) throws YarnException,
|
||||||
IOException {
|
IOException {
|
||||||
PrintWriter writer = new PrintWriter(sysout);
|
PrintWriter writer = new PrintWriter(sysout);
|
||||||
|
|
||||||
List<ApplicationAttemptReport> appAttemptsReport = client
|
List<ApplicationAttemptReport> appAttemptsReport = client
|
||||||
.getApplicationAttempts(ConverterUtils.toApplicationId(appId));
|
.getApplicationAttempts(ConverterUtils.toApplicationId(applicationId));
|
||||||
writer.println("Total number of application attempts " + ":"
|
writer.println("Total number of application attempts " + ":"
|
||||||
+ appAttemptsReport.size());
|
+ appAttemptsReport.size());
|
||||||
writer.printf(APPLICATION_ATTEMPTS_PATTERN, "ApplicationAttempt-Id",
|
writer.printf(APPLICATION_ATTEMPTS_PATTERN, "ApplicationAttempt-Id",
|
||||||
|
|
|
@ -740,12 +740,16 @@ public class TestYarnCLI {
|
||||||
.getApplicationReport(applicationId);
|
.getApplicationReport(applicationId);
|
||||||
cli = createAndGetAppCLI();
|
cli = createAndGetAppCLI();
|
||||||
try {
|
try {
|
||||||
cli.run(new String[] { "application","-kill", applicationId.toString() });
|
int exitCode =
|
||||||
Assert.fail();
|
cli.run(new String[] { "application","-kill", applicationId.toString() });
|
||||||
} catch (Exception ex) {
|
verify(sysOut).println("Application with id '" + applicationId +
|
||||||
Assert.assertTrue(ex instanceof ApplicationNotFoundException);
|
"' doesn't exist in RM.");
|
||||||
Assert.assertEquals("Application with id '" + applicationId +
|
Assert.assertNotSame("should return non-zero exit code.", 0, exitCode);
|
||||||
"' doesn't exist in RM.", ex.getMessage());
|
} catch (ApplicationNotFoundException appEx) {
|
||||||
|
Assert.fail("application -kill should not throw" +
|
||||||
|
"ApplicationNotFoundException. " + appEx);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Assert.fail("Unexpected exception: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue