Java Code Examples for org.apache.hadoop.yarn.state.InvalidStateTransitonException

The following examples show how to use org.apache.hadoop.yarn.state.InvalidStateTransitonException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hadoop   Source File: LocalizedResource.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void handle(ResourceEvent event) {
  try {
    this.writeLock.lock();

    Path resourcePath = event.getLocalResourceRequest().getPath();
    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 (InvalidStateTransitonException e) {
      LOG.warn("Can't handle this event at current state", e);
    }
    if (oldState != newState) {
      LOG.info("Resource " + resourcePath + (localPath != null ? 
        "(->" + localPath + ")": "") + " transitioned from " + oldState
          + " to " + newState);
    }
  } finally {
    this.writeLock.unlock();
  }
}
 
Example 2
Source Project: hadoop   Source File: ApplicationImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void handle(ApplicationEvent event) {

  this.writeLock.lock();

  try {
    ApplicationId applicationID = event.getApplicationID();
    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 (InvalidStateTransitonException e) {
      LOG.warn("Can't handle this event at current state", e);
    }
    if (oldState != newState) {
      LOG.info("Application " + applicationID + " transitioned from "
          + oldState + " to " + newState);
    }
  } finally {
    this.writeLock.unlock();
  }
}
 
Example 3
Source Project: hadoop   Source File: ContainerImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void handle(ContainerEvent event) {
  try {
    this.writeLock.lock();

    ContainerId containerID = event.getContainerID();
    LOG.debug("Processing " + containerID + " of type " + event.getType());

    ContainerState oldState = stateMachine.getCurrentState();
    ContainerState newState = null;
    try {
      newState =
          stateMachine.doTransition(event.getType(), event);
    } catch (InvalidStateTransitonException e) {
      LOG.warn("Can't handle this event at current state: Current: ["
          + oldState + "], eventType: [" + event.getType() + "]", e);
    }
    if (oldState != newState) {
      LOG.info("Container " + containerID + " transitioned from "
          + oldState
          + " to " + newState);
    }
  } finally {
    this.writeLock.unlock();
  }
}
 
Example 4
Source Project: hadoop   Source File: RMContainerImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void handle(RMContainerEvent event) {
  LOG.debug("Processing " + event.getContainerId() + " of type " + event.getType());
  try {
    writeLock.lock();
    RMContainerState oldState = getState();
    try {
       stateMachine.doTransition(event.getType(), event);
    } catch (InvalidStateTransitonException e) {
      LOG.error("Can't handle this event at current state", e);
      LOG.error("Invalid event " + event.getType() + 
          " on container " + this.containerId);
    }
    if (oldState != getState()) {
      LOG.info(event.getContainerId() + " Container Transitioned from "
          + oldState + " to " + getState());
    }
  }
  
  finally {
    writeLock.unlock();
  }
}
 
Example 5
Source Project: hadoop   Source File: RMNodeImpl.java    License: Apache License 2.0 6 votes vote down vote up
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 (InvalidStateTransitonException e) {
      LOG.error("Can't handle this event at current state", e);
      LOG.error("Invalid event " + event.getType() + 
          " on Node  " + this.nodeId);
    }
    if (oldState != getState()) {
      LOG.info(nodeId + " Node Transitioned from " + oldState + " to "
               + getState());
    }
  }
  
  finally {
    writeLock.unlock();
  }
}
 
Example 6
Source Project: hadoop   Source File: RMAppImpl.java    License: Apache License 2.0 6 votes vote down vote up
@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 (InvalidStateTransitonException e) {
      LOG.error("Can't handle this event at current state", e);
      /* TODO fail the application on the failed transition */
    }

    if (oldState != getState()) {
      LOG.info(appID + " State change from " + oldState + " to "
          + getState());
    }
  } finally {
    this.writeLock.unlock();
  }
}
 
Example 7
Source Project: hadoop   Source File: RMAppAttemptImpl.java    License: Apache License 2.0 6 votes vote down vote up
@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 (InvalidStateTransitonException e) {
      LOG.error("Can't handle this event at current state", e);
      /* TODO fail the application on the failed transition */
    }

    if (oldState != getAppAttemptState()) {
      LOG.info(appAttemptID + " State change from " + oldState + " to "
          + getAppAttemptState());
    }
  } finally {
    this.writeLock.unlock();
  }
}
 
