Java Code Examples for org.apache.hadoop.yarn.api.records.ContainerExitStatus#SUCCESS

The following examples show how to use org.apache.hadoop.yarn.api.records.ContainerExitStatus#SUCCESS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestHistoryEventsProtoConversion.java    From incubator-tez with Apache License 2.0 6 votes vote down vote up
private void testContainerStoppedEvent() throws Exception {
  ContainerStoppedEvent event = new ContainerStoppedEvent(
      ContainerId.newInstance(ApplicationAttemptId.newInstance(
          ApplicationId.newInstance(0, 1), 1), 1001), 100034566,
      ContainerExitStatus.SUCCESS, ApplicationAttemptId.newInstance(
          ApplicationId.newInstance(0, 1), 1));
  ContainerStoppedEvent deserializedEvent = (ContainerStoppedEvent)
      testProtoConversion(event);
  Assert.assertEquals(event.getContainerId(),
      deserializedEvent.getContainerId());
  Assert.assertEquals(event.getStoppedTime(),
      deserializedEvent.getStoppedTime());
  Assert.assertEquals(event.getApplicationAttemptId(),
      deserializedEvent.getApplicationAttemptId());
  logEvents(event, deserializedEvent);
}
 
Example 2
Source File: TaskSchedulerManager.java    From tez with Apache License 2.0 6 votes vote down vote up
public synchronized void containerCompleted(int schedulerId, Object task, ContainerStatus containerStatus) {
  // SchedulerId isn't used here since no node updates are sent out
  // Inform the Containers about completion.
  AMContainer amContainer = appContext.getAllContainers().get(containerStatus.getContainerId());
  if (amContainer != null) {
    String message = "Container completed. ";
    TaskAttemptTerminationCause errCause = TaskAttemptTerminationCause.CONTAINER_EXITED;
    int exitStatus = containerStatus.getExitStatus();
    if (exitStatus == ContainerExitStatus.PREEMPTED) {
      message = "Container preempted externally. ";
      errCause = TaskAttemptTerminationCause.EXTERNAL_PREEMPTION;
    } else if (exitStatus == ContainerExitStatus.DISKS_FAILED) {
      message = "Container disk failed. ";
      errCause = TaskAttemptTerminationCause.NODE_DISK_ERROR;
    } else if (exitStatus != ContainerExitStatus.SUCCESS){
      message = "Container failed, exitCode=" + exitStatus + ". ";
    }
    if (containerStatus.getDiagnostics() != null) {
      message += containerStatus.getDiagnostics();
    }
    sendEvent(new AMContainerEventCompleted(amContainer.getContainerId(), exitStatus, message, errCause));
  }
}
 
Example 3
Source File: TestHistoryEventsProtoConversion.java    From tez with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
private void testContainerStoppedEvent() throws Exception {
  ContainerStoppedEvent event = new ContainerStoppedEvent(
      ContainerId.newInstance(ApplicationAttemptId.newInstance(
          ApplicationId.newInstance(0, 1), 1), 1001), 100034566,
      ContainerExitStatus.SUCCESS, ApplicationAttemptId.newInstance(
          ApplicationId.newInstance(0, 1), 1));
  ContainerStoppedEvent deserializedEvent = (ContainerStoppedEvent)
      testProtoConversion(event);
  Assert.assertEquals(event.getContainerId(),
      deserializedEvent.getContainerId());
  Assert.assertEquals(event.getStoppedTime(),
      deserializedEvent.getStoppedTime());
  Assert.assertEquals(event.getApplicationAttemptId(),
      deserializedEvent.getApplicationAttemptId());
  logEvents(event, deserializedEvent);
}
 
Example 4
Source File: AbstractApplicationMaster.java    From Scribengin with GNU Affero General Public License v3.0 5 votes vote down vote up
public void onContainersCompleted(List<ContainerStatus> statuses) {
  LOG.info("onContainersCompleted");
  for (ContainerStatus status : statuses) {
    assert (status.getState() == ContainerState.COMPLETE);

    int exitStatus = status.getExitStatus();
    if (exitStatus != ContainerExitStatus.SUCCESS) {
      if (exitStatus != ContainerExitStatus.ABORTED) {
        failedContainerCount.incrementAndGet();
      }
      allocatedContainerCount.decrementAndGet();
      requestedContainerCount.decrementAndGet();
      recordFailedCommand(status.getContainerId());
    } else {
      completedContainerCount.incrementAndGet();
    }
  }

  int askAgainCount = totalContainerCount - requestedContainerCount.get();
  requestedContainerCount.addAndGet(askAgainCount);

  if (askAgainCount > 0) {
    // need to reallocate failed containers
    for (int i = 0; i < askAgainCount; i++) {
      ContainerRequest req = setupContainerReqForRM();
      resourceManager.addContainerRequest(req);
    }
  }

  if (completedContainerCount.get() == totalContainerCount) {
    done = true;
  }
}
 
