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());
}
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);
}
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);
}
}
}
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());
}
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!");
}
}
}
Aggregations