コード例 #1
0
ファイル: ContainerImpl.java プロジェクト: ericsonyc/Projects
 @Override
 public NMContainerStatus getNMContainerStatus() {
   this.readLock.lock();
   try {
     return NMContainerStatus.newInstance(
         this.containerId,
         getCurrentState(),
         getResource(),
         diagnostics.toString(),
         exitCode,
         containerTokenIdentifier.getPriority(),
         containerTokenIdentifier.getCreationTime());
   } finally {
     this.readLock.unlock();
   }
 }
コード例 #2
0
  @SuppressWarnings({"unchecked", "rawtypes"})
  @Test
  public void testHandleContainerStatusInvalidCompletions() throws Exception {
    rm = new MockRM(new YarnConfiguration());
    rm.start();

    EventHandler handler = spy(rm.getRMContext().getDispatcher().getEventHandler());

    // Case 1: Unmanaged AM
    RMApp app = rm.submitApp(1024, true);

    // Case 1.1: AppAttemptId is null
    NMContainerStatus report =
        NMContainerStatus.newInstance(
            ContainerId.newContainerId(
                ApplicationAttemptId.newInstance(app.getApplicationId(), 2), 1),
            ContainerState.COMPLETE,
            Resource.newInstance(1024, 1),
            "Dummy Completed",
            0,
            Priority.newInstance(10),
            1234);
    rm.getResourceTrackerService().handleNMContainerStatus(report, null);
    verify(handler, never()).handle((Event) any());

    // Case 1.2: Master container is null
    RMAppAttemptImpl currentAttempt = (RMAppAttemptImpl) app.getCurrentAppAttempt();
    currentAttempt.setMasterContainer(null);
    report =
        NMContainerStatus.newInstance(
            ContainerId.newContainerId(currentAttempt.getAppAttemptId(), 0),
            ContainerState.COMPLETE,
            Resource.newInstance(1024, 1),
            "Dummy Completed",
            0,
            Priority.newInstance(10),
            1234);
    rm.getResourceTrackerService().handleNMContainerStatus(report, null);
    verify(handler, never()).handle((Event) any());

    // Case 2: Managed AM
    app = rm.submitApp(1024);

    // Case 2.1: AppAttemptId is null
    report =
        NMContainerStatus.newInstance(
            ContainerId.newContainerId(
                ApplicationAttemptId.newInstance(app.getApplicationId(), 2), 1),
            ContainerState.COMPLETE,
            Resource.newInstance(1024, 1),
            "Dummy Completed",
            0,
            Priority.newInstance(10),
            1234);
    try {
      rm.getResourceTrackerService().handleNMContainerStatus(report, null);
    } catch (Exception e) {
      // expected - ignore
    }
    verify(handler, never()).handle((Event) any());

    // Case 2.2: Master container is null
    currentAttempt = (RMAppAttemptImpl) app.getCurrentAppAttempt();
    currentAttempt.setMasterContainer(null);
    report =
        NMContainerStatus.newInstance(
            ContainerId.newContainerId(currentAttempt.getAppAttemptId(), 0),
            ContainerState.COMPLETE,
            Resource.newInstance(1024, 1),
            "Dummy Completed",
            0,
            Priority.newInstance(10),
            1234);
    try {
      rm.getResourceTrackerService().handleNMContainerStatus(report, null);
    } catch (Exception e) {
      // expected - ignore
    }
    verify(handler, never()).handle((Event) any());
  }