@SuppressWarnings("unchecked") @Override public void appACLsUpdated(RMApp app, String appViewACLs, long updatedTime) { ApplicationEntity entity = createApplicationEntity(app.getApplicationId()); TimelineEvent tEvent = new TimelineEvent(); Map<String, Object> entityInfo = new HashMap<String, Object>(); entityInfo.put(ApplicationMetricsConstants.APP_VIEW_ACLS_ENTITY_INFO, (appViewACLs == null) ? "" : appViewACLs); entity.setInfo(entityInfo); tEvent.setId(ApplicationMetricsConstants.ACLS_UPDATED_EVENT_TYPE); tEvent.setTimestamp(updatedTime); entity.addEvent(tEvent); getDispatcher().getEventHandler().handle(new TimelineV2PublishEvent( SystemMetricsEventType.PUBLISH_ENTITY, entity, app.getApplicationId())); }
private void publishContainerStartFailedEventOnTimelineServiceV2( final ContainerId containerId, String diagnostics) { final org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity entity = new org.apache.hadoop.yarn.api.records.timelineservice. TimelineEntity(); entity.setId(containerId.toString()); entity.setType(DSEntity.DS_CONTAINER.toString()); entity.addInfo("user", appSubmitterUgi.getShortUserName()); org.apache.hadoop.yarn.api.records.timelineservice.TimelineEvent event = new org.apache.hadoop.yarn.api.records.timelineservice .TimelineEvent(); event.setTimestamp(System.currentTimeMillis()); event.setId(DSEvent.DS_CONTAINER_END.toString()); event.addInfo(DIAGNOSTICS, diagnostics); entity.addEvent(event); try { appSubmitterUgi.doAs((PrivilegedExceptionAction<Object>) () -> { timelineV2Client.putEntitiesAsync(entity); return null; }); } catch (Exception e) { LOG.error("Container start failed event could not be published for {}", containerId, e instanceof UndeclaredThrowableException ? e.getCause() : e); } }
for (TimelineEvent event : events) { if (event != null) { String eventId = event.getId(); if (eventId != null) { long eventTimestamp = event.getTimestamp(); eventTimestamp = System.currentTimeMillis(); Map<String, Object> eventInfo = event.getInfo(); if ((eventInfo == null) || (eventInfo.size() == 0)) { byte[] columnQualifierBytes =
@SuppressWarnings("unchecked") @Override public void appStateUpdated(RMApp app, YarnApplicationState appState, long updatedTime) { ApplicationEntity entity = createApplicationEntity(app.getApplicationId()); Map<String, Object> eventInfo = new HashMap<String, Object>(); eventInfo.put(ApplicationMetricsConstants.STATE_EVENT_INFO, appState); TimelineEvent tEvent = new TimelineEvent(); tEvent.setId(ApplicationMetricsConstants.STATE_UPDATED_EVENT_TYPE); tEvent.setTimestamp(updatedTime); tEvent.setInfo(eventInfo); entity.addEvent(tEvent); // publish in entity info also to query using filters Map<String, Object> entityInfo = new HashMap<String, Object>(); entityInfo.put(ApplicationMetricsConstants.STATE_EVENT_INFO, appState); entity.setInfo(entityInfo); getDispatcher().getEventHandler().handle(new TimelineV2PublishEvent( SystemMetricsEventType.PUBLISH_ENTITY, entity, app.getApplicationId())); }
TimelineEvent event1 = new TimelineEvent(); event1.setId("test event id 1"); event1.addInfo("test info key 1", "test info value 1"); event1.addInfo("test info key 2", Arrays.asList("test info value 2", "test info value 3")); event1.addInfo("test info key 3", true); Assert.assertTrue( event1.getInfo().get("test info key 3") instanceof Boolean); event1.setTimestamp(1L); entity.addEvent(event1); TimelineEvent event2 = new TimelineEvent(); event2.setId("test event id 2"); event2.addInfo("test info key 1", "test info value 1"); event2.addInfo("test info key 2", Arrays.asList("test info value 2", "test info value 3")); event2.addInfo("test info key 3", true); Assert.assertTrue( event2.getInfo().get("test info key 3") instanceof Boolean); event2.setTimestamp(2L); entity.addEvent(event2); event1.equals(event2)); TimelineEvent event3 = new TimelineEvent(); event3.setId("test event id 1"); event3.setTimestamp(1L); Assert.assertEquals("event1 should equal to event3! ", event3, event1); Assert.assertNotEquals("event1 should not equal to event2! ",
private org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity createBaseEntity(HistoryEvent event, long timestamp, String entityType, boolean setCreatedTime) { org.apache.hadoop.yarn.api.records.timelineservice.TimelineEvent tEvent = event.toTimelineEvent(); tEvent.setTimestamp(timestamp); org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity entity = new org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity(); entity.addEvent(tEvent); entity.setType(entityType); if (setCreatedTime) { entity.setCreatedTime(timestamp); } Set<TimelineMetric> timelineMetrics = event.getTimelineMetrics(); if (timelineMetrics != null) { entity.setMetrics(timelineMetrics); } return entity; }
/** * @param te TimelineEntity object. * @param eventId event with this id needs to be fetched * @return TimelineEvent if TimelineEntity contains the desired event. */ public static TimelineEvent getApplicationEvent(TimelineEntity te, String eventId) { if (isApplicationEntity(te)) { for (TimelineEvent event : te.getEvents()) { if (event.getId().equals(eventId)) { return event; } } } return null; } }
@SuppressWarnings("unchecked") @Override public void appUpdated(RMApp app, long currentTimeMillis) { ApplicationEntity entity = createApplicationEntity(app.getApplicationId()); Map<String, Object> eventInfo = new HashMap<String, Object>(); eventInfo.put(ApplicationMetricsConstants.QUEUE_ENTITY_INFO, app.getQueue()); eventInfo.put(ApplicationMetricsConstants.APPLICATION_PRIORITY_INFO, app.getApplicationPriority().getPriority()); TimelineEvent tEvent = new TimelineEvent(); tEvent.setId(ApplicationMetricsConstants.UPDATED_EVENT_TYPE); tEvent.setTimestamp(currentTimeMillis); tEvent.setInfo(eventInfo); entity.addEvent(tEvent); getDispatcher().getEventHandler().handle(new TimelineV2PublishEvent( SystemMetricsEventType.PUBLISH_ENTITY, entity, app.getApplicationId())); }
assertEquals(idPrefix, entity.getIdPrefix()); for (TimelineEvent event : entity.getEvents()) { if (event.getId().equals(eventForCreatedTime)) { assertTrue(entity.getCreatedTime() > 0); break;
@SuppressWarnings("unchecked") private void publishContainerFinishedEvent(ContainerStatus containerStatus, long containerFinishTime, long containerStartTime) { ContainerId containerId = containerStatus.getContainerId(); TimelineEntity entity = createContainerEntity(containerId); Map<String, Object> entityInfo = new HashMap<String, Object>(); entityInfo.put(ContainerMetricsConstants.DIAGNOSTICS_INFO, containerStatus.getDiagnostics()); entityInfo.put(ContainerMetricsConstants.EXIT_STATUS_INFO, containerStatus.getExitStatus()); entityInfo.put(ContainerMetricsConstants.STATE_INFO, ContainerState.COMPLETE.toString()); entityInfo.put(ContainerMetricsConstants.CONTAINER_FINISHED_TIME, containerFinishTime); entity.setInfo(entityInfo); TimelineEvent tEvent = new TimelineEvent(); tEvent.setId(ContainerMetricsConstants.FINISHED_EVENT_TYPE); tEvent.setTimestamp(containerFinishTime); entity.addEvent(tEvent); entity.setIdPrefix(TimelineServiceHelper.invertLong(containerStartTime)); dispatcher.getEventHandler().handle(new TimelinePublishEvent(entity, containerId.getApplicationAttemptId().getApplicationId())); }
if (event == null) { event = new TimelineEvent(); event.setId(eventColumnName.getId()); event.setTimestamp(eventColumnName.getTimestamp()); eventsMap.put(key, event); event.addInfo(eventColumnName.getInfoKey(), eventResult.getValue());
assertEquals(idPrefix, entity.getIdPrefix()); for (TimelineEvent event : entity.getEvents()) { if (event.getId().equals(eventForCreatedTime)) { assertTrue(entity.getCreatedTime() > 0); break;
@SuppressWarnings("unchecked") @Override public void containerFinished(RMContainer container, long finishedTime) { if (publishContainerEvents) { TimelineEntity entity = createContainerEntity(container.getContainerId()); TimelineEvent tEvent = new TimelineEvent(); tEvent.setId(ContainerMetricsConstants.FINISHED_IN_RM_EVENT_TYPE); tEvent.setTimestamp(finishedTime); entity.addEvent(tEvent); Map<String, Object> entityInfo = new HashMap<String, Object>(); entityInfo.put(ContainerMetricsConstants.DIAGNOSTICS_INFO, container.getDiagnosticsInfo()); entityInfo.put(ContainerMetricsConstants.EXIT_STATUS_INFO, container.getContainerExitStatus()); entityInfo.put(ContainerMetricsConstants.STATE_INFO, container.getContainerState().toString()); entityInfo.put(ContainerMetricsConstants.CONTAINER_FINISHED_TIME, finishedTime); entity.setInfo(entityInfo); getDispatcher().getEventHandler().handle(new TimelineV2PublishEvent( SystemMetricsEventType.PUBLISH_ENTITY, entity, container .getContainerId().getApplicationAttemptId().getApplicationId())); } }
new org.apache.hadoop.yarn.api.records.timelineservice.TimelineEvent(); event.setTimestamp(System.currentTimeMillis()); event.setId(DSEvent.DS_CONTAINER_END.toString()); event.addInfo("State", container.getState().name()); event.addInfo("Exit Status", container.getExitStatus()); event.addInfo(DIAGNOSTICS, container.getDiagnostics()); entity.addEvent(event); entity.setIdPrefix(TimelineServiceHelper.invertLong(containerStartTime));
new org.apache.hadoop.yarn.api.records.timelineservice.TimelineEvent(); event.setId(appEvent.toString()); event.setTimestamp(ts); entity.addEvent(event); entity.setIdPrefix(
new org.apache.hadoop.yarn.api.records.timelineservice.TimelineEvent(); event.setTimestamp(startTime); event.setId(DSEvent.DS_CONTAINER_START.toString()); event.addInfo("Node", container.getNodeId().toString()); event.addInfo("Resources", container.getResource().toString()); entity.addEvent(event); entity.setIdPrefix(TimelineServiceHelper.invertLong(startTime));
entity.setInfo(entityInfo); TimelineEvent tEvent = new TimelineEvent(); tEvent.setId(ContainerMetricsConstants.CREATED_EVENT_TYPE); tEvent.setTimestamp(event.getTimestamp());
TimelineEntity entity = createContainerEntity(containerId); TimelineEvent tEvent = new TimelineEvent(); tEvent.setId(eventType); tEvent.setTimestamp(event.getTimestamp()); entity.addEvent(tEvent); entity.setIdPrefix(TimelineServiceHelper.
@SuppressWarnings("unchecked") @Override public void appFinished(RMApp app, RMAppState state, long finishedTime) { ApplicationEntity entity = createApplicationEntity(app.getApplicationId()); TimelineEvent tEvent = new TimelineEvent(); tEvent.setId(ApplicationMetricsConstants.FINISHED_EVENT_TYPE); tEvent.setTimestamp(finishedTime); entity.addEvent(tEvent); Map<String, Object> entityInfo = new HashMap<String, Object>(); entityInfo.put(ApplicationMetricsConstants.DIAGNOSTICS_INFO_EVENT_INFO, app.getDiagnostics().toString()); entityInfo.put(ApplicationMetricsConstants.FINAL_STATUS_EVENT_INFO, app.getFinalApplicationStatus().toString()); entityInfo.put(ApplicationMetricsConstants.STATE_EVENT_INFO, RMServerUtils.createApplicationState(state).toString()); ApplicationAttemptId appAttemptId = app.getCurrentAppAttempt() == null ? null : app.getCurrentAppAttempt().getAppAttemptId(); if (appAttemptId != null) { entityInfo.put(ApplicationMetricsConstants.LATEST_APP_ATTEMPT_EVENT_INFO, appAttemptId.toString()); } entity.setInfo(entityInfo); RMAppMetrics appMetrics = app.getRMAppMetrics(); Set<TimelineMetric> entityMetrics = getTimelinelineAppMetrics(appMetrics, finishedTime); entity.setMetrics(entityMetrics); getDispatcher().getEventHandler().handle( new ApplicationFinishPublishEvent(SystemMetricsEventType. PUBLISH_APPLICATION_FINISHED_ENTITY, entity, app)); }
@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())); }