Search in sources :

Example 1 with DataEventDependencyInfo

use of org.apache.tez.dag.app.dag.impl.TaskAttemptImpl.DataEventDependencyInfo in project tez by apache.

the class DAGUtils method convertDataEventDependecyInfoToATS.

public static Map<String, Object> convertDataEventDependecyInfoToATS(List<DataEventDependencyInfo> info) {
    ArrayList<Object> infoList = new ArrayList<Object>();
    for (DataEventDependencyInfo event : info) {
        Map<String, Object> eventObj = new LinkedHashMap<String, Object>();
        String id = "";
        if (event.getTaskAttemptId() != null) {
            id = event.getTaskAttemptId().toString();
        }
        eventObj.put(EntityTypes.TEZ_TASK_ATTEMPT_ID.name(), id);
        eventObj.put(ATSConstants.TIMESTAMP, event.getTimestamp());
        infoList.add(eventObj);
    }
    Map<String, Object> object = new LinkedHashMap<String, Object>();
    putInto(object, ATSConstants.LAST_DATA_EVENTS, infoList);
    return object;
}
Also used : DataEventDependencyInfo(org.apache.tez.dag.app.dag.impl.TaskAttemptImpl.DataEventDependencyInfo) ArrayList(java.util.ArrayList) JSONObject(org.codehaus.jettison.json.JSONObject) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with DataEventDependencyInfo

use of org.apache.tez.dag.app.dag.impl.TaskAttemptImpl.DataEventDependencyInfo in project tez by apache.

the class TaskAttemptFinishedEvent method toProto.

public TaskAttemptFinishedProto toProto() throws IOException {
    TaskAttemptFinishedProto.Builder builder = TaskAttemptFinishedProto.newBuilder();
    builder.setTaskAttemptId(taskAttemptId.toString()).setState(state.ordinal()).setCreationTime(creationTime).setAllocationTime(allocationTime).setStartTime(startTime).setFinishTime(finishTime);
    if (taskFailureType != null) {
        builder.setTaskFailureType(TezConverterUtils.failureTypeToProto(taskFailureType));
    }
    if (creationCausalTA != null) {
        builder.setCreationCausalTA(creationCausalTA.toString());
    }
    if (diagnostics != null) {
        builder.setDiagnostics(diagnostics);
    }
    if (error != null) {
        builder.setErrorEnum(error.name());
    }
    if (tezCounters != null) {
        builder.setCounters(DagTypeConverters.convertTezCountersToProto(tezCounters));
    }
    if (dataEvents != null && !dataEvents.isEmpty()) {
        for (DataEventDependencyInfo info : dataEvents) {
            builder.addDataEvents(DataEventDependencyInfo.toProto(info));
        }
    }
    if (taGeneratedEvents != null && !taGeneratedEvents.isEmpty()) {
        for (TezEvent event : taGeneratedEvents) {
            builder.addTaGeneratedEvents(TezEventUtils.toProto(event));
        }
    }
    if (containerId != null) {
        builder.setContainerId(containerId.toString());
    }
    if (nodeId != null) {
        builder.setNodeId(nodeId.toString());
    }
    if (nodeHttpAddress != null) {
        builder.setNodeHttpAddress(nodeHttpAddress);
    }
    return builder.build();
}
Also used : DataEventDependencyInfo(org.apache.tez.dag.app.dag.impl.TaskAttemptImpl.DataEventDependencyInfo) TaskAttemptFinishedProto(org.apache.tez.dag.recovery.records.RecoveryProtos.TaskAttemptFinishedProto) TezEvent(org.apache.tez.runtime.api.impl.TezEvent)

Example 3 with DataEventDependencyInfo

use of org.apache.tez.dag.app.dag.impl.TaskAttemptImpl.DataEventDependencyInfo in project tez by apache.

the class TestHistoryEventTimelineConversion method testConvertTaskAttemptFinishedEvent.

