Sfoglia il codice sorgente

MAPREDUCE-4556. FairScheduler: PoolSchedulable#updateDemand() has potential redundant computation (kkambatl via tucu)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1@1394331 13f79535-47bb-0310-9956-ffa450edef68
Alejandro Abdelnur 13 anni fa
parent
commit
1343bd6acd

+ 3 - 0
CHANGES.txt

@@ -81,6 +81,9 @@ Release 1.2.0 - unreleased
     MAPREDUCE-4464. Reduce tasks failing with NullPointerException in
     ConcurrentHashMap.get(). (Clint Heath via harsh)
 
+    MAPREDUCE-4556. FairScheduler: PoolSchedulable#updateDemand() has potential 
+    redundant computation (kkambatl via tucu)
+
   OPTIMIZATIONS
 
     HDFS-2533. Backport: Remove needless synchronization on some FSDataSet

+ 9 - 4
src/contrib/fairscheduler/src/java/org/apache/hadoop/mapred/PoolSchedulable.java

@@ -79,15 +79,20 @@ public class PoolSchedulable extends Schedulable {
    */
   @Override
   public void updateDemand() {
+    // limit the demand to maxTasks
+    int maxTasks = poolMgr.getMaxSlots(pool.getName(), taskType);
     demand = 0;
     for (JobSchedulable sched: jobScheds) {
       sched.updateDemand();
       demand += sched.getDemand();
+      if (demand >= maxTasks) {
+        demand = maxTasks;
+        break;
+      }
     }
-    // if demand exceeds the cap for this pool, limit to the max
-    int maxTasks = poolMgr.getMaxSlots(pool.getName(), taskType);
-    if(demand > maxTasks) {
-      demand = maxTasks;
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("The pool " + pool.getName() + " demand is " + demand
+          + "; maxTasks is " + maxTasks);
     }
   }