Search in sources :

Example 6 with InvalidStateTransitionException

use of org.apache.hadoop.yarn.state.InvalidStateTransitionException in project hadoop by apache.

the class RMAppAttemptImpl method handle.

@Override
public void handle(RMAppAttemptEvent event) {
    this.writeLock.lock();
    try {
        ApplicationAttemptId appAttemptID = event.getApplicationAttemptId();
        LOG.debug("Processing event for " + appAttemptID + " of type " + event.getType());
        final RMAppAttemptState oldState = getAppAttemptState();
        try {
            /* keep the master in sync with the state machine */
            this.stateMachine.doTransition(event.getType(), event);
        } catch (InvalidStateTransitionException e) {
            LOG.error("Can't handle this event at current state", e);
        /* TODO fail the application on the failed transition */
        }
        // Log at DEBUG otherwise.
        if ((oldState != getAppAttemptState()) && ((recoveredFinalState == null) || (event.getType() != RMAppAttemptEventType.RECOVER))) {
            LOG.info(String.format(STATE_CHANGE_MESSAGE, appAttemptID, oldState, getAppAttemptState(), event.getType()));
        } else if ((oldState != getAppAttemptState()) && LOG.isDebugEnabled()) {
            LOG.debug(String.format(STATE_CHANGE_MESSAGE, appAttemptID, oldState, getAppAttemptState(), event.getType()));
        }
    } finally {
        this.writeLock.unlock();
    }
}
Also used : InvalidStateTransitionException(org.apache.hadoop.yarn.state.InvalidStateTransitionException) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId)

Example 7 with InvalidStateTransitionException

use of org.apache.hadoop.yarn.state.InvalidStateTransitionException in project hadoop by apache.

the class RMAppImpl method handle.

@Override
public void handle(RMAppEvent event) {
    this.writeLock.lock();
    try {
        ApplicationId appID = event.getApplicationId();
        LOG.debug("Processing event for " + appID + " of type " + event.getType());
        final RMAppState oldState = getState();
        try {
            /* keep the master in sync with the state machine */
            this.stateMachine.doTransition(event.getType(), event);
        } catch (InvalidStateTransitionException e) {
            LOG.error("Can't handle this event at current state", e);
        /* TODO fail the application on the failed transition */
        }
        // Log at DEBUG otherwise.
        if ((oldState != getState()) && (((recoveredFinalState == null)) || (event.getType() != RMAppEventType.RECOVER))) {
            LOG.info(String.format(STATE_CHANGE_MESSAGE, appID, oldState, getState(), event.getType()));
        } else if ((oldState != getState()) && LOG.isDebugEnabled()) {
            LOG.debug(String.format(STATE_CHANGE_MESSAGE, appID, oldState, getState(), event.getType()));
        }
    } finally {
        this.writeLock.unlock();
    }
}
Also used : InvalidStateTransitionException(org.apache.hadoop.yarn.state.InvalidStateTransitionException) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId)

Example 8 with InvalidStateTransitionException

use of org.apache.hadoop.yarn.state.InvalidStateTransitionException in project hadoop by apache.

the class RMNodeImpl method handle.

public void handle(RMNodeEvent event) {
    LOG.debug("Processing " + event.getNodeId() + " of type " + event.getType());
    try {
        writeLock.lock();
        NodeState oldState = getState();
        try {
            stateMachine.doTransition(event.getType(), event);
        } catch (InvalidStateTransitionException e) {
            LOG.error("Can't handle this event at current state", e);
            LOG.error("Invalid event " + event.getType() + " on Node  " + this.nodeId + " oldState " + oldState);
        }
        if (oldState != getState()) {
            LOG.info(nodeId + " Node Transitioned from " + oldState + " to " + getState());
        }
    } finally {
        writeLock.unlock();
    }
}
Also used : NodeState(org.apache.hadoop.yarn.api.records.NodeState) InvalidStateTransitionException(org.apache.hadoop.yarn.state.InvalidStateTransitionException)

Example 9 with InvalidStateTransitionException

use of org.apache.hadoop.yarn.state.InvalidStateTransitionException in project hadoop by apache.

the class TaskAttemptImpl method handle.

