Search in sources :

Example 51 with ApplicationStateData

use of org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationStateData in project hadoop by apache.

the class RMAppImpl method recover.

@Override
public void recover(RMState state) {
    ApplicationStateData appState = state.getApplicationState().get(getApplicationId());
    this.recoveredFinalState = appState.getState();
    if (recoveredFinalState == null) {
        LOG.info(String.format(RECOVERY_MESSAGE, getApplicationId(), appState.getAttemptCount(), "NONE"));
    } else if (LOG.isDebugEnabled()) {
        LOG.debug(String.format(RECOVERY_MESSAGE, getApplicationId(), appState.getAttemptCount(), recoveredFinalState));
    }
    this.diagnostics.append(null == appState.getDiagnostics() ? "" : appState.getDiagnostics());
    this.storedFinishTime = appState.getFinishTime();
    this.startTime = appState.getStartTime();
    this.callerContext = appState.getCallerContext();
    this.applicationTimeouts = appState.getApplicationTimeouts();
    // If interval > 0, some attempts might have been deleted.
    if (this.attemptFailuresValidityInterval > 0) {
        this.firstAttemptIdInStateStore = appState.getFirstAttemptId();
        this.nextAttemptId = firstAttemptIdInStateStore;
    }
    //TODO recover collector address.
    //this.collectorAddr = appState.getCollectorAddr();
    // send the ATS create Event during RM recovery.
    // NOTE: it could be duplicated with events sent before RM get restarted.
    sendATSCreateEvent();
    RMAppAttemptImpl preAttempt = null;
    for (ApplicationAttemptId attemptId : new TreeSet<>(appState.attempts.keySet())) {
        // create attempt
        createNewAttempt(attemptId);
        ((RMAppAttemptImpl) this.currentAttempt).recover(state);
        // about its final state.
        if (preAttempt != null && preAttempt.getRecoveredFinalState() == null) {
            preAttempt.setRecoveredFinalState(RMAppAttemptState.FAILED);
        }
        preAttempt = (RMAppAttemptImpl) currentAttempt;
    }
    if (currentAttempt != null) {
        nextAttemptId = currentAttempt.getAppAttemptId().getAttemptId() + 1;
    }
}
Also used : TreeSet(java.util.TreeSet) RMAppAttemptImpl(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptImpl) ApplicationStateData(org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationStateData) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId)

Aggregations

ApplicationStateData (org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationStateData)51 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)32 Test (org.junit.Test)29 MemoryRMStateStore (org.apache.hadoop.yarn.server.resourcemanager.recovery.MemoryRMStateStore)27 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)26 RMState (org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.RMState)21 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)14 RMAppAttempt (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt)13 ApplicationAttemptStateData (org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationAttemptStateData)12 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)8 ApplicationAccessType (org.apache.hadoop.yarn.api.records.ApplicationAccessType)7 IOException (java.io.IOException)6 ApplicationSubmissionContext (org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext)6 MockNM (org.apache.hadoop.yarn.server.resourcemanager.MockNM)6 MockRM (org.apache.hadoop.yarn.server.resourcemanager.MockRM)6 ArrayList (java.util.ArrayList)5 YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)5 NMContainerStatus (org.apache.hadoop.yarn.server.api.protocolrecords.NMContainerStatus)5 MockAM (org.apache.hadoop.yarn.server.resourcemanager.MockAM)5 HashMap (java.util.HashMap)4