Search in sources :

Example 21 with VertexEvent

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

the class TestVertexImpl method testInitStartRace.

@Test(timeout = 5000)
public void testInitStartRace() throws TezException {
    // Race when a source vertex manages to start before the target vertex has
    // been initialized
    setupPreDagCreation();
    dagPlan = createSamplerDAGPlan(false);
    setupPostDagCreation();
    VertexImpl vA = vertices.get("A");
    VertexImpl vB = vertices.get("B");
    VertexImpl vC = vertices.get("C");
    dispatcher.getEventHandler().handle(new VertexEvent(vA.getVertexId(), VertexEventType.V_INIT));
    dispatcher.getEventHandler().handle(new VertexEvent(vA.getVertexId(), VertexEventType.V_START));
    dispatcher.await();
    Assert.assertEquals(VertexState.RUNNING, vA.getState());
    Assert.assertEquals(VertexState.RUNNING, vB.getState());
    Assert.assertEquals(VertexState.RUNNING, vC.getState());
}
Also used : VertexEvent(org.apache.tez.dag.app.dag.event.VertexEvent) VertexManagerPluginForTest(org.apache.tez.test.VertexManagerPluginForTest) Test(org.junit.Test) GraceShuffleVertexManagerForTest(org.apache.tez.test.GraceShuffleVertexManagerForTest) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest) EdgeManagerForTest(org.apache.tez.test.EdgeManagerForTest)

Example 22 with VertexEvent

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

the class TestDAGImpl method testDAGErrorAbortNonSuccessfulOutputs.

@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testDAGErrorAbortNonSuccessfulOutputs() {
    // vertex success -> vertex output commit. failed dag aborts only non-successful vertices
    mrrDag.getConf().setBoolean(TezConfiguration.TEZ_AM_COMMIT_ALL_OUTPUTS_ON_DAG_SUCCESS, false);
    initDAG(mrrDag);
    dispatcher.await();
    startDAG(mrrDag);
    dispatcher.await();
    for (int i = 0; i < 2; ++i) {
        Vertex v = mrrDag.getVertex("vertex" + (i + 1));
        dispatcher.getEventHandler().handle(new VertexEventTaskCompleted(TezTaskID.getInstance(v.getVertexId(), 0), TaskState.SUCCEEDED));
        dispatcher.await();
        Assert.assertEquals(VertexState.SUCCEEDED, v.getState());
        Assert.assertEquals(i + 1, mrrDag.getSuccessfulVertices());
        for (OutputCommitter c : v.getOutputCommitters().values()) {
            CountingOutputCommitter committer = (CountingOutputCommitter) c;
            Assert.assertEquals(0, committer.abortCounter);
            Assert.assertEquals(1, committer.commitCounter);
            Assert.assertEquals(1, committer.initCounter);
            Assert.assertEquals(1, committer.setupCounter);
        }
    }
    // error on vertex -> dag error
    Vertex errorVertex = mrrDag.getVertex("vertex3");
    dispatcher.getEventHandler().handle(new VertexEvent(errorVertex.getVertexId(), VertexEventType.V_INTERNAL_ERROR));
    dispatcher.await();
    Assert.assertEquals(VertexState.ERROR, errorVertex.getState());
    dispatcher.await();
    Assert.assertEquals(DAGState.ERROR, mrrDag.getState());
    for (Vertex vertex : mrrDag.vertices.values()) {
        for (OutputCommitter c : vertex.getOutputCommitters().values()) {
            CountingOutputCommitter committer = (CountingOutputCommitter) c;
            if (vertex == errorVertex) {
                Assert.assertEquals(1, committer.abortCounter);
                Assert.assertEquals(0, committer.commitCounter);
                Assert.assertEquals(1, committer.initCounter);
                Assert.assertEquals(1, committer.setupCounter);
            } else {
                // abort operation should take no side effort on the successful commit
                Assert.assertEquals(1, committer.abortCounter);
                Assert.assertEquals(1, committer.commitCounter);
                Assert.assertEquals(1, committer.initCounter);
                Assert.assertEquals(1, committer.setupCounter);
            }
        }
    }
}
Also used : Vertex(org.apache.tez.dag.app.dag.Vertex) CountingOutputCommitter(org.apache.tez.dag.app.dag.impl.TestVertexImpl.CountingOutputCommitter) OutputCommitter(org.apache.tez.runtime.api.OutputCommitter) VertexEvent(org.apache.tez.dag.app.dag.event.VertexEvent) VertexEventTaskCompleted(org.apache.tez.dag.app.dag.event.VertexEventTaskCompleted) PlanTaskLocationHint(org.apache.tez.dag.api.records.DAGProtos.PlanTaskLocationHint) CountingOutputCommitter(org.apache.tez.dag.app.dag.impl.TestVertexImpl.CountingOutputCommitter) Test(org.junit.Test) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)

