@Test public void testGetContainers() throws Exception { final ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1); Collection<ContainerReport> containers; if (callerUGI == null) { containers = historyManager.getContainers(appAttemptId).values(); } else { try { containers = callerUGI.doAs( new PrivilegedExceptionAction<Collection<ContainerReport>> () { @Override public Collection<ContainerReport> run() throws Exception { return historyManager.getContainers(appAttemptId).values(); } }); if (callerUGI != null && callerUGI.getShortUserName().equals("user3")) { Assert.fail(); } } catch (AuthorizationException e) { if (callerUGI != null && callerUGI.getShortUserName().equals("user3")) { return; } throw e; } } Assert.assertNotNull(containers); Assert.assertEquals(SCALE, containers.size()); }
@Override public Map<ContainerId, ContainerReport> getContainers( ApplicationAttemptId appAttemptId) throws YarnException, IOException { ApplicationReportExt app = getApplication( appAttemptId.getApplicationId(), ApplicationReportField.USER_AND_ACLS); checkAccess(app); TimelineEntities entities = timelineDataManager.getEntities( ContainerMetricsConstants.ENTITY_TYPE, new NameValuePair( ContainerMetricsConstants.PARENT_PRIMARIY_FILTER, appAttemptId.toString()), null, null, null, null, null, Long.MAX_VALUE, EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); Map<ContainerId, ContainerReport> containers = new LinkedHashMap<ContainerId, ContainerReport>(); if (entities != null && entities.getEntities() != null) { for (TimelineEntity entity : entities.getEntities()) { ContainerReport container = convertToContainerReport( entity, serverHttpAddress, app.appReport.getUser()); containers.put(container.getContainerId(), container); } } return containers; }
ApplicationHistoryManagerOnTimelineStore extends AbstractService implements
    ApplicationHistoryManager { @Override public Map<ContainerId, ContainerReport> getContainers( ApplicationAttemptId appAttemptId) throws YarnException, IOException { ApplicationReportExt app = getApplication( appAttemptId.getApplicationId(), ApplicationReportField.USER_AND_ACLS); checkAccess(app); TimelineEntities entities = timelineDataManager.getEntities( ContainerMetricsConstants.ENTITY_TYPE, new NameValuePair( ContainerMetricsConstants.PARENT_PRIMARIY_FILTER, appAttemptId.toString()), null, null, null, null, null, Long.MAX_VALUE, EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); Map<ContainerId, ContainerReport> containers = new LinkedHashMap<ContainerId, ContainerReport>(); if (entities != null && entities.getEntities() != null) { for (TimelineEntity entity : entities.getEntities()) { ContainerReport container = convertToContainerReport( entity, serverHttpAddress, app.appReport.getUser()); containers.put(container.getContainerId(), container); } } return containers; } }
ApplicationHistoryManagerOnTimelineStore extends AbstractService implements
    ApplicationHistoryManager { @Override public Map<ContainerId, ContainerReport> getContainers( ApplicationAttemptId appAttemptId) throws YarnException, IOException { ApplicationReportExt app = getApplication( appAttemptId.getApplicationId(), ApplicationReportField.USER_AND_ACLS); checkAccess(app); TimelineEntities entities = timelineDataManager.getEntities( ContainerMetricsConstants.ENTITY_TYPE, new NameValuePair( ContainerMetricsConstants.PARENT_PRIMARIY_FILTER, appAttemptId.toString()), null, null, null, null, null, Long.MAX_VALUE, EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); Map<ContainerId, ContainerReport> containers = new LinkedHashMap<ContainerId, ContainerReport>(); if (entities != null && entities.getEntities() != null) { for (TimelineEntity entity : entities.getEntities()) { ContainerReport container = convertToContainerReport( entity, serverHttpAddress, app.appReport.getUser()); containers.put(container.getContainerId(), container); } } return containers; } ApplicationHistoryManagerOnTimelineStore(
      TimelineDataManager timelineDataManager,
      ApplicationACLsManager aclsManager); }
ApplicationHistoryManagerOnTimelineStore extends AbstractService implements
    ApplicationHistoryManager { @Override public Map<ContainerId, ContainerReport> getContainers( ApplicationAttemptId appAttemptId) throws YarnException, IOException { ApplicationReportExt app = getApplication( appAttemptId.getApplicationId(), ApplicationReportField.USER_AND_ACLS); checkAccess(app); TimelineEntities entities = timelineDataManager.getEntities( ContainerMetricsConstants.ENTITY_TYPE, new NameValuePair( ContainerMetricsConstants.PARENT_PRIMARIY_FILTER, appAttemptId.toString()), null, null, null, null, null, Long.MAX_VALUE, EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); Map<ContainerId, ContainerReport> containers = new LinkedHashMap<ContainerId, ContainerReport>(); if (entities != null && entities.getEntities() != null) { for (TimelineEntity entity : entities.getEntities()) { ContainerReport container = convertToContainerReport( entity, serverHttpAddress, app.appReport.getUser()); containers.put(container.getContainerId(), container); } } return containers; } ApplicationHistoryManagerOnTimelineStore(
      TimelineDataManager timelineDataManager,
      ApplicationACLsManager aclsManager); @Override ApplicationReport getApplication(ApplicationId appId); @Override Map<ApplicationId, ApplicationReport> getApplications(long appsNum); @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 Map<ContainerId, ContainerReport> getContainers( ApplicationAttemptId appAttemptId) throws YarnException, IOException { ApplicationReportExt app = getApplication( appAttemptId.getApplicationId(), ApplicationReportField.USER_AND_ACLS); checkAccess(app); TimelineEntities entities = timelineDataManager.getEntities( ContainerMetricsConstants.ENTITY_TYPE, new NameValuePair( ContainerMetricsConstants.PARENT_PRIMARIY_FILTER, appAttemptId.toString()), null, null, null, null, null, Long.MAX_VALUE, EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); Map<ContainerId, ContainerReport> containers = new LinkedHashMap<ContainerId, ContainerReport>(); if (entities != null && entities.getEntities() != null) { for (TimelineEntity entity : entities.getEntities()) { ContainerReport container = convertToContainerReport( entity, serverHttpAddress, app.appReport.getUser()); containers.put(container.getContainerId(), container); } } return containers; } ApplicationHistoryManagerOnTimelineStore(
      TimelineDataManager timelineDataManager,
      ApplicationACLsManager aclsManager); @Override ApplicationReport getApplication(ApplicationId appId); @Override Map<ApplicationId, ApplicationReport> getApplications(long appsNum); @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);  }