Example 8
Source Project: hadoop   Source File: RMStateStore.java    License: Apache License 2.0 6 votes vote down vote up
protected void handleStoreEvent(RMStateStoreEvent event) {
  this.writeLock.lock();
  try {

    if (LOG.isDebugEnabled()) {
      LOG.debug("Processing event of type " + event.getType());
    }

    final RMStateStoreState oldState = getRMStateStoreState();

    this.stateMachine.doTransition(event.getType(), event);

    if (oldState != getRMStateStoreState()) {
      LOG.info("RMStateStore state change from " + oldState + " to "
          + getRMStateStoreState());
    }

  } catch (InvalidStateTransitonException e) {
    LOG.error("Can't handle this event at current state", e);
  } finally {
    this.writeLock.unlock();
  }
}
 
Example 9
Source Project: hadoop   Source File: TaskImpl.java    License: Apache License 2.0 6 votes vote down vote up
@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 (InvalidStateTransitonException 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();
  }
}
 
Example 10
Source Project: big-c   Source File: LocalizedResource.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void handle(ResourceEvent event) {
  try {
    this.writeLock.lock();

    Path resourcePath = event.getLocalResourceRequest().getPath();
    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 (InvalidStateTransitonException e) {
      LOG.warn("Can't handle this event at current state", e);
    }
    if (oldState != newState) {
      LOG.info("Resource " + resourcePath + (localPath != null ? 
        "(->" + localPath + ")": "") + " transitioned from " + oldState
          + " to " + newState);
    }
  } finally {
    this.writeLock.unlock();
  }
}
 
Example 11
Source Project: big-c   Source File: ApplicationImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void handle(ApplicationEvent event) {

  this.writeLock.lock();

  try {
    ApplicationId applicationID = event.getApplicationID();
    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 (InvalidStateTransitonException e) {
      LOG.warn("Can't handle this event at current state", e);
    }
    if (oldState != newState) {
      LOG.info("Application " + applicationID + " transitioned from "
          + oldState + " to " + newState);
    }
  } finally {
    this.writeLock.unlock();
  }
}
 
Example 12
Source Project: big-c   Source File: ContainerImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void handle(ContainerEvent event) {
  try {
    this.writeLock.lock();

    ContainerId containerID = event.getContainerID();
    LOG.debug("Processing " + containerID + " of type " + event.getType());

    ContainerState oldState = stateMachine.getCurrentState();
    ContainerState newState = null;
    try {
      newState =
          stateMachine.doTransition(event.getType(), event);
    } catch (InvalidStateTransitonException e) {
      LOG.warn("Can't handle this event at current state: Current: ["
          + oldState + "], eventType: [" + event.getType() + "]", e);
    }
    if (oldState != newState) {
      LOG.info("Container " + containerID + " transitioned from "
          + oldState
          + " to " + newState);
    }
  } finally {
    this.writeLock.unlock();
  }
}
 
Example 13
Source Project: big-c   Source File: RMContainerImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void handle(RMContainerEvent event) {
  LOG.debug("Processing " + event.getContainerId() + " of type " + event.getType());
  try {
    writeLock.lock();
    RMContainerState oldState = getState();
    try {
       stateMachine.doTransition(event.getType(), event);
    } catch (InvalidStateTransitonException e) {
      LOG.error("Can't handle this event at current state", e);
      LOG.error("Invalid event " + event.getType() + 
          " on container " + this.containerId);
    }
    if (oldState != getState()) {
      LOG.info(event.getContainerId() + " Container Transitioned from "
          + oldState + " to " + getState());
    }
  }
  
  finally {
    writeLock.unlock();
  }
}
 
Example 14
Source Project: big-c   Source File: RMNodeImpl.java    License: Apache License 2.0 6 votes vote down vote up
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 (InvalidStateTransitonException e) {
      LOG.error("Can't handle this event at current state", e);
      LOG.error("Invalid event " + event.getType() + 
          " on Node  " + this.nodeId);
    }
    if (oldState != getState()) {
      LOG.info(nodeId + " Node Transitioned from " + oldState + " to "
               + getState());
    }
  }
  
  finally {
    writeLock.unlock();
  }
}
 
Example 15
Source Project: big-c   Source File: RMAppImpl.java    License: Apache License 2.0 6 votes vote down vote up
@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 (InvalidStateTransitonException e) {
      LOG.error("Can't handle this event at current state", e);
      /* TODO fail the application on the failed transition */
    }

    if (oldState != getState()) {
      LOG.info(appID + " State change from " + oldState + " to "
          + getState());
    }
  } finally {
    this.writeLock.unlock();
  }
}
 
