gpt4 book ai didi

org.apache.samza.job.yarn.YarnClusterResourceManager.getIDForContainer()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 00:41:31 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.samza.job.yarn.YarnClusterResourceManager.getIDForContainer()方法的一些代码示例,展示了YarnClusterResourceManager.getIDForContainer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YarnClusterResourceManager.getIDForContainer()方法的具体详情如下:
包路径:org.apache.samza.job.yarn.YarnClusterResourceManager
类名称:YarnClusterResourceManager
方法名:getIDForContainer

YarnClusterResourceManager.getIDForContainer介绍

[英]Given a lookupContainerId from Yarn (for example: containerId_app_12345, this method returns the SamzaContainer ID in the range [0,N-1] that maps to it.
[中]给定一个lookupContainerId from Thread(例如:containerId_app_12345),该方法返回映射到它的[0,N-1]范围内的SamzaContainer ID。

代码示例

代码示例来源:origin: org.apache.samza/samza-yarn_2.11

/**
 * Callback invoked from Yarn when containers complete. This translates the yarn callbacks into Samza specific
 * ones.
 *
 * @param statuses the YarnContainerStatus callbacks from Yarn.
 */
@Override
public void onContainersCompleted(List<ContainerStatus> statuses) {
 List<SamzaResourceStatus> samzaResrcStatuses = new ArrayList<>();
 for(ContainerStatus status: statuses) {
  log.info("Container completed from RM " + status);
  SamzaResourceStatus samzaResrcStatus = new SamzaResourceStatus(status.getContainerId().toString(), status.getDiagnostics(), status.getExitStatus());
  samzaResrcStatuses.add(samzaResrcStatus);
  String completedContainerID = getIDForContainer(status.getContainerId().toString());
  log.info("Completed container had ID: {}", completedContainerID);
  //remove the container from the list of running containers, if failed with a non-zero exit code, add it to the list of
  //failed containers.
  if(!completedContainerID.equals(INVALID_YARN_CONTAINER_ID)){
   if(state.runningYarnContainers.containsKey(completedContainerID)) {
    log.info("Removing container ID {} from completed containers", completedContainerID);
    state.runningYarnContainers.remove(completedContainerID);
    if(status.getExitStatus() != ContainerExitStatus.SUCCESS)
     state.failedContainersStatus.put(status.getContainerId().toString(), status);
   }
  }
 }
 clusterManagerCallback.onResourcesCompleted(samzaResrcStatuses);
}

代码示例来源:origin: org.apache.samza/samza-yarn

/**
 * Callback invoked from Yarn when containers complete. This translates the yarn callbacks into Samza specific
 * ones.
 *
 * @param statuses the YarnContainerStatus callbacks from Yarn.
 */
@Override
public void onContainersCompleted(List<ContainerStatus> statuses) {
 List<SamzaResourceStatus> samzaResrcStatuses = new ArrayList<>();
 for(ContainerStatus status: statuses) {
  log.info("Container completed from RM " + status);
  SamzaResourceStatus samzaResrcStatus = new SamzaResourceStatus(status.getContainerId().toString(), status.getDiagnostics(), status.getExitStatus());
  samzaResrcStatuses.add(samzaResrcStatus);
  String completedContainerID = getIDForContainer(status.getContainerId().toString());
  log.info("Completed container had ID: {}", completedContainerID);
  //remove the container from the list of running containers, if failed with a non-zero exit code, add it to the list of
  //failed containers.
  if(!completedContainerID.equals(INVALID_YARN_CONTAINER_ID)){
   if(state.runningYarnContainers.containsKey(completedContainerID)) {
    log.info("Removing container ID {} from completed containers", completedContainerID);
    state.runningYarnContainers.remove(completedContainerID);
    if(status.getExitStatus() != ContainerExitStatus.SUCCESS)
     state.failedContainersStatus.put(status.getContainerId().toString(), status);
   }
  }
 }
 clusterManagerCallback.onResourcesCompleted(samzaResrcStatuses);
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com