瀏覽代碼

MAPREDUCE-4492. Configuring total queue capacity between 100.5 and 99.5 at perticular level is sucessfull (Mayank Bansal via bobby)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1367719 13f79535-47bb-0310-9956-ffa450edef68
Robert Joseph Evans 12 年之前
父節點
當前提交
89c59bbe3d

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

@@ -774,6 +774,9 @@ Release 0.23.3 - UNRELEASED
     MAPREDUCE-4493. Distibuted Cache Compatability Issues (Robert Evans
     via tgraves)
 
+    MAPREDUCE-4492. Configuring total queue capacity between 100.5 and 99.5 at
+    perticular level is sucessfull (Mayank Bansal via bobby)
+
 Release 0.23.2 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 1 - 1
hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ParentQueue.java

@@ -193,7 +193,7 @@ public class ParentQueue implements CSQueue {
         ", acls=" + aclsString);
   }
 
-  private static float PRECISION = 0.005f; // 0.05% precision
+  private static float PRECISION = 0.0005f; // 0.05% precision
   void setChildQueues(Collection<CSQueue> childQueues) {
     
     // Validate

+ 57 - 0
hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestParentQueue.java

@@ -34,6 +34,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import junit.framework.Assert;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.security.UserGroupInformation;
@@ -270,6 +272,61 @@ public class TestParentQueue {
     verifyQueueMetrics(b, 9*GB, clusterResource);
   }
 
+  @Test
+  public void testSingleLevelQueuesPrecision() throws Exception {
+    // Setup queue configs
+    setupSingleLevelQueues(csConf);
+    final String Q_A = CapacitySchedulerConfiguration.ROOT + "." + "a";
+    csConf.setCapacity(Q_A, 30);
+    final String Q_B = CapacitySchedulerConfiguration.ROOT + "." + "b";
+    csConf.setCapacity(Q_B, 70.5F);
+
+    Map<String, CSQueue> queues = new HashMap<String, CSQueue>();
+    boolean exceptionOccured = false;
+    try {
+      CapacityScheduler.parseQueue(csContext, csConf, null,
+          CapacitySchedulerConfiguration.ROOT, queues, queues,
+          CapacityScheduler.queueComparator,
+          CapacityScheduler.applicationComparator, TestUtils.spyHook);
+    } catch (IllegalArgumentException ie) {
+      exceptionOccured = true;
+    }
+    if (!exceptionOccured) {
+      Assert.fail("Capacity is more then 100% so should be failed.");
+    }
+    csConf.setCapacity(Q_A, 30);
+    csConf.setCapacity(Q_B, 70);
+    exceptionOccured = false;
+    queues.clear();
+    try {
+      CapacityScheduler.parseQueue(csContext, csConf, null,
+          CapacitySchedulerConfiguration.ROOT, queues, queues,
+          CapacityScheduler.queueComparator,
+          CapacityScheduler.applicationComparator, TestUtils.spyHook);
+    } catch (IllegalArgumentException ie) {
+      exceptionOccured = true;
+    }
+    if (exceptionOccured) {
+      Assert.fail("Capacity is 100% so should not be failed.");
+    }
+    csConf.setCapacity(Q_A, 30);
+    csConf.setCapacity(Q_B, 70.005F);
+    exceptionOccured = false;
+    queues.clear();
+    try {
+      CapacityScheduler.parseQueue(csContext, csConf, null,
+          CapacitySchedulerConfiguration.ROOT, queues, queues,
+          CapacityScheduler.queueComparator,
+          CapacityScheduler.applicationComparator, TestUtils.spyHook);
+    } catch (IllegalArgumentException ie) {
+      exceptionOccured = true;
+    }
+    if (exceptionOccured) {
+      Assert
+          .fail("Capacity is under PRECISION which is .05% so should not be failed.");
+    }
+  }
+  
   private static final String C = "c";
   private static final String C1 = "c1";
   private static final String C11 = "c11";