Example 16
Source Project: big-c   Source File: RMAppAttemptImpl.java    License: Apache License 2.0 6 votes vote down vote up
@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 (InvalidStateTransitonException e) {
      LOG.error("Can't handle this event at current state", e);
      /* TODO fail the application on the failed transition */
    }

    if (oldState != getAppAttemptState()) {
      LOG.info(appAttemptID + " State change from " + oldState + " to "
          + getAppAttemptState());
    }
  } finally {
    this.writeLock.unlock();
  }
}
 
Example 17
Source Project: big-c   Source File: RMStateStore.java    License: Apache License 2.0 6 votes vote down vote up
protected void handleStoreEvent(RMStateStoreEvent event) {
  this.writeLock.lock();
  try {

    if (LOG.isDebugEnabled()) {
      LOG.debug("Processing event of type " + event.getType());
    }

    final RMStateStoreState oldState = getRMStateStoreState();

    this.stateMachine.doTransition(event.getType(), event);

    if (oldState != getRMStateStoreState()) {
      LOG.info("RMStateStore state change from " + oldState + " to "
          + getRMStateStoreState());
    }

  } catch (InvalidStateTransitonException e) {
    LOG.error("Can't handle this event at current state", e);
  } finally {
    this.writeLock.unlock();
  }
}
 
Example 18
Source Project: big-c   Source File: TaskImpl.java    License: Apache License 2.0 6 votes vote down vote up
@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 (InvalidStateTransitonException 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();
  }
}
 
Example 19
Source Project: incubator-tez   Source File: TaskImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void handle(TaskEvent event) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Processing TaskEvent " + event.getTaskID() + " of type "
        + event.getType() + " while in state " + getInternalState()
        + ". Event: " + event);
  }
  try {
    writeLock.lock();
    TaskStateInternal oldState = getInternalState();
    try {
      stateMachine.doTransition(event.getType(), event);
    } catch (InvalidStateTransitonException 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();
  }
}
 
Example 20
Source Project: incubator-tez   Source File: AMNodeImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void handle(AMNodeEvent event) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Processing AMNodeEvent " + event.getNodeId()
        + " of type " + event.getType() + " while in state: " + getState()
        + ". Event: " + event);
  }
  this.writeLock.lock();
  try {
    final AMNodeState oldState = getState();
    try {
      stateMachine.doTransition(event.getType(), event);
    } catch (InvalidStateTransitonException e) {
      LOG.error("Can't handle event " + event.getType()
          + " at current state " + oldState + " for NodeId " + this.nodeId, e);
      // TODO Should this fail the job ?
    }
    if (oldState != getState()) {
      LOG.info("AMNode " + this.nodeId + " transitioned from " + oldState
          + " to " + getState());
    }
  } finally {
    writeLock.unlock();
  }
}
 
Example 21
Source Project: tez   Source File: AMNodeImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void handle(AMNodeEvent event) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Processing AMNodeEvent " + event.getNodeId()
        + " of type " + event.getType() + " while in state: " + getState()
        + ". Event: " + event);
  }
  this.writeLock.lock();
  try {
    final AMNodeState oldState = getState();
    try {
      stateMachine.doTransition(event.getType(), event);
    } catch (InvalidStateTransitonException e) {
      LOG.error("Can't handle event " + event.getType()
          + " at current state " + oldState + " for NodeId " + this.nodeId, e);
      // TODO Should this fail the job ?
    }
    if (oldState != getState()) {
      LOG.info("AMNode " + this.nodeId + " transitioned from " + oldState
          + " to " + getState());
    }
  } finally {
    writeLock.unlock();
  }
}
 
Example 22
Source Project: hadoop   Source File: NMClientAsyncImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void handle(ContainerEvent event) {
  writeLock.lock();
  try {
    try {
      this.stateMachine.doTransition(event.getType(), event);
    } catch (InvalidStateTransitonException e) {
      LOG.error("Can't handle this event at current state", e);
    }
  } finally {
    writeLock.unlock();
  }
}
 
Example 23
Source Project: hadoop   Source File: TaskAttemptImpl.java    License: Apache License 2.0 5 votes vote down vote up
@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 (InvalidStateTransitonException 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()) {
        LOG.info(attemptId + " TaskAttempt Transitioned from " 
         + oldState + " to "
         + getInternalState());
    }
  } finally {
    writeLock.unlock();
  }
}
 
