Search in sources :

Example 16 with DAGEvent

use of org.apache.tez.dag.app.dag.event.DAGEvent in project tez by apache.

the class TestDAGImpl method testEdgeManager_RouteDataMovementEventToDestination.

@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testEdgeManager_RouteDataMovementEventToDestination() {
    setupDAGWithCustomEdge(ExceptionLocation.RouteDataMovementEventToDestination);
    dispatcher.getEventHandler().handle(new DAGEvent(dagWithCustomEdge.getID(), DAGEventType.DAG_INIT));
    dispatcher.getEventHandler().handle(new DAGEventStartDag(dagWithCustomEdge.getID(), null));
    dispatcher.await();
    Assert.assertEquals(DAGState.RUNNING, dagWithCustomEdge.getState());
    VertexImpl v1 = (VertexImpl) dagWithCustomEdge.getVertex("vertex1");
    VertexImpl v2 = (VertexImpl) dagWithCustomEdge.getVertex("vertex2");
    dispatcher.await();
    Task t1 = v2.getTask(0);
    TaskAttemptImpl ta1 = (TaskAttemptImpl) t1.getAttempt(TezTaskAttemptID.getInstance(t1.getTaskId(), 0));
    DataMovementEvent daEvent = DataMovementEvent.create(ByteBuffer.wrap(new byte[0]));
    TezEvent tezEvent = new TezEvent(daEvent, new EventMetaData(EventProducerConsumerType.INPUT, "vertex1", "vertex2", ta1.getID()));
    dispatcher.getEventHandler().handle(new VertexEventRouteEvent(v2.getVertexId(), Lists.newArrayList(tezEvent)));
    dispatcher.await();
    v2.getTaskAttemptTezEvents(ta1.getID(), 0, 0, 1000);
    dispatcher.await();
    Assert.assertEquals(VertexState.FAILED, v2.getState());
    Assert.assertEquals(VertexState.KILLED, v1.getState());
    String diag = StringUtils.join(v2.getDiagnostics(), ",");
    Assert.assertTrue(diag.contains(ExceptionLocation.RouteDataMovementEventToDestination.name()));
}
Also used : DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) Task(org.apache.tez.dag.app.dag.Task) DAGEventStartDag(org.apache.tez.dag.app.dag.event.DAGEventStartDag) DataMovementEvent(org.apache.tez.runtime.api.events.DataMovementEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) VertexEventRouteEvent(org.apache.tez.dag.app.dag.event.VertexEventRouteEvent) ByteString(com.google.protobuf.ByteString) EventMetaData(org.apache.tez.runtime.api.impl.EventMetaData) Test(org.junit.Test) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)

Example 17 with DAGEvent

use of org.apache.tez.dag.app.dag.event.DAGEvent in project tez by apache.

the class TaskImpl method internalErrorUncaughtException.

protected void internalErrorUncaughtException(TaskEventType type, Exception e) {
    eventHandler.handle(new DAGEventDiagnosticsUpdate(this.taskId.getVertexID().getDAGId(), "Uncaught exception when handling  event " + type + " on Task " + this.taskId + ", error=" + e.getMessage()));
    eventHandler.handle(new DAGEvent(this.taskId.getVertexID().getDAGId(), DAGEventType.INTERNAL_ERROR));
}
Also used : DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) DAGEventDiagnosticsUpdate(org.apache.tez.dag.app.dag.event.DAGEventDiagnosticsUpdate)

Example 18 with DAGEvent

use of org.apache.tez.dag.app.dag.event.DAGEvent in project tez by apache.

the class TaskImpl method internalError.

protected void internalError(TaskEventType type) {
    LOG.error("Invalid event " + type + " on Task " + this.taskId + " in state:" + getInternalState());
    eventHandler.handle(new DAGEventDiagnosticsUpdate(this.taskId.getVertexID().getDAGId(), "Invalid event " + type + " on Task " + this.taskId));
    eventHandler.handle(new DAGEvent(this.taskId.getVertexID().getDAGId(), DAGEventType.INTERNAL_ERROR));
}
Also used : DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) DAGEventDiagnosticsUpdate(org.apache.tez.dag.app.dag.event.DAGEventDiagnosticsUpdate)

Example 19 with DAGEvent

use of org.apache.tez.dag.app.dag.event.DAGEvent in project tez by apache.

the class VertexImpl method finished.

