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

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

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

Resources.isNone介绍

[英]Check whether a resource object is empty (0 memory and 0 virtual cores).
[中]检查资源对象是否为空(0个内存和0个虚拟核)。

代码示例

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

/**
 * Is application starved for fairshare or minshare.
 */
boolean isStarved() {
 return isStarvedForFairShare() || !Resources.isNone(minshareStarvation);
}

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

@Override
 public Boolean answer(InvocationOnMock invocationOnMock)
   throws Throwable {
  return !Resources.isNone(request);
 }
}

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

/**
 * Helper method for tests to check if a queue is starved for minShare.
 * @return whether starved for minshare
 */
@VisibleForTesting
private boolean isStarvedForMinShare() {
 return !Resources.isNone(minShareStarvation());
}

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

/**
 * Fetch the subset of apps that have unmet demand. When used for
 * preemption-related code (as opposed to allocation), omits apps that
 * should not be checked for starvation.
 *
 * @param assignment whether the apps are for allocation containers, as
 *                   opposed to preemption calculations
 * @return Set of apps with unmet demand
 */
private TreeSet<FSAppAttempt> fetchAppsWithDemand(boolean assignment) {
 TreeSet<FSAppAttempt> pendingForResourceApps =
   new TreeSet<>(policy.getComparator());
 readLock.lock();
 try {
  for (FSAppAttempt app : runnableApps) {
   if (!Resources.isNone(app.getPendingDemand()) &&
     (assignment || app.shouldCheckForStarvation())) {
    pendingForResourceApps.add(app);
   }
  }
 } finally {
  readLock.unlock();
 }
 return pendingForResourceApps;
}

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

@Private
public boolean hasPendingResourceRequest(String nodePartition,
  SchedulingMode schedulingMode) {
 // We need to consider unconfirmed allocations
 if (schedulingMode == SchedulingMode.IGNORE_PARTITION_EXCLUSIVITY) {
  nodePartition = RMNodeLabelsManager.NO_LABEL;
 }
 Resource pending = attemptResourceUsage.getPending(nodePartition);
 // TODO, need consider node partition here
 // To avoid too many allocation-proposals rejected for non-default
 // partition allocation
 if (StringUtils.equals(nodePartition, RMNodeLabelsManager.NO_LABEL)) {
  pending = Resources.subtractNonNegative(pending, Resources
    .createResource(unconfirmedAllocatedMem.get(),
      unconfirmedAllocatedVcores.get()));
 }
 return !Resources.isNone(pending);
}

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

/**
 * Remove apps that have their preemption requests fulfilled.
 */
private void cleanupPreemptionList() {
 // Synchronize separately to avoid potential deadlocks
 // This may cause delayed deletion of reservations
 LinkedList<FSAppAttempt> candidates;
 synchronized (this) {
  candidates = Lists.newLinkedList(resourcesPreemptedForApp.keySet());
 }
 for (FSAppAttempt app : candidates) {
  if (app.isStopped() || !app.isStarved() ||
    (Resources.isNone(app.getFairshareStarvation()) &&
     Resources.isNone(app.getMinshareStarvation()))) {
   // App does not need more resources
   synchronized (this) {
    Resource removed = resourcesPreemptedForApp.remove(app);
    if (removed != null) {
     Resources.subtractFrom(totalResourcesPreempted,
       removed);
     appIdToAppMap.remove(app.getApplicationAttemptId());
    }
   }
  }
 }
}

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

/**
 * Assign preempted containers to the applications that have reserved
 * resources for preempted containers.
 * @param node Node to check
 */
static void assignPreemptedContainers(FSSchedulerNode node) {
 for (Entry<FSAppAttempt, Resource> entry :
   node.getPreemptionList().entrySet()) {
  FSAppAttempt app = entry.getKey();
  Resource preemptionPending = Resources.clone(entry.getValue());
  while (!app.isStopped() && !Resources.isNone(preemptionPending)) {
   Resource assigned = app.assignContainer(node);
   if (Resources.isNone(assigned) ||
     assigned.equals(FairScheduler.CONTAINER_RESERVED)) {
    // Fail to assign, let's not try further
    break;
   }
   Resources.subtractFromNonNegative(preemptionPending, assigned);
  }
 }
}

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

