YARN-6582. FSAppAttempt demand can be updated atomically in updateDemand(). (Karthik Kambatla via Yufei Gu)

This commit is contained in:
Yufei Gu 2017-05-25 14:22:13 -07:00
parent 3fd6a2da4e
commit 87590090c8
1 changed files with 10 additions and 13 deletions

View File

@ -1286,24 +1286,21 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
@Override
public void updateDemand() {
demand = Resources.createResource(0);
// Demand is current consumption plus outstanding requests
Resources.addTo(demand, getCurrentConsumption());
Resource tmpDemand = Resources.clone(getCurrentConsumption());
// Add up outstanding resource requests
try {
writeLock.lock();
for (SchedulerRequestKey k : getSchedulerKeys()) {
PendingAsk pendingAsk = getPendingAsk(k, ResourceRequest.ANY);
if (pendingAsk.getCount() > 0) {
Resources.multiplyAndAddTo(demand,
Resources.multiplyAndAddTo(tmpDemand,
pendingAsk.getPerAllocationResource(),
pendingAsk.getCount());
}
}
} finally {
writeLock.unlock();
}
// Update demand
demand = tmpDemand;
}
@Override