VertexState finished(VertexState finalState, VertexTerminationCause termCause, String diag) {
    if (finishTime == 0)
        setFinishTime();
    if (termCause != null) {
        trySetTerminationCause(termCause);
    }
    if (rootInputInitializerManager != null) {
        rootInputInitializerManager.shutdown();
        rootInputInitializerManager = null;
    }
    switch(finalState) {
        case ERROR:
            addDiagnostic("Vertex: " + logIdentifier + " error due to:" + terminationCause);
            if (!StringUtils.isEmpty(diag)) {
                addDiagnostic(diag);
            }
            abortVertex(VertexStatus.State.valueOf(finalState.name()));
            eventHandler.handle(new DAGEvent(getDAGId(), DAGEventType.INTERNAL_ERROR));
            try {
                logJobHistoryVertexFailedEvent(finalState);
            } catch (IOException e) {
                LOG.error("Failed to send vertex finished event to recovery", e);
            }
            break;
        case KILLED:
        case FAILED:
            addDiagnostic("Vertex " + logIdentifier + " killed/failed due to:" + terminationCause);
            if (!StringUtils.isEmpty(diag)) {
                addDiagnostic(diag);
            }
            abortVertex(VertexStatus.State.valueOf(finalState.name()));
            eventHandler.handle(new DAGEventVertexCompleted(getVertexId(), finalState, terminationCause));
            try {
                logJobHistoryVertexFailedEvent(finalState);
            } catch (IOException e) {
                LOG.error("Failed to send vertex finished event to recovery", e);
            }
            break;
        case SUCCEEDED:
            try {
                try {
                    logJobHistoryVertexFinishedEvent();
                    eventHandler.handle(new DAGEventVertexCompleted(getVertexId(), finalState));
                } catch (LimitExceededException e) {
                    LOG.error("Counter limits exceeded for vertex: " + getLogIdentifier(), e);
                    finalState = VertexState.FAILED;
                    addDiagnostic("Counters limit exceeded: " + e.getMessage());
                    trySetTerminationCause(VertexTerminationCause.COUNTER_LIMITS_EXCEEDED);
                    logJobHistoryVertexFailedEvent(finalState);
                    eventHandler.handle(new DAGEventVertexCompleted(getVertexId(), finalState));
                }
            } catch (IOException e) {
                LOG.error("Failed to send vertex finished event to recovery", e);
                finalState = VertexState.FAILED;
                trySetTerminationCause(VertexTerminationCause.INTERNAL_ERROR);
                eventHandler.handle(new DAGEventVertexCompleted(getVertexId(), finalState));
            }
            break;
        default:
            throw new TezUncheckedException("Unexpected VertexState: " + finalState);
    }
    return finalState;
}
Also used : DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) TezUncheckedException(org.apache.tez.dag.api.TezUncheckedException) DAGEventVertexCompleted(org.apache.tez.dag.app.dag.event.DAGEventVertexCompleted) LimitExceededException(org.apache.tez.common.counters.LimitExceededException) IOException(java.io.IOException)

Example 20 with DAGEvent

use of org.apache.tez.dag.app.dag.event.DAGEvent in project tez by apache.

the class DAGAppMaster method startDAGExecution.

private void startDAGExecution(DAG dag, final Map<String, LocalResource> additionalAmResources) throws TezException {
    currentDAG = dag;
    // Try localizing the actual resources.
    List<URL> additionalUrlsForClasspath;
    try {
        additionalUrlsForClasspath = dag.getDagUGI().doAs(new PrivilegedExceptionAction<List<URL>>() {

            @Override
            public List<URL> run() throws Exception {
                return processAdditionalResources(currentDAG.getID(), additionalAmResources);
            }
        });
    } catch (IOException e) {
        throw new TezException(e);
    } catch (InterruptedException e) {
        throw new TezException(e);
    }
    dagIDs.add(currentDAG.getID().toString());
    // End of creating the job.
    ((RunningAppContext) context).setDAG(currentDAG);
    // Send out an event to inform components that a new DAG has been submitted.
    // Information about this DAG is available via the context.
    sendEvent(new DAGAppMasterEvent(DAGAppMasterEventType.NEW_DAG_SUBMITTED));
    // create a job event for job initialization
    DAGEvent initDagEvent = new DAGEvent(currentDAG.getID(), DAGEventType.DAG_INIT);
    // Send init to the job (this does NOT trigger job execution)
    // This is a synchronous call, not an event through dispatcher. We want
    // job-init to be done completely here.
    dagEventDispatcher.handle(initDagEvent);
    // All components have started, start the job.
    /**
     * create a job-start event to get this ball rolling
     */
    DAGEvent startDagEvent = new DAGEventStartDag(currentDAG.getID(), additionalUrlsForClasspath);
    /**
     * send the job-start event. this triggers the job execution.
     */
    sendEvent(startDagEvent);
}
Also used : TezException(org.apache.tez.dag.api.TezException) DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) DAGAppMasterEvent(org.apache.tez.dag.app.dag.event.DAGAppMasterEvent) DAGEventStartDag(org.apache.tez.dag.app.dag.event.DAGEventStartDag) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) IOException(java.io.IOException) URL(java.net.URL)

Aggregations

DAGEvent (org.apache.tez.dag.app.dag.event.DAGEvent)20 Test (org.junit.Test)13 StateChangeNotifierForTest (org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)11 DAGEventStartDag (org.apache.tez.dag.app.dag.event.DAGEventStartDag)8 ByteString (com.google.protobuf.ByteString)7 Task (org.apache.tez.dag.app.dag.Task)5 VertexEventRouteEvent (org.apache.tez.dag.app.dag.event.VertexEventRouteEvent)5 EventMetaData (org.apache.tez.runtime.api.impl.EventMetaData)5 TezEvent (org.apache.tez.runtime.api.impl.TezEvent)5 IOException (java.io.IOException)2 DAGEventDiagnosticsUpdate (org.apache.tez.dag.app.dag.event.DAGEventDiagnosticsUpdate)2 VertexEventTaskCompleted (org.apache.tez.dag.app.dag.event.VertexEventTaskCompleted)2 DataMovementEvent (org.apache.tez.runtime.api.events.DataMovementEvent)2 InputReadErrorEvent (org.apache.tez.runtime.api.events.InputReadErrorEvent)2 URL (java.net.URL)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 InvalidStateTransitonException (org.apache.hadoop.yarn.state.InvalidStateTransitonException)1 LimitExceededException (org.apache.tez.common.counters.LimitExceededException)1 TezException (org.apache.tez.dag.api.TezException)1 TezUncheckedException (org.apache.tez.dag.api.TezUncheckedException)1