YARN-400. RM can return null application resource usage report leading to NPE in client (Jason Lowe via tgraves)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1448241 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Graves 2013-02-20 15:35:06 +00:00
parent c8f35bc3d2
commit efaaf58605
3 changed files with 19 additions and 7 deletions

View File

@ -331,6 +331,9 @@ Release 0.23.7 - UNRELEASED
YARN-362. Unexpected extra results when using webUI table search (Ravi YARN-362. Unexpected extra results when using webUI table search (Ravi
Prakash via jlowe) Prakash via jlowe)
YARN-400. RM can return null application resource usage report leading to
NPE in client (Jason Lowe via tgraves)
Release 0.23.6 - UNRELEASED Release 0.23.6 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -406,7 +406,8 @@ public ApplicationReport createAndGetApplicationReport(boolean allowAccess) {
String host = UNAVAILABLE; String host = UNAVAILABLE;
String origTrackingUrl = UNAVAILABLE; String origTrackingUrl = UNAVAILABLE;
int rpcPort = -1; int rpcPort = -1;
ApplicationResourceUsageReport appUsageReport = null; ApplicationResourceUsageReport appUsageReport =
DUMMY_APPLICATION_RESOURCE_USAGE_REPORT;
FinalApplicationStatus finishState = getFinalApplicationStatus(); FinalApplicationStatus finishState = getFinalApplicationStatus();
String diags = UNAVAILABLE; String diags = UNAVAILABLE;
if (allowAccess) { if (allowAccess) {
@ -418,18 +419,17 @@ public ApplicationReport createAndGetApplicationReport(boolean allowAccess) {
host = this.currentAttempt.getHost(); host = this.currentAttempt.getHost();
rpcPort = this.currentAttempt.getRpcPort(); rpcPort = this.currentAttempt.getRpcPort();
appUsageReport = currentAttempt.getApplicationResourceUsageReport(); appUsageReport = currentAttempt.getApplicationResourceUsageReport();
} else {
currentApplicationAttemptId =
BuilderUtils.newApplicationAttemptId(this.applicationId,
DUMMY_APPLICATION_ATTEMPT_NUMBER);
} }
diags = this.diagnostics.toString(); diags = this.diagnostics.toString();
} else { }
appUsageReport = DUMMY_APPLICATION_RESOURCE_USAGE_REPORT;
if (currentApplicationAttemptId == null) {
currentApplicationAttemptId = currentApplicationAttemptId =
BuilderUtils.newApplicationAttemptId(this.applicationId, BuilderUtils.newApplicationAttemptId(this.applicationId,
DUMMY_APPLICATION_ATTEMPT_NUMBER); DUMMY_APPLICATION_ATTEMPT_NUMBER);
} }
return BuilderUtils.newApplicationReport(this.applicationId, return BuilderUtils.newApplicationReport(this.applicationId,
currentApplicationAttemptId, this.user, this.queue, currentApplicationAttemptId, this.user, this.queue,
this.name, host, rpcPort, clientToken, this.name, host, rpcPort, clientToken,

View File

@ -29,6 +29,7 @@
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.MockApps; import org.apache.hadoop.yarn.MockApps;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationSubmissionContextPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationSubmissionContextPBImpl;
@ -616,4 +617,12 @@ public void testAppKilledKilled() throws IOException {
assertTimesAtFinish(application); assertTimesAtFinish(application);
assertAppState(RMAppState.KILLED, application); assertAppState(RMAppState.KILLED, application);
} }
@Test
public void testGetAppReport() {
RMApp app = createNewTestApp(null);
assertAppState(RMAppState.NEW, app);
ApplicationReport report = app.createAndGetApplicationReport(true);
Assert.assertNotNull(report.getApplicationResourceUsageReport());
}
} }