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

The following examples show how to use org.apache.hadoop.yarn.api.records.ContainerExitStatus#INVALID . 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: YarnService.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
private ImmutableMap.Builder<String, String> buildContainerStatusEventMetadata(ContainerStatus containerStatus) {
  ImmutableMap.Builder<String, String> eventMetadataBuilder = new ImmutableMap.Builder<>();
  eventMetadataBuilder.put(GobblinYarnMetricTagNames.CONTAINER_ID, containerStatus.getContainerId().toString());
  eventMetadataBuilder.put(GobblinYarnEventConstants.EventMetadata.CONTAINER_STATUS_CONTAINER_STATE,
      containerStatus.getState().toString());
  if (ContainerExitStatus.INVALID != containerStatus.getExitStatus()) {
    eventMetadataBuilder.put(GobblinYarnEventConstants.EventMetadata.CONTAINER_STATUS_EXIT_STATUS,
        containerStatus.getExitStatus() + "");
  }
  if (!Strings.isNullOrEmpty(containerStatus.getDiagnostics())) {
    eventMetadataBuilder.put(GobblinYarnEventConstants.EventMetadata.CONTAINER_STATUS_EXIT_DIAGNOSTICS,
        containerStatus.getDiagnostics());
  }

  return eventMetadataBuilder;
}
 
Example 2
Source File: ContainerInfo.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public ContainerInfo(final Context nmContext, final Container container,
     String requestUri, String pathPrefix) {

  this.id = container.getContainerId().toString();
  this.nodeId = nmContext.getNodeId().toString();
  ContainerStatus containerData = container.cloneAndGetContainerStatus();
  this.exitCode = containerData.getExitStatus();
  this.exitStatus =
      (this.exitCode == ContainerExitStatus.INVALID) ?
          "N/A" : String.valueOf(exitCode);
  this.state = container.getContainerState().toString();
  this.diagnostics = containerData.getDiagnostics();
  if (this.diagnostics == null || this.diagnostics.isEmpty()) {
    this.diagnostics = "";
  }

  this.user = container.getUser();
  Resource res = container.getResource();
  if (res != null) {
    this.totalMemoryNeededMB = res.getMemory();
    this.totalVCoresNeeded = res.getVirtualCores();
  }
  this.containerLogsShortLink = ujoin("containerlogs", this.id,
      container.getUser());

  if (requestUri == null) {
    requestUri = "";
  }
  if (pathPrefix == null) {
    pathPrefix = "";
  }
  this.containerLogsLink = join(requestUri, pathPrefix,
      this.containerLogsShortLink);
}
 
Example 3
Source File: NMMemoryStateStoreService.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void storeContainerLaunched(ContainerId containerId)
    throws IOException {
  RecoveredContainerState rcs = getRecoveredContainerState(containerId);
  if (rcs.exitCode != ContainerExitStatus.INVALID) {
    throw new IOException("Container already completed");
  }
  rcs.status = RecoveredContainerStatus.LAUNCHED;
}
 
Example 4
Source File: ContainerInfo.java    From big-c with Apache License 2.0 5 votes vote down vote up
public ContainerInfo(final Context nmContext, final Container container,
     String requestUri, String pathPrefix) {

  this.id = container.getContainerId().toString();
  this.nodeId = nmContext.getNodeId().toString();
  ContainerStatus containerData = container.cloneAndGetContainerStatus();
  this.exitCode = containerData.getExitStatus();
  this.exitStatus =
      (this.exitCode == ContainerExitStatus.INVALID) ?
          "N/A" : String.valueOf(exitCode);
  this.state = container.getContainerState().toString();
  this.diagnostics = containerData.getDiagnostics();
  if (this.diagnostics == null || this.diagnostics.isEmpty()) {
    this.diagnostics = "";
  }

  this.user = container.getUser();
  Resource res = container.getResource();
  if (res != null) {
    this.totalMemoryNeededMB = res.getMemory();
    this.totalVCoresNeeded = res.getVirtualCores();
  }
  this.containerLogsShortLink = ujoin("containerlogs", this.id,
      container.getUser());

  if (requestUri == null) {
    requestUri = "";
  }
  if (pathPrefix == null) {
    pathPrefix = "";
  }
  this.containerLogsLink = join(requestUri, pathPrefix,
      this.containerLogsShortLink);
}
 
Example 5
Source File: NMMemoryStateStoreService.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void storeContainerLaunched(ContainerId containerId)
    throws IOException {
  RecoveredContainerState rcs = getRecoveredContainerState(containerId);
  if (rcs.exitCode != ContainerExitStatus.INVALID) {
    throw new IOException("Container already completed");
  }
  rcs.status = RecoveredContainerStatus.LAUNCHED;
}
 
Example 6
Source File: ContainerImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private boolean hasDefaultExitCode() {
  return (this.exitCode == ContainerExitStatus.INVALID);
}
 
Example 7
Source File: RMAppAttemptImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private void rememberTargetTransitionsAndStoreState(RMAppAttemptEvent event,
    Object transitionToDo, RMAppAttemptState targetFinalState,
    RMAppAttemptState stateToBeStored) {

  rememberTargetTransitions(event, transitionToDo, targetFinalState);
  stateBeforeFinalSaving = getState();

  // As of today, finalState, diagnostics, final-tracking-url and
  // finalAppStatus are the only things that we store into the StateStore
  // AFTER the initial saving on app-attempt-start
  // These fields can be visible from outside only after they are saved in
  // StateStore
  String diags = null;

  // don't leave the tracking URL pointing to a non-existent AM
  setTrackingUrlToRMAppPage(stateToBeStored);
  String finalTrackingUrl = getOriginalTrackingUrl();
  FinalApplicationStatus finalStatus = null;
  int exitStatus = ContainerExitStatus.INVALID;
  switch (event.getType()) {
  case LAUNCH_FAILED:
    RMAppAttemptLaunchFailedEvent launchFaileEvent =
        (RMAppAttemptLaunchFailedEvent) event;
    diags = launchFaileEvent.getMessage();
    break;
  case REGISTERED:
    diags = getUnexpectedAMRegisteredDiagnostics();
    break;
  case UNREGISTERED:
    RMAppAttemptUnregistrationEvent unregisterEvent =
        (RMAppAttemptUnregistrationEvent) event;
    diags = unregisterEvent.getDiagnostics();
    // reset finalTrackingUrl to url sent by am
    finalTrackingUrl = sanitizeTrackingUrl(unregisterEvent.getFinalTrackingUrl());
    finalStatus = unregisterEvent.getFinalApplicationStatus();
    break;
  case CONTAINER_FINISHED:
    RMAppAttemptContainerFinishedEvent finishEvent =
        (RMAppAttemptContainerFinishedEvent) event;
    diags = getAMContainerCrashedDiagnostics(finishEvent);
    exitStatus = finishEvent.getContainerStatus().getExitStatus();
    break;
  case KILL:
    break;
  case EXPIRE:
    diags = getAMExpiredDiagnostics(event);
    break;
  default:
    break;
  }
  AggregateAppResourceUsage resUsage =
      this.attemptMetrics.getAggregateAppResourceUsage();
  RMStateStore rmStore = rmContext.getStateStore();
  setFinishTime(System.currentTimeMillis());

  ApplicationAttemptStateData attemptState =
      ApplicationAttemptStateData.newInstance(
          applicationAttemptId,  getMasterContainer(),
          rmStore.getCredentialsFromAppAttempt(this),
          startTime, stateToBeStored, finalTrackingUrl, diags,
          finalStatus, exitStatus,
        getFinishTime(), resUsage.getMemorySeconds(),
        resUsage.getVcoreSeconds(), resUsage.getGcoreSeconds());
  LOG.info("Updating application attempt " + applicationAttemptId
      + " with final state: " + targetedFinalState + ", and exit status: "
      + exitStatus);
  rmStore.updateApplicationAttemptState(attemptState);
}
 
Example 8
Source File: ContainerImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
private boolean hasDefaultExitCode() {
  return (this.exitCode == ContainerExitStatus.INVALID);
}
 
Example 9
Source File: RMAppAttemptImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void rememberTargetTransitionsAndStoreState(RMAppAttemptEvent event,
    Object transitionToDo, RMAppAttemptState targetFinalState,
    RMAppAttemptState stateToBeStored) {

  rememberTargetTransitions(event, transitionToDo, targetFinalState);
  stateBeforeFinalSaving = getState();

  // As of today, finalState, diagnostics, final-tracking-url and
  // finalAppStatus are the only things that we store into the StateStore
  // AFTER the initial saving on app-attempt-start
  // These fields can be visible from outside only after they are saved in
  // StateStore
  String diags = null;

  // don't leave the tracking URL pointing to a non-existent AM
  setTrackingUrlToRMAppPage(stateToBeStored);
  String finalTrackingUrl = getOriginalTrackingUrl();
  FinalApplicationStatus finalStatus = null;
  int exitStatus = ContainerExitStatus.INVALID;
  switch (event.getType()) {
  case LAUNCH_FAILED:
    RMAppAttemptLaunchFailedEvent launchFaileEvent =
        (RMAppAttemptLaunchFailedEvent) event;
    diags = launchFaileEvent.getMessage();
    break;
  case REGISTERED:
    diags = getUnexpectedAMRegisteredDiagnostics();
    break;
  case UNREGISTERED:
    RMAppAttemptUnregistrationEvent unregisterEvent =
        (RMAppAttemptUnregistrationEvent) event;
    diags = unregisterEvent.getDiagnostics();
    // reset finalTrackingUrl to url sent by am
    finalTrackingUrl = sanitizeTrackingUrl(unregisterEvent.getFinalTrackingUrl());
    finalStatus = unregisterEvent.getFinalApplicationStatus();
    break;
  case CONTAINER_FINISHED:
    RMAppAttemptContainerFinishedEvent finishEvent =
        (RMAppAttemptContainerFinishedEvent) event;
    diags = getAMContainerCrashedDiagnostics(finishEvent);
    exitStatus = finishEvent.getContainerStatus().getExitStatus();
    break;
  case KILL:
    break;
  case EXPIRE:
    diags = getAMExpiredDiagnostics(event);
    break;
  default:
    break;
  }
  AggregateAppResourceUsage resUsage =
      this.attemptMetrics.getAggregateAppResourceUsage();
  RMStateStore rmStore = rmContext.getStateStore();
  setFinishTime(System.currentTimeMillis());

  ApplicationAttemptStateData attemptState =
      ApplicationAttemptStateData.newInstance(
          applicationAttemptId,  getMasterContainer(),
          rmStore.getCredentialsFromAppAttempt(this),
          startTime, stateToBeStored, finalTrackingUrl, diags,
          finalStatus, exitStatus,
        getFinishTime(), resUsage.getMemorySeconds(),
        resUsage.getVcoreSeconds());
  LOG.info("Updating application attempt " + applicationAttemptId
      + " with final state: " + targetedFinalState + ", and exit status: "
      + exitStatus);
  rmStore.updateApplicationAttemptState(attemptState);
}
 
Example 10
Source File: ApplicationHistoryManagerOnTimelineStore.java    From big-c with Apache License 2.0 4 votes vote down vote up
private static ContainerReport convertToContainerReport(
    TimelineEntity entity, String serverHttpAddress, String user) {
  int allocatedMem = 0;
  int allocatedVcore = 0;
  String allocatedHost = null;
  int allocatedPort = -1;
  int allocatedPriority = 0;
  long createdTime = 0;
  long finishedTime = 0;
  String diagnosticsInfo = null;
  int exitStatus = ContainerExitStatus.INVALID;
  ContainerState state = null;
  String nodeHttpAddress = null;
  Map<String, Object> entityInfo = entity.getOtherInfo();
  if (entityInfo != null) {
    if (entityInfo
        .containsKey(ContainerMetricsConstants.ALLOCATED_MEMORY_ENTITY_INFO)) {
      allocatedMem = (Integer) entityInfo.get(
              ContainerMetricsConstants.ALLOCATED_MEMORY_ENTITY_INFO);
    }
    if (entityInfo
        .containsKey(ContainerMetricsConstants.ALLOCATED_VCORE_ENTITY_INFO)) {
      allocatedVcore = (Integer) entityInfo.get(
              ContainerMetricsConstants.ALLOCATED_VCORE_ENTITY_INFO);
    }
    if (entityInfo
        .containsKey(ContainerMetricsConstants.ALLOCATED_HOST_ENTITY_INFO)) {
      allocatedHost =
          entityInfo
              .get(ContainerMetricsConstants.ALLOCATED_HOST_ENTITY_INFO)
              .toString();
    }
    if (entityInfo
        .containsKey(ContainerMetricsConstants.ALLOCATED_PORT_ENTITY_INFO)) {
      allocatedPort = (Integer) entityInfo.get(
              ContainerMetricsConstants.ALLOCATED_PORT_ENTITY_INFO);
    }
    if (entityInfo
        .containsKey(ContainerMetricsConstants.ALLOCATED_PRIORITY_ENTITY_INFO)) {
      allocatedPriority = (Integer) entityInfo.get(
              ContainerMetricsConstants.ALLOCATED_PRIORITY_ENTITY_INFO);
    }
    if (entityInfo.containsKey(
        ContainerMetricsConstants.ALLOCATED_HOST_HTTP_ADDRESS_ENTITY_INFO)) {
      nodeHttpAddress =
          (String) entityInfo
            .get(ContainerMetricsConstants.ALLOCATED_HOST_HTTP_ADDRESS_ENTITY_INFO);
    }
  }
  List<TimelineEvent> events = entity.getEvents();
  if (events != null) {
    for (TimelineEvent event : events) {
      if (event.getEventType().equals(
          ContainerMetricsConstants.CREATED_EVENT_TYPE)) {
        createdTime = event.getTimestamp();
      } else if (event.getEventType().equals(
          ContainerMetricsConstants.FINISHED_EVENT_TYPE)) {
        finishedTime = event.getTimestamp();
        Map<String, Object> eventInfo = event.getEventInfo();
        if (eventInfo == null) {
          continue;
        }
        if (eventInfo
            .containsKey(ContainerMetricsConstants.DIAGNOSTICS_INFO_EVENT_INFO)) {
          diagnosticsInfo =
              eventInfo.get(
                  ContainerMetricsConstants.DIAGNOSTICS_INFO_EVENT_INFO)
                  .toString();
        }
        if (eventInfo
            .containsKey(ContainerMetricsConstants.EXIT_STATUS_EVENT_INFO)) {
          exitStatus = (Integer) eventInfo.get(
                  ContainerMetricsConstants.EXIT_STATUS_EVENT_INFO);
        }
        if (eventInfo
            .containsKey(ContainerMetricsConstants.STATE_EVENT_INFO)) {
          state =
              ContainerState.valueOf(eventInfo.get(
                  ContainerMetricsConstants.STATE_EVENT_INFO).toString());
        }
      }
    }
  }
  NodeId allocatedNode = NodeId.newInstance(allocatedHost, allocatedPort);
  ContainerId containerId =
      ConverterUtils.toContainerId(entity.getEntityId());
  String logUrl = WebAppUtils.getAggregatedLogURL(
      serverHttpAddress,
      allocatedNode.toString(),
      containerId.toString(),
      containerId.toString(),
      user);
  return ContainerReport.newInstance(
      ConverterUtils.toContainerId(entity.getEntityId()),
      Resource.newInstance(allocatedMem, allocatedVcore),
      NodeId.newInstance(allocatedHost, allocatedPort),
      Priority.newInstance(allocatedPriority),
      createdTime, finishedTime, diagnosticsInfo, logUrl, exitStatus, state,
      nodeHttpAddress);
}