use of org.apache.tez.dag.app.dag.event.DAGEventStartDag in project tez by apache.
the class TestCommit method startDAG.
@SuppressWarnings("unchecked")
private void startDAG(DAGImpl impl) {
dispatcher.getEventHandler().handle(new DAGEventStartDag(impl.getID(), null));
dispatcher.await();
Assert.assertEquals(DAGState.RUNNING, impl.getState());
}
use of org.apache.tez.dag.app.dag.event.DAGEventStartDag in project tez by apache.
the class TestDAGImpl method startDAG.
@SuppressWarnings("unchecked")
private void startDAG(DAGImpl impl) {
dispatcher.getEventHandler().handle(new DAGEventStartDag(impl.getID(), null));
dispatcher.await();
Assert.assertEquals(DAGState.RUNNING, impl.getState());
}
use of org.apache.tez.dag.app.dag.event.DAGEventStartDag in project tez by apache.
the class TestDAGImpl method testEdgeManager_RouteInputSourceTaskFailedEventToDestinationLegacyRouting.
@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testEdgeManager_RouteInputSourceTaskFailedEventToDestinationLegacyRouting() {
// Remove after legacy routing is removed
setupDAGWithCustomEdge(ExceptionLocation.RouteInputSourceTaskFailedEventToDestination, true);
dispatcher.getEventHandler().handle(new DAGEvent(dagWithCustomEdge.getID(), DAGEventType.DAG_INIT));
dispatcher.getEventHandler().handle(new DAGEventStartDag(dagWithCustomEdge.getID(), null));
dispatcher.await();
Assert.assertEquals(DAGState.RUNNING, dagWithCustomEdge.getState());
VertexImpl v1 = (VertexImpl) dagWithCustomEdge.getVertex("vertex1");
VertexImpl v2 = (VertexImpl) dagWithCustomEdge.getVertex("vertex2");
dispatcher.await();
Task t1 = v2.getTask(0);
TaskAttemptImpl ta1 = (TaskAttemptImpl) t1.getAttempt(TezTaskAttemptID.getInstance(t1.getTaskId(), 0));
InputFailedEvent ifEvent = InputFailedEvent.create(0, 1);
TezEvent tezEvent = new TezEvent(ifEvent, new EventMetaData(EventProducerConsumerType.INPUT, "vertex1", "vertex2", ta1.getID()));
dispatcher.getEventHandler().handle(new VertexEventRouteEvent(v2.getVertexId(), Lists.newArrayList(tezEvent)));
dispatcher.await();
v2.getTaskAttemptTezEvents(ta1.getID(), 0, 0, 1000);
dispatcher.await();
Assert.assertEquals(VertexState.FAILED, v2.getState());
Assert.assertEquals(VertexState.KILLED, v1.getState());
String diag = StringUtils.join(v2.getDiagnostics(), ",");
Assert.assertTrue(diag.contains(ExceptionLocation.RouteInputSourceTaskFailedEventToDestination.name()));
}
use of org.apache.tez.dag.app.dag.event.DAGEventStartDag 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.DAGEventStartDag in project tez by apache.
the class TestDAGImpl method testEdgeManager_GetNumSourceTaskPhysicalOutputs.
@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testEdgeManager_GetNumSourceTaskPhysicalOutputs() {
setupDAGWithCustomEdge(ExceptionLocation.GetNumSourceTaskPhysicalOutputs);
dispatcher.getEventHandler().handle(new DAGEvent(dagWithCustomEdge.getID(), DAGEventType.DAG_INIT));
dispatcher.getEventHandler().handle(new DAGEventStartDag(dagWithCustomEdge.getID(), null));
dispatcher.await();
// After TEZ-1711, all task attempts of v1 fail which result in task fail, and finally
// dag failed.
Assert.assertEquals(DAGState.FAILED, dagWithCustomEdge.getState());
VertexImpl v1 = (VertexImpl) dagWithCustomEdge.getVertex("vertex1");
String diag = StringUtils.join(v1.getDiagnostics(), ",");
Assert.assertTrue(diag.contains(ExceptionLocation.GetNumSourceTaskPhysicalOutputs.name()));
}
Aggregations