/**
 * Mark {@code containers} as being considered for preemption so they are
 * not considered again. A call to this requires a corresponding call to
 * {@code releaseContainer} to ensure we do not mark a container for
 * preemption and never consider it again and avoid memory leaks.
 *
 * @param containers container to mark
 */
void addContainersForPreemption(Collection<RMContainer> containers,
                FSAppAttempt app) {
 Resource appReserved = Resources.createResource(0);
 for(RMContainer container : containers) {
  if(containersForPreemption.add(container)) {
   Resources.addTo(appReserved, container.getAllocatedResource());
  }
 }
 synchronized (this) {
  if (!Resources.isNone(appReserved)) {
   Resources.addTo(totalResourcesPreempted,
     appReserved);
   appIdToAppMap.putIfAbsent(app.getApplicationAttemptId(), app);
   resourcesPreemptedForApp.
     putIfAbsent(app, Resource.newInstance(0, 0));
   Resources.addTo(resourcesPreemptedForApp.get(app), appReserved);
  }
 }
}

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

if (!Resources.isNone(resToIncrease)) {
 Map<SchedulerRequestKey, Map<String, ResourceRequest>> updateResReqs =
   new HashMap<>();

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

private void saturateCluster(FSSchedulerNode schedulerNode) {
 while (!Resources.isNone(schedulerNode.getUnallocatedResource())) {
  createDefaultContainer();
  schedulerNode.allocateContainer(containers.get(containers.size() - 1));
  schedulerNode.containerStarted(containers.get(containers.size() - 1).
    getContainerId());
 }
}

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

if (!Resources.isNone(allocated)) {
  Resources.subtractFrom(reserved, fulfilled);
  Resources.subtractFrom(totalResourcesPreempted, fulfilled);
  if (Resources.isNone(reserved)) {

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

/**
 * Compute the extent of fairshare starvation for a set of apps.
 *
 * @param appsWithDemand apps to compute fairshare starvation for
 * @return aggregate fairshare starvation for all apps
 */
private Resource updateStarvedAppsFairshare(
  TreeSet<FSAppAttempt> appsWithDemand) {
 Resource fairShareStarvation = Resources.clone(none());
 // Fetch apps with unmet demand sorted by fairshare starvation
 for (FSAppAttempt app : appsWithDemand) {
  Resource appStarvation = app.fairShareStarvation();
  if (!Resources.isNone(appStarvation))  {
   context.getStarvedApps().addStarvedApp(app);
   Resources.addTo(fairShareStarvation, appStarvation);
  } else {
   break;
  }
 }
 return fairShareStarvation;
}

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

@Override
 public Resource answer(InvocationOnMock invocationOnMock)
   throws Throwable {
  Resource response = Resource.newInstance(0, 0);
  while (!Resources.isNone(request) &&
    !Resources.isNone(schedulerNode.getUnallocatedResource())) {
   RMContainer container = createContainer(request, appAttemptId);
   schedulerNode.allocateContainer(container);
   Resources.addTo(response, container.getAllocatedResource());
   Resources.subtractFrom(request,
     container.getAllocatedResource());
  }
  return response;
 }
});

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

if (Resources.isNone(pending)) {

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

/**
 * Helper method to compute the amount of minshare starvation.
 *
 * @return the extent of minshare starvation
 */
private Resource minShareStarvation() {
 // If demand < minshare, we should use demand to determine starvation
 Resource starvation =
   Resources.componentwiseMin(getMinShare(), getDemand());
 Resources.subtractFromNonNegative(starvation, getResourceUsage());
 boolean starved = !Resources.isNone(starvation);
 long now = scheduler.getClock().getTime();
 if (!starved) {
  // Record that the queue is not starved
  setLastTimeAtMinShare(now);
 }
 if (now - lastTimeAtMinShare < getMinSharePreemptionTimeout()) {
  // the queue is not starved for the preemption timeout
  starvation = Resources.clone(Resources.none());
 }
 return starvation;
}

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

if (!Resources.isNone(pending)) {
 Resource appMinShare = app.getPendingDemand();
 Resources.subtractFromNonNegative(

相关文章