Search in sources :

Example 6 with VertexEventTaskReschedule

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

the class TestCommit method testDAGCommitVertexRerunWhileCommitting_OnDAGSuccess.

@Test(timeout = 5000)
public void testDAGCommitVertexRerunWhileCommitting_OnDAGSuccess() throws Exception {
    conf.setBoolean(TezConfiguration.TEZ_AM_COMMIT_ALL_OUTPUTS_ON_DAG_SUCCESS, true);
    setupDAG(createDAGPlan(true, true));
    initDAG(dag);
    startDAG(dag);
    VertexImpl v1 = (VertexImpl) dag.getVertex("vertex1");
    VertexImpl v2 = (VertexImpl) dag.getVertex("vertex2");
    VertexImpl v3 = (VertexImpl) dag.getVertex("vertex3");
    // need to make vertices to go to SUCCEEDED
    v1.handle(new VertexEventTaskCompleted(v1.getTask(0).getTaskID(), TaskState.SUCCEEDED));
    v2.handle(new VertexEventTaskCompleted(v2.getTask(0).getTaskID(), TaskState.SUCCEEDED));
    v3.handle(new VertexEventTaskCompleted(v3.getTask(0).getTaskID(), TaskState.SUCCEEDED));
    waitUntil(dag, DAGState.COMMITTING);
    TezTaskID newTaskId = TezTaskID.getInstance(v1.getVertexId(), 1);
    v1.handle(new VertexEventTaskReschedule(newTaskId));
    // dag is in TERMINATING, wait for the complete of its rescheduled tasks
    waitUntil(dag, DAGState.TERMINATING);
    waitUntil(v1, VertexState.TERMINATING);
    // reschedueled task is killed
    v1.handle(new VertexEventTaskCompleted(newTaskId, TaskState.KILLED));
    waitUntil(dag, DAGState.FAILED);
    Assert.assertEquals(VertexState.FAILED, v1.getState());
    Assert.assertEquals(DAGState.FAILED, dag.getState());
    Assert.assertEquals(VertexTerminationCause.VERTEX_RERUN_IN_COMMITTING, v1.getTerminationCause());
    Assert.assertEquals(DAGTerminationCause.VERTEX_RERUN_IN_COMMITTING, dag.getTerminationCause());
    Assert.assertTrue(dag.commitFutures.isEmpty());
    historyEventHandler.verifyVertexGroupCommitStartedEvent("uv12", 0);
    historyEventHandler.verifyVertexGroupCommitFinishedEvent("uv12", 0);
    historyEventHandler.verifyVertexCommitStartedEvent(v1.getVertexId(), 0);
    // VertexFinishedEvent is logged twice due to vertex-rerun
    historyEventHandler.verifyVertexFinishedEvent(v1.getVertexId(), 2);
    historyEventHandler.verifyVertexCommitStartedEvent(v2.getVertexId(), 0);
    historyEventHandler.verifyVertexFinishedEvent(v2.getVertexId(), 1);
    historyEventHandler.verifyVertexCommitStartedEvent(v3.getVertexId(), 0);
    historyEventHandler.verifyVertexFinishedEvent(v3.getVertexId(), 1);
    historyEventHandler.verifyDAGCommitStartedEvent(dag.getID(), 1);
    historyEventHandler.verifyDAGFinishedEvent(dag.getID(), 1);
    CountingOutputCommitter v12OutputCommitter = (CountingOutputCommitter) v1.getOutputCommitter("v12Out");
    CountingOutputCommitter v3OutputCommitter = (CountingOutputCommitter) v3.getOutputCommitter("v3Out");
    Assert.assertEquals(1, v12OutputCommitter.initCounter);
    Assert.assertEquals(1, v12OutputCommitter.setupCounter);
    // commit may not have started, so can't verify commitCounter
    Assert.assertEquals(1, v12OutputCommitter.abortCounter);
    Assert.assertEquals(1, v3OutputCommitter.initCounter);
    Assert.assertEquals(1, v3OutputCommitter.setupCounter);
    // commit may not have started, so can't verify commitCounter
    Assert.assertEquals(1, v3OutputCommitter.abortCounter);
}
Also used : VertexEventTaskReschedule(org.apache.tez.dag.app.dag.event.VertexEventTaskReschedule) VertexEventTaskCompleted(org.apache.tez.dag.app.dag.event.VertexEventTaskCompleted) TezTaskID(org.apache.tez.dag.records.TezTaskID) Test(org.junit.Test)

