Search in sources :

Example 1 with ServicePluginInfo

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

the class TestHistoryEventTimelineConversion method testConvertVertexInitializedEvent.

@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testConvertVertexInitializedEvent() {
    long initRequestedTime = random.nextLong();
    long initedTime = random.nextLong();
    int numTasks = random.nextInt();
    VertexInitializedEvent event = new VertexInitializedEvent(tezVertexID, "v1", initRequestedTime, initedTime, numTasks, "proc", null, null, new ServicePluginInfo().setContainerLauncherName("abc").setTaskSchedulerName("def").setTaskCommunicatorName("ghi").setContainerLauncherClassName("abc1").setTaskSchedulerClassName("def1").setTaskCommunicatorClassName("ghi1"));
    List<TimelineEntity> entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
    Assert.assertEquals(1, entities.size());
    TimelineEntity timelineEntity = entities.get(0);
    Assert.assertEquals(EntityTypes.TEZ_VERTEX_ID.name(), timelineEntity.getEntityType());
    Assert.assertEquals(tezVertexID.toString(), timelineEntity.getEntityId());
    Assert.assertEquals(initedTime, timelineEntity.getStartTime().longValue());
    Assert.assertEquals(1, timelineEntity.getRelatedEntities().size());
    Assert.assertTrue(timelineEntity.getRelatedEntities().get(EntityTypes.TEZ_DAG_ID.name()).contains(tezDAGID.toString()));
    Assert.assertEquals(2, timelineEntity.getPrimaryFilters().size());
    Assert.assertTrue(timelineEntity.getPrimaryFilters().get(ATSConstants.APPLICATION_ID).contains(applicationId.toString()));
    Assert.assertTrue(timelineEntity.getPrimaryFilters().get(EntityTypes.TEZ_DAG_ID.name()).contains(tezDAGID.toString()));
    Assert.assertEquals(1, timelineEntity.getEvents().size());
    TimelineEvent timelineEvent = timelineEntity.getEvents().get(0);
    Assert.assertEquals(HistoryEventType.VERTEX_INITIALIZED.name(), timelineEvent.getEventType());
    Assert.assertEquals(initedTime, timelineEvent.getTimestamp());
    Assert.assertEquals("v1", timelineEntity.getOtherInfo().get(ATSConstants.VERTEX_NAME));
    Assert.assertEquals("proc", timelineEntity.getOtherInfo().get(ATSConstants.PROCESSOR_CLASS_NAME));
    Assert.assertEquals(initedTime, ((Long) timelineEntity.getOtherInfo().get(ATSConstants.INIT_TIME)).longValue());
    Assert.assertEquals(initRequestedTime, ((Long) timelineEntity.getOtherInfo().get(ATSConstants.INIT_REQUESTED_TIME)).longValue());
    Assert.assertEquals(initedTime, ((Long) timelineEntity.getOtherInfo().get(ATSConstants.INIT_TIME)).longValue());
    Assert.assertEquals(numTasks, ((Integer) timelineEntity.getOtherInfo().get(ATSConstants.NUM_TASKS)).intValue());
    Assert.assertNotNull(timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN));
    Assert.assertEquals("abc", ((Map<String, Object>) timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(ATSConstants.CONTAINER_LAUNCHER_NAME));
    Assert.assertEquals("def", ((Map<String, Object>) timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(ATSConstants.TASK_SCHEDULER_NAME));
    Assert.assertEquals("ghi", ((Map<String, Object>) timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(ATSConstants.TASK_COMMUNICATOR_NAME));
    Assert.assertEquals("abc1", ((Map<String, Object>) timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(ATSConstants.CONTAINER_LAUNCHER_CLASS_NAME));
    Assert.assertEquals("def1", ((Map<String, Object>) timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(ATSConstants.TASK_SCHEDULER_CLASS_NAME));
    Assert.assertEquals("ghi1", ((Map<String, Object>) timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(ATSConstants.TASK_COMMUNICATOR_CLASS_NAME));
}
Also used : ServicePluginInfo(org.apache.tez.dag.app.dag.impl.ServicePluginInfo) TimelineEvent(org.apache.hadoop.yarn.api.records.timeline.TimelineEvent) VertexInitializedEvent(org.apache.tez.dag.history.events.VertexInitializedEvent) TimelineEntity(org.apache.hadoop.yarn.api.records.timeline.TimelineEntity) Test(org.junit.Test)

Example 2 with ServicePluginInfo

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

the class TestHistoryEventTimelineConversion method testConvertVertexFinishedEvent.

@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testConvertVertexFinishedEvent() {
    String vertexName = "v1";
    long initRequestedTime = random.nextLong();
    long initedTime = random.nextLong();
    long startRequestedTime = random.nextLong();
    long startTime = random.nextLong();
    long finishTime = random.nextLong();
    Map<String, Integer> taskStats = new HashMap<String, Integer>();
    taskStats.put("FOO", 100);
    taskStats.put("BAR", 200);
    VertexStats vertexStats = new VertexStats();
    VertexFinishedEvent event = new VertexFinishedEvent(tezVertexID, vertexName, 1, initRequestedTime, initedTime, startRequestedTime, startTime, finishTime, VertexState.ERROR, "diagnostics", null, vertexStats, taskStats, new ServicePluginInfo().setContainerLauncherName("abc").setTaskSchedulerName("def").setTaskCommunicatorName("ghi").setContainerLauncherClassName("abc1").setTaskSchedulerClassName("def1").setTaskCommunicatorClassName("ghi1"));
    List<TimelineEntity> entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
    Assert.assertEquals(1, entities.size());
    TimelineEntity timelineEntity = entities.get(0);
    Assert.assertEquals(EntityTypes.TEZ_VERTEX_ID.name(), timelineEntity.getEntityType());
    Assert.assertEquals(tezVertexID.toString(), timelineEntity.getEntityId());
    Assert.assertEquals(0, timelineEntity.getRelatedEntities().size());
    Assert.assertEquals(3, timelineEntity.getPrimaryFilters().size());
    Assert.assertTrue(timelineEntity.getPrimaryFilters().get(ATSConstants.APPLICATION_ID).contains(applicationId.toString()));
    Assert.assertTrue(timelineEntity.getPrimaryFilters().get(EntityTypes.TEZ_DAG_ID.name()).contains(tezDAGID.toString()));
    Assert.assertTrue(timelineEntity.getPrimaryFilters().get(ATSConstants.STATUS).contains(VertexState.ERROR.name()));
    Assert.assertEquals(1, timelineEntity.getEvents().size());
    TimelineEvent timelineEvent = timelineEntity.getEvents().get(0);
    Assert.assertEquals(HistoryEventType.VERTEX_FINISHED.name(), timelineEvent.getEventType());
    Assert.assertEquals(finishTime, timelineEvent.getTimestamp());
    Assert.assertEquals(vertexName, timelineEntity.getOtherInfo().get(ATSConstants.VERTEX_NAME));
    Assert.assertEquals(finishTime, ((Long) timelineEntity.getOtherInfo().get(ATSConstants.FINISH_TIME)).longValue());
    Assert.assertEquals(finishTime - startTime, ((Long) timelineEntity.getOtherInfo().get(ATSConstants.TIME_TAKEN)).longValue());
    Assert.assertEquals(VertexState.ERROR.name(), timelineEntity.getOtherInfo().get(ATSConstants.STATUS));
    Assert.assertEquals("diagnostics", timelineEntity.getOtherInfo().get(ATSConstants.DIAGNOSTICS));
    Assert.assertNotNull(timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN));
    Assert.assertEquals("abc", ((Map<String, Object>) timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(ATSConstants.CONTAINER_LAUNCHER_NAME));
    Assert.assertEquals("def", ((Map<String, Object>) timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(ATSConstants.TASK_SCHEDULER_NAME));
    Assert.assertEquals("ghi", ((Map<String, Object>) timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(ATSConstants.TASK_COMMUNICATOR_NAME));
    Assert.assertEquals("abc1", ((Map<String, Object>) timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(ATSConstants.CONTAINER_LAUNCHER_CLASS_NAME));
    Assert.assertEquals("def1", ((Map<String, Object>) timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(ATSConstants.TASK_SCHEDULER_CLASS_NAME));
    Assert.assertEquals("ghi1", ((Map<String, Object>) timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(ATSConstants.TASK_COMMUNICATOR_CLASS_NAME));
    Assert.assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.STATS));
    Assert.assertEquals(100, ((Integer) timelineEntity.getOtherInfo().get("FOO")).intValue());
    Assert.assertEquals(200, ((Integer) timelineEntity.getOtherInfo().get("BAR")).intValue());
}
Also used : ServicePluginInfo(org.apache.tez.dag.app.dag.impl.ServicePluginInfo) TimelineEvent(org.apache.hadoop.yarn.api.records.timeline.TimelineEvent) HashMap(java.util.HashMap) VertexStats(org.apache.tez.dag.app.dag.impl.VertexStats) TimelineEntity(org.apache.hadoop.yarn.api.records.timeline.TimelineEntity) VertexFinishedEvent(org.apache.tez.dag.history.events.VertexFinishedEvent) Test(org.junit.Test)

Aggregations

TimelineEntity (org.apache.hadoop.yarn.api.records.timeline.TimelineEntity)2 TimelineEvent (org.apache.hadoop.yarn.api.records.timeline.TimelineEvent)2 ServicePluginInfo (org.apache.tez.dag.app.dag.impl.ServicePluginInfo)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 VertexStats (org.apache.tez.dag.app.dag.impl.VertexStats)1 VertexFinishedEvent (org.apache.tez.dag.history.events.VertexFinishedEvent)1 VertexInitializedEvent (org.apache.tez.dag.history.events.VertexInitializedEvent)1