NMTimelinePublisher extends CompositeService { @SuppressWarnings("unchecked") private void publishContainerResumedEvent( ContainerEvent event) { if (publishNMContainerEvents) { ContainerResumeEvent resumeEvent = (ContainerResumeEvent) event; ContainerId containerId = resumeEvent.getContainerID(); ContainerEntity entity = createContainerEntity(containerId); Map<String, Object> entityInfo = new HashMap<String, Object>(); entityInfo.put(ContainerMetricsConstants.DIAGNOSTICS_INFO, resumeEvent.getDiagnostic()); entity.setInfo(entityInfo); Container container = context.getContainers().get(containerId); if (container != null) { TimelineEvent tEvent = new TimelineEvent(); tEvent.setId(ContainerMetricsConstants.RESUMED_EVENT_TYPE); tEvent.setTimestamp(event.getTimestamp()); entity.addEvent(tEvent); dispatcher.getEventHandler().handle(new TimelinePublishEvent(entity, containerId.getApplicationAttemptId().getApplicationId())); } } } NMTimelinePublisher(Context context); void reportContainerResourceUsage(Container container, Long pmemUsage,
      Float cpuUsagePercentPerCore); void publishApplicationEvent(ApplicationEvent event); void publishContainerEvent(ContainerEvent event); void publishLocalizationEvent(LocalizationEvent event); void createTimelineClient(ApplicationId appId); void stopTimelineClient(ApplicationId appId); void setTimelineServiceAddress(ApplicationId appId,
      String collectorAddr);  }
@Test public void testPublishContainerResumedEvent() { ApplicationId appId = ApplicationId.newInstance(0, 1); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); ContainerId cId = ContainerId.newContainerId(appAttemptId, 1); ContainerEvent containerEvent = new ContainerResumeEvent(cId, "test resume"); publisher.createTimelineClient(appId); publisher.publishContainerEvent(containerEvent); publisher.stopTimelineClient(appId); dispatcher.await(); ContainerEntity cEntity = new ContainerEntity(); cEntity.setId(cId.toString()); TimelineEntity[] lastPublishedEntities = timelineClient.getLastPublishedEntities(); Assert.assertNotNull(lastPublishedEntities); Assert.assertEquals(1, lastPublishedEntities.length); TimelineEntity entity = lastPublishedEntities[0]; Assert.assertEquals(cEntity, entity); NavigableSet<TimelineEvent> events = entity.getEvents(); Assert.assertEquals(1, events.size()); Assert.assertEquals(ContainerMetricsConstants.RESUMED_EVENT_TYPE, events.iterator().next().getId()); Map<String, Object> info = entity.getInfo(); Assert.assertTrue( info.containsKey(ContainerMetricsConstants.DIAGNOSTICS_INFO)); Assert.assertEquals("test resume", info.get(ContainerMetricsConstants.DIAGNOSTICS_INFO)); }