Search in sources :

Example 1 with VertexEventTermination

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

the class TestVertexImpl method testVertexKillPending.

@Test(timeout = 5000)
public void testVertexKillPending() {
    initAllVertices(VertexState.INITED);
    VertexImpl v = vertices.get("vertex2");
    startVertex(v);
    dispatcher.getEventHandler().handle(new VertexEventTermination(v.getVertexId(), VertexTerminationCause.DAG_TERMINATED));
    dispatcher.await();
    Assert.assertEquals(VertexState.KILLED, v.getState());
    dispatcher.getEventHandler().handle(new VertexEventTaskCompleted(TezTaskID.getInstance(v.getVertexId(), 0), TaskState.SUCCEEDED));
    dispatcher.await();
    Assert.assertEquals(VertexState.KILLED, v.getState());
    dispatcher.getEventHandler().handle(new VertexEventTaskCompleted(TezTaskID.getInstance(v.getVertexId(), 1), TaskState.KILLED));
    dispatcher.await();
    Assert.assertEquals(VertexState.KILLED, v.getState());
}
Also used : VertexEventTermination(org.apache.tez.dag.app.dag.event.VertexEventTermination) VertexEventTaskCompleted(org.apache.tez.dag.app.dag.event.VertexEventTaskCompleted) 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 2 with VertexEventTermination

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

the class TestVertexImpl method killVertex.

private void killVertex(VertexImpl v) {
    dispatcher.getEventHandler().handle(new VertexEventTermination(v.getVertexId(), VertexTerminationCause.DAG_TERMINATED));
    dispatcher.await();
    Assert.assertEquals(VertexState.KILLED, v.getState());
    Assert.assertEquals(v.getTerminationCause(), VertexTerminationCause.DAG_TERMINATED);
}
Also used : VertexEventTermination(org.apache.tez.dag.app.dag.event.VertexEventTermination)

Example 3 with VertexEventTermination

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

the class TestVertexImpl method testVertexNoTasksTerminated.

@Test(timeout = 10000)
public void testVertexNoTasksTerminated() {
    TezVertexID vId = null;
    try {
        TezDAGID invalidDagId = TezDAGID.getInstance(dagId.getApplicationId(), 1000);
        vId = TezVertexID.getInstance(invalidDagId, 1);
        VertexPlan vPlan = invalidDagPlan.getVertex(0);
        EventHandler mockEventHandler = mock(EventHandler.class);
        VertexImpl v = new VertexImpl(vId, vPlan, vPlan.getName(), conf, mockEventHandler, taskCommunicatorManagerInterface, clock, thh, true, appContext, vertexLocationHint, null, taskSpecificLaunchCmdOption, updateTracker, new Configuration(false));
        v.setInputVertices(new HashMap());
        vertexIdMap.put(vId, v);
        vertices.put(v.getName(), v);
        v.handle(new VertexEvent(vId, VertexEventType.V_INIT));
        Assert.assertEquals(VertexState.INITED, v.getState());
        v.handle(new VertexEvent(vId, VertexEventType.V_START));
        Assert.assertEquals(VertexState.RUNNING, v.getState());
        v.handle(new VertexEventTermination(vId, VertexTerminationCause.OTHER_VERTEX_FAILURE));
        Assert.assertEquals(VertexState.TERMINATING, v.getState());
        v.handle(new VertexEvent(vId, VertexEventType.V_COMPLETED));
        Assert.assertEquals(VertexState.KILLED, v.getState());
        Assert.assertTrue(1.0f == v.getCompletedTaskProgress());
    } finally {
        if (vId != null) {
            vertexIdMap.remove(vId);
        }
    }
}
Also used : VertexPlan(org.apache.tez.dag.api.records.DAGProtos.VertexPlan) PlanTaskConfiguration(org.apache.tez.dag.api.records.DAGProtos.PlanTaskConfiguration) Configuration(org.apache.hadoop.conf.Configuration) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) HashMap(java.util.HashMap) VertexEventTermination(org.apache.tez.dag.app.dag.event.VertexEventTermination) TezDAGID(org.apache.tez.dag.records.TezDAGID) EventHandler(org.apache.hadoop.yarn.event.EventHandler) HistoryEventHandler(org.apache.tez.dag.history.HistoryEventHandler) VertexEvent(org.apache.tez.dag.app.dag.event.VertexEvent) TezVertexID(org.apache.tez.dag.records.TezVertexID) 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 4 with VertexEventTermination

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

