Bläddra i källkod

MAPREDUCE-3784. Fixed CapacityScheduler so that maxActiveApplications and maxActiveApplicationsPerUser per queue are not too low for small clusters. Contributed by Arun C Murthy.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1239971 13f79535-47bb-0310-9956-ffa450edef68
Vinod Kumar Vavilapalli 13 år sedan
förälder
incheckning
a5c46c9165

+ 4 - 0
hadoop-mapreduce-project/CHANGES.txt

@@ -226,6 +226,10 @@ Release 0.23.1 - Unreleased
     MAPREDUCE-3771. Un-deprecated the old mapred apis, port of MAPREDUCE-1735.
     (acmurthy)
 
+    MAPREDUCE-3784. Fixed CapacityScheduler so that maxActiveApplications and
+    maxActiveApplicationsPerUser per queue are not too low for small
+    clusters. (Arun C Murthy via vinodkv)
+
   OPTIMIZATIONS
 
     MAPREDUCE-3567. Extraneous JobConf objects in AM heap. (Vinod Kumar

+ 10 - 4
hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CSQueueUtils.java

@@ -46,17 +46,23 @@ class CSQueueUtils {
   }
 
   public static int computeMaxActiveApplications(Resource clusterResource,
-      float maxAMResourcePercent, float absoluteCapacity) {
+      Resource minimumAllocation, float maxAMResourcePercent, 
+      float absoluteMaxCapacity) {
     return 
         Math.max(
-            (int)((clusterResource.getMemory() / (float)LeafQueue.DEFAULT_AM_RESOURCE) * 
-                   maxAMResourcePercent * absoluteCapacity), 
+            (int)Math.ceil(
+                     ((float)clusterResource.getMemory() / 
+                         minimumAllocation.getMemory()) * 
+                     maxAMResourcePercent * absoluteMaxCapacity), 
             1);
   }
 
   public static int computeMaxActiveApplicationsPerUser(
       int maxActiveApplications, int userLimit, float userLimitFactor) {
-    return (int)(maxActiveApplications * (userLimit / 100.0f) * userLimitFactor);
+    return Math.max(
+        (int)Math.ceil(
+            maxActiveApplications * (userLimit / 100.0f) * userLimitFactor),
+        1);
   }
   
 }

+ 26 - 17
hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java

