use of org.apache.tez.dag.app.dag.event.VertexEventRouteEvent in project tez by apache.
the class TestTaskCommunicatorManager1 method testTaskEventRouting.
@Test(timeout = 5000)
public void testTaskEventRouting() throws Exception {
List<TezEvent> events = Arrays.asList(new TezEvent(new TaskStatusUpdateEvent(null, 0.0f, null, false), new EventMetaData(EventProducerConsumerType.PROCESSOR, "v1", "v2", taskAttemptID)), new TezEvent(DataMovementEvent.create(0, ByteBuffer.wrap(new byte[0])), new EventMetaData(EventProducerConsumerType.OUTPUT, "v1", "v2", taskAttemptID)), new TezEvent(new TaskAttemptCompletedEvent(), new EventMetaData(EventProducerConsumerType.SYSTEM, "v1", "v2", taskAttemptID)));
generateHeartbeat(events, 0, 1, 0, new ArrayList<TezEvent>());
ArgumentCaptor<Event> arg = ArgumentCaptor.forClass(Event.class);
verify(eventHandler, times(4)).handle(arg.capture());
final List<Event> argAllValues = arg.getAllValues();
final Event statusUpdateEvent = argAllValues.get(0);
assertEquals("First event should be status update", TaskAttemptEventType.TA_STATUS_UPDATE, statusUpdateEvent.getType());
assertEquals(false, ((TaskAttemptEventStatusUpdate) statusUpdateEvent).getReadErrorReported());
final TaskAttemptEventTezEventUpdate taEvent = (TaskAttemptEventTezEventUpdate) argAllValues.get(1);
assertEquals(1, taEvent.getTezEvents().size());
assertEquals(EventType.DATA_MOVEMENT_EVENT, taEvent.getTezEvents().get(0).getEventType());
final TaskAttemptEvent taCompleteEvent = (TaskAttemptEvent) argAllValues.get(2);
assertEquals(TaskAttemptEventType.TA_DONE, taCompleteEvent.getType());
final VertexEventRouteEvent vertexRouteEvent = (VertexEventRouteEvent) argAllValues.get(3);
assertEquals(1, vertexRouteEvent.getEvents().size());
assertEquals(EventType.DATA_MOVEMENT_EVENT, vertexRouteEvent.getEvents().get(0).getEventType());
}
use of org.apache.tez.dag.app.dag.event.VertexEventRouteEvent in project tez by apache.
the class TestTaskCommunicatorManager1 method testTaskEventRoutingWithReadError.
@Test(timeout = 5000)
public void testTaskEventRoutingWithReadError() throws Exception {
List<TezEvent> events = Arrays.asList(new TezEvent(new TaskStatusUpdateEvent(null, 0.0f, null, false), null), new TezEvent(InputReadErrorEvent.create("", 0, 0), new EventMetaData(EventProducerConsumerType.INPUT, "v2", "v1", taskAttemptID)), new TezEvent(new TaskAttemptCompletedEvent(), new EventMetaData(EventProducerConsumerType.SYSTEM, "v1", "v2", taskAttemptID)));
generateHeartbeat(events, 0, 1, 0, new ArrayList<TezEvent>());
ArgumentCaptor<Event> arg = ArgumentCaptor.forClass(Event.class);
verify(eventHandler, times(3)).handle(arg.capture());
final List<Event> argAllValues = arg.getAllValues();
final Event statusUpdateEvent = argAllValues.get(0);
assertEquals("First event should be status update", TaskAttemptEventType.TA_STATUS_UPDATE, statusUpdateEvent.getType());
assertEquals(true, ((TaskAttemptEventStatusUpdate) statusUpdateEvent).getReadErrorReported());
final Event taFinishedEvent = argAllValues.get(1);
assertEquals("Second event should be TA_DONE", TaskAttemptEventType.TA_DONE, taFinishedEvent.getType());
final Event vertexEvent = argAllValues.get(2);
final VertexEventRouteEvent vertexRouteEvent = (VertexEventRouteEvent) vertexEvent;
assertEquals("Third event should be routed to vertex", VertexEventType.V_ROUTE_EVENT, vertexEvent.getType());
assertEquals(EventType.INPUT_READ_ERROR_EVENT, vertexRouteEvent.getEvents().get(0).getEventType());
}
use of org.apache.tez.dag.app.dag.event.VertexEventRouteEvent in project tez by apache.
the class TestDAGImpl method testEdgeManager_GetNumDestinationConsumerTasks.
@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testEdgeManager_GetNumDestinationConsumerTasks() {
setupDAGWithCustomEdge(ExceptionLocation.GetNumDestinationConsumerTasks);
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));
InputReadErrorEvent ireEvent = InputReadErrorEvent.create("", 0, 0);
TezEvent tezEvent = new TezEvent(ireEvent, new EventMetaData(EventProducerConsumerType.INPUT, "vertex2", "vertex1", ta1.getID()));
dispatcher.getEventHandler().handle(new VertexEventRouteEvent(v2.getVertexId(), Lists.newArrayList(tezEvent)));
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.GetNumDestinationConsumerTasks.name()));
}
use of org.apache.tez.dag.app.dag.event.VertexEventRouteEvent in project tez by apache.
the class TestDAGImpl method testEdgeManager_RouteDataMovementEventToDestinationWithLegacyRouting.
@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testEdgeManager_RouteDataMovementEventToDestinationWithLegacyRouting() {
// Remove after legacy routing is removed
setupDAGWithCustomEdge(ExceptionLocation.RouteDataMovementEventToDestination, 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));
DataMovementEvent daEvent = DataMovementEvent.create(ByteBuffer.wrap(new byte[0]));
TezEvent tezEvent = new TezEvent(daEvent, new EventMetaData(EventProducerConsumerType.INPUT, "vertex1", "vertex2", ta1.getID()));
dispatcher.getEventHandler().handle(new VertexEventRouteEvent(v2.getVertexId(), Lists.newArrayList(tezEvent)));
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.RouteDataMovementEventToDestination.name()));
}
use of org.apache.tez.dag.app.dag.event.VertexEventRouteEvent in project tez by apache.
the class TestDAGImpl method testEdgeManager_RouteInputErrorEventToSource.
@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testEdgeManager_RouteInputErrorEventToSource() {
setupDAGWithCustomEdge(ExceptionLocation.RouteInputErrorEventToSource);
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));
InputReadErrorEvent ireEvent = InputReadErrorEvent.create("", 0, 0);
TezEvent tezEvent = new TezEvent(ireEvent, new EventMetaData(EventProducerConsumerType.INPUT, "vertex2", "vertex1", ta1.getID()));
dispatcher.getEventHandler().handle(new VertexEventRouteEvent(v2.getVertexId(), Lists.newArrayList(tezEvent)));
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.RouteInputErrorEventToSource.name()));
}
Aggregations