Search in sources :

Example 1 with DAGEventStartDag

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

the class TestCommit method startDAG.

@SuppressWarnings("unchecked")
private void startDAG(DAGImpl impl) {
    dispatcher.getEventHandler().handle(new DAGEventStartDag(impl.getID(), null));
    dispatcher.await();
    Assert.assertEquals(DAGState.RUNNING, impl.getState());
}
Also used : DAGEventStartDag(org.apache.tez.dag.app.dag.event.DAGEventStartDag)

Example 2 with DAGEventStartDag

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

the class TestDAGImpl method startDAG.

@SuppressWarnings("unchecked")
private void startDAG(DAGImpl impl) {
    dispatcher.getEventHandler().handle(new DAGEventStartDag(impl.getID(), null));
    dispatcher.await();
    Assert.assertEquals(DAGState.RUNNING, impl.getState());
}
Also used : DAGEventStartDag(org.apache.tez.dag.app.dag.event.DAGEventStartDag)

Example 3 with DAGEventStartDag

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

the class TestDAGImpl method testEdgeManager_RouteInputSourceTaskFailedEventToDestinationLegacyRouting.

@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testEdgeManager_RouteInputSourceTaskFailedEventToDestinationLegacyRouting() {
    // Remove after legacy routing is removed
    setupDAGWithCustomEdge(ExceptionLocation.RouteInputSourceTaskFailedEventToDestination, true);
    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));
    InputFailedEvent ifEvent = InputFailedEvent.create(0, 1);
    TezEvent tezEvent = new TezEvent(ifEvent, 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.RouteInputSourceTaskFailedEventToDestination.name()));
}
Also used : DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) InputFailedEvent(org.apache.tez.runtime.api.events.InputFailedEvent) Task(org.apache.tez.dag.app.dag.Task) DAGEventStartDag(org.apache.tez.dag.app.dag.event.DAGEventStartDag) 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 4 with DAGEventStartDag

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

the class TestDAGImpl method runTestGetDAGStatusReturnOnDagFinished.

@SuppressWarnings("unchecked")
public void runTestGetDAGStatusReturnOnDagFinished(DAGStatusBuilder.State testState) throws TezException, InterruptedException {
    initDAG(dag);
    startDAG(dag);
    dispatcher.await();
    // All vertices except one succeed
    for (int i = 0; i < dag.getVertices().size() - 1; ++i) {
        dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 0), VertexState.SUCCEEDED));
    }
    dispatcher.await();
    Assert.assertEquals(DAGState.RUNNING, dag.getState());
    Assert.assertEquals(5, dag.getSuccessfulVertices());
    ReentrantLock lock = new ReentrantLock();
    Condition startCondition = lock.newCondition();
    Condition endCondition = lock.newCondition();
    DagStatusCheckRunnable statusCheckRunnable = new DagStatusCheckRunnable(lock, startCondition, endCondition);
    Thread t1 = new Thread(statusCheckRunnable);
    t1.start();
    lock.lock();
    try {
        while (!statusCheckRunnable.started.get()) {
            startCondition.await();
        }
    } finally {
        lock.unlock();
    }
    // Sleep for 2 seconds. Then mark the last vertex is successful.
    Thread.sleep(2000l);
    if (testState == DAGStatus.State.SUCCEEDED) {
        dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 5), VertexState.SUCCEEDED));
    } else if (testState == DAGStatus.State.FAILED) {
        dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 5), VertexState.FAILED));
    } else if (testState == DAGStatus.State.KILLED) {
        dispatcher.getEventHandler().handle(new DAGEventTerminateDag(dagId, DAGTerminationCause.DAG_KILL, null));
    } else if (testState == DAGStatus.State.ERROR) {
        dispatcher.getEventHandler().handle(new DAGEventStartDag(dagId, new LinkedList<URL>()));
    } else {
        throw new UnsupportedOperationException("Unsupported state for test: " + testState);
    }
    dispatcher.await();
    // Wait for the dag status to return
    lock.lock();
    try {
        while (!statusCheckRunnable.ended.get()) {
            endCondition.await();
        }
    } finally {
        lock.unlock();
    }
    long diff = statusCheckRunnable.dagStatusEndTime - statusCheckRunnable.dagStatusStartTime;
    Assert.assertNotNull(statusCheckRunnable.dagStatus);
    Assert.assertTrue(diff > 1000 && diff < 3500);
    Assert.assertEquals(testState, statusCheckRunnable.dagStatus.getState());
    t1.join();
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) Condition(java.util.concurrent.locks.Condition) DAGEventStartDag(org.apache.tez.dag.app.dag.event.DAGEventStartDag) DAGEventVertexCompleted(org.apache.tez.dag.app.dag.event.DAGEventVertexCompleted) DAGEventTerminateDag(org.apache.tez.dag.app.dag.event.DAGEventTerminateDag) PlanTaskLocationHint(org.apache.tez.dag.api.records.DAGProtos.PlanTaskLocationHint) URL(java.net.URL)

Example 5 with DAGEventStartDag

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

the class TestDAGImpl method testEdgeManager_GetNumSourceTaskPhysicalOutputs.

@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testEdgeManager_GetNumSourceTaskPhysicalOutputs() {
    setupDAGWithCustomEdge(ExceptionLocation.GetNumSourceTaskPhysicalOutputs);
    dispatcher.getEventHandler().handle(new DAGEvent(dagWithCustomEdge.getID(), DAGEventType.DAG_INIT));
    dispatcher.getEventHandler().handle(new DAGEventStartDag(dagWithCustomEdge.getID(), null));
    dispatcher.await();
    // After TEZ-1711, all task attempts of v1 fail which result in task fail, and finally
    // dag failed.
    Assert.assertEquals(DAGState.FAILED, dagWithCustomEdge.getState());
    VertexImpl v1 = (VertexImpl) dagWithCustomEdge.getVertex("vertex1");
    String diag = StringUtils.join(v1.getDiagnostics(), ",");
    Assert.assertTrue(diag.contains(ExceptionLocation.GetNumSourceTaskPhysicalOutputs.name()));
}
Also used : DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) DAGEventStartDag(org.apache.tez.dag.app.dag.event.DAGEventStartDag) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)

Aggregations

DAGEventStartDag (org.apache.tez.dag.app.dag.event.DAGEventStartDag)12 StateChangeNotifierForTest (org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)8 DAGEvent (org.apache.tez.dag.app.dag.event.DAGEvent)8 Test (org.junit.Test)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 URL (java.net.URL)2 DataMovementEvent (org.apache.tez.runtime.api.events.DataMovementEvent)2 InputReadErrorEvent (org.apache.tez.runtime.api.events.InputReadErrorEvent)2 IOException (java.io.IOException)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 Condition (java.util.concurrent.locks.Condition)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 TezException (org.apache.tez.dag.api.TezException)1 PlanTaskLocationHint (org.apache.tez.dag.api.records.DAGProtos.PlanTaskLocationHint)1 DAGAppMasterEvent (org.apache.tez.dag.app.dag.event.DAGAppMasterEvent)1 DAGEventTerminateDag (org.apache.tez.dag.app.dag.event.DAGEventTerminateDag)1