@SuppressWarnings("unchecked")
@Override
public void handle(TaskAttemptEvent event) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Processing " + event.getTaskAttemptID() + " of type " + event.getType());
    }
    writeLock.lock();
    try {
        final TaskAttemptStateInternal oldState = getInternalState();
        try {
            stateMachine.doTransition(event.getType(), event);
        } catch (InvalidStateTransitionException e) {
            LOG.error("Can't handle this event at current state for " + this.attemptId, e);
            eventHandler.handle(new JobDiagnosticsUpdateEvent(this.attemptId.getTaskId().getJobId(), "Invalid event " + event.getType() + " on TaskAttempt " + this.attemptId));
            eventHandler.handle(new JobEvent(this.attemptId.getTaskId().getJobId(), JobEventType.INTERNAL_ERROR));
        }
        if (oldState != getInternalState()) {
            if (getInternalState() == TaskAttemptStateInternal.FAILED) {
                String nodeId = null == this.container ? "Not-assigned" : this.container.getNodeId().toString();
                LOG.info(attemptId + " transitioned from state " + oldState + " to " + getInternalState() + ", event type is " + event.getType() + " and nodeId=" + nodeId);
            } else {
                LOG.info(attemptId + " TaskAttempt Transitioned from " + oldState + " to " + getInternalState());
            }
        }
    } finally {
        writeLock.unlock();
    }
}
Also used : TaskAttemptStateInternal(org.apache.hadoop.mapreduce.v2.app.job.TaskAttemptStateInternal) InvalidStateTransitionException(org.apache.hadoop.yarn.state.InvalidStateTransitionException) JobEvent(org.apache.hadoop.mapreduce.v2.app.job.event.JobEvent) JobDiagnosticsUpdateEvent(org.apache.hadoop.mapreduce.v2.app.job.event.JobDiagnosticsUpdateEvent)

Example 10 with InvalidStateTransitionException

use of org.apache.hadoop.yarn.state.InvalidStateTransitionException in project hadoop by apache.

the class ContainerImpl method handle.

@Override
public void handle(ContainerEvent event) {
    try {
        this.writeLock.lock();
        ContainerId containerID = event.getContainerID();
        if (LOG.isDebugEnabled()) {
            LOG.debug("Processing " + containerID + " of type " + event.getType());
        }
        ContainerState oldState = stateMachine.getCurrentState();
        ContainerState newState = null;
        try {
            newState = stateMachine.doTransition(event.getType(), event);
        } catch (InvalidStateTransitionException e) {
            LOG.warn("Can't handle this event at current state: Current: [" + oldState + "], eventType: [" + event.getType() + "]," + " container: [" + containerID + "]", e);
        }
        if (newState != null && oldState != newState) {
            LOG.info("Container " + containerID + " transitioned from " + oldState + " to " + newState);
        }
    } finally {
        this.writeLock.unlock();
    }
}
Also used : InvalidStateTransitionException(org.apache.hadoop.yarn.state.InvalidStateTransitionException) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) RecoveredContainerState(org.apache.hadoop.yarn.server.nodemanager.recovery.NMStateStoreService.RecoveredContainerState)

Aggregations

InvalidStateTransitionException (org.apache.hadoop.yarn.state.InvalidStateTransitionException)10 JobEvent (org.apache.hadoop.mapreduce.v2.app.job.event.JobEvent)2 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)2 Path (org.apache.hadoop.fs.Path)1 JobStateInternal (org.apache.hadoop.mapreduce.v2.app.job.JobStateInternal)1 TaskAttemptStateInternal (org.apache.hadoop.mapreduce.v2.app.job.TaskAttemptStateInternal)1 TaskStateInternal (org.apache.hadoop.mapreduce.v2.app.job.TaskStateInternal)1 JobDiagnosticsUpdateEvent (org.apache.hadoop.mapreduce.v2.app.job.event.JobDiagnosticsUpdateEvent)1 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)1 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)1 NodeId (org.apache.hadoop.yarn.api.records.NodeId)1 NodeState (org.apache.hadoop.yarn.api.records.NodeState)1 RecoveredContainerState (org.apache.hadoop.yarn.server.nodemanager.recovery.NMStateStoreService.RecoveredContainerState)1 RMContainer (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)1 RMContainerReservedEvent (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerReservedEvent)1