@Test public void testGetContainerReport() throws Exception { final ContainerId containerId = ContainerId.newContainerId(ApplicationAttemptId.newInstance( ApplicationId.newInstance(0, 1), 1), 1); ContainerReport container; if (callerUGI == null) { container = historyManager.getContainer(containerId); } else { try { container = callerUGI.doAs(new PrivilegedExceptionAction<ContainerReport> () { @Override public ContainerReport run() throws Exception { return historyManager.getContainer(containerId); } }); if (callerUGI != null && callerUGI.getShortUserName().equals("user3")) { Assert.fail(); } } catch (AuthorizationException e) { if (callerUGI != null && callerUGI.getShortUserName().equals("user3")) { return; } throw e; } } Assert.assertNotNull(container); Assert.assertEquals(Integer.MAX_VALUE + 1L, container.getCreationTime()); Assert.assertEquals(Integer.MAX_VALUE + 2L, container.getFinishTime()); Assert.assertEquals(Resource.newInstance(-1, -1, -1), container.getAllocatedResource()); Assert.assertEquals(NodeId.newInstance("test host", 100), container.getAssignedNode()); Assert.assertEquals(Priority.UNDEFINED, container.getPriority()); Assert .assertEquals("test diagnostics info", container.getDiagnosticsInfo()); Assert.assertEquals(ContainerState.COMPLETE, container.getContainerState()); Assert.assertEquals(-1, container.getContainerExitStatus()); Assert.assertEquals("http: "test host:100/container_0_0001_01_000001/" + "container_0_0001_01_000001/user1", container.getLogUrl()); }
@Override public ContainerReport getContainer(ContainerId containerId) throws YarnException, IOException { ApplicationReportExt app = getApplication( containerId.getApplicationAttemptId().getApplicationId(), ApplicationReportField.USER_AND_ACLS); checkAccess(app); TimelineEntity entity = timelineDataManager.getEntity( ContainerMetricsConstants.ENTITY_TYPE, containerId.toString(), EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); if (entity == null) { throw new ContainerNotFoundException( "The entity for container " + containerId + " doesn't exist in the timeline store"); } else { return convertToContainerReport( entity, serverHttpAddress, app.appReport.getUser()); } }
ApplicationHistoryManagerOnTimelineStore extends AbstractService implements
    ApplicationHistoryManager { @Override public ContainerReport getContainer(ContainerId containerId) throws YarnException, IOException { ApplicationReportExt app = getApplication( containerId.getApplicationAttemptId().getApplicationId(), ApplicationReportField.USER_AND_ACLS); checkAccess(app); TimelineEntity entity = timelineDataManager.getEntity( ContainerMetricsConstants.ENTITY_TYPE, containerId.toString(), EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); if (entity == null) { throw new ContainerNotFoundException( "The entity for container " + containerId + " doesn't exist in the timeline store"); } else { return convertToContainerReport( entity, serverHttpAddress, app.appReport.getUser()); } } }
ApplicationHistoryManagerOnTimelineStore extends AbstractService implements
    ApplicationHistoryManager { @Override public ContainerReport getContainer(ContainerId containerId) throws YarnException, IOException { ApplicationReportExt app = getApplication( containerId.getApplicationAttemptId().getApplicationId(), ApplicationReportField.USER_AND_ACLS); checkAccess(app); TimelineEntity entity = timelineDataManager.getEntity( ContainerMetricsConstants.ENTITY_TYPE, containerId.toString(), EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); if (entity == null) { throw new ContainerNotFoundException( "The entity for container " + containerId + " doesn't exist in the timeline store"); } else { return convertToContainerReport( entity, serverHttpAddress, app.appReport.getUser()); } } ApplicationHistoryManagerOnTimelineStore(
      TimelineDataManager timelineDataManager,
      ApplicationACLsManager aclsManager); }
ApplicationHistoryManagerOnTimelineStore extends AbstractService implements
    ApplicationHistoryManager { @Override public ContainerReport getContainer(ContainerId containerId) throws YarnException, IOException { ApplicationReportExt app = getApplication( containerId.getApplicationAttemptId().getApplicationId(), ApplicationReportField.USER_AND_ACLS); checkAccess(app); TimelineEntity entity = timelineDataManager.getEntity( ContainerMetricsConstants.ENTITY_TYPE, containerId.toString(), EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); if (entity == null) { throw new ContainerNotFoundException( "The entity for container " + containerId + " doesn't exist in the timeline store"); } else { return convertToContainerReport( entity, serverHttpAddress, app.appReport.getUser()); } } ApplicationHistoryManagerOnTimelineStore(
      TimelineDataManager timelineDataManager,
      ApplicationACLsManager aclsManager); @Override ApplicationReport getApplication(ApplicationId appId); @Override Map<ApplicationId, ApplicationReport> getAllApplications(); @Override Map<ApplicationAttemptId, ApplicationAttemptReport> getApplicationAttempts(ApplicationId appId); @Override ApplicationAttemptReport getApplicationAttempt(
      ApplicationAttemptId appAttemptId); @Override ContainerReport getContainer(ContainerId containerId); @Override ContainerReport getAMContainer(ApplicationAttemptId appAttemptId); @Override Map<ContainerId, ContainerReport> getContainers(
      ApplicationAttemptId appAttemptId); }
ApplicationHistoryManagerOnTimelineStore extends AbstractService implements
    ApplicationHistoryManager { @Override public ContainerReport getContainer(ContainerId containerId) throws YarnException, IOException { ApplicationReportExt app = getApplication( containerId.getApplicationAttemptId().getApplicationId(), ApplicationReportField.USER_AND_ACLS); checkAccess(app); TimelineEntity entity = timelineDataManager.getEntity( ContainerMetricsConstants.ENTITY_TYPE, containerId.toString(), EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); if (entity == null) { throw new ContainerNotFoundException( "The entity for container " + containerId + " doesn't exist in the timeline store"); } else { return convertToContainerReport( entity, serverHttpAddress, app.appReport.getUser()); } } ApplicationHistoryManagerOnTimelineStore(
      TimelineDataManager timelineDataManager,
      ApplicationACLsManager aclsManager); @Override ApplicationReport getApplication(ApplicationId appId); @Override Map<ApplicationId, ApplicationReport> getAllApplications(); @Override Map<ApplicationAttemptId, ApplicationAttemptReport> getApplicationAttempts(ApplicationId appId); @Override ApplicationAttemptReport getApplicationAttempt(
      ApplicationAttemptId appAttemptId); @Override ContainerReport getContainer(ContainerId containerId); @Override ContainerReport getAMContainer(ApplicationAttemptId appAttemptId); @Override Map<ContainerId, ContainerReport> getContainers(
      ApplicationAttemptId appAttemptId);  }