use of org.apache.tez.dag.app.dag.event.DAGEventVertexCompleted in project tez by apache.
the class TestDAGImpl method testVertexSuccessfulCompletionUpdates.
@SuppressWarnings("unchecked")
@Test(timeout = 5000)
// Duplicate completions from a vertex would be a bug. Invalid test.
@Ignore
public void testVertexSuccessfulCompletionUpdates() {
initDAG(dag);
startDAG(dag);
dispatcher.await();
for (int i = 0; i < 6; ++i) {
dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 0), VertexState.SUCCEEDED));
}
dispatcher.await();
Assert.assertEquals(DAGState.RUNNING, dag.getState());
Assert.assertEquals(1, dag.getSuccessfulVertices());
dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 1), VertexState.SUCCEEDED));
dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 2), VertexState.SUCCEEDED));
dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 3), VertexState.SUCCEEDED));
dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 4), VertexState.SUCCEEDED));
dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 5), VertexState.SUCCEEDED));
dispatcher.await();
Assert.assertEquals(DAGState.SUCCEEDED, dag.getState());
Assert.assertEquals(6, dag.getSuccessfulVertices());
}
use of org.apache.tez.dag.app.dag.event.DAGEventVertexCompleted in project tez by apache.
the class TestDAGImpl method _testDAGKillPending.
// Vertex KILLED after a DAG_KILLED is issued. Termination reason should be DAG_KILLED
@SuppressWarnings("unchecked")
private void _testDAGKillPending(DAGTerminationCause terminationCause) {
initDAG(dag);
startDAG(dag);
dispatcher.await();
dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 0), VertexState.SUCCEEDED));
dispatcher.await();
Assert.assertEquals(DAGState.RUNNING, dag.getState());
dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 1), VertexState.SUCCEEDED));
for (int i = 2; i < 5; ++i) {
dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, i), VertexState.SUCCEEDED));
}
dispatcher.await();
dispatcher.getEventHandler().handle(new DAGEventTerminateDag(dagId, terminationCause, null));
dispatcher.await();
Assert.assertEquals(terminationCause.getFinishedState(), dag.getState());
dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 5), VertexState.KILLED));
dispatcher.await();
Assert.assertEquals(terminationCause.getFinishedState(), dag.getState());
Assert.assertEquals(5, dag.getSuccessfulVertices());
Assert.assertEquals(dag.getVertex(TezVertexID.getInstance(dagId, 5)).getTerminationCause(), VertexTerminationCause.DAG_TERMINATED);
Assert.assertEquals(1, dagFinishEventHandler.dagFinishEvents);
}
use of org.apache.tez.dag.app.dag.event.DAGEventVertexCompleted 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();
}
use of org.apache.tez.dag.app.dag.event.DAGEventVertexCompleted in project tez by apache.
the class TestDAGImpl method _testDAGKillVertexSuccessAfterTerminated.
// Vertices succeed after a DAG kill has been processed. Should be ignored.
@SuppressWarnings("unchecked")
private void _testDAGKillVertexSuccessAfterTerminated(DAGTerminationCause terminationCause) {
initDAG(dag);
startDAG(dag);
dispatcher.await();
dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 0), VertexState.SUCCEEDED));
dispatcher.await();
Assert.assertEquals(DAGState.RUNNING, dag.getState());
dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 1), VertexState.SUCCEEDED));
dispatcher.getEventHandler().handle(new DAGEventTerminateDag(dagId, terminationCause, null));
dispatcher.await();
Assert.assertEquals(terminationCause.getFinishedState(), dag.getState());
// Vertex SUCCESS gets processed after the DAG has reached the KILLED state. Should be ignored.
for (int i = 2; i < 6; ++i) {
dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, i), VertexState.SUCCEEDED));
}
dispatcher.await();
int killedCount = 0;
for (Map.Entry<TezVertexID, Vertex> vEntry : dag.getVertices().entrySet()) {
if (vEntry.getValue().getState() == VertexState.KILLED) {
killedCount++;
}
}
Assert.assertEquals(4, killedCount);
Assert.assertEquals(terminationCause, dag.getTerminationCause());
Assert.assertEquals(2, dag.getSuccessfulVertices());
for (Vertex v : dag.getVertices().values()) {
Assert.assertEquals(VertexTerminationCause.DAG_TERMINATED, v.getTerminationCause());
}
Assert.assertEquals(1, dagFinishEventHandler.dagFinishEvents);
}
use of org.apache.tez.dag.app.dag.event.DAGEventVertexCompleted in project tez by apache.
the class TestDAGImpl method testVertexFailureHandling.
@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testVertexFailureHandling() {
initDAG(dag);
startDAG(dag);
dispatcher.await();
dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 0), VertexState.SUCCEEDED));
dispatcher.await();
Assert.assertEquals(DAGState.RUNNING, dag.getState());
dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 1), VertexState.SUCCEEDED));
dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 2), VertexState.FAILED));
dispatcher.await();
Assert.assertEquals(DAGState.FAILED, dag.getState());
Assert.assertEquals(2, dag.getSuccessfulVertices());
// Expect running vertices to be killed on first failure
for (int i = 3; i < 6; ++i) {
TezVertexID vId = TezVertexID.getInstance(dagId, i);
Vertex v = dag.getVertex(vId);
Assert.assertEquals(VertexState.KILLED, v.getState());
}
}
Aggregations