Example 5
Source File: YarnManager.java    From Scribengin with GNU Affero General Public License v3.0 5 votes vote down vote up
public void onContainersCompleted(List<ContainerStatus> statuses) {
  logger.info("Start onContainersCompleted(List<ContainerStatus> statuses)");
  for (ContainerStatus status: statuses) {
    assert (status.getState() == ContainerState.COMPLETE);
    int exitStatus = status.getExitStatus();
    //TODO: update vm descriptor status
    if (exitStatus != ContainerExitStatus.SUCCESS) {
    } else {
    }
  }
  logger.info("Finish onContainersCompleted(List<ContainerStatus> statuses)");
}
 
Example 6
Source File: ResourceSchedulerWrapper.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private void updateQueueWithNodeUpdate(
        NodeUpdateSchedulerEventWrapper eventWrapper) {
  RMNodeWrapper node = (RMNodeWrapper) eventWrapper.getRMNode();
  List<UpdatedContainerInfo> containerList = node.getContainerUpdates();
  for (UpdatedContainerInfo info : containerList) {
    for (ContainerStatus status : info.getCompletedContainers()) {
      ContainerId containerId = status.getContainerId();
      SchedulerAppReport app = scheduler.getSchedulerAppInfo(
              containerId.getApplicationAttemptId());

      if (app == null) {
        // this happens for the AM container
        // The app have already removed when the NM sends the release
        // information.
        continue;
      }

      String queue =
          appQueueMap.get(containerId.getApplicationAttemptId()
            .getApplicationId());
      int releasedMemory = 0, releasedVCores = 0;
      if (status.getExitStatus() == ContainerExitStatus.SUCCESS) {
        for (RMContainer rmc : app.getLiveContainers()) {
          if (rmc.getContainerId() == containerId) {
            releasedMemory += rmc.getContainer().getResource().getMemory();
            releasedVCores += rmc.getContainer()
                    .getResource().getVirtualCores();
            break;
          }
        }
      } else if (status.getExitStatus() == ContainerExitStatus.ABORTED) {
        if (preemptionContainerMap.containsKey(containerId)) {
          Resource preResource = preemptionContainerMap.get(containerId);
          releasedMemory += preResource.getMemory();
          releasedVCores += preResource.getVirtualCores();
          preemptionContainerMap.remove(containerId);
        }
      }
      // update queue counters
      updateQueueMetrics(queue, releasedMemory, releasedVCores);
    }
  }
}
 
Example 7
Source File: ResourceSchedulerWrapper.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void updateQueueWithNodeUpdate(
        NodeUpdateSchedulerEventWrapper eventWrapper) {
  RMNodeWrapper node = (RMNodeWrapper) eventWrapper.getRMNode();
  List<UpdatedContainerInfo> containerList = node.getContainerUpdates();
  for (UpdatedContainerInfo info : containerList) {
    for (ContainerStatus status : info.getCompletedContainers()) {
      ContainerId containerId = status.getContainerId();
      SchedulerAppReport app = scheduler.getSchedulerAppInfo(
              containerId.getApplicationAttemptId());

      if (app == null) {
        // this happens for the AM container
        // The app have already removed when the NM sends the release
        // information.
        continue;
      }

      String queue =
          appQueueMap.get(containerId.getApplicationAttemptId()
            .getApplicationId());
      int releasedMemory = 0, releasedVCores = 0;
      if (status.getExitStatus() == ContainerExitStatus.SUCCESS) {
        for (RMContainer rmc : app.getLiveContainers()) {
          if (rmc.getContainerId() == containerId) {
            releasedMemory += rmc.getContainer().getResource().getMemory();
            releasedVCores += rmc.getContainer()
                    .getResource().getVirtualCores();
            break;
          }
        }
      } else if (status.getExitStatus() == ContainerExitStatus.ABORTED) {
        if (preemptionContainerMap.containsKey(containerId)) {
          Resource preResource = preemptionContainerMap.get(containerId);
          releasedMemory += preResource.getMemory();
          releasedVCores += preResource.getVirtualCores();
          preemptionContainerMap.remove(containerId);
        }
      }
      // update queue counters
      updateQueueMetrics(queue, releasedMemory, releasedVCores);
    }
  }
}