Search in sources :

Example 1 with InvalidStateTransitionException

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

the class TaskImpl method handle.

@Override
public void handle(TaskEvent event) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Processing " + event.getTaskID() + " of type " + event.getType());
    }
    try {
        writeLock.lock();
        TaskStateInternal oldState = getInternalState();
        try {
            stateMachine.doTransition(event.getType(), event);
        } catch (InvalidStateTransitionException e) {
            LOG.error("Can't handle this event at current state for " + this.taskId, e);
            internalError(event.getType());
        }
        if (oldState != getInternalState()) {
            LOG.info(taskId + " Task Transitioned from " + oldState + " to " + getInternalState());
        }
    } finally {
        writeLock.unlock();
    }
}
Also used : TaskStateInternal(org.apache.hadoop.mapreduce.v2.app.job.TaskStateInternal) InvalidStateTransitionException(org.apache.hadoop.yarn.state.InvalidStateTransitionException)

Example 2 with InvalidStateTransitionException

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

the class JobImpl method handle.

@Override
public /**
   * The only entry point to change the Job.
   */
void handle(JobEvent event) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Processing " + event.getJobId() + " of type " + event.getType());
    }
    try {
        writeLock.lock();
        JobStateInternal oldState = getInternalState();
        try {
            getStateMachine().doTransition(event.getType(), event);
        } catch (InvalidStateTransitionException e) {
            LOG.error("Can't handle this event at current state", e);
            addDiagnostic("Invalid event " + event.getType() + " on Job " + this.jobId);
            eventHandler.handle(new JobEvent(this.jobId, JobEventType.INTERNAL_ERROR));
        }
        //notify the eventhandler of state change
        if (oldState != getInternalState()) {
            LOG.info(jobId + "Job Transitioned from " + oldState + " to " + getInternalState());
            rememberLastNonFinalState(oldState);
        }
    } finally {
        writeLock.unlock();
    }
}
Also used : InvalidStateTransitionException(org.apache.hadoop.yarn.state.InvalidStateTransitionException) JobEvent(org.apache.hadoop.mapreduce.v2.app.job.event.JobEvent) JobStateInternal(org.apache.hadoop.mapreduce.v2.app.job.JobStateInternal)

Example 3 with InvalidStateTransitionException

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

the class LocalizedResource method handle.

@Override
public void handle(ResourceEvent event) {
    try {
        this.writeLock.lock();
        Path resourcePath = event.getLocalResourceRequest().getPath();
        if (LOG.isDebugEnabled()) {
            LOG.debug("Processing " + resourcePath + " of type " + event.getType());
        }
        ResourceState oldState = this.stateMachine.getCurrentState();
        ResourceState newState = null;
        try {
            newState = this.stateMachine.doTransition(event.getType(), event);
        } catch (InvalidStateTransitionException e) {
            LOG.warn("Can't handle this event at current state", e);
        }
        if (newState != null && oldState != newState) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Resource " + resourcePath + (localPath != null ? "(->" + localPath + ")" : "") + " transitioned from " + oldState + " to " + newState);
            }
        }
    } finally {
        this.writeLock.unlock();
    }
}
Also used : Path(org.apache.hadoop.fs.Path) InvalidStateTransitionException(org.apache.hadoop.yarn.state.InvalidStateTransitionException)

Example 4 with InvalidStateTransitionException

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

the class ApplicationImpl method handle.

@Override
public void handle(ApplicationEvent event) {
    this.writeLock.lock();
    try {
        ApplicationId applicationID = event.getApplicationID();
        if (LOG.isDebugEnabled()) {
            LOG.debug("Processing " + applicationID + " of type " + event.getType());
        }
        ApplicationState oldState = stateMachine.getCurrentState();
        ApplicationState newState = null;
        try {
            // queue event requesting init of the same app
            newState = stateMachine.doTransition(event.getType(), event);
        } catch (InvalidStateTransitionException e) {
            LOG.warn("Can't handle this event at current state", e);
        }
        if (newState != null && oldState != newState) {
            LOG.info("Application " + applicationID + " transitioned from " + oldState + " to " + newState);
        }
    } finally {
        this.writeLock.unlock();
    }
}
Also used : InvalidStateTransitionException(org.apache.hadoop.yarn.state.InvalidStateTransitionException) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId)

Example 5 with InvalidStateTransitionException

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

the class SchedulerApplicationAttempt method commonReserve.

private boolean commonReserve(SchedulerNode node, SchedulerRequestKey schedulerKey, RMContainer rmContainer, Resource reservedResource) {
    try {
        rmContainer.handle(new RMContainerReservedEvent(rmContainer.getContainerId(), reservedResource, node.getNodeID(), schedulerKey));
    } catch (InvalidStateTransitionException e) {
        // false indicate it fails
        return false;
    }
    Map<NodeId, RMContainer> reservedContainers = this.reservedContainers.get(schedulerKey);
    if (reservedContainers == null) {
        reservedContainers = new HashMap<NodeId, RMContainer>();
        this.reservedContainers.put(schedulerKey, reservedContainers);
    }
    reservedContainers.put(node.getNodeID(), rmContainer);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Application attempt " + getApplicationAttemptId() + " reserved container " + rmContainer + " on node " + node + ". This attempt currently has " + reservedContainers.size() + " reserved containers at priority " + schedulerKey.getPriority() + "; currentReservation " + reservedResource);
    }
    return true;
}
Also used : InvalidStateTransitionException(org.apache.hadoop.yarn.state.InvalidStateTransitionException) NodeId(org.apache.hadoop.yarn.api.records.NodeId) RMContainerReservedEvent(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerReservedEvent) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)

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