@Test (timeout = 180000) public void testStoreAllContainerMetrics() throws Exception { Configuration conf = new Configuration(); conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, 1); MockRM rm1 = new MockRM(conf); SystemMetricsPublisher publisher = mock(SystemMetricsPublisher.class); rm1.getRMContext().setSystemMetricsPublisher(publisher); rm1.start(); MockNM nm1 = rm1.registerNode("unknownhost:1234", 8000); RMApp app1 = rm1.submitApp(1024); MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1); nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 1, ContainerState.RUNNING); am1.allocate("127.0.0.1", 1024, 1, new ArrayList<ContainerId>()); ContainerId containerId2 = ContainerId.newContainerId( am1.getApplicationAttemptId(), 2); rm1.waitForState(nm1, containerId2, RMContainerState.ALLOCATED); am1.allocate(new ArrayList<ResourceRequest>(), new ArrayList<ContainerId>()) .getAllocatedContainers(); rm1.waitForState(nm1, containerId2, RMContainerState.ACQUIRED); nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 2, ContainerState.RUNNING); nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 2, ContainerState.COMPLETE); nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 1, ContainerState.COMPLETE); rm1.waitForState(nm1, containerId2, RMContainerState.COMPLETED); rm1.stop(); verify(publisher, times(2)).containerCreated(any(RMContainer.class), anyLong()); verify(publisher, times(2)).containerFinished(any(RMContainer.class), anyLong()); }
@Override public ApplicationAttemptId getApplicationAttemptId() { return this.appAttemptId; }
RMContainerImpl implements RMContainer { @Override public ApplicationAttemptId getApplicationAttemptId() { return this.appAttemptId; } }
RMContainerImpl implements RMContainer { @Override public ApplicationAttemptId getApplicationAttemptId() { return this.appAttemptId; } RMContainerImpl(Container container,
      ApplicationAttemptId appAttemptId, NodeId nodeId, String user,
      RMContext rmContext);  RMContainerImpl(Container container,
      ApplicationAttemptId appAttemptId, NodeId nodeId,
      String user, RMContext rmContext, long creationTime); }
RMContainerImpl implements RMContainer { @Override public ApplicationAttemptId getApplicationAttemptId() { return this.appAttemptId; } RMContainerImpl(Container container,
      ApplicationAttemptId appAttemptId, NodeId nodeId, String user,
      RMContext rmContext);  RMContainerImpl(Container container,
      ApplicationAttemptId appAttemptId, NodeId nodeId,
      String user, RMContext rmContext, long creationTime); @Override ContainerId getContainerId(); @Override ApplicationAttemptId getApplicationAttemptId(); @Override Container getContainer(); @Override RMContainerState getState(); @Override Resource getReservedResource(); @Override NodeId getReservedNode(); @Override Priority getReservedPriority(); @Override Resource getAllocatedResource(); @Override NodeId getAllocatedNode(); @Override Priority getAllocatedPriority(); @Override long getCreationTime(); @Override long getFinishTime(); @Override String getDiagnosticsInfo(); @Override String getLogURL(); @Override int getContainerExitStatus(); @Override ContainerState getContainerState(); @Override List<ResourceRequest> getResourceRequests(); void setResourceRequests(List<ResourceRequest> requests); @Override String toString(); @Override boolean isAMContainer(); void setAMContainer(boolean isAMContainer); @Override void handle(RMContainerEvent event); ContainerStatus getFinishedStatus(); @Override ContainerReport createContainerReport(); @Override String getNodeHttpAddress(); }
RMContainerImpl implements RMContainer { @Override public ApplicationAttemptId getApplicationAttemptId() { return this.appAttemptId; } RMContainerImpl(Container container,
      ApplicationAttemptId appAttemptId, NodeId nodeId, String user,
      RMContext rmContext);  RMContainerImpl(Container container,
      ApplicationAttemptId appAttemptId, NodeId nodeId,
      String user, RMContext rmContext, long creationTime); @Override ContainerId getContainerId(); @Override ApplicationAttemptId getApplicationAttemptId(); @Override Container getContainer(); @Override RMContainerState getState(); @Override Resource getReservedResource(); @Override NodeId getReservedNode(); @Override Priority getReservedPriority(); @Override Resource getAllocatedResource(); @Override NodeId getAllocatedNode(); @Override Priority getAllocatedPriority(); @Override long getCreationTime(); @Override long getFinishTime(); @Override String getDiagnosticsInfo(); @Override String getLogURL(); @Override int getContainerExitStatus(); @Override ContainerState getContainerState(); @Override List<ResourceRequest> getResourceRequests(); void setResourceRequests(List<ResourceRequest> requests); @Override String toString(); @Override boolean isAMContainer(); void setAMContainer(boolean isAMContainer); @Override void handle(RMContainerEvent event); ContainerStatus getFinishedStatus(); @Override ContainerReport createContainerReport(); @Override String getNodeHttpAddress();  }