Merge r1580997 from trunk. YARN-1852. Fixed RMAppAttempt to not resend AttemptFailed/AttemptKilled events to already recovered Failed/Killed RMApps. Contributed by Rohith Sharmaks

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1581001 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jian He 2014-03-24 19:06:50 +00:00
parent 95f1b6f5d5
commit cb9fcd7f03
3 changed files with 60 additions and 1 deletions

View File

@ -550,6 +550,9 @@ Release 2.4.0 - UNRELEASED
YARN-1705. Reset cluster-metrics on transition to standby. (Rohith via kasha) YARN-1705. Reset cluster-metrics on transition to standby. (Rohith via kasha)
YARN-1852. Fixed RMAppAttempt to not resend AttemptFailed/AttemptKilled
events to already recovered Failed/Killed RMApps. (Rohith via jianhe)
Release 2.3.1 - UNRELEASED Release 2.3.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -1136,8 +1136,12 @@ public class RMAppImpl implements RMApp, Recoverable {
} }
public static boolean isAppInFinalState(RMApp rmApp) { public static boolean isAppInFinalState(RMApp rmApp) {
RMAppState appState = rmApp.getState(); RMAppState appState = ((RMAppImpl) rmApp).getRecoveredFinalState();
return appState == RMAppState.FAILED || appState == RMAppState.FINISHED return appState == RMAppState.FAILED || appState == RMAppState.FINISHED
|| appState == RMAppState.KILLED; || appState == RMAppState.KILLED;
} }
private RMAppState getRecoveredFinalState() {
return this.recoveredFinalState;
}
} }

View File

@ -27,6 +27,7 @@ import static org.mockito.Mockito.verify;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Map;
import org.junit.Assert; import org.junit.Assert;
@ -53,6 +54,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.RMContextImpl;
import org.apache.hadoop.yarn.server.resourcemanager.ahs.RMApplicationHistoryWriter; import org.apache.hadoop.yarn.server.resourcemanager.ahs.RMApplicationHistoryWriter;
import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore; import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore;
import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.ApplicationState; import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.ApplicationState;
import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.RMState;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.AMLivelinessMonitor; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.AMLivelinessMonitor;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptEvent; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptEvent;
@ -863,6 +865,56 @@ public class TestRMAppTransitions {
assertAppState(RMAppState.KILLED, application); assertAppState(RMAppState.KILLED, application);
} }
@Test(timeout = 30000)
public void testAppsRecoveringStates() throws Exception {
RMState state = new RMState();
Map<ApplicationId, ApplicationState> applicationState =
state.getApplicationState();
createRMStateForApplications(applicationState, RMAppState.FINISHED);
createRMStateForApplications(applicationState, RMAppState.KILLED);
createRMStateForApplications(applicationState, RMAppState.FAILED);
for (ApplicationState appState : applicationState.values()) {
testRecoverApplication(appState, state);
}
}
public void testRecoverApplication(ApplicationState appState, RMState rmState)
throws Exception {
ApplicationSubmissionContext submissionContext =
appState.getApplicationSubmissionContext();
RMAppImpl application =
new RMAppImpl(appState.getAppId(), rmContext, conf,
submissionContext.getApplicationName(), null,
submissionContext.getQueue(), submissionContext, null, null,
appState.getSubmitTime(), submissionContext.getApplicationType(),
submissionContext.getApplicationTags());
Assert.assertEquals(RMAppState.NEW, application.getState());
application.recover(rmState);
// Application final status looked from recoveredFinalStatus
Assert.assertTrue("Application is not in recoveredFinalStatus.",
RMAppImpl.isAppInFinalState(application));
// Trigger RECOVER event.
application.handle(new RMAppEvent(appState.getAppId(),
RMAppEventType.RECOVER));
rmDispatcher.await();
RMAppState finalState = appState.getState();
Assert.assertEquals("Application is not in finalState.", finalState,
application.getState());
}
public void createRMStateForApplications(
Map<ApplicationId, ApplicationState> applicationState,
RMAppState rmAppState) {
RMApp app = createNewTestApp(null);
ApplicationState appState =
new ApplicationState(app.getSubmitTime(), app.getStartTime(),
app.getApplicationSubmissionContext(), app.getUser(), rmAppState,
null, app.getFinishTime());
applicationState.put(app.getApplicationId(), appState);
}
@Test @Test
public void testGetAppReport() { public void testGetAppReport() {
RMApp app = createNewTestApp(null); RMApp app = createNewTestApp(null);