Example 24
Source Project: hadoop   Source File: JobImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
/**
 * The only entry point to change the Job.
 */
public 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 (InvalidStateTransitonException 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();
  }
}
 
Example 25
Source Project: big-c   Source File: NMClientAsyncImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void handle(ContainerEvent event) {
  writeLock.lock();
  try {
    try {
      this.stateMachine.doTransition(event.getType(), event);
    } catch (InvalidStateTransitonException e) {
      LOG.error("Can't handle this event at current state", e);
    }
  } finally {
    writeLock.unlock();
  }
}
 
Example 26
Source Project: big-c   Source File: TaskAttemptImpl.java    License: Apache License 2.0 5 votes vote down vote up
@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 (InvalidStateTransitonException 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()) {
        LOG.info(attemptId + " TaskAttempt Transitioned from " 
         + oldState + " to "
         + getInternalState());
    }
  } finally {
    writeLock.unlock();
  }
}
 
Example 27
Source Project: big-c   Source File: JobImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
/**
 * The only entry point to change the Job.
 */
public 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 (InvalidStateTransitonException 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();
  }
}
 
Example 28
Source Project: incubator-tez   Source File: DAGImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
/**
 * The only entry point to change the DAG.
 */
public void handle(DAGEvent event) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Processing DAGEvent " + event.getDAGId() + " of type "
        + event.getType() + " while in state " + getInternalState()
        + ". Event: " + event);
  }
  try {
    writeLock.lock();
    DAGState oldState = getInternalState();
    try {
       getStateMachine().doTransition(event.getType(), event);
    } catch (InvalidStateTransitonException e) {
      LOG.error("Can't handle this event at current state", e);
      addDiagnostic("Invalid event " + event.getType() +
          " on Job " + this.dagId);
      eventHandler.handle(new DAGEvent(this.dagId,
          DAGEventType.INTERNAL_ERROR));
    }
    //notify the eventhandler of state change
    if (oldState != getInternalState()) {
      LOG.info(dagId + " transitioned from " + oldState + " to "
               + getInternalState());
    }
  }

  finally {
    writeLock.unlock();
  }
}
 
Example 29
Source Project: incubator-tez   Source File: TaskAttemptImpl.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void handle(TaskAttemptEvent event) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Processing TaskAttemptEvent " + event.getTaskAttemptID()
        + " of type " + event.getType() + " while in state "
        + getInternalState() + ". Event: " + event);
  }
  writeLock.lock();
  try {
    final TaskAttemptStateInternal oldState = getInternalState();
    try {
      stateMachine.doTransition(event.getType(), event);
    } catch (InvalidStateTransitonException e) {
      LOG.error("Can't handle this event at current state for "
          + this.attemptId, e);
      eventHandler.handle(new DAGEventDiagnosticsUpdate(
          this.attemptId.getTaskID().getVertexID().getDAGId(),
          "Invalid event " + event.getType() +
          " on TaskAttempt " + this.attemptId));
      eventHandler.handle(
          new DAGEvent(
              this.attemptId.getTaskID().getVertexID().getDAGId(),
              DAGEventType.INTERNAL_ERROR)
          );
    }
    if (oldState != getInternalState()) {
        LOG.info(attemptId + " TaskAttempt Transitioned from "
         + oldState + " to "
         + getInternalState() + " due to event "
         + event.getType());
    }
  } finally {
    writeLock.unlock();
  }
}
 
Example 30
Source Project: incubator-tez   Source File: VertexImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
/**
 * The only entry point to change the Vertex.
 */
public void handle(VertexEvent event) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Processing VertexEvent " + event.getVertexId()
        + " of type " + event.getType() + " while in state "
        + getInternalState() + ". Event: " + event);
  }
  try {
    writeLock.lock();
    VertexState oldState = getInternalState();
    try {
       getStateMachine().doTransition(event.getType(), event);
    } catch (InvalidStateTransitonException e) {
      String message = "Invalid event " + event.getType() +
          " on vertex " + this.vertexName +
          " with vertexId " + this.vertexId +
          " at current state " + oldState;
      LOG.error("Can't handle " + message, e);
      addDiagnostic(message);
      eventHandler.handle(new VertexEvent(this.vertexId,
          VertexEventType.V_INTERNAL_ERROR));
    }

    if (oldState != getInternalState()) {
      LOG.info(logIdentifier + " transitioned from " + oldState + " to "
          + getInternalState() + " due to event "
          + event.getType());
    }
  }

  finally {
    writeLock.unlock();
  }
}