diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java index 4f7e16483a..a5772badf2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java @@ -1286,24 +1286,21 @@ public void setFairShare(Resource fairShare) { @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, - pendingAsk.getPerAllocationResource(), - pendingAsk.getCount()); - } + for (SchedulerRequestKey k : getSchedulerKeys()) { + PendingAsk pendingAsk = getPendingAsk(k, ResourceRequest.ANY); + if (pendingAsk.getCount() > 0) { + Resources.multiplyAndAddTo(tmpDemand, + pendingAsk.getPerAllocationResource(), + pendingAsk.getCount()); } - } finally { - writeLock.unlock(); } + + // Update demand + demand = tmpDemand; } @Override