本文整理了Java中org.apache.hadoop.yarn.util.resource.Resources.subtractFromNonNegative
方法的一些代码示例,展示了Resources.subtractFromNonNegative
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resources.subtractFromNonNegative
方法的具体详情如下:
包路径:org.apache.hadoop.yarn.util.resource.Resources
类名称:Resources
方法名:subtractFromNonNegative
[英]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
/**
* Subtract {@code rhs} from {@code lhs} and reset any negative values to
* zero. This call will operate on a copy of {@code lhs}, leaving {@code lhs}
* unmodified.
*
* @param lhs {@link Resource} to subtract from
* @param rhs {@link Resource} to subtract
* @return the value of lhs after subtraction
*/
public static Resource subtractNonNegative(Resource lhs, Resource rhs) {
return subtractFromNonNegative(clone(lhs), rhs);
}
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager
private void subtractResourcesOnBlacklistedNodes(
Resource availableResources) {
if (appSchedulingInfo.getAndResetBlacklistChanged()) {
blacklistNodeIds.clear();
blacklistNodeIds.addAll(scheduler.getBlacklistedNodes(this));
}
for (FSSchedulerNode node: blacklistNodeIds) {
Resources.subtractFromNonNegative(availableResources,
node.getUnallocatedResource());
}
}
代码示例来源: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
private void calculateToBePreemptedResourcePerApp(Resource clusterResource,
TreeSet<TempAppPerPartition> orderedApps, Resource preemptionLimit) {
for (TempAppPerPartition tmpApp : orderedApps) {
if (Resources.lessThanOrEqual(rc, clusterResource, preemptionLimit,
Resources.none())
|| Resources.lessThanOrEqual(rc, clusterResource, tmpApp.getUsed(),
Resources.none())) {
continue;
}
Resource preemtableFromApp = Resources.subtract(tmpApp.getUsed(),
tmpApp.idealAssigned);
Resources.subtractFromNonNegative(preemtableFromApp, tmpApp.selected);
Resources.subtractFromNonNegative(preemtableFromApp, tmpApp.getAMUsed());
if (context.getIntraQueuePreemptionOrderPolicy()
.equals(IntraQueuePreemptionOrderPolicy.USERLIMIT_FIRST)) {
Resources.subtractFromNonNegative(preemtableFromApp,
tmpApp.getFiCaSchedulerApp().getCSLeafQueue().getMinimumAllocation());
}
// Calculate toBePreempted from apps as follows:
// app.preemptable = min(max(app.used - app.selected - app.ideal, 0),
// intra_q_preemptable)
tmpApp.toBePreempted = Resources.min(rc, clusterResource, Resources
.max(rc, clusterResource, preemtableFromApp, Resources.none()),
Resources.clone(preemptionLimit));
preemptionLimit = Resources.subtractFromNonNegative(preemptionLimit,
tmpApp.toBePreempted);
}
}
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager
Resources.subtractFromNonNegative(minShareStarvation, fairShareStarvation);
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager
if (!Resources.isNone(pending)) {
Resource appMinShare = app.getPendingDemand();
Resources.subtractFromNonNegative(
appMinShare, app.getFairshareStarvation());
Resources.subtractFromNonNegative(appMinShare, pending);
pending = none();
} else {
Resources.subtractFromNonNegative(pending, appMinShare);
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager
Resources.subtractFromNonNegative(pending,
Resources.multiply(rr.getCapability(), rr.getNumContainers()));
代码示例来源: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
Resources.subtractFromNonNegative(queueReassignableResource,
tmpApp.idealAssigned);
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager
Resource potential = Resources.subtractFromNonNegative(
Resources.clone(node.getUnallocatedResource()),
node.getTotalReserved());
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager
/**
* Helper method that computes the extent of fairshare starvation.
* @return freshly computed fairshare starvation
*/
Resource fairShareStarvation() {
long now = scheduler.getClock().getTime();
Resource threshold = Resources.multiply(
getFairShare(), getQueue().getFairSharePreemptionThreshold());
Resource fairDemand = Resources.componentwiseMin(threshold, demand);
// Check if the queue is starved for fairshare
boolean starved = isUsageBelowShare(getResourceUsage(), fairDemand);
if (!starved) {
lastTimeAtFairShare = now;
}
if (!starved ||
now - lastTimeAtFairShare <
getQueue().getFairSharePreemptionTimeout()) {
fairshareStarvation = Resources.none();
} else {
// The app has been starved for longer than preemption-timeout.
fairshareStarvation =
Resources.subtractFromNonNegative(fairDemand, getResourceUsage());
}
return fairshareStarvation;
}
内容来源于网络,如有侵权,请联系作者删除!