Example 7 with VertexEventTaskReschedule

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

the class TestCommit method testVertexRescheduleWhileCommitting.

@Test(timeout = 5000)
public void testVertexRescheduleWhileCommitting() throws Exception {
    conf.setBoolean(TezConfiguration.TEZ_AM_COMMIT_ALL_OUTPUTS_ON_DAG_SUCCESS, false);
    setupDAG(createDAGPlan_SingleVertexWith2Committer(true, true));
    initDAG(dag);
    startDAG(dag);
    VertexImpl v1 = (VertexImpl) dag.getVertex("vertex1");
    v1.handle(new VertexEventTaskCompleted(v1.getTask(0).getTaskID(), TaskState.SUCCEEDED));
    Assert.assertEquals(VertexState.COMMITTING, v1.getState());
    // reschedule task
    v1.handle(new VertexEventTaskReschedule(TezTaskID.getInstance(v1.getVertexId(), 2)));
    dispatcher.await();
    Assert.assertEquals(VertexState.FAILED, v1.getState());
    Assert.assertEquals(VertexTerminationCause.VERTEX_RERUN_IN_COMMITTING, v1.getTerminationCause());
    Assert.assertTrue(v1.commitFutures.isEmpty());
    Assert.assertEquals(DAGState.FAILED, dag.getState());
    Assert.assertEquals(DAGTerminationCause.VERTEX_FAILURE, dag.getTerminationCause());
    historyEventHandler.verifyVertexCommitStartedEvent(v1.getVertexId(), 1);
    historyEventHandler.verifyVertexFinishedEvent(v1.getVertexId(), 1);
    CountingOutputCommitter v1OutputCommitter_1 = (CountingOutputCommitter) v1.getOutputCommitter("v1Out_1");
    CountingOutputCommitter v1OutputCommitter_2 = (CountingOutputCommitter) v1.getOutputCommitter("v1Out_2");
    Assert.assertEquals(1, v1OutputCommitter_1.initCounter);
    Assert.assertEquals(1, v1OutputCommitter_1.setupCounter);
    // commit may not have started, so can't verify commitCounter
    Assert.assertEquals(1, v1OutputCommitter_1.abortCounter);
    Assert.assertEquals(1, v1OutputCommitter_2.initCounter);
    Assert.assertEquals(1, v1OutputCommitter_2.setupCounter);
    // commit may not have started, so can't verify commitCounter
    Assert.assertEquals(1, v1OutputCommitter_2.abortCounter);
}
Also used : VertexEventTaskReschedule(org.apache.tez.dag.app.dag.event.VertexEventTaskReschedule) VertexEventTaskCompleted(org.apache.tez.dag.app.dag.event.VertexEventTaskCompleted) Test(org.junit.Test)

Aggregations

VertexEventTaskCompleted (org.apache.tez.dag.app.dag.event.VertexEventTaskCompleted)7 VertexEventTaskReschedule (org.apache.tez.dag.app.dag.event.VertexEventTaskReschedule)7 Test (org.junit.Test)7 StateChangeNotifierForTest (org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)5 TezTaskID (org.apache.tez.dag.records.TezTaskID)5 EdgeManagerForTest (org.apache.tez.test.EdgeManagerForTest)4 GraceShuffleVertexManagerForTest (org.apache.tez.test.GraceShuffleVertexManagerForTest)4 VertexManagerPluginForTest (org.apache.tez.test.VertexManagerPluginForTest)4 ArrayList (java.util.ArrayList)1 RootInputLeafOutputProto (org.apache.tez.dag.api.records.DAGProtos.RootInputLeafOutputProto)1 DAGScheduler (org.apache.tez.dag.app.dag.DAGScheduler)1 Vertex (org.apache.tez.dag.app.dag.Vertex)1 TaskEventTALaunched (org.apache.tez.dag.app.dag.event.TaskEventTALaunched)1 TaskEventTASucceeded (org.apache.tez.dag.app.dag.event.TaskEventTASucceeded)1 TezVertexID (org.apache.tez.dag.records.TezVertexID)1 VertexStatistics (org.apache.tez.runtime.api.VertexStatistics)1