Example 23 with VertexEvent

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

the class TestVertexImpl method testTez2684.

@Test(timeout = 5000)
public void testTez2684() throws IOException, TezException {
    setupPreDagCreation();
    dagPlan = createSamplerDAGPlan2();
    setupPostDagCreation();
    VertexImpl vA = vertices.get("A");
    VertexImpl vB = vertices.get("B");
    VertexImpl vC = vertices.get("C");
    // vA init & start
    dispatcher.getEventHandler().handle(new VertexEvent(vA.getVertexId(), VertexEventType.V_INIT));
    dispatcher.getEventHandler().handle(new VertexEvent(vA.getVertexId(), VertexEventType.V_START));
    dispatcher.await();
    Assert.assertEquals(VertexState.RUNNING, vA.getState());
    Assert.assertEquals(VertexState.NEW, vB.getState());
    Assert.assertEquals(VertexState.NEW, vC.getState());
    // vB init
    dispatcher.getEventHandler().handle(new VertexEvent(vB.getVertexId(), VertexEventType.V_INIT));
    dispatcher.await();
    Assert.assertEquals(VertexState.INITED, vB.getState());
    Assert.assertEquals(VertexState.INITED, vC.getState());
    // Send VertexManagerEvent
    long[] sizes = new long[] { (100_000_000L) };
    Event vmEvent = getVertexManagerEvent(sizes, 1_060_000_000L, vB);
    sendTaskGeneratedEvent(vmEvent, EventProducerConsumerType.INPUT, vC, vB);
    Assert.assertEquals(VertexState.INITED, vC.getState());
    // vB start
    dispatcher.getEventHandler().handle(new VertexEvent(vB.getVertexId(), VertexEventType.V_START));
    dispatcher.await();
    Assert.assertEquals(VertexState.RUNNING, vC.getState());
}
Also used : InputFailedEvent(org.apache.tez.runtime.api.events.InputFailedEvent) VertexManagerEvent(org.apache.tez.runtime.api.events.VertexManagerEvent) CallableEvent(org.apache.tez.dag.app.dag.event.CallableEvent) VertexEventRouteEvent(org.apache.tez.dag.app.dag.event.VertexEventRouteEvent) InputDataInformationEvent(org.apache.tez.runtime.api.events.InputDataInformationEvent) TaskAttemptEvent(org.apache.tez.dag.app.dag.event.TaskAttemptEvent) Event(org.apache.tez.runtime.api.Event) CompositeDataMovementEvent(org.apache.tez.runtime.api.events.CompositeDataMovementEvent) TaskEvent(org.apache.tez.dag.app.dag.event.TaskEvent) InputInitializerEvent(org.apache.tez.runtime.api.events.InputInitializerEvent) DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) AMSchedulerEvent(org.apache.tez.dag.app.rm.AMSchedulerEvent) InputUpdatePayloadEvent(org.apache.tez.runtime.api.events.InputUpdatePayloadEvent) VertexEvent(org.apache.tez.dag.app.dag.event.VertexEvent) InputConfigureVertexTasksEvent(org.apache.tez.runtime.api.events.InputConfigureVertexTasksEvent) DataMovementEvent(org.apache.tez.runtime.api.events.DataMovementEvent) DAGHistoryEvent(org.apache.tez.dag.history.DAGHistoryEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) VertexEvent(org.apache.tez.dag.app.dag.event.VertexEvent) VertexManagerPluginForTest(org.apache.tez.test.VertexManagerPluginForTest) Test(org.junit.Test) GraceShuffleVertexManagerForTest(org.apache.tez.test.GraceShuffleVertexManagerForTest) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest) EdgeManagerForTest(org.apache.tez.test.EdgeManagerForTest)

Example 24 with VertexEvent

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

the class TestVertexImpl method testNonExistVertexManager.

