YARN-7057. FSAppAttempt#getResourceUsage doesn't need to consider resources queued for preemption. (Contributed by Karthik via Yufei Gu)

(cherry picked from commit 82c5dd1d50)
This commit is contained in:
Yufei Gu 2017-09-12 14:58:23 -07:00
parent c314a66353
commit 1d40bc225a
1 changed files with 10 additions and 9 deletions

View File

@ -614,9 +614,16 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
// Check if the app's allocation will be over its fairshare even
// after preempting this container
Resource usageAfterPreemption = Resources.subtract(
getResourceUsage(), container.getAllocatedResource());
Resource usageAfterPreemption = Resources.clone(getResourceUsage());
// Subtract resources of containers already queued for preemption
synchronized (preemptionVariablesLock) {
Resources.subtractFrom(usageAfterPreemption, resourcesToBePreempted);
}
// Subtract this container's allocation to compute usage after preemption
Resources.subtractFrom(
usageAfterPreemption, container.getAllocatedResource());
return !isUsageBelowShare(usageAfterPreemption, getFairShare());
}
@ -1268,13 +1275,7 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
@Override
public Resource getResourceUsage() {
// Subtract copies the object, so that we have a snapshot,
// in case usage changes, while the caller is using the value
synchronized (preemptionVariablesLock) {
return containersToBePreempted.isEmpty()
? getCurrentConsumption()
: Resources.subtract(getCurrentConsumption(), resourcesToBePreempted);
}
return getCurrentConsumption();
}
@Override