Search in sources :

Example 41 with TezEvent

use of org.apache.tez.runtime.api.impl.TezEvent 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.getTaskAttemptID()));
    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()));
}
Also used : DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) Task(org.apache.tez.dag.app.dag.Task) DAGEventStartDag(org.apache.tez.dag.app.dag.event.DAGEventStartDag) InputReadErrorEvent(org.apache.tez.runtime.api.events.InputReadErrorEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) VertexEventRouteEvent(org.apache.tez.dag.app.dag.event.VertexEventRouteEvent) ByteString(com.google.protobuf.ByteString) EventMetaData(org.apache.tez.runtime.api.impl.EventMetaData) Test(org.junit.Test) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)

Example 42 with TezEvent

use of org.apache.tez.runtime.api.impl.TezEvent in project tez by apache.

the class TestTaskCommunicatorManager1 method testTaskEventRoutingTaskAttemptOnly.

@Test(timeout = 5000)
public void testTaskEventRoutingTaskAttemptOnly() throws Exception {
    List<TezEvent> events = Arrays.asList(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(1)).handle(arg.capture());
    final List<Event> argAllValues = arg.getAllValues();
    final Event event = argAllValues.get(0);
    // Route to TaskAttempt directly rather than through Vertex
    assertEquals("only event should be route event", TaskAttemptEventType.TA_DONE, event.getType());
}
Also used : TaskAttemptEvent(org.apache.tez.dag.app.dag.event.TaskAttemptEvent) Event(org.apache.hadoop.yarn.event.Event) TaskStatusUpdateEvent(org.apache.tez.runtime.api.events.TaskStatusUpdateEvent) DataMovementEvent(org.apache.tez.runtime.api.events.DataMovementEvent) TaskAttemptCompletedEvent(org.apache.tez.runtime.api.events.TaskAttemptCompletedEvent) InputReadErrorEvent(org.apache.tez.runtime.api.events.InputReadErrorEvent) VertexEventRouteEvent(org.apache.tez.dag.app.dag.event.VertexEventRouteEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) TaskAttemptCompletedEvent(org.apache.tez.runtime.api.events.TaskAttemptCompletedEvent) EventMetaData(org.apache.tez.runtime.api.impl.EventMetaData) Test(org.junit.Test)

Example 43 with TezEvent

use of org.apache.tez.runtime.api.impl.TezEvent 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());
}
Also used : TaskAttemptEvent(org.apache.tez.dag.app.dag.event.TaskAttemptEvent) Event(org.apache.hadoop.yarn.event.Event) TaskStatusUpdateEvent(org.apache.tez.runtime.api.events.TaskStatusUpdateEvent) DataMovementEvent(org.apache.tez.runtime.api.events.DataMovementEvent) TaskAttemptCompletedEvent(org.apache.tez.runtime.api.events.TaskAttemptCompletedEvent) InputReadErrorEvent(org.apache.tez.runtime.api.events.InputReadErrorEvent) VertexEventRouteEvent(org.apache.tez.dag.app.dag.event.VertexEventRouteEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) TaskStatusUpdateEvent(org.apache.tez.runtime.api.events.TaskStatusUpdateEvent) VertexEventRouteEvent(org.apache.tez.dag.app.dag.event.VertexEventRouteEvent) TaskAttemptCompletedEvent(org.apache.tez.runtime.api.events.TaskAttemptCompletedEvent) EventMetaData(org.apache.tez.runtime.api.impl.EventMetaData) Test(org.junit.Test)

Example 44 with TezEvent