@Test(timeout = 5000)
public void testNonExistVertexManager() throws TezException {
    setupPreDagCreation();
    dagPlan = createDAGPlanWithNonExistVertexManager();
    setupPostDagCreation();
    VertexImpl v1 = vertices.get("vertex1");
    v1.handle(new VertexEvent(v1.getVertexId(), VertexEventType.V_INIT));
    Assert.assertEquals(VertexState.FAILED, v1.getState());
    Assert.assertEquals(VertexTerminationCause.INIT_FAILURE, v1.getTerminationCause());
    Assert.assertTrue(StringUtils.join(v1.getDiagnostics(), "").contains("java.lang.ClassNotFoundException: non-exist-vertexmanager"));
}
Also used : VertexEvent(org.apache.tez.dag.app.dag.event.VertexEvent) VertexManagerPluginForTest(org.apache.tez.test.VertexManagerPluginForTest) Test(org.junit.Test) GraceShuffleVertexManagerForTest(org.apache.tez.test.GraceShuffleVertexManagerForTest) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest) EdgeManagerForTest(org.apache.tez.test.EdgeManagerForTest)

Example 25 with VertexEvent

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

the class TestVertexImpl method testVertexConfigureEventWithReconfigure.

@Test(timeout = 5000)
public void testVertexConfigureEventWithReconfigure() throws Exception {
    useCustomInitializer = true;
    setupPreDagCreation();
    // initialize() will make VM call planned() and started() will make VM call done()
    dagPlan = createDAGPlanWithVMException("TestVMStateUpdate", VMExceptionLocation.NoExceptionDoReconfigure);
    setupPostDagCreation();
    TestUpdateListener listener = new TestUpdateListener();
    updateTracker.registerForVertexUpdates("vertex2", EnumSet.of(org.apache.tez.dag.api.event.VertexState.CONFIGURED), listener);
    VertexImplWithControlledInitializerManager v1 = (VertexImplWithControlledInitializerManager) vertices.get("vertex1");
    VertexImpl v2 = vertices.get("vertex2");
    dispatcher.getEventHandler().handle(new VertexEvent(v1.getVertexId(), VertexEventType.V_INIT));
    // wait to ensure init is completed, so that rootInitManager is not null
    dispatcher.await();
    RootInputInitializerManagerControlled initializerManager1 = v1.getRootInputInitializerManager();
    initializerManager1.completeInputInitialization();
    dispatcher.await();
    Assert.assertEquals(VertexState.INITED, v2.getState());
    // configured event not sent
    Assert.assertEquals(0, listener.events.size());
    startVertex(v1, true);
    dispatcher.await();
    Assert.assertEquals(VertexState.RUNNING, v2.getState());
    // configured event sent after VM
    Assert.assertEquals(1, listener.events.size());
    Assert.assertEquals("vertex2", listener.events.get(0).getVertexName());
    Assert.assertEquals(org.apache.tez.dag.api.event.VertexState.CONFIGURED, listener.events.get(0).getVertexState());
    updateTracker.unregisterForVertexUpdates("vertex2", listener);
}
Also used : VertexEvent(org.apache.tez.dag.app.dag.event.VertexEvent) VertexManagerPluginForTest(org.apache.tez.test.VertexManagerPluginForTest) Test(org.junit.Test) GraceShuffleVertexManagerForTest(org.apache.tez.test.GraceShuffleVertexManagerForTest) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest) EdgeManagerForTest(org.apache.tez.test.EdgeManagerForTest)

Aggregations

VertexEvent (org.apache.tez.dag.app.dag.event.VertexEvent)40 Test (org.junit.Test)34 StateChangeNotifierForTest (org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)33 EdgeManagerForTest (org.apache.tez.test.EdgeManagerForTest)31 GraceShuffleVertexManagerForTest (org.apache.tez.test.GraceShuffleVertexManagerForTest)31 VertexManagerPluginForTest (org.apache.tez.test.VertexManagerPluginForTest)31 ByteString (com.google.protobuf.ByteString)9 PlanTaskLocationHint (org.apache.tez.dag.api.records.DAGProtos.PlanTaskLocationHint)9 TaskLocationHint (org.apache.tez.dag.api.TaskLocationHint)8 VertexLocationHint (org.apache.tez.dag.api.VertexLocationHint)6 VertexEventRouteEvent (org.apache.tez.dag.app.dag.event.VertexEventRouteEvent)5 GroupInputSpec (org.apache.tez.runtime.api.impl.GroupInputSpec)5 Vertex (org.apache.tez.dag.app.dag.Vertex)4 TezTaskAttemptID (org.apache.tez.dag.records.TezTaskAttemptID)4 EventMetaData (org.apache.tez.runtime.api.impl.EventMetaData)4 TezEvent (org.apache.tez.runtime.api.impl.TezEvent)4 HashMap (java.util.HashMap)3 EdgeManagerPluginDescriptor (org.apache.tez.dag.api.EdgeManagerPluginDescriptor)3 EdgeProperty (org.apache.tez.dag.api.EdgeProperty)3 InputSpec (org.apache.tez.runtime.api.impl.InputSpec)3