當前位置: 首頁>>代碼示例>>Java>>正文


Java Container.getResource方法代碼示例

本文整理匯總了Java中org.apache.hadoop.yarn.api.records.Container.getResource方法的典型用法代碼示例。如果您正苦於以下問題:Java Container.getResource方法的具體用法?Java Container.getResource怎麽用?Java Container.getResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.yarn.api.records.Container的用法示例。


在下文中一共展示了Container.getResource方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addNewContainer

import org.apache.hadoop.yarn.api.records.Container; //導入方法依賴的package包/類
/**
 * launch a new container with the given life time
 */
public void addNewContainer(Container container, long lifeTimeMS) {
  LOG.debug(MessageFormat.format("NodeManager {0} launches a new " +
          "container ({1}).", node.getNodeID(), container.getId()));
  if (lifeTimeMS != -1) {
    // normal container
    ContainerSimulator cs = new ContainerSimulator(container.getId(),
            container.getResource(), lifeTimeMS + System.currentTimeMillis(),
            lifeTimeMS);
    containerQueue.add(cs);
    runningContainers.put(cs.getId(), cs);
  } else {
    // AM container
    // -1 means AMContainer
    synchronized(amContainerList) {
      amContainerList.add(container.getId());
    }
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:22,代碼來源:NMSimulator.java

示例2: assignContainer

import org.apache.hadoop.yarn.api.records.Container; //導入方法依賴的package包/類
/**
 * Assign a container to this node to facilitate {@code request}. If node does
 * not have enough memory, create a reservation. This is called once we are
 * sure the particular request should be facilitated by this node.
 *
 * @param node
 *     The node to try placing the container on.
 * @param request
 *     The ResourceRequest we're trying to satisfy.
 * @param type
 *     The locality of the assignment.
 * @param reserved
 *     Whether there's already a container reserved for this app on the node.
 * @return
 *     If an assignment was made, returns the resources allocated to the
 *     container.  If a reservation was made, returns
 *     FairScheduler.CONTAINER_RESERVED.  If no assignment or reservation was
 *     made, returns an empty resource.
 */
private Resource assignContainer(
    FSSchedulerNode node, ResourceRequest request, NodeType type,
    boolean reserved) {

  // How much does this request need?
  Resource capability = request.getCapability();

  // How much does the node have?
  Resource available = node.getAvailableResource();

  Container container = null;
  if (reserved) {
    container = node.getReservedContainer().getContainer();
  } else {
    container = createContainer(node, capability, request.getPriority());
  }

  // Can we allocate a container on this node?
  if (Resources.fitsIn(capability, available)) {
    // Inform the application of the new container for this request
    RMContainer allocatedContainer =
        allocate(type, node, request.getPriority(), request, container);
    if (allocatedContainer == null) {
      // Did the application need this resource?
      if (reserved) {
        unreserve(request.getPriority(), node);
      }
      return Resources.none();
    }

    // If we had previously made a reservation, delete it
    if (reserved) {
      unreserve(request.getPriority(), node);
    }

    // Inform the node
    node.allocateContainer(allocatedContainer);

    // If this container is used to run AM, update the leaf queue's AM usage
    if (getLiveContainers().size() == 1 && !getUnmanagedAM()) {
      getQueue().addAMResourceUsage(container.getResource());
      setAmRunning(true);
    }

    return container.getResource();
  } else {
    if (!FairScheduler.fitsInMaxShare(getQueue(), capability)) {
      return Resources.none();
    }

    // The desired container won't fit here, so reserve
    reserve(request.getPriority(), node, container, reserved);

    return FairScheduler.CONTAINER_RESERVED;
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:76,代碼來源:FSAppAttempt.java


注:本文中的org.apache.hadoop.yarn.api.records.Container.getResource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。