use of org.apache.tez.runtime.api.impl.TezEvent 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());
}
Also used : TaskAttemptEventTezEventUpdate(org.apache.tez.dag.app.dag.event.TaskAttemptEventTezEventUpdate) TaskAttemptEvent(org.apache.tez.dag.app.dag.event.TaskAttemptEvent) Event(org.apache.hadoop.yarn.event.Event) TaskStatusUpdateEvent(org.apache.tez.runtime.api.events.TaskStatusUpdateEvent) DataMovementEvent(org.apache.tez.runtime.api.events.DataMovementEvent) TaskAttemptCompletedEvent(org.apache.tez.runtime.api.events.TaskAttemptCompletedEvent) InputReadErrorEvent(org.apache.tez.runtime.api.events.InputReadErrorEvent) VertexEventRouteEvent(org.apache.tez.dag.app.dag.event.VertexEventRouteEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) TaskAttemptEvent(org.apache.tez.dag.app.dag.event.TaskAttemptEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) TaskStatusUpdateEvent(org.apache.tez.runtime.api.events.TaskStatusUpdateEvent) VertexEventRouteEvent(org.apache.tez.dag.app.dag.event.VertexEventRouteEvent) TaskAttemptCompletedEvent(org.apache.tez.runtime.api.events.TaskAttemptCompletedEvent) EventMetaData(org.apache.tez.runtime.api.impl.EventMetaData) Test(org.junit.Test)

Example 45 with TezEvent

use of org.apache.tez.runtime.api.impl.TezEvent in project tez by apache.

the class TezTrapEventHandler method handle.

/**
 * Decide what to do with the events.
 * @param tezTrapEvent event holding the tez events.
 */
@Override
public final void handle(final TezTrapEvent tezTrapEvent) {
    Preconditions.checkArgument(tezTrapEvent.getTezEvents() != null);
    List<TezEvent> tezEvents = new ArrayList<TezEvent>(tezTrapEvent.getTezEvents().size());
    for (TezEvent tezEvent : tezTrapEvent.getTezEvents()) {
        switch(tezEvent.getEventType()) {
            case COMPOSITE_DATA_MOVEMENT_EVENT:
            case DATA_MOVEMENT_EVENT:
                String errorMsg = "Some events won't be sent to the AM because all" + " the events should have been sent at this point. Most likely" + " this would result in a bug. " + " event:" + tezEvent.toString();
                Throwable throwable = new Throwable(errorMsg);
                LOG.error(errorMsg, throwable);
                break;
            default:
                LOG.info("Event of type " + tezEvent.getEventType() + " will be sent" + " to the AM after the task was closed ");
                tezEvents.add(tezEvent);
        }
    }
    tezUmbilical.addEvents(tezEvents);
}
Also used : ArrayList(java.util.ArrayList) TezEvent(org.apache.tez.runtime.api.impl.TezEvent)

Aggregations

TezEvent (org.apache.tez.runtime.api.impl.TezEvent)86 Test (org.junit.Test)56 EventMetaData (org.apache.tez.runtime.api.impl.EventMetaData)51 TezTaskAttemptID (org.apache.tez.dag.records.TezTaskAttemptID)37 TezTaskID (org.apache.tez.dag.records.TezTaskID)34 StateChangeNotifierForTest (org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)31 VertexEventRouteEvent (org.apache.tez.dag.app.dag.event.VertexEventRouteEvent)31 EdgeManagerForTest (org.apache.tez.test.EdgeManagerForTest)19 ArrayList (java.util.ArrayList)18 DataMovementEvent (org.apache.tez.runtime.api.events.DataMovementEvent)17 GraceShuffleVertexManagerForTest (org.apache.tez.test.GraceShuffleVertexManagerForTest)16 VertexManagerPluginForTest (org.apache.tez.test.VertexManagerPluginForTest)16 TezVertexID (org.apache.tez.dag.records.TezVertexID)15 InputReadErrorEvent (org.apache.tez.runtime.api.events.InputReadErrorEvent)15 VertexInitializedEvent (org.apache.tez.dag.history.events.VertexInitializedEvent)14 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)12 VertexConfigurationDoneEvent (org.apache.tez.dag.history.events.VertexConfigurationDoneEvent)12 TaskLocationHint (org.apache.tez.dag.api.TaskLocationHint)11 TaskRecoveryData (org.apache.tez.dag.app.RecoveryParser.TaskRecoveryData)11 VertexRecoveryData (org.apache.tez.dag.app.RecoveryParser.VertexRecoveryData)11