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/FairScheduler.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/FairScheduler.java index 04418598bf..8ea07ab8b1 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/FairScheduler.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/FairScheduler.java @@ -369,17 +369,20 @@ public void update() { } public float getAppWeight(FSAppAttempt app) { - try { + double weight = 1.0; + + if (sizeBasedWeight) { readLock.lock(); - double weight = 1.0; - if (sizeBasedWeight) { + + try { // Set weight based on current memory demand weight = Math.log1p(app.getDemand().getMemorySize()) / Math.log(2); + } finally { + readLock.unlock(); } - return (float)weight * app.getPriority().getPriority(); - } finally { - readLock.unlock(); } + + return (float)weight * app.getPriority().getPriority(); } public Resource getIncrementResourceCapability() {