@@ -125,8 +125,6 @@ public class LeafQueue implements CSQueue {
   
   private final ActiveUsersManager activeUsersManager;
   
-  final static int DEFAULT_AM_RESOURCE = 2 * 1024;
-  
   public LeafQueue(CapacitySchedulerContext cs, 
       String queueName, CSQueue parent, 
       Comparator<SchedulerApp> applicationComparator, CSQueue old) {
@@ -166,8 +164,9 @@ public class LeafQueue implements CSQueue {
     this.maxAMResourcePercent = 
         cs.getConfiguration().getMaximumApplicationMasterResourcePercent();
     int maxActiveApplications = 
-        CSQueueUtils.computeMaxActiveApplications(cs.getClusterResources(), 
-            maxAMResourcePercent, absoluteCapacity);
+        CSQueueUtils.computeMaxActiveApplications(
+            cs.getClusterResources(), this.minimumAllocation,
+            maxAMResourcePercent, absoluteMaxCapacity);
     int maxActiveApplicationsPerUser = 
         CSQueueUtils.computeMaxActiveApplicationsPerUser(maxActiveApplications, userLimit, 
             userLimitFactor);
@@ -246,30 +245,39 @@ public class LeafQueue implements CSQueue {
         " [= configuredMaxCapacity ]" + "\n" +
         "absoluteMaxCapacity = " + absoluteMaxCapacity +
         " [= 1.0 maximumCapacity undefined, " +
-        "(parentAbsoluteMaxCapacity * maximumCapacity) / 100 otherwise ]" + "\n" +
+        "(parentAbsoluteMaxCapacity * maximumCapacity) / 100 otherwise ]" + 
+        "\n" +
         "userLimit = " + userLimit +
         " [= configuredUserLimit ]" + "\n" +
         "userLimitFactor = " + userLimitFactor +
         " [= configuredUserLimitFactor ]" + "\n" +
         "maxApplications = " + maxApplications +
-        " [= (int)(configuredMaximumSystemApplications * absoluteCapacity) ]" + "\n" +
+        " [= (int)(configuredMaximumSystemApplications * absoluteCapacity) ]" + 
+        "\n" +
         "maxApplicationsPerUser = " + maxApplicationsPerUser +
-        " [= (int)(maxApplications * (userLimit / 100.0f) * userLimitFactor) ]" + "\n" +
+        " [= (int)(maxApplications * (userLimit / 100.0f) * " +
+        "userLimitFactor) ]" + "\n" +
         "maxActiveApplications = " + maxActiveApplications +
         " [= max(" + 
-        "(int)((clusterResourceMemory / (float)DEFAULT_AM_RESOURCE) *" + 
-        "maxAMResourcePercent * absoluteCapacity)," + 
+        "(int)ceil((clusterResourceMemory / minimumAllocation) *" + 
+        "maxAMResourcePercent * absoluteMaxCapacity)," + 
         "1) ]" + "\n" +
         "maxActiveApplicationsPerUser = " + maxActiveApplicationsPerUser +
-        " [= (int)(maxActiveApplications * (userLimit / 100.0f) * userLimitFactor) ]" + "\n" +
+        " [= max(" +
+        "(int)(maxActiveApplications * (userLimit / 100.0f) * " +
+        "userLimitFactor)," +
+        "1) ]" + "\n" +
         "utilization = " + utilization +
-        " [= usedResourcesMemory /  (clusterResourceMemory * absoluteCapacity)]" + "\n" +
+        " [= usedResourcesMemory / " +
+        "(clusterResourceMemory * absoluteCapacity)]" + "\n" +
         "usedCapacity = " + usedCapacity +
-        " [= usedResourcesMemory / (clusterResourceMemory * parent.absoluteCapacity)]" + "\n" +
+        " [= usedResourcesMemory / " +
+        "(clusterResourceMemory * parent.absoluteCapacity)]" + "\n" +
         "maxAMResourcePercent = " + maxAMResourcePercent +
         " [= configuredMaximumAMResourcePercent ]" + "\n" +
         "minimumAllocationFactor = " + minimumAllocationFactor +
-        " [= (float)(maximumAllocationMemory - minimumAllocationMemory) / maximumAllocationMemory ]" + "\n" +
+        " [= (float)(maximumAllocationMemory - minimumAllocationMemory) / " +
+        "maximumAllocationMemory ]" + "\n" +
         "numContainers = " + numContainers +
         " [= currentNumContainers ]" + "\n" +
         "state = " + state +
@@ -1359,11 +1367,12 @@ public class LeafQueue implements CSQueue {
   public synchronized void updateClusterResource(Resource clusterResource) {
     // Update queue properties
     maxActiveApplications = 
-        CSQueueUtils.computeMaxActiveApplications(clusterResource, maxAMResourcePercent, 
-            absoluteCapacity);
+        CSQueueUtils.computeMaxActiveApplications(
+            clusterResource, minimumAllocation, 
+            maxAMResourcePercent, absoluteMaxCapacity);
     maxActiveApplicationsPerUser = 
-        CSQueueUtils.computeMaxActiveApplicationsPerUser(maxActiveApplications, userLimit, 
-            userLimitFactor);
+        CSQueueUtils.computeMaxActiveApplicationsPerUser(
+            maxActiveApplications, userLimit, userLimitFactor);
     
     // Update application properties
     for (SchedulerApp application : activeApplications) {

+ 13 - 11
hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestApplicationLimits.java

@@ -153,29 +153,31 @@ public class TestApplicationLimits {
     		queue.getMaximumActiveApplicationsPerUser());
     int expectedMaxActiveApps = 
         Math.max(1, 
-            (int)((clusterResource.getMemory() / LeafQueue.DEFAULT_AM_RESOURCE) * 
+            (int)Math.ceil(((float)clusterResource.getMemory() / (1*GB)) * 
                    csConf.getMaximumApplicationMasterResourcePercent() *
-                   queue.getAbsoluteCapacity()));
+                   queue.getAbsoluteMaximumCapacity()));
     assertEquals(expectedMaxActiveApps, 
                  queue.getMaximumActiveApplications());
-    assertEquals((int)(expectedMaxActiveApps * (queue.getUserLimit() / 100.0f) * 
-                       queue.getUserLimitFactor()), 
-                 queue.getMaximumActiveApplicationsPerUser());
+    assertEquals(
+        (int)Math.ceil(
+            expectedMaxActiveApps * (queue.getUserLimit() / 100.0f) * 
+            queue.getUserLimitFactor()), 
+        queue.getMaximumActiveApplicationsPerUser());
     
     // Add some nodes to the cluster & test new limits
     clusterResource = Resources.createResource(120 * 16 * GB);
     root.updateClusterResource(clusterResource);
     expectedMaxActiveApps = 
         Math.max(1, 
-            (int)((clusterResource.getMemory() / LeafQueue.DEFAULT_AM_RESOURCE) * 
+            (int)Math.ceil(((float)clusterResource.getMemory() / (1*GB)) * 
                    csConf.getMaximumApplicationMasterResourcePercent() *
-                   queue.getAbsoluteCapacity()));
+                   queue.getAbsoluteMaximumCapacity()));
     assertEquals(expectedMaxActiveApps, 
                  queue.getMaximumActiveApplications());
-    assertEquals((int)(expectedMaxActiveApps * (queue.getUserLimit() / 100.0f) * 
-                       queue.getUserLimitFactor()), 
-                 queue.getMaximumActiveApplicationsPerUser());
-    
+    assertEquals(
+        (int)Math.ceil(expectedMaxActiveApps * 
+            (queue.getUserLimit() / 100.0f) * queue.getUserLimitFactor()), 
+        queue.getMaximumActiveApplicationsPerUser());
   }
   
   @Test