Search in sources :

Example 1 with TaskAttemptCompletedEvent

use of org.apache.tez.runtime.api.events.TaskAttemptCompletedEvent 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 2 with TaskAttemptCompletedEvent

use of org.apache.tez.runtime.api.events.TaskAttemptCompletedEvent 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 3 with TaskAttemptCompletedEvent

use of org.apache.tez.runtime.api.events.TaskAttemptCompletedEvent 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 4 with TaskAttemptCompletedEvent

use of org.apache.tez.runtime.api.events.TaskAttemptCompletedEvent in project tez by apache.

the class TezEvent method deserializeEvent.

private void deserializeEvent(DataInput in) throws IOException {
    if (!in.readBoolean()) {
        event = null;
        return;
    }
    eventType = EventType.values()[in.readInt()];
    eventReceivedTime = in.readLong();
    if (eventType.equals(EventType.TASK_STATUS_UPDATE_EVENT)) {
        // TODO NEWTEZ convert to PB
        event = new TaskStatusUpdateEvent();
        ((TaskStatusUpdateEvent) event).readFields(in);
    } else {
        int eventBytesLen = in.readInt();
        byte[] eventBytes;
        CodedInputStream input;
        int startOffset = 0;
        if (in instanceof DataInputBuffer) {
            eventBytes = ((DataInputBuffer) in).getData();
            startOffset = ((DataInputBuffer) in).getPosition();
        } else {
            eventBytes = new byte[eventBytesLen];
            in.readFully(eventBytes);
        }
        input = CodedInputStream.newInstance(eventBytes, startOffset, eventBytesLen);
        switch(eventType) {
            case CUSTOM_PROCESSOR_EVENT:
                CustomProcessorEventProto cpProto = CustomProcessorEventProto.parseFrom(input);
                event = ProtoConverters.convertCustomProcessorEventFromProto(cpProto);
                break;
            case DATA_MOVEMENT_EVENT:
                DataMovementEventProto dmProto = DataMovementEventProto.parseFrom(input);
                event = ProtoConverters.convertDataMovementEventFromProto(dmProto);
                break;
            case COMPOSITE_ROUTED_DATA_MOVEMENT_EVENT:
                CompositeRoutedDataMovementEventProto edmProto = CompositeRoutedDataMovementEventProto.parseFrom(eventBytes);
                event = ProtoConverters.convertCompositeRoutedDataMovementEventFromProto(edmProto);
                break;
            case COMPOSITE_DATA_MOVEMENT_EVENT:
                CompositeEventProto cProto = CompositeEventProto.parseFrom(input);
                event = ProtoConverters.convertCompositeDataMovementEventFromProto(cProto);
                break;
            case VERTEX_MANAGER_EVENT:
                VertexManagerEventProto vmProto = VertexManagerEventProto.parseFrom(input);
                event = ProtoConverters.convertVertexManagerEventFromProto(vmProto);
                break;
            case INPUT_READ_ERROR_EVENT:
                InputReadErrorEventProto ideProto = InputReadErrorEventProto.parseFrom(input);
                event = InputReadErrorEvent.create(ideProto.getDiagnostics(), ideProto.getIndex(), ideProto.getVersion());
                break;
            case TASK_ATTEMPT_FAILED_EVENT:
                TaskAttemptFailedEventProto tfProto = TaskAttemptFailedEventProto.parseFrom(input);
                event = new TaskAttemptFailedEvent(tfProto.getDiagnostics(), TezConverterUtils.failureTypeFromProto(tfProto.getTaskFailureType()));
                break;
            case TASK_ATTEMPT_KILLED_EVENT:
                TaskAttemptKilledEventProto tkProto = TaskAttemptKilledEventProto.parseFrom(input);
                event = new TaskAttemptKilledEvent(tkProto.getDiagnostics());
                break;
            case TASK_ATTEMPT_COMPLETED_EVENT:
                event = new TaskAttemptCompletedEvent();
                break;
            case INPUT_FAILED_EVENT:
                InputFailedEventProto ifProto = InputFailedEventProto.parseFrom(input);
                event = InputFailedEvent.create(ifProto.getTargetIndex(), ifProto.getVersion());
                break;
            case ROOT_INPUT_DATA_INFORMATION_EVENT:
                RootInputDataInformationEventProto difProto = RootInputDataInformationEventProto.parseFrom(input);
                event = ProtoConverters.convertRootInputDataInformationEventFromProto(difProto);
                break;
            case ROOT_INPUT_INITIALIZER_EVENT:
                EventProtos.RootInputInitializerEventProto riiProto = EventProtos.RootInputInitializerEventProto.parseFrom(input);
                event = ProtoConverters.convertRootInputInitializerEventFromProto(riiProto);
                break;
            default:
                // RootInputUpdatePayload event not wrapped in a TezEvent.
                throw new TezUncheckedException("Unexpected TezEvent" + ", type=" + eventType);
        }
        if (in instanceof DataInputBuffer) {
            // Skip so that position is updated
            int skipped = in.skipBytes(eventBytesLen);
            if (skipped != eventBytesLen) {
                throw new TezUncheckedException("Expected to skip " + eventBytesLen + " bytes. Actually skipped = " + skipped);
            }
        }
    }
}
Also used : VertexManagerEventProto(org.apache.tez.runtime.api.events.EventProtos.VertexManagerEventProto) TezUncheckedException(org.apache.tez.dag.api.TezUncheckedException) TaskAttemptFailedEventProto(org.apache.tez.runtime.internals.api.events.SystemEventProtos.TaskAttemptFailedEventProto) CodedInputStream(com.google.protobuf.CodedInputStream) InputFailedEventProto(org.apache.tez.runtime.api.events.EventProtos.InputFailedEventProto) TaskStatusUpdateEvent(org.apache.tez.runtime.api.events.TaskStatusUpdateEvent) TaskAttemptFailedEvent(org.apache.tez.runtime.api.events.TaskAttemptFailedEvent) CompositeRoutedDataMovementEventProto(org.apache.tez.runtime.api.events.EventProtos.CompositeRoutedDataMovementEventProto) DataInputBuffer(org.apache.hadoop.io.DataInputBuffer) DataMovementEventProto(org.apache.tez.runtime.api.events.EventProtos.DataMovementEventProto) CompositeRoutedDataMovementEventProto(org.apache.tez.runtime.api.events.EventProtos.CompositeRoutedDataMovementEventProto) RootInputDataInformationEventProto(org.apache.tez.runtime.api.events.EventProtos.RootInputDataInformationEventProto) InputReadErrorEventProto(org.apache.tez.runtime.api.events.EventProtos.InputReadErrorEventProto) EventProtos(org.apache.tez.runtime.api.events.EventProtos) CompositeEventProto(org.apache.tez.runtime.api.events.EventProtos.CompositeEventProto) TaskAttemptKilledEventProto(org.apache.tez.runtime.internals.api.events.SystemEventProtos.TaskAttemptKilledEventProto) TaskAttemptKilledEvent(org.apache.tez.runtime.api.events.TaskAttemptKilledEvent) TaskAttemptCompletedEvent(org.apache.tez.runtime.api.events.TaskAttemptCompletedEvent)

