YARN-6948. Invalid event: ATTEMPT_ADDED at FINAL_SAVING. Contributed by lujie
(cherry picked from commit 90c86d6e09
)
Conflicts:
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java
This commit is contained in:
parent
f15c7e86e8
commit
c892789896
|
@ -416,7 +416,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
|
||||
|
@ -908,7 +909,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.
|
||||
|
@ -2281,6 +2282,11 @@ 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 */
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link CharSequence} appender that considers its {@link #limit} as upper
|
||||
* bound.
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue