org.apache.hadoop.yarn.api.records.ContainerStatus Java Examples

The following examples show how to use org.apache.hadoop.yarn.api.records.ContainerStatus. 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: YarnResourceManager.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void onContainersCompleted(final List<ContainerStatus> statuses) {
	runAsync(() -> {
			log.debug("YARN ResourceManager reported the following containers completed: {}.", statuses);
			for (final ContainerStatus containerStatus : statuses) {

				final ResourceID resourceId = new ResourceID(containerStatus.getContainerId().toString());
				final YarnWorkerNode yarnWorkerNode = workerNodeMap.remove(resourceId);

				if (yarnWorkerNode != null) {
					// Container completed unexpectedly ~> start a new one
					requestYarnContainerIfRequired();
				}
				// Eagerly close the connection with task manager.
				closeTaskManagerConnection(resourceId, new Exception(containerStatus.getDiagnostics()));
			}
		}
	);
}
 
Example #2
Source File: TestLocalContainerAllocator.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
public AllocateResponse allocate(AllocateRequest request)
    throws YarnException, IOException {
  Assert.assertEquals("response ID mismatch",
      responseId, request.getResponseId());
  ++responseId;
  org.apache.hadoop.yarn.api.records.Token yarnToken = null;
  if (amToken != null) {
    yarnToken = org.apache.hadoop.yarn.api.records.Token.newInstance(
        amToken.getIdentifier(), amToken.getKind().toString(),
        amToken.getPassword(), amToken.getService().toString());
  }
  return AllocateResponse.newInstance(responseId,
      Collections.<ContainerStatus>emptyList(),
      Collections.<Container>emptyList(),
      Collections.<NodeReport>emptyList(),
      Resources.none(), null, 1, null,
      Collections.<NMToken>emptyList(),
      yarnToken,
      Collections.<ContainerResourceIncrease>emptyList(),
      Collections.<ContainerResourceDecrease>emptyList());
}
 
Example #3
Source File: TaskSchedulerEventHandler.java    From incubator-tez with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void containerCompleted(Object task, ContainerStatus containerStatus) {
  // Inform the Containers about completion.
  AMContainer amContainer = appContext.getAllContainers().get(containerStatus.getContainerId());
  if (amContainer != null) {
    String message = null;
    int exitStatus = containerStatus.getExitStatus();
    if (exitStatus == ContainerExitStatus.PREEMPTED) {
      message = "Container preempted externally. ";
    } else if (exitStatus == ContainerExitStatus.DISKS_FAILED) {
      message = "Container disk failed. ";
    } else {
      message = "Container failed. ";
    }
    if (containerStatus.getDiagnostics() != null) {
      message += containerStatus.getDiagnostics();
    }
    sendEvent(new AMContainerEventCompleted(amContainer.getContainerId(), exitStatus, message));
  }
}
 
Example #4
Source File: ContainerManagerImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Get a list of container statuses running on this NodeManager
 */
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {

  List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : request.getContainerIds()) {
    try {
      ContainerStatus status = getContainerStatusInternal(id, identifier);
      succeededRequests.add(status);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return GetContainerStatusesResponse.newInstance(succeededRequests,
    failedRequests);
}
 
Example #5
Source File: BuilderUtils.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public static AllocateResponse newAllocateResponse(int responseId,
    List<ContainerStatus> completedContainers,
    List<Container> allocatedContainers, List<NodeReport> updatedNodes,
    Resource availResources, AMCommand command, int numClusterNodes,
    PreemptionMessage preempt) {
  AllocateResponse response = recordFactory
      .newRecordInstance(AllocateResponse.class);
  response.setNumClusterNodes(numClusterNodes);
  response.setResponseId(responseId);
  response.setCompletedContainersStatuses(completedContainers);
  response.setAllocatedContainers(allocatedContainers);
  response.setUpdatedNodes(updatedNodes);
  response.setAvailableResources(availResources);
  response.setAMCommand(command);
  response.setPreemptionMessage(preempt);

  return response;
}
 
Example #6
Source File: ApplicationMaster.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private static void publishContainerEndEvent(
    final TimelineClient timelineClient, ContainerStatus container,
    String domainId, UserGroupInformation ugi) {
  final TimelineEntity entity = new TimelineEntity();
  entity.setEntityId(container.getContainerId().toString());
  entity.setEntityType(DSEntity.DS_CONTAINER.toString());
  entity.setDomainId(domainId);
  entity.addPrimaryFilter("user", ugi.getShortUserName());
  TimelineEvent event = new TimelineEvent();
  event.setTimestamp(System.currentTimeMillis());
  event.setEventType(DSEvent.DS_CONTAINER_END.toString());
  event.addEventInfo("State", container.getState().name());
  event.addEventInfo("Exit Status", container.getExitStatus());
  entity.addEvent(event);
  try {
    timelineClient.putEntities(entity);
  } catch (YarnException | IOException e) {
    LOG.error("Container end event could not be published for "
        + container.getContainerId().toString(), e);
  }
}
 
Example #7
Source File: NodeStatusUpdaterImpl.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private NodeStatus getNodeStatus(int responseId) throws IOException {

    NodeHealthStatus nodeHealthStatus = this.context.getNodeHealthStatus();
    nodeHealthStatus.setHealthReport(healthChecker.getHealthReport());
    nodeHealthStatus.setIsNodeHealthy(healthChecker.isHealthy());
    nodeHealthStatus.setLastHealthReportTime(healthChecker
      .getLastHealthReportTime());
    if (LOG.isDebugEnabled()) {
      LOG.debug("Node's health-status : " + nodeHealthStatus.getIsNodeHealthy()
          + ", " + nodeHealthStatus.getHealthReport());
    }
    List<ContainerStatus> containersStatuses = getContainerStatuses();
    NodeStatus nodeStatus =
        NodeStatus.newInstance(nodeId, responseId, containersStatuses,
          createKeepAliveApplicationList(), nodeHealthStatus);

    return nodeStatus;
  }
 
Example #8
Source File: RMAppAttemptImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
private String getAMContainerCrashedDiagnostics(
    RMAppAttemptContainerFinishedEvent finishEvent) {
  ContainerStatus status = finishEvent.getContainerStatus();
  StringBuilder diagnosticsBuilder = new StringBuilder();
  diagnosticsBuilder.append("AM Container for ").append(
    finishEvent.getApplicationAttemptId()).append(
    " exited with ").append(" exitCode: ").append(status.getExitStatus()).
    append("\n");
  if (this.getTrackingUrl() != null) {
    diagnosticsBuilder.append("For more detailed output,").append(
      " check application tracking page:").append(
      this.getTrackingUrl()).append(
      "Then, click on links to logs of each attempt.\n");
  }
  diagnosticsBuilder.append("Diagnostics: ").append(status.getDiagnostics())
      .append("Failing this attempt");
  return diagnosticsBuilder.toString();
}
 
Example #9
Source File: BaseContainerManagerTest.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public static void waitForContainerState(ContainerManagementProtocol containerManager,
      ContainerId containerID, ContainerState finalState, int timeOutMax)
      throws InterruptedException, YarnException, IOException {
List<ContainerId> list = new ArrayList<ContainerId>();
list.add(containerID);
GetContainerStatusesRequest request =
    GetContainerStatusesRequest.newInstance(list);
ContainerStatus containerStatus =
    containerManager.getContainerStatuses(request).getContainerStatuses()
      .get(0);
int timeoutSecs = 0;
  while (!containerStatus.getState().equals(finalState)
      && timeoutSecs++ < timeOutMax) {
      Thread.sleep(1000);
      LOG.info("Waiting for container to get into state " + finalState
          + ". Current state is " + containerStatus.getState());
      containerStatus = containerManager.getContainerStatuses(request).getContainerStatuses().get(0);
    }
    LOG.info("Container state is " + containerStatus.getState());
    Assert.assertEquals("ContainerState is not correct (timedout)",
        finalState, containerStatus.getState());
  }
 
Example #10
Source File: NMClientImpl.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
public ContainerStatus getContainerStatus(ContainerId containerId,
    NodeId nodeId) throws YarnException, IOException {

  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    GetContainerStatusesResponse response =
        proxy.getContainerManagementProtocol().getContainerStatuses(
            GetContainerStatusesRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t =
          response.getFailedRequests().get(containerId).deSerialize();
      parseAndThrowException(t);
    }
    ContainerStatus containerStatus = response.getContainerStatuses().get(0);
    return containerStatus;
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
 
Example #11
Source File: NodeStatusUpdaterImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
private NodeStatus getNodeStatus(int responseId) throws IOException {

    NodeHealthStatus nodeHealthStatus = this.context.getNodeHealthStatus();
    nodeHealthStatus.setHealthReport(healthChecker.getHealthReport());
    nodeHealthStatus.setIsNodeHealthy(healthChecker.isHealthy());
    nodeHealthStatus.setLastHealthReportTime(healthChecker
      .getLastHealthReportTime());
    if (LOG.isDebugEnabled()) {
      LOG.debug("Node's health-status : " + nodeHealthStatus.getIsNodeHealthy()
          + ", " + nodeHealthStatus.getHealthReport());
    }
    List<ContainerStatus> containersStatuses = getContainerStatuses();
    NodeStatus nodeStatus =
        NodeStatus.newInstance(nodeId, responseId, containersStatuses,
          createKeepAliveApplicationList(), nodeHealthStatus);

    return nodeStatus;
  }
 
Example #12
Source File: ContainerManagerImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
private ContainerStatus getContainerStatusInternal(ContainerId containerID,
    NMTokenIdentifier nmTokenIdentifier) throws YarnException {
  String containerIDStr = containerID.toString();
  Container container = this.context.getContainers().get(containerID);

  LOG.info("Getting container-status for " + containerIDStr);
  authorizeGetAndStopContainerRequest(containerID, container, false,
    nmTokenIdentifier);

  if (container == null) {
    if (nodeStatusUpdater.isContainerRecentlyStopped(containerID)) {
      throw RPCUtil.getRemoteException("Container " + containerIDStr
        + " was recently stopped on node manager.");
    } else {
      throw RPCUtil.getRemoteException("Container " + containerIDStr
        + " is not handled by this NodeManager");
    }
  }
  ContainerStatus containerStatus = container.cloneAndGetContainerStatus();
  LOG.info("Returning " + containerStatus);
  return containerStatus;
}
 
Example #13
Source File: RMAppAttemptImpl.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private String getAMContainerCrashedDiagnostics(
    RMAppAttemptContainerFinishedEvent finishEvent) {
  ContainerStatus status = finishEvent.getContainerStatus();
  StringBuilder diagnosticsBuilder = new StringBuilder();
  diagnosticsBuilder.append("AM Container for ").append(
    finishEvent.getApplicationAttemptId()).append(
    " exited with ").append(" exitCode: ").append(status.getExitStatus()).
    append("\n");
  if (this.getTrackingUrl() != null) {
    diagnosticsBuilder.append("For more detailed output,").append(
      " check application tracking page:").append(
      this.getTrackingUrl()).append(
      "Then, click on links to logs of each attempt.\n");
  }
  diagnosticsBuilder.append("Diagnostics: ").append(status.getDiagnostics())
      .append("Failing this attempt");
  return diagnosticsBuilder.toString();
}
 
Example #14
Source File: StreamingAppMasterService.java    From Bats with Apache License 2.0 5 votes vote down vote up
@Override
public void onContainerStatusReceived(ContainerId containerId, ContainerStatus containerStatus)
{
  LOG.debug("Container Status: id={}, status={}", containerId, containerStatus);
  if (containerStatus.getState() != ContainerState.RUNNING) {
    recoverContainer(containerId);
  }
}
 
Example #15
Source File: TestAMRMClientAsync.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void onContainersCompleted(List<ContainerStatus> statuses) {
  completedContainers = statuses;
  // wait for containers to be taken before returning
  synchronized (completedContainers) {
    while (completedContainers != null) {
      try {
        completedContainers.wait();
      } catch (InterruptedException ex) {
        LOG.error("Interrupted during wait", ex);
      }
    }
  }
}
 
Example #16
Source File: NMHeartBeatHandler.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
protected Resource getResourcesUnderUse(RMNodeStatusEvent statusEvent) {
  Resource usedResources = Resource.newInstance(0, 0);
  for (ContainerStatus status : statusEvent.getContainers()) {
    if (containerInUse(status)) {
      RMContainer rmContainer = yarnScheduler.getRMContainer(status.getContainerId());
      // (sdaingade) This check is needed as RMContainer information may not be populated
      // immediately after a RM restart.
      if (rmContainer != null) {
        Resources.addTo(usedResources, rmContainer.getAllocatedResource());
      }
    }
  }
  return usedResources;
}
 
Example #17
Source File: RMContainerImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public RMContainerState transition(RMContainerImpl container,
    RMContainerEvent event) {
  NMContainerStatus report =
      ((RMContainerRecoverEvent) event).getContainerReport();
  if (report.getContainerState().equals(ContainerState.COMPLETE)) {
    ContainerStatus status =
        ContainerStatus.newInstance(report.getContainerId(),
          report.getContainerState(), report.getDiagnostics(),
          report.getContainerExitStatus());

    new FinishedTransition().transition(container,
      new RMContainerFinishedEvent(container.containerId, status,
        RMContainerEventType.FINISHED));
    return RMContainerState.COMPLETED;
  } else if (report.getContainerState().equals(ContainerState.RUNNING)) {
    // Tell the app
    container.eventHandler.handle(new RMAppRunningOnNodeEvent(container
        .getApplicationAttemptId().getApplicationId(), container.nodeId));
    return RMContainerState.RUNNING;
  } else {
    // This can never happen.
    LOG.warn("RMContainer received unexpected recover event with container"
        + " state " + report.getContainerState() + " while recovering.");
    return RMContainerState.RUNNING;
  }
}
 
Example #18
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 #19
Source File: RMContainerAllocator.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
public TaskAttemptEvent createContainerFinishedEvent(ContainerStatus cont,
    TaskAttemptId attemptID) {
  if (cont.getExitStatus() == ContainerExitStatus.ABORTED
      || cont.getExitStatus() == ContainerExitStatus.PREEMPTED) {
    // killed by framework
    return new TaskAttemptEvent(attemptID,
        TaskAttemptEventType.TA_KILL);
  } else {
    return new TaskAttemptEvent(attemptID,
        TaskAttemptEventType.TA_CONTAINER_COMPLETED);
  }
}
 
Example #20
Source File: RMNodeStatusEvent.java    From big-c with Apache License 2.0 5 votes vote down vote up
public RMNodeStatusEvent(NodeId nodeId, NodeHealthStatus nodeHealthStatus,
    List<ContainerStatus> collection, List<ApplicationId> keepAliveAppIds,
    NodeHeartbeatResponse latestResponse) {
  super(nodeId, RMNodeEventType.STATUS_UPDATE);
  this.nodeHealthStatus = nodeHealthStatus;
  this.containersCollection = collection;
  this.keepAliveAppIds = keepAliveAppIds;
  this.latestResponse = latestResponse;
}
 
Example #21
Source File: NodeStatus.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static NodeStatus newInstance(NodeId nodeId, int responseId,
    List<ContainerStatus> containerStatuses,
    List<ApplicationId> keepAliveApplications,
    NodeHealthStatus nodeHealthStatus) {
  NodeStatus nodeStatus = Records.newRecord(NodeStatus.class);
  nodeStatus.setResponseId(responseId);
  nodeStatus.setNodeId(nodeId);
  nodeStatus.setContainersStatuses(containerStatuses);
  nodeStatus.setKeepAliveApplications(keepAliveApplications);
  nodeStatus.setNodeHealthStatus(nodeHealthStatus);
  return nodeStatus;
}
 
Example #22
Source File: TestNodeStatusUpdater.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static Container getMockContainer(ContainerStatus containerStatus) {
  ContainerImpl container = mock(ContainerImpl.class);
  when(container.cloneAndGetContainerStatus()).thenReturn(containerStatus);
  when(container.getCurrentState()).thenReturn(containerStatus.getState());
  when(container.getContainerId()).thenReturn(
    containerStatus.getContainerId());
  if (containerStatus.getState().equals(ContainerState.COMPLETE)) {
    when(container.getContainerState())
      .thenReturn(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState.DONE);
  } else if (containerStatus.getState().equals(ContainerState.RUNNING)) {
    when(container.getContainerState())
    .thenReturn(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState.RUNNING);
  }
  return container;
}
 
Example #23
Source File: AllocateResponsePBImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private synchronized void initLocalFinishedContainerList() {
  if (this.completedContainersStatuses != null) {
    return;
  }
  AllocateResponseProtoOrBuilder p = viaProto ? proto : builder;
  List<ContainerStatusProto> list = p.getCompletedContainerStatusesList();
  completedContainersStatuses = new ArrayList<ContainerStatus>();

  for (ContainerStatusProto c : list) {
    completedContainersStatuses.add(convertFromProtoFormat(c));
  }
}
 
Example #24
Source File: ResourceTrackerService.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to handle received ContainerStatus. If this corresponds to
 * the completion of a master-container of a managed AM,
 * we call the handler for RMAppAttemptContainerFinishedEvent.
 */
@SuppressWarnings("unchecked")
@VisibleForTesting
void handleNMContainerStatus(NMContainerStatus containerStatus, NodeId nodeId) {
  ApplicationAttemptId appAttemptId =
      containerStatus.getContainerId().getApplicationAttemptId();
  RMApp rmApp =
      rmContext.getRMApps().get(appAttemptId.getApplicationId());
  if (rmApp == null) {
    LOG.error("Received finished container : "
        + containerStatus.getContainerId()
        + " for unknown application " + appAttemptId.getApplicationId()
        + " Skipping.");
    return;
  }

  if (rmApp.getApplicationSubmissionContext().getUnmanagedAM()) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Ignoring container completion status for unmanaged AM "
          + rmApp.getApplicationId());
    }
    return;
  }

  RMAppAttempt rmAppAttempt = rmApp.getRMAppAttempt(appAttemptId);
  Container masterContainer = rmAppAttempt.getMasterContainer();
  if (masterContainer.getId().equals(containerStatus.getContainerId())
      && containerStatus.getContainerState() == ContainerState.COMPLETE) {
    ContainerStatus status =
        ContainerStatus.newInstance(containerStatus.getContainerId(),
          containerStatus.getContainerState(), containerStatus.getDiagnostics(),
          containerStatus.getContainerExitStatus());
    // sending master container finished event.
    RMAppAttemptContainerFinishedEvent evt =
        new RMAppAttemptContainerFinishedEvent(appAttemptId, status,
            nodeId);
    rmContext.getDispatcher().getEventHandler().handle(evt);
  }
}
 
Example #25
Source File: TestAMRMClientAsync.java    From big-c with Apache License 2.0 5 votes vote down vote up
private AllocateResponse createAllocateResponse(
    List<ContainerStatus> completed, List<Container> allocated,
    List<NMToken> nmTokens) {
  AllocateResponse response =
      AllocateResponse.newInstance(0, completed, allocated,
          new ArrayList<NodeReport>(), null, null, 1, null, nmTokens);
  return response;
}
 
Example #26
Source File: TestRMAppAttemptTransitions.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void testUnmanagedAMSuccess(String url) {
  unmanagedAM = true;
  when(submissionContext.getUnmanagedAM()).thenReturn(true);
  // submit AM and check it goes to LAUNCHED state
  scheduleApplicationAttempt();
  testAppAttemptLaunchedState(null);
  verify(amLivelinessMonitor, times(1)).register(
      applicationAttempt.getAppAttemptId());

  // launch AM
  runApplicationAttempt(null, "host", 8042, url, true);

  // complete a container
  Container container = mock(Container.class);
  when(container.getNodeId()).thenReturn(NodeId.newInstance("host", 1234));
  application.handle(new RMAppRunningOnNodeEvent(application.getApplicationId(),
      container.getNodeId()));
  applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent(
      applicationAttempt.getAppAttemptId(), mock(ContainerStatus.class),
      container.getNodeId()));
  // complete AM
  String diagnostics = "Successful";
  FinalApplicationStatus finalStatus = FinalApplicationStatus.SUCCEEDED;
  applicationAttempt.handle(new RMAppAttemptUnregistrationEvent(
      applicationAttempt.getAppAttemptId(), url, finalStatus,
      diagnostics));
  testAppAttemptFinishedState(null, finalStatus, url, diagnostics, 1,
      true);
  assertFalse(transferStateFromPreviousAttempt);
}
 
Example #27
Source File: RMAppAttemptImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void
    transition(RMAppAttemptImpl appAttempt, RMAppAttemptEvent event) {
  RMAppAttemptContainerFinishedEvent containerFinishedEvent =
      (RMAppAttemptContainerFinishedEvent) event;
  ContainerStatus containerStatus =
      containerFinishedEvent.getContainerStatus();

  // If this is the AM container, it means the AM container is finished,
  // but we are not yet acknowledged that the final state has been saved.
  // Thus, we still return FINAL_SAVING state here.
  if (appAttempt.masterContainer.getId().equals(
    containerStatus.getContainerId())) {
    appAttempt.sendAMContainerToNM(appAttempt, containerFinishedEvent);

    if (appAttempt.targetedFinalState.equals(RMAppAttemptState.FAILED)
        || appAttempt.targetedFinalState.equals(RMAppAttemptState.KILLED)) {
      // ignore Container_Finished Event if we were supposed to reach
      // FAILED/KILLED state.
      return;
    }

    // pass in the earlier AMUnregistered Event also, as this is needed for
    // AMFinishedAfterFinalSavingTransition later on
    appAttempt.rememberTargetTransitions(event,
      new AMFinishedAfterFinalSavingTransition(
        appAttempt.eventCausingFinalSaving), RMAppAttemptState.FINISHED);
    return;
  }

  // Add all finished containers so that they can be acked to NM.
  addJustFinishedContainer(appAttempt, containerFinishedEvent);
}
 
Example #28
Source File: GetContainerStatusesResponse.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Private
@Unstable
public static GetContainerStatusesResponse newInstance(
    List<ContainerStatus> statuses,
    Map<ContainerId, SerializedException> failedRequests) {
  GetContainerStatusesResponse response =
      Records.newRecord(GetContainerStatusesResponse.class);
  response.setContainerStatuses(statuses);
  response.setFailedRequests(failedRequests);
  return response;
}
 
Example #29
Source File: YarnService.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
@Override
public void onContainerStatusReceived(ContainerId containerId, ContainerStatus containerStatus) {
  if (eventSubmitter.isPresent()) {
    eventSubmitter.get().submit(GobblinYarnEventConstants.EventNames.CONTAINER_STATUS_RECEIVED,
        buildContainerStatusEventMetadata(containerStatus).build());
  }

  LOGGER.info(String.format("Received container status for container %s: %s", containerId, containerStatus));
}
 
Example #30
Source File: CompositeInterceptor.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
@Override
public void beforeCompletedContainer(RMContainer rmContainer, ContainerStatus containerStatus, RMContainerEventType event) {
  if (rmContainer != null && rmContainer.getContainer() != null) {
    NodeId nodeId = rmContainer.getContainer().getNodeId();
    for (YarnSchedulerInterceptor interceptor : interceptors.values()) {
      if (interceptor.getCallBackFilter().allowCallBacksForNode(nodeId)) {
        interceptor.beforeCompletedContainer(rmContainer, containerStatus, event);
      }
    }
  }
}