@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testConvertTaskAttemptFinishedEvent() {
    String vertexName = "testVertex";
    long creationTime = random.nextLong();
    long startTime = creationTime + 1000;
    long allocationTime = creationTime + 1001;
    long finishTime = startTime + 1002;
    TaskAttemptState state = TaskAttemptState.values()[random.nextInt(TaskAttemptState.values().length)];
    TaskAttemptTerminationCause error = TaskAttemptTerminationCause.values()[random.nextInt(TaskAttemptTerminationCause.values().length)];
    String diagnostics = "random diagnostics message";
    TezCounters counters = new TezCounters();
    long lastDataEventTime = finishTime - 1;
    List<DataEventDependencyInfo> events = Lists.newArrayList();
    events.add(new DataEventDependencyInfo(lastDataEventTime, tezTaskAttemptID));
    events.add(new DataEventDependencyInfo(lastDataEventTime, tezTaskAttemptID));
    TaskAttemptFinishedEvent event = new TaskAttemptFinishedEvent(tezTaskAttemptID, vertexName, startTime, finishTime, state, TaskFailureType.FATAL, error, diagnostics, counters, events, null, creationTime, tezTaskAttemptID, allocationTime, containerId, nodeId, "inProgressURL", "logsURL", "nodeHttpAddress");
    List<TimelineEntity> entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
    Assert.assertEquals(1, entities.size());
    TimelineEntity timelineEntity = entities.get(0);
    Assert.assertEquals(tezTaskAttemptID.toString(), timelineEntity.getEntityId());
    Assert.assertEquals(EntityTypes.TEZ_TASK_ATTEMPT_ID.name(), timelineEntity.getEntityType());
    final Map<String, Set<Object>> primaryFilters = timelineEntity.getPrimaryFilters();
    Assert.assertEquals(5, primaryFilters.size());
    Assert.assertTrue(primaryFilters.get(ATSConstants.APPLICATION_ID).contains(applicationId.toString()));
    Assert.assertTrue(primaryFilters.get(EntityTypes.TEZ_DAG_ID.name()).contains(tezDAGID.toString()));
    Assert.assertTrue(primaryFilters.get(EntityTypes.TEZ_VERTEX_ID.name()).contains(tezVertexID.toString()));
    Assert.assertTrue(primaryFilters.get(EntityTypes.TEZ_TASK_ID.name()).contains(tezTaskID.toString()));
    Assert.assertTrue(primaryFilters.get(ATSConstants.STATUS).contains(state.toString()));
    Assert.assertEquals(1, timelineEntity.getEvents().size());
    TimelineEvent evt = timelineEntity.getEvents().get(0);
    Assert.assertEquals(HistoryEventType.TASK_ATTEMPT_FINISHED.name(), evt.getEventType());
    Assert.assertEquals(finishTime, evt.getTimestamp());
    final Map<String, Object> otherInfo = timelineEntity.getOtherInfo();
    Assert.assertEquals(17, otherInfo.size());
    Assert.assertEquals(tezTaskAttemptID.toString(), timelineEntity.getOtherInfo().get(ATSConstants.CREATION_CAUSAL_ATTEMPT));
    Assert.assertEquals(creationTime, timelineEntity.getOtherInfo().get(ATSConstants.CREATION_TIME));
    Assert.assertEquals(allocationTime, timelineEntity.getOtherInfo().get(ATSConstants.ALLOCATION_TIME));
    Assert.assertEquals(startTime, timelineEntity.getOtherInfo().get(ATSConstants.START_TIME));
    Assert.assertEquals(finishTime, otherInfo.get(ATSConstants.FINISH_TIME));
    Assert.assertEquals(finishTime - startTime, otherInfo.get(ATSConstants.TIME_TAKEN));
    Assert.assertEquals(state.name(), otherInfo.get(ATSConstants.STATUS));
    Assert.assertEquals(TaskFailureType.FATAL.name(), otherInfo.get(ATSConstants.TASK_FAILURE_TYPE));
    Assert.assertEquals(error.name(), otherInfo.get(ATSConstants.TASK_ATTEMPT_ERROR_ENUM));
    Assert.assertEquals(diagnostics, otherInfo.get(ATSConstants.DIAGNOSTICS));
    Map<String, Object> obj1 = (Map<String, Object>) otherInfo.get(ATSConstants.LAST_DATA_EVENTS);
    List<Object> obj2 = (List<Object>) obj1.get(ATSConstants.LAST_DATA_EVENTS);
    Assert.assertEquals(2, obj2.size());
    Map<String, Object> obj3 = (Map<String, Object>) obj2.get(0);
    Assert.assertEquals(events.get(0).getTimestamp(), obj3.get(ATSConstants.TIMESTAMP));
    Assert.assertTrue(otherInfo.containsKey(ATSConstants.COUNTERS));
    Assert.assertEquals("inProgressURL", otherInfo.get(ATSConstants.IN_PROGRESS_LOGS_URL));
    Assert.assertEquals("logsURL", otherInfo.get(ATSConstants.COMPLETED_LOGS_URL));
    Assert.assertEquals(nodeId.toString(), otherInfo.get(ATSConstants.NODE_ID));
    Assert.assertEquals(containerId.toString(), otherInfo.get(ATSConstants.CONTAINER_ID));
    Assert.assertEquals("nodeHttpAddress", otherInfo.get(ATSConstants.NODE_HTTP_ADDRESS));
    TaskAttemptFinishedEvent eventWithNullFailureType = new TaskAttemptFinishedEvent(tezTaskAttemptID, vertexName, startTime, finishTime, state, null, error, diagnostics, counters, events, null, creationTime, tezTaskAttemptID, allocationTime, containerId, nodeId, "inProgressURL", "logsURL", "nodeHttpAddress");
    List<TimelineEntity> evtEntities = HistoryEventTimelineConversion.convertToTimelineEntities(eventWithNullFailureType);
    Assert.assertEquals(1, evtEntities.size());
    TimelineEntity timelineEntityWithNullFailureType = evtEntities.get(0);
    Assert.assertNull(timelineEntityWithNullFailureType.getOtherInfo().get(ATSConstants.TASK_FAILURE_TYPE));
}
Also used : TimelineEvent(org.apache.hadoop.yarn.api.records.timeline.TimelineEvent) Set(java.util.Set) TimelineEntity(org.apache.hadoop.yarn.api.records.timeline.TimelineEntity) TezCounters(org.apache.tez.common.counters.TezCounters) DataEventDependencyInfo(org.apache.tez.dag.app.dag.impl.TaskAttemptImpl.DataEventDependencyInfo) TaskAttemptState(org.apache.tez.dag.api.oldrecords.TaskAttemptState) List(java.util.List) TaskAttemptTerminationCause(org.apache.tez.dag.records.TaskAttemptTerminationCause) TaskAttemptFinishedEvent(org.apache.tez.dag.history.events.TaskAttemptFinishedEvent) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

DataEventDependencyInfo (org.apache.tez.dag.app.dag.impl.TaskAttemptImpl.DataEventDependencyInfo)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 TimelineEntity (org.apache.hadoop.yarn.api.records.timeline.TimelineEntity)1 TimelineEvent (org.apache.hadoop.yarn.api.records.timeline.TimelineEvent)1 TezCounters (org.apache.tez.common.counters.TezCounters)1 TaskAttemptState (org.apache.tez.dag.api.oldrecords.TaskAttemptState)1 TaskAttemptFinishedEvent (org.apache.tez.dag.history.events.TaskAttemptFinishedEvent)1 TaskAttemptTerminationCause (org.apache.tez.dag.records.TaskAttemptTerminationCause)1 TaskAttemptFinishedProto (org.apache.tez.dag.recovery.records.RecoveryProtos.TaskAttemptFinishedProto)1 TezEvent (org.apache.tez.runtime.api.impl.TezEvent)1 JSONObject (org.codehaus.jettison.json.JSONObject)1 Test (org.junit.Test)1