private static ApplicationAttemptEntity createAppAttemptEntity( ApplicationAttemptId appAttemptId) { ApplicationAttemptEntity entity = new ApplicationAttemptEntity(); entity.setId(appAttemptId.toString()); entity.setParent(new Identifier(TimelineEntityType.YARN_APPLICATION.name(), appAttemptId.getApplicationId().toString())); return entity; }
public ApplicationAttemptEntity(TimelineEntity entity) { super(entity); if (!entity.getType().equals( TimelineEntityType.YARN_APPLICATION_ATTEMPT.toString())) { throw new IllegalArgumentException("Incompatible entity type: " + getId()); } } }
app2.setQueue(queue.getId()); ApplicationAttemptEntity appAttempt = new ApplicationAttemptEntity(); appAttempt.setId(ApplicationAttemptId.newInstance( ApplicationId.newInstance(0, 1), 1).toString()); app1.setParent(TimelineEntityType.YARN_FLOW_RUN.toString(), flow2.getId()); app1.addChild(TimelineEntityType.YARN_APPLICATION_ATTEMPT.toString(), appAttempt.getId()); appAttempt .setParent(TimelineEntityType.YARN_APPLICATION.toString(), app1.getId()); app2.setParent(TimelineEntityType.YARN_FLOW_RUN.toString(), flow2.getId()); appAttempt.addChild(TimelineEntityType.YARN_CONTAINER.toString(), container.getId()); container.setParent(TimelineEntityType.YARN_APPLICATION_ATTEMPT.toString(), appAttempt.getId()); Assert.assertEquals(1, app1.getChildren().size()); Assert.assertEquals( appAttempt.getType(), app1.getChildren().iterator().next().getType()); Assert.assertEquals( appAttempt.getId(), app1.getChildren().iterator().next().getId()); app1.addInfo(ApplicationEntity.CHILDREN_INFO_KEY, Collections.singletonList("invalid children set"));
ApplicationAttemptEntity attempt1 = new ApplicationAttemptEntity(); attempt1.setId("app-attempt-1"); attempt1.setCreatedTime(1425017502003L); writeEntityFile(attempt1, attemptDir); ApplicationAttemptEntity attempt2 = new ApplicationAttemptEntity(); attempt2.setId("app-attempt-2"); attempt2.setCreatedTime(1425017502004L); writeEntityFile(attempt2, attemptDir); ContainerEntity containerEntity1 = new ContainerEntity(); containerEntity1.setId("container_1_1"); containerEntity1.setParent(attempt1.getIdentifier()); containerEntity1.setCreatedTime(1425017502003L); writeEntityFile(containerEntity1, entityDir); containerEntity2.setParent(attempt2.getIdentifier()); containerEntity2.setCreatedTime(1425018502003L); writeEntityFile(containerEntity2, entityDir); containerEntity3.setParent(attempt2.getIdentifier()); containerEntity3.setCreatedTime(1425018502003L); writeEntityFile(containerEntity3, entityDir);
ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 1); ApplicationAttemptEntity appAttempt = new ApplicationAttemptEntity(); appAttempt.setId(attemptId.toString()); ContainerId containerId = ContainerId.newContainerId(attemptId, 1); ContainerEntity container = new ContainerEntity();
@SuppressWarnings("unchecked") @Override public void appAttemptFinished(RMAppAttempt appAttempt, RMAppAttemptState appAttemtpState, RMApp app, long finishedTime) { ApplicationAttemptId attemptId = appAttempt.getAppAttemptId(); ApplicationAttemptEntity entity = createAppAttemptEntity(appAttempt.getAppAttemptId()); TimelineEvent tEvent = new TimelineEvent(); tEvent.setId(AppAttemptMetricsConstants.FINISHED_EVENT_TYPE); tEvent.setTimestamp(finishedTime); entity.addEvent(tEvent); Map<String, Object> entityInfo = new HashMap<String, Object>(); entityInfo.put(AppAttemptMetricsConstants.DIAGNOSTICS_INFO, appAttempt.getDiagnostics()); // app will get the final status from app attempt, or create one // based on app state if it doesn't exist entityInfo.put(AppAttemptMetricsConstants.FINAL_STATUS_INFO, app.getFinalApplicationStatus().toString()); entityInfo.put(AppAttemptMetricsConstants.STATE_INFO, RMServerUtils .createApplicationAttemptState(appAttemtpState).toString()); entity.setInfo(entityInfo); entity.setIdPrefix( TimelineServiceHelper.invertLong(attemptId.getAttemptId())); getDispatcher().getEventHandler().handle( new TimelineV2PublishEvent(SystemMetricsEventType.PUBLISH_ENTITY, entity, appAttempt.getAppAttemptId().getApplicationId())); }