YARN-4411. RMAppAttemptImpl#createApplicationAttemptReport throws

IllegalArgumentException. Contributed by Bibin A Chundatt and yarntime.

(cherry picked from commit a277bdc9ed)
This commit is contained in:
Devaraj K 2016-01-29 13:51:37 +05:30
parent 6ce9b1240e
commit 123269c07f
3 changed files with 21 additions and 5 deletions

View File

@ -334,6 +334,9 @@ Release 2.8.0 - UNRELEASED
YARN-4219. New levelDB cache storage for timeline v1.5. (Li Lu via xgong)
YARN-4411. RMAppAttemptImpl#createApplicationAttemptReport throws
IllegalArgumentException. (Bibin A Chundatt, yarntime via devaraj)
IMPROVEMENTS
YARN-644. Basic null check is not performed on passed in arguments before

View File

@ -2067,11 +2067,11 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
// am container.
ContainerId amId =
masterContainer == null ? null : masterContainer.getId();
attemptReport = ApplicationAttemptReport.newInstance(this
.getAppAttemptId(), this.getHost(), this.getRpcPort(), this
.getTrackingUrl(), this.getOriginalTrackingUrl(), this.getDiagnostics(),
YarnApplicationAttemptState.valueOf(this.getState().toString()),
amId, this.startTime, this.finishTime);
attemptReport = ApplicationAttemptReport.newInstance(
this.getAppAttemptId(), this.getHost(), this.getRpcPort(),
this.getTrackingUrl(), this.getOriginalTrackingUrl(),
this.getDiagnostics(), createApplicationAttemptState(), amId,
this.startTime, this.finishTime);
} finally {
this.readLock.unlock();
}

View File

@ -917,6 +917,19 @@ public class TestRMAppAttemptTransitions {
testAppAttemptFailedState(amContainer, diagnostics);
}
@Test(timeout = 10000)
public void testCreateAppAttemptReport() {
RMAppAttemptState[] attemptStates = RMAppAttemptState.values();
applicationAttempt.handle(new RMAppAttemptEvent(
applicationAttempt.getAppAttemptId(), RMAppAttemptEventType.KILL));
// ALL RMAppAttemptState TO BE CHECK
RMAppAttempt attempt = spy(applicationAttempt);
for (RMAppAttemptState rmAppAttemptState : attemptStates) {
when(attempt.getState()).thenReturn(rmAppAttemptState);
attempt.createApplicationAttemptReport();
}
}
@Test(timeout = 10000)
public void testLaunchedAtFinalSaving() {
Container amContainer = allocateApplicationAttempt();