Example 5 with TaskAttemptCompletedEvent

use of org.apache.tez.runtime.api.events.TaskAttemptCompletedEvent in project tez by apache.

the class TestTezEvent method testSerialization.

@Test
public void testSerialization() throws IOException {
    ArrayList<TezEvent> events = new ArrayList<TezEvent>();
    Configuration conf = new Configuration(true);
    String confVal = RandomStringUtils.random(10000, true, true);
    conf.set("testKey", confVal);
    UserPayload payload = TezUtils.createUserPayloadFromConf(conf);
    TezTaskAttemptID srcTAID = TezTaskAttemptID.getInstance(TezTaskID.fromString("task_1454468251169_866787_1_02_000000"), 1000);
    TezTaskAttemptID destTAID = TezTaskAttemptID.getInstance(TezTaskID.fromString("task_1454468251169_866787_1_02_000000"), 2000);
    EventMetaData srcInfo = new EventMetaData(EventProducerConsumerType.OUTPUT, "v1", "v2", srcTAID);
    EventMetaData destInfo = new EventMetaData(EventProducerConsumerType.OUTPUT, "v3", "v4", destTAID);
    // Case of size less than 4K and parsing skipped during deserialization
    events.add(new TezEvent(new TaskAttemptCompletedEvent(), new EventMetaData(EventProducerConsumerType.PROCESSOR, "v1", "v2", srcTAID)));
    TezEvent dmeEvent = new TezEvent(DataMovementEvent.create(1000, 3, 1, payload.getPayload()), srcInfo, System.currentTimeMillis());
    dmeEvent.setDestinationInfo(destInfo);
    events.add(dmeEvent);
    // Different code path
    events.add(new TezEvent(new TaskStatusUpdateEvent(null, 0.1f, null, false), new EventMetaData(EventProducerConsumerType.PROCESSOR, "v5", "v6", srcTAID)));
    // Serialize to different types of DataOutput
    // One that implements OutputStream and one that does not
    DataOutputBuffer dataout = new DataOutputBuffer();
    ByteArrayDataOutput bout = ByteStreams.newDataOutput();
    serializeEvents(events, dataout);
    serializeEvents(events, bout);
    // Deserialize from different types of DataInput
    // One with DataInputBuffer and another different implementation
    DataInputBuffer datain = new DataInputBuffer();
    datain.reset(dataout.getData(), dataout.getLength());
    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(dataout.getData(), 0, dataout.getLength()));
    ArrayList<TezEvent> actual1 = deserializeEvents(datain);
    ArrayList<TezEvent> actual2 = deserializeEvents(dis);
    assertEventEquals(events, actual1);
    assertEventEquals(events, actual2);
    byte[] serializedBytes = bout.toByteArray();
    datain.reset(serializedBytes, serializedBytes.length);
    dis = new DataInputStream(new ByteArrayInputStream(serializedBytes));
    actual1 = deserializeEvents(datain);
    actual2 = deserializeEvents(dis);
    assertEventEquals(events, actual1);
    assertEventEquals(events, actual2);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) UserPayload(org.apache.tez.dag.api.UserPayload) ArrayList(java.util.ArrayList) TaskStatusUpdateEvent(org.apache.tez.runtime.api.events.TaskStatusUpdateEvent) DataInputStream(java.io.DataInputStream) DataInputBuffer(org.apache.hadoop.io.DataInputBuffer) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayDataOutput(com.google.common.io.ByteArrayDataOutput) DataOutputBuffer(org.apache.hadoop.io.DataOutputBuffer) TaskAttemptCompletedEvent(org.apache.tez.runtime.api.events.TaskAttemptCompletedEvent) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) Test(org.junit.Test)

