YARN-6948. Invalid event: ATTEMPT_ADDED at FINAL_SAVING. Contributed by lujie

This commit is contained in:
Jason Lowe 2018-01-09 10:51:15 -06:00
parent ebff4decfe
commit 90c86d6e09
2 changed files with 33 additions and 3 deletions

View File

@ -418,7 +418,8 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
RMAppAttemptEventType.CONTAINER_ALLOCATED,
RMAppAttemptEventType.ATTEMPT_NEW_SAVED,
RMAppAttemptEventType.KILL,
RMAppAttemptEventType.FAIL))
RMAppAttemptEventType.FAIL,
RMAppAttemptEventType.ATTEMPT_ADDED))
// Transitions from FAILED State
// For work-preserving AM restart, failed attempt are still capturing
@ -909,7 +910,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
} catch (InvalidStateTransitionException e) {
LOG.error("App attempt: " + appAttemptID
+ " can't handle this event at current state", e);
/* TODO fail the application on the failed transition */
onInvalidTranstion(event.getType(), oldState);
}
// Log at INFO if we're not recovering or not in a terminal state.
@ -2240,4 +2241,8 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
return Collections.EMPTY_SET;
}
protected void onInvalidTranstion(RMAppAttemptEventType rmAppAttemptEventType,
RMAppAttemptState state){
/* TODO fail the application on the failed transition */
}
}

View File

@ -327,7 +327,15 @@ public class TestRMAppAttemptTransitions {
masterService, submissionContext, new Configuration(),
Collections.singletonList(BuilderUtils.newResourceRequest(
RMAppAttemptImpl.AM_CONTAINER_PRIORITY, ResourceRequest.ANY,
submissionContext.getResource(), 1)), application);
submissionContext.getResource(), 1)), application) {
@Override
protected void onInvalidTranstion(
RMAppAttemptEventType rmAppAttemptEventType,
RMAppAttemptState state) {
Assert.assertTrue("RMAppAttemptImpl can't handle "
+ rmAppAttemptEventType + " at state " + state, false);
}
};
when(application.getCurrentAppAttempt()).thenReturn(applicationAttempt);
when(application.getApplicationId()).thenReturn(applicationId);
@ -974,6 +982,23 @@ public class TestRMAppAttemptTransitions {
applicationAttempt.getAppAttemptState());
}
@Test(timeout = 10000)
public void testAttemptAddedAtFinalSaving() {
submitApplicationAttempt();
// SUBNITED->FINAL_SAVING
applicationAttempt.handle(new RMAppAttemptEvent(applicationAttempt
.getAppAttemptId(), RMAppAttemptEventType.KILL));
assertEquals(RMAppAttemptState.FINAL_SAVING,
applicationAttempt.getAppAttemptState());
applicationAttempt.handle(new RMAppAttemptEvent(applicationAttempt
.getAppAttemptId(), RMAppAttemptEventType.ATTEMPT_ADDED));
assertEquals(RMAppAttemptState.FINAL_SAVING,
applicationAttempt.getAppAttemptState());
}
@Test
public void testAMCrashAtAllocated() {
Container amContainer = allocateApplicationAttempt();