Search in sources :

Example 1 with VertexState

use of org.apache.tez.dag.app.dag.VertexState in project tez by apache.

the class VertexImpl method handle.

@Override
public /**
 * The only entry point to change the Vertex.
 */
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));
        } catch (RuntimeException e) {
            String message = "Uncaught Exception when handling event " + event.getType() + " on vertex " + this.vertexName + " with vertexId " + this.vertexId + " at current state " + oldState;
            LOG.error(message, e);
            addDiagnostic(message);
            if (!internalErrorTriggered.getAndSet(true)) {
                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();
    }
}
Also used : InvalidStateTransitonException(org.apache.hadoop.yarn.state.InvalidStateTransitonException) VertexEvent(org.apache.tez.dag.app.dag.event.VertexEvent) VertexState(org.apache.tez.dag.app.dag.VertexState)

Example 2 with VertexState

use of org.apache.tez.dag.app.dag.VertexState in project tez by apache.

the class TestVertexStatusBuilder method testVertexStateConversion.

@Test(timeout = 5000)
public void testVertexStateConversion() {
    for (VertexState state : VertexState.values()) {
        DAGProtos.VertexStatusStateProto stateProto = VertexStatusBuilder.getProtoState(state);
        VertexStatus.State clientState = VertexStatus.getState(stateProto);
        Assert.assertEquals(state.name(), clientState.name());
    }
}
Also used : State(org.apache.tez.dag.api.client.VertexStatus.State) DAGProtos(org.apache.tez.dag.api.records.DAGProtos) VertexState(org.apache.tez.dag.app.dag.VertexState) Test(org.junit.Test)

Aggregations

VertexState (org.apache.tez.dag.app.dag.VertexState)2 InvalidStateTransitonException (org.apache.hadoop.yarn.state.InvalidStateTransitonException)1 State (org.apache.tez.dag.api.client.VertexStatus.State)1 DAGProtos (org.apache.tez.dag.api.records.DAGProtos)1 VertexEvent (org.apache.tez.dag.app.dag.event.VertexEvent)1 Test (org.junit.Test)1