the class TestVertexImpl method testVertexKill.

@Test(timeout = 5000)
public void testVertexKill() {
    initAllVertices(VertexState.INITED);
    VertexImpl v = vertices.get("vertex2");
    startVertex(v);
    dispatcher.getEventHandler().handle(new VertexEventTermination(v.getVertexId(), VertexTerminationCause.DAG_TERMINATED));
    dispatcher.await();
    Assert.assertEquals(VertexState.KILLED, v.getState());
    dispatcher.getEventHandler().handle(new VertexEventTaskCompleted(TezTaskID.getInstance(v.getVertexId(), 0), TaskState.SUCCEEDED));
    dispatcher.await();
    Assert.assertEquals(VertexState.KILLED, v.getState());
    dispatcher.getEventHandler().handle(new VertexEventTaskCompleted(TezTaskID.getInstance(v.getVertexId(), 1), TaskState.SUCCEEDED));
    dispatcher.await();
    Assert.assertEquals(VertexState.KILLED, v.getState());
}
Also used : VertexEventTermination(org.apache.tez.dag.app.dag.event.VertexEventTermination) VertexEventTaskCompleted(org.apache.tez.dag.app.dag.event.VertexEventTaskCompleted) 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 5 with VertexEventTermination

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

the class TestVertexImpl method testTerminatingVertexForTaskComplete.

@Test(timeout = 5000)
public void testTerminatingVertexForTaskComplete() throws Exception {
    setupPreDagCreation();
    dagPlan = createSamplerDAGPlan(false);
    setupPostDagCreation();
    VertexImpl vertex = spy(vertices.get("A"));
    initVertex(vertex);
    startVertex(vertex);
    vertex.handle(new VertexEventTermination(vertex.getVertexId(), VertexTerminationCause.INTERNAL_ERROR));
    dispatcher.await();
    Assert.assertTrue(vertex.inTerminalState());
    for (String diagnostic : vertex.getDiagnostics()) {
        if (diagnostic.contains("Invalid event")) {
            fail("Unexpected Invalid event transition!");
        }
    }
}
Also used : VertexEventTermination(org.apache.tez.dag.app.dag.event.VertexEventTermination) ByteString(com.google.protobuf.ByteString) 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

VertexEventTermination (org.apache.tez.dag.app.dag.event.VertexEventTermination)6 StateChangeNotifierForTest (org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)5 EdgeManagerForTest (org.apache.tez.test.EdgeManagerForTest)5 GraceShuffleVertexManagerForTest (org.apache.tez.test.GraceShuffleVertexManagerForTest)5 VertexManagerPluginForTest (org.apache.tez.test.VertexManagerPluginForTest)5 Test (org.junit.Test)5 ByteString (com.google.protobuf.ByteString)2 VertexEvent (org.apache.tez.dag.app.dag.event.VertexEvent)2 VertexEventTaskCompleted (org.apache.tez.dag.app.dag.event.VertexEventTaskCompleted)2 HashMap (java.util.HashMap)1 Configuration (org.apache.hadoop.conf.Configuration)1 EventHandler (org.apache.hadoop.yarn.event.EventHandler)1 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)1 PlanTaskConfiguration (org.apache.tez.dag.api.records.DAGProtos.PlanTaskConfiguration)1 VertexPlan (org.apache.tez.dag.api.records.DAGProtos.VertexPlan)1 HistoryEventHandler (org.apache.tez.dag.history.HistoryEventHandler)1 TezDAGID (org.apache.tez.dag.records.TezDAGID)1 TezVertexID (org.apache.tez.dag.records.TezVertexID)1