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


Java AllocateResponse.getNumClusterNodes方法代码示例

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


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

示例1: makeRemoteRequest

import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse; //导入方法依赖的package包/类
protected AllocateResponse makeRemoteRequest() throws YarnException,
    IOException {
  applyRequestLimits();
  ResourceBlacklistRequest blacklistRequest =
      ResourceBlacklistRequest.newInstance(new ArrayList<String>(blacklistAdditions),
          new ArrayList<String>(blacklistRemovals));
  AllocateRequest allocateRequest =
      AllocateRequest.newInstance(lastResponseID,
        super.getApplicationProgress(), new ArrayList<ResourceRequest>(ask),
        new ArrayList<ContainerId>(release), blacklistRequest);
  AllocateResponse allocateResponse = scheduler.allocate(allocateRequest);
  lastResponseID = allocateResponse.getResponseId();
  availableResources = allocateResponse.getAvailableResources();
  lastClusterNmCount = clusterNmCount;
  clusterNmCount = allocateResponse.getNumClusterNodes();
  int numCompletedContainers =
      allocateResponse.getCompletedContainersStatuses().size();

  if (ask.size() > 0 || release.size() > 0) {
    LOG.info("getResources() for " + applicationId + ":" + " ask="
        + ask.size() + " release= " + release.size() + " newContainers="
        + allocateResponse.getAllocatedContainers().size()
        + " finishedContainers=" + numCompletedContainers
        + " resourcelimit=" + availableResources + " knownNMs="
        + clusterNmCount);
  }

  ask.clear();
  release.clear();

  if (numCompletedContainers > 0) {
    // re-send limited requests when a container completes to trigger asking
    // for more containers
    requestLimitsToUpdate.addAll(requestLimits.keySet());
  }

  if (blacklistAdditions.size() > 0 || blacklistRemovals.size() > 0) {
    LOG.info("Update the blacklist for " + applicationId +
        ": blacklistAdditions=" + blacklistAdditions.size() +
        " blacklistRemovals=" +  blacklistRemovals.size());
  }
  blacklistAdditions.clear();
  blacklistRemovals.clear();
  return allocateResponse;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:46,代码来源:RMContainerRequestor.java

示例2: allocate

import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse; //导入方法依赖的package包/类
@Override
public AllocationResponse allocate(float progressIndicator)
  throws YarnRemoteException {
  AllocateResponse allocateResponse = null;
  ArrayList<ResourceRequest> askList = null;
  ArrayList<ContainerId> releaseList = null;
  AllocateRequest allocateRequest = null;

  try {
    synchronized (this) {
      askList = new ArrayList<ResourceRequest>(ask);
      releaseList = new ArrayList<ContainerId>(release);
      // optimistically clear this collection assuming no RPC failure
      ask.clear();
      release.clear();
      allocateRequest = BuilderUtils
        .newAllocateRequest(appAttemptId, lastResponseId, progressIndicator,
                            askList, releaseList);
    }

    allocateResponse = rmClient.allocate(allocateRequest);
    AllocationResponse response = AllocationResponses.create(allocateResponse);

    synchronized (this) {
      // update these on successful RPC
      clusterNodeCount = allocateResponse.getNumClusterNodes();
      lastResponseId = response.getResponseId();
      clusterAvailableResources = response.getAvailableResources();
    }

    return response;
  } finally {
    // TODO how to differentiate remote YARN exception vs error in RPC
    if (allocateResponse == null) {
      // We hit an exception in allocate()
      // Preserve ask and release for next call to allocate()
      synchronized (this) {
        release.addAll(releaseList);
        // Requests could have been added or deleted during call to allocate.
        // If requests were added/removed then there is nothing to do since
        // the ResourceRequest object in ask would have the actual new value.
        // If ask does not have this ResourceRequest then it was unchanged and
        // so we can add the value back safely.
        // This assumes that there will no concurrent calls to allocate() and
        // so we don't have to worry about ask being changed in the
        // synchronized block at the beginning of this method.
        for (ResourceRequest oldAsk : askList) {
          if (!ask.contains(oldAsk)) {
            ask.add(oldAsk);
          }
        }
      }
    }
  }
}
 
开发者ID:apache,项目名称:twill,代码行数:56,代码来源:AMRMClientImpl.java


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