org.apache.hadoop.yarn.util.resource.Resources.fitsIn()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(163)

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

Resources.fitsIn介绍

暂无

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Override
public boolean checkIfUsageOverFairShare(Resource usage, Resource fairShare) {
 return !Resources.fitsIn(usage, fairShare);
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-resourcemanager

@Override
public boolean checkIfAMResourceUsageOverLimit(Resource usage, Resource maxAMResource) {
 return !Resources.fitsIn(usage, maxAMResource);
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-yarn-server-resourcemanager

@Override
public boolean checkIfUsageOverFairShare(Resource usage, Resource fairShare) {
 return !Resources.fitsIn(usage, fairShare);
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-resourcemanager

@Override
public boolean checkIfUsageOverFairShare(Resource usage, Resource fairShare) {
 return !Resources.fitsIn(usage, fairShare);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

private boolean shouldContinueAssigning(int containers,
  Resource maxResourcesToAssign, Resource assignedResource) {
 if (!assignMultiple) {
  return false; // assignMultiple is not enabled. Allocate one at a time.
 }
 if (maxAssignDynamic) {
  // Using fitsIn to check if the resources assigned so far are less than
  // or equal to max resources to assign (half of remaining resources).
  // The "equal to" part can lead to allocating one extra container.
  return Resources.fitsIn(assignedResource, maxResourcesToAssign);
 } else {
  return maxAssign <= 0 || containers < maxAssign;
 }
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-yarn-server-resourcemanager

@Override
public boolean checkIfAMResourceUsageOverLimit(Resource usage, Resource maxAMResource) {
 return !Resources.fitsIn(usage, maxAMResource);
}

代码示例来源:origin: org.apache.slider/slider-core

/**
 * Query for the resource requirements matching; always false before a request is issued
 * @param resource
 * @return
 */
public synchronized boolean resourceRequirementsMatch(Resource resource) {
 return issuedRequest != null && Resources.fitsIn(issuedRequest.getCapability(), resource);
}

代码示例来源:origin: apache/incubator-slider

/**
 * Query for the resource requirements matching; always false before a request is issued
 * @param resource
 * @return
 */
public synchronized boolean resourceRequirementsMatch(Resource resource) {
 return issuedRequest != null && Resources.fitsIn(issuedRequest.getCapability(), resource);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

private void checkMinAndMaxResource(Map<String, Resource> minResources,
   Map<String, ConfigurableResource> maxResources, String queueName) {

  ConfigurableResource maxConfigurableResource = maxResources.get(queueName);
  Resource minResource = minResources.get(queueName);

  if (maxConfigurableResource != null && minResource != null) {
   Resource maxResource = maxConfigurableResource.getResource();

   // check whether max resource is greater or equals to min resource when
   // max resource are absolute values
   if (maxResource != null && !Resources.fitsIn(minResource, maxResource)) {
    LOG.warn(String.format(
      "Queue %s has max resources %s less than " + "min resources %s",
      queueName, maxResource, minResource));
   }
  }
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Override
 public int compare(FSAppAttempt app1, FSAppAttempt app2) {
  int ret = 1;
  if (Resources.fitsIn(app1.getStarvation(), app2.getStarvation())) {
   ret = -1;
  }
  return ret;
 }
}

代码示例来源:origin: io.hops/hadoop-yarn-client

private void validateContainerResourceChangeRequest(
  ContainerId containerId, Resource original, Resource target) {
 Preconditions.checkArgument(containerId != null,
   "ContainerId cannot be null");
 Preconditions.checkArgument(original != null,
   "Original resource capability cannot be null");
 Preconditions.checkArgument(!Resources.equals(Resources.none(), original)
     && Resources.fitsIn(Resources.none(), original),
   "Original resource capability must be greater than 0");
 Preconditions.checkArgument(target != null,
   "Target resource capability cannot be null");
 Preconditions.checkArgument(!Resources.equals(Resources.none(), target)
     && Resources.fitsIn(Resources.none(), target),
   "Target resource capability must be greater than 0");
}

代码示例来源:origin: io.hops/hadoop-yarn-client

private List<UpdateContainerRequest> createUpdateList() {
 List<UpdateContainerRequest> updateList = new ArrayList<>();
 for (Map.Entry<ContainerId, SimpleEntry<Container, Resource>> entry :
   change.entrySet()) {
  Resource targetCapability = entry.getValue().getValue();
  Resource currCapability = entry.getValue().getKey().getResource();
  int version = entry.getValue().getKey().getVersion();
  ContainerUpdateType updateType =
    ContainerUpdateType.INCREASE_RESOURCE;
  if (Resources.fitsIn(targetCapability, currCapability)) {
   updateType = ContainerUpdateType.DECREASE_RESOURCE;
  }
  updateList.add(
    UpdateContainerRequest.newInstance(version, entry.getKey(),
      updateType, targetCapability));
 }
 return updateList;
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

boolean attemptPlacementOnNode(ApplicationId appId,
  Resource availableResources, SchedulingRequest schedulingRequest,
  SchedulerNode schedulerNode, boolean ignoreResourceCheck)
  throws InvalidAllocationTagsQueryException {
 boolean fitsInNode = ignoreResourceCheck ||
   Resources.fitsIn(resourceCalculator,
     schedulingRequest.getResourceSizing().getResources(),
     availableResources);
 boolean constraintsSatisfied =
   PlacementConstraintsUtil.canSatisfyConstraints(appId,
   schedulingRequest, schedulerNode, constraintManager, tagsManager);
 return fitsInNode && constraintsSatisfied;
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

/**
 * Check whether this queue can run the Application Master under the
 * maxAMShare limit.
 *
 * @param amResource resources required to run the AM
 * @return true if this queue can run
 */
public boolean canRunAppAM(Resource amResource) {
 if (Math.abs(maxAMShare - -1.0f) < 0.0001) {
  return true;
 }
 Resource maxAMResource = computeMaxAMResource();
 getMetrics().setMaxAMShare(maxAMResource);
 Resource ifRunAMResource = Resources.add(amResourceUsage, amResource);
 return Resources.fitsIn(ifRunAMResource, maxAMResource);
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-yarn-server-resourcemanager

static boolean fitsInMaxShare(FSQueue queue, Resource
  additionalResource) {
 Resource usagePlusAddition =
   Resources.add(queue.getResourceUsage(), additionalResource);
 if (!Resources.fitsIn(usagePlusAddition, queue.getMaxShare())) {
  return false;
 }
 
 FSQueue parentQueue = queue.getParent();
 if (parentQueue != null) {
  return fitsInMaxShare(parentQueue, additionalResource);
 }
 return true;
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-yarn-server-resourcemanager

/**
 * Helper method to check if the queue should attempt assigning resources
 * 
 * @return true if check passes (can assign) or false otherwise
 */
protected boolean assignContainerPreCheck(FSSchedulerNode node) {
 if (!Resources.fitsIn(getResourceUsage(),
   scheduler.getAllocationConfiguration().getMaxResources(getName()))
   || node.getReservedContainer() != null) {
  return false;
 }
 return true;
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-resourcemanager

static boolean fitsInMaxShare(FSQueue queue, Resource
  additionalResource) {
 Resource usagePlusAddition =
   Resources.add(queue.getResourceUsage(), additionalResource);
 if (!Resources.fitsIn(usagePlusAddition, queue.getMaxShare())) {
  return false;
 }
 
 FSQueue parentQueue = queue.getParent();
 if (parentQueue != null) {
  return fitsInMaxShare(parentQueue, additionalResource);
 }
 return true;
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-resourcemanager

/**
 * Helper method to check if the queue should attempt assigning resources
 * 
 * @return true if check passes (can assign) or false otherwise
 */
protected boolean assignContainerPreCheck(FSSchedulerNode node) {
 if (!Resources.fitsIn(getResourceUsage(),
   scheduler.getAllocationConfiguration().getMaxResources(getName()))
   || node.getReservedContainer() != null) {
  return false;
 }
 return true;
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-resourcemanager

@Test(timeout=1000)
public void testFitsIn() {
 assertTrue(fitsIn(createResource(1, 1), createResource(2, 2)));
 assertTrue(fitsIn(createResource(2, 2), createResource(2, 2)));
 assertFalse(fitsIn(createResource(2, 2), createResource(1, 1)));
 assertFalse(fitsIn(createResource(1, 2), createResource(2, 1)));
 assertFalse(fitsIn(createResource(2, 1), createResource(1, 2)));
}

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

@Test(timeout = 1000)
public void testFitsIn() {
 assertTrue(fitsIn(createResource(1, 1), createResource(2, 2)));
 assertTrue(fitsIn(createResource(2, 2), createResource(2, 2)));
 assertFalse(fitsIn(createResource(2, 2), createResource(1, 1)));
 assertFalse(fitsIn(createResource(1, 2), createResource(2, 1)));
 assertFalse(fitsIn(createResource(2, 1), createResource(1, 2)));
 assertTrue(fitsIn(createResource(1, 1, 1), createResource(2, 2, 2)));
 assertTrue(fitsIn(createResource(1, 1, 0), createResource(2, 2, 0)));
 assertTrue(fitsIn(createResource(1, 1, 1), createResource(2, 2, 2)));
}

相关文章