Aggregations

TaskAttemptCompletedEvent (org.apache.tez.runtime.api.events.TaskAttemptCompletedEvent)5 TaskStatusUpdateEvent (org.apache.tez.runtime.api.events.TaskStatusUpdateEvent)5 Test (org.junit.Test)4 Event (org.apache.hadoop.yarn.event.Event)3 TaskAttemptEvent (org.apache.tez.dag.app.dag.event.TaskAttemptEvent)3 VertexEventRouteEvent (org.apache.tez.dag.app.dag.event.VertexEventRouteEvent)3 DataMovementEvent (org.apache.tez.runtime.api.events.DataMovementEvent)3 InputReadErrorEvent (org.apache.tez.runtime.api.events.InputReadErrorEvent)3 EventMetaData (org.apache.tez.runtime.api.impl.EventMetaData)3 TezEvent (org.apache.tez.runtime.api.impl.TezEvent)3 DataInputBuffer (org.apache.hadoop.io.DataInputBuffer)2 ByteArrayDataOutput (com.google.common.io.ByteArrayDataOutput)1 CodedInputStream (com.google.protobuf.CodedInputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 ArrayList (java.util.ArrayList)1 Configuration (org.apache.hadoop.conf.Configuration)1 DataOutputBuffer (org.apache.hadoop.io.DataOutputBuffer)1 TezUncheckedException (org.apache.tez.dag.api.TezUncheckedException)1 UserPayload (org.apache.tez.dag.api.UserPayload)1