YARN-4246. NPE while listing app attempt. (Nijel S F via rohithsharmaks)

This commit is contained in:
Rohith Sharma K S 2015-10-26 11:56:36 +05:30
parent 1aa735c188
commit b57f08c0d2
3 changed files with 29 additions and 2 deletions

View File

@ -997,6 +997,8 @@ Release 2.8.0 - UNRELEASED
YARN-3724. Use POSIX nftw(3) instead of fts(3) (Alan Burlison via aw)
YARN-4246. NPE while listing app attempt. (Nijel S F via rohithsharmaks)
Release 2.7.2 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -349,8 +349,9 @@ private int printApplicationAttemptReport(String applicationAttemptId)
appAttemptReportStr.println(appAttemptReport
.getYarnApplicationAttemptState());
appAttemptReportStr.print("\tAMContainer : ");
appAttemptReportStr.println(appAttemptReport.getAMContainerId()
.toString());
appAttemptReportStr
.println(appAttemptReport.getAMContainerId() == null ? "N/A"
: appAttemptReport.getAMContainerId().toString());
appAttemptReportStr.print("\tTracking-URL : ");
appAttemptReportStr.println(appAttemptReport.getTrackingUrl());
appAttemptReportStr.print("\tRPC Port : ");
@ -667,6 +668,7 @@ private void listApplicationAttempts(String applicationId) throws YarnException,
writer.printf(APPLICATION_ATTEMPTS_PATTERN, appAttemptReport
.getApplicationAttemptId(), appAttemptReport
.getYarnApplicationAttemptState(), appAttemptReport
.getAMContainerId() == null ? "N/A" : appAttemptReport
.getAMContainerId().toString(), appAttemptReport.getTrackingUrl());
}
writer.flush();

View File

@ -1590,4 +1590,27 @@ private String createNodeCLIHelpMessage() throws IOException {
private static String normalize(String s) {
return SPACES_PATTERN.matcher(s).replaceAll(" "); // single space
}
@Test
public void testAppAttemptReportWhileContainerIsNotAssigned()
throws Exception {
ApplicationCLI cli = createAndGetAppCLI();
ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
ApplicationAttemptId attemptId =
ApplicationAttemptId.newInstance(applicationId, 1);
ApplicationAttemptReport attemptReport =
ApplicationAttemptReport.newInstance(attemptId, "host", 124, "url",
"oUrl", "diagnostics", YarnApplicationAttemptState.SCHEDULED, null,
1000l, 2000l);
when(client.getApplicationAttemptReport(any(ApplicationAttemptId.class)))
.thenReturn(attemptReport);
int result =
cli.run(new String[] { "applicationattempt", "-status",
attemptId.toString() });
assertEquals(0, result);
result =
cli.run(new String[] { "applicationattempt", "-list",
applicationId.toString() });
assertEquals(0, result);
}
}