当前位置: 首页>>代码示例>>Java>>正文


Java StartContainerRequest.getContainerLaunchContext方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest.getContainerLaunchContext方法的典型用法代码示例。如果您正苦于以下问题:Java StartContainerRequest.getContainerLaunchContext方法的具体用法?Java StartContainerRequest.getContainerLaunchContext怎么用?Java StartContainerRequest.getContainerLaunchContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest的用法示例。


在下文中一共展示了StartContainerRequest.getContainerLaunchContext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: recoverContainer

import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void recoverContainer(RecoveredContainerState rcs)
    throws IOException {
  StartContainerRequest req = rcs.getStartRequest();
  ContainerLaunchContext launchContext = req.getContainerLaunchContext();
  ContainerTokenIdentifier token =
      BuilderUtils.newContainerTokenIdentifier(req.getContainerToken());
  ContainerId containerId = token.getContainerID();
  ApplicationId appId =
      containerId.getApplicationAttemptId().getApplicationId();

  LOG.info("Recovering " + containerId + " in state " + rcs.getStatus()
      + " with exit code " + rcs.getExitCode());

  if (context.getApplications().containsKey(appId)) {
    Credentials credentials = parseCredentials(launchContext);
    Container container = new ContainerImpl(getConfig(), dispatcher,
        context.getNMStateStore(), req.getContainerLaunchContext(),
        credentials, metrics, token, rcs.getStatus(), rcs.getExitCode(),
        rcs.getDiagnostics(), rcs.getKilled());
    context.getContainers().put(containerId, container);
    dispatcher.getEventHandler().handle(
        new ApplicationContainerInitEvent(container));
  } else {
    if (rcs.getStatus() != RecoveredContainerStatus.COMPLETED) {
      LOG.warn(containerId + " has no corresponding application!");
    }
    LOG.info("Adding " + containerId + " to recently stopped containers");
    nodeStatusUpdater.addCompletedContainer(containerId);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:32,代码来源:ContainerManagerImpl.java

示例2: recoverContainer

import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void recoverContainer(RecoveredContainerState rcs)
    throws IOException {
  StartContainerRequest req = rcs.getStartRequest();
  ContainerLaunchContext launchContext = req.getContainerLaunchContext();
  ContainerTokenIdentifier token =
      BuilderUtils.newContainerTokenIdentifier(req.getContainerToken());
  ContainerId containerId = token.getContainerID();
  ApplicationId appId =
      containerId.getApplicationAttemptId().getApplicationId();

  LOG.info("Recovering " + containerId + " in state " + rcs.getStatus()
      + " with exit code " + rcs.getExitCode());

  if (context.getApplications().containsKey(appId)) {
    Credentials credentials =
        YarnServerSecurityUtils.parseCredentials(launchContext);
    Container container = new ContainerImpl(getConfig(), dispatcher,
        context.getNMStateStore(), req.getContainerLaunchContext(),
        credentials, metrics, token, rcs.getStatus(), rcs.getExitCode(),
        rcs.getDiagnostics(), rcs.getKilled(), rcs.getCapability());
    context.getContainers().put(containerId, container);
    dispatcher.getEventHandler().handle(
        new ApplicationContainerInitEvent(container));
  } else {
    if (rcs.getStatus() != RecoveredContainerStatus.COMPLETED) {
      LOG.warn(containerId + " has no corresponding application!");
    }
    LOG.info("Adding " + containerId + " to recently stopped containers");
    nodeStatusUpdater.addCompletedContainer(containerId);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:33,代码来源:ContainerManagerImpl.java

示例3: recoverContainer

import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void recoverContainer(RecoveredContainerState rcs)
    throws IOException {
  StartContainerRequest req = rcs.getStartRequest();
  ContainerLaunchContext launchContext = req.getContainerLaunchContext();
  ContainerTokenIdentifier token =
      BuilderUtils.newContainerTokenIdentifier(req.getContainerToken());
  ContainerId containerId = token.getContainerID();
  ApplicationId appId =
      containerId.getApplicationAttemptId().getApplicationId();

  LOG.info("Recovering " + containerId + " in state " + rcs.getStatus()
      + " with exit code " + rcs.getExitCode());
  
  Set<Integer> cores= this.context.getCoresManager().allocateCores(containerId, 
  		                          token.getResource().getVirtualCores());
 
  if (context.getApplications().containsKey(appId)) {
    Credentials credentials = parseCredentials(launchContext);
    Container container = new ContainerImpl(this.context,getConfig(), dispatcher,
        context.getNMStateStore(), req.getContainerLaunchContext(),
        credentials, metrics, token, rcs.getStatus(), rcs.getExitCode(),
        rcs.getDiagnostics(), rcs.getKilled(),cores);
    
    context.getContainers().put(containerId, container);
    dispatcher.getEventHandler().handle(
        new ApplicationContainerInitEvent(container));
  } else {
    if (rcs.getStatus() != RecoveredContainerStatus.COMPLETED) {
      LOG.warn(containerId + " has no corresponding application!");
    }
    LOG.info("Adding " + containerId + " to recently stopped containers");
    nodeStatusUpdater.addCompletedContainer(containerId);
  }
}
 
开发者ID:yncxcw,项目名称:big-c,代码行数:36,代码来源:ContainerManagerImpl.java

示例4: recoverContainer

import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void recoverContainer(RecoveredContainerState rcs)
    throws IOException {
  StartContainerRequest req = rcs.getStartRequest();
  ContainerLaunchContext launchContext = req.getContainerLaunchContext();
  ContainerTokenIdentifier token =
      BuilderUtils.newContainerTokenIdentifier(req.getContainerToken());
  ContainerId containerId = token.getContainerID();
  ApplicationId appId =
      containerId.getApplicationAttemptId().getApplicationId();

  LOG.info("Recovering " + containerId + " in state " + rcs.getStatus()
      + " with exit code " + rcs.getExitCode());

  Application app = context.getApplications().get(appId);
  if (app != null) {
    Credentials credentials =
        YarnServerSecurityUtils.parseCredentials(launchContext);
    Container container = new ContainerImpl(getConfig(), dispatcher,
        req.getContainerLaunchContext(),
        credentials, metrics, token, context, rcs);
    context.getContainers().put(containerId, container);
    app.handle(new ApplicationContainerInitEvent(container));
  } else {
    if (rcs.getStatus() != RecoveredContainerStatus.COMPLETED) {
      LOG.warn(containerId + " has no corresponding application!");
    }
    LOG.info("Adding " + containerId + " to recently stopped containers");
    nodeStatusUpdater.addCompletedContainer(containerId);
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:32,代码来源:ContainerManagerImpl.java

示例5: startContainers

import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest; //导入方法依赖的package包/类
@Override
public ContainersResponse startContainers(List<StartContainerRequest> requests)
    throws IOException {

  List<ContainerId> succeededContainers = new ArrayList<ContainerId>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();

  for (StartContainerRequest startContainerRequest : requests) {
    ContainerLaunchContext containerLaunchContext = startContainerRequest
        .getContainerLaunchContext();
    Token containerToken = startContainerRequest.getContainerToken();
    String containerIdStr = new String(containerToken.getIdentifier().array());
    ContainerId containerId = ConverterUtils.toContainerId(containerIdStr);

    int pbsJobId = containersInfo.get(containerId);

    try {
      LOG.info("Starting container : " + containerIdStr
          + " for the PBS Job id : " + pbsJobId);
      // Launch Containers
      String containerHostName = ContainerResponses.getResponse(pbsJobId)
          .getContainerHostName();
      PBSCommandExecutor.launchContainer(containerLaunchContext,
          containerIdStr, null, conf, pbsJobId, false, containerHostName);
      succeededContainers.add(containerId);
      LaunchedPBSJobs.addRunningContainer(containerId, pbsJobId);
    } catch (Throwable t) {
      LOG.error("Failed to launch container : " + containerIdStr, t);
      SerializedException exception = SerializedException.newInstance(t);
      failedRequests.put(containerId, exception);
    }
  }

  Map<String, ByteBuffer> allServicesMetaData = new HashMap<String, ByteBuffer>();
  ByteBuffer buffer = ByteBuffer.allocate(200);
  buffer.putInt(100);
  allServicesMetaData.put("mapreduce_shuffle", buffer);

  ContainersResponse response = new ContainersResponse();
  response.setServicesMetaData(allServicesMetaData);
  response.setFailedContainers(failedRequests);
  response.setSucceededContainers(succeededContainers);
  return response;
}
 
开发者ID:intel-hpdd,项目名称:scheduling-connector-for-hadoop,代码行数:46,代码来源:PBSContainerManager.java

示例6: startContainerInternal

import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void startContainerInternal(NMTokenIdentifier nmTokenIdentifier,
    ContainerTokenIdentifier containerTokenIdentifier,
    StartContainerRequest request) throws YarnException, IOException {

  /*
   * 1) It should save the NMToken into NMTokenSecretManager. This is done
   * here instead of RPC layer because at the time of opening/authenticating
   * the connection it doesn't know what all RPC calls user will make on it.
   * Also new NMToken is issued only at startContainer (once it gets renewed).
   * 
   * 2) It should validate containerToken. Need to check below things. a) It
   * is signed by correct master key (part of retrieve password). b) It
   * belongs to correct Node Manager (part of retrieve password). c) It has
   * correct RMIdentifier. d) It is not expired.
   */
  authorizeStartRequest(nmTokenIdentifier, containerTokenIdentifier);
 
  if (containerTokenIdentifier.getRMIdentifer() != nodeStatusUpdater
      .getRMIdentifier()) {
      // Is the container coming from unknown RM
      StringBuilder sb = new StringBuilder("\nContainer ");
      sb.append(containerTokenIdentifier.getContainerID().toString())
        .append(" rejected as it is allocated by a previous RM");
      throw new InvalidContainerException(sb.toString());
  }
  // update NMToken
  updateNMTokenIdentifier(nmTokenIdentifier);

  ContainerId containerId = containerTokenIdentifier.getContainerID();
  String containerIdStr = containerId.toString();
  String user = containerTokenIdentifier.getApplicationSubmitter();

  LOG.info("Start request for " + containerIdStr + " by user " + user);

  ContainerLaunchContext launchContext = request.getContainerLaunchContext();

  Credentials credentials = parseCredentials(launchContext);

  Container container =
      new ContainerImpl(getConfig(), this.dispatcher, launchContext,
        credentials, metrics, containerTokenIdentifier);
  ApplicationId applicationID =
      containerId.getApplicationAttemptId().getApplicationId();
  if (context.getContainers().putIfAbsent(containerId, container) != null) {
    NMAuditLogger.logFailure(user, AuditConstants.START_CONTAINER,
      "ContainerManagerImpl", "Container already running on this node!",
      applicationID, containerId);
    throw RPCUtil.getRemoteException("Container " + containerIdStr
        + " already is running on this node!!");
  }

  // Create the application
  Application application =
      new ApplicationImpl(dispatcher, this.aclsManager, user, applicationID,
        credentials, context);
  if (null == context.getApplications().putIfAbsent(applicationID,
    application)) {
    LOG.info("Creating a new application reference for app " + applicationID);

    dispatcher.getEventHandler().handle(
      new ApplicationInitEvent(applicationID, container.getLaunchContext()
        .getApplicationACLs()));
  }

  dispatcher.getEventHandler().handle(
    new ApplicationContainerInitEvent(container));

  this.context.getContainerTokenSecretManager().startContainerSuccessful(
    containerTokenIdentifier);
  NMAuditLogger.logSuccess(user, AuditConstants.START_CONTAINER,
    "ContainerManageImpl", applicationID, containerId);
  // TODO launchedContainer misplaced -> doesn't necessarily mean a container
  // launch. A finished Application will not launch containers.
  metrics.launchedContainer();
  metrics.allocateContainer(containerTokenIdentifier.getResource()); 
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:78,代码来源:ContainerManagerImpl.java


注:本文中的org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest.getContainerLaunchContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。