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

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

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

Resources.subtractFrom介绍

[英]Subtract rhs from lhs and reset any negative values to zero. This call will modify lhs.
[中]从lhs中减去rhs,并将所有负值重置为零。此调用将修改lhs。

代码示例

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

public void removeNode(Resource nodeRes) {
 Resources.subtractFrom(resource, nodeRes);
 numActiveNMs--;
}

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

public void removeNode(Resource nodeRes) {
 Resources.subtractFrom(resource, nodeRes);
 numActiveNMs--;
}

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

public void removeNode(Resource nodeRes) {
 Resources.subtractFrom(resource, nodeRes);
 numActiveNMs--;
}

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

private Resource getUsageAfterPreemptingContainer(Resource containerResources,
    Resource alreadyConsideringForPreemption) {
 Resource usageAfterPreemption = Resources.clone(getResourceUsage());
 // Subtract resources of containers already queued for preemption
 synchronized (preemptionVariablesLock) {
  Resources.subtractFrom(usageAfterPreemption, resourcesToBePreempted);
 }
 // Subtract resources of this container and other containers of this app
 // that the FSPreemptionThread is already considering for preemption.
 Resources.subtractFrom(usageAfterPreemption, containerResources);
 Resources.subtractFrom(usageAfterPreemption,
     alreadyConsideringForPreemption);
 return usageAfterPreemption;
}

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

private void _dec(String label, ResourceType type, Resource res) {
 try {
  writeLock.lock();
  UsageByLabel usage = getAndAddIfMissing(label);
  Resources.subtractFrom(usage.resArr[type.idx], res);
 } finally {
  writeLock.unlock();
 }
}

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

private void _dec(String label, ResourceType type, Resource res) {
 try {
  writeLock.lock();
  UsageByLabel usage = getAndAddIfMissing(label);
  Resources.subtractFrom(usage.resArr[type.idx], res);
 } finally {
  writeLock.unlock();
 }
}

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

private void untrackContainerForPreemption(RMContainer container) {
 synchronized (preemptionVariablesLock) {
  if (containersToBePreempted.remove(container)) {
   Resources.subtractFrom(resourcesToBePreempted,
     container.getAllocatedResource());
  }
 }
}

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

public static Resource subtract(Resource lhs, Resource rhs) {
 return subtractFrom(clone(lhs), rhs);
}

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

public static Resource subtract(Resource lhs, Resource rhs) {
 return subtractFrom(clone(lhs), rhs);
}

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

/**
 * Decrease resource usage for this queue and all parent queues.
 *
 * @param res the resource to decrease
 */
protected void decUsedResource(Resource res) {
 synchronized (resourceUsage) {
  Resources.subtractFrom(resourceUsage, res);
  if (parent != null) {
   parent.decUsedResource(res);
  }
 }
}

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

public synchronized void markContainerToNonKillable(ContainerId containerId) {
 RMContainer c = getContainer(containerId);
 if (c != null && killableContainers.containsKey(containerId)) {
  killableContainers.remove(containerId);
  Resources.subtractFrom(totalKillableResources, c.getAllocatedResource());
 }
}

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

private synchronized void addAvailableResource(Resource resource) {
 if (resource == null) {
  LOG.error("Invalid resource addition of null resource for "
    + rmNode.getNodeAddress());
  return;
 }
 Resources.addTo(availableResource, resource);
 Resources.subtractFrom(usedResource, resource);
}

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

private synchronized void deductAvailableResource(Resource resource) {
 if (resource == null) {
  LOG.error("Invalid deduction of null resource for "
    + rmNode.getNodeAddress());
  return;
 }
 Resources.subtractFrom(availableResource, resource);
 Resources.addTo(usedResource, resource);
}

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

private synchronized void addAvailableResource(Resource resource) {
 if (resource == null) {
  LOG.error("Invalid resource addition of null resource for "
    + rmNode.getNodeAddress());
  return;
 }
 Resources.addTo(availableResource, resource);
 Resources.subtractFrom(usedResource, resource);
}

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

private synchronized void deductAvailableResource(Resource resource) {
 if (resource == null) {
  LOG.error("Invalid deduction of null resource for "
    + rmNode.getNodeAddress());
  return;
 }
 Resources.subtractFrom(availableResource, resource);
 Resources.addTo(usedResource, resource);
}

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

/**
 * Add unallocated resources to the node. This is used when unallocating a
 * container.
 * @param resource Resources to add.
 */
private synchronized void addUnallocatedResource(Resource resource) {
 if (resource == null) {
  LOG.error("Invalid resource addition of null resource for "
    + rmNode.getNodeAddress());
  return;
 }
 Resources.addTo(unallocatedResource, resource);
 Resources.subtractFrom(allocatedResource, resource);
}

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

@Override
protected synchronized void updateResourceForReleasedContainer(
  Container container) {
 super.updateResourceForReleasedContainer(container);
 if (killableContainers.containsKey(container.getId())) {
  Resources.subtractFrom(totalKillableResources, container.getResource());
  killableContainers.remove(container.getId());
 }
}

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

public void deductActuallyToBePreempted(ResourceCalculator resourceCalculator,
  Resource cluster, Resource toBeDeduct) {
 if (Resources.greaterThan(resourceCalculator, cluster,
   getActuallyToBePreempted(), toBeDeduct)) {
  Resources.subtractFrom(getActuallyToBePreempted(), toBeDeduct);
 }
}

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

private void addContainerToSchedulerNode(NodeId nodeId, RMContainer container,
  boolean isReserved) {
 SchedulerNode node = nodeIdToSchedulerNodes.get(nodeId);
 assert node != null;
 if (isReserved) {
  when(node.getReservedContainer()).thenReturn(container);
 } else {
  node.getCopiedListOfRunningContainers().add(container);
  Resources.subtractFrom(node.getUnallocatedResource(),
    container.getAllocatedResource());
 }
}

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

public void deductActuallyToBePreempted(ResourceCalculator rc,
  Resource cluster, Resource toBeDeduct) {
 if (Resources.greaterThan(rc, cluster, getActuallyToBePreempted(),
   toBeDeduct)) {
  Resources.subtractFrom(getActuallyToBePreempted(), toBeDeduct);
 }
 setActuallyToBePreempted(Resources.max(rc, cluster,
   getActuallyToBePreempted(), Resources.none()));
}

相关文章