From 89c59bbe3d490a99db9eb258a3ec6fb5b84aea45 Mon Sep 17 00:00:00 2001 From: Robert Joseph Evans Date: Tue, 31 Jul 2012 19:34:29 +0000 Subject: [PATCH] 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 --- hadoop-mapreduce-project/CHANGES.txt | 3 + .../scheduler/capacity/ParentQueue.java | 2 +- .../scheduler/capacity/TestParentQueue.java | 57 +++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index 9f83acd587..929168eacd 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/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 diff --git a/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 b/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 index 819fb5c9b2..25e982bbc0 100644 --- a/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 +++ b/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 @@ private synchronized void setupQueueConfigs( ", acls=" + aclsString); } - private static float PRECISION = 0.005f; // 0.05% precision + private static float PRECISION = 0.0005f; // 0.05% precision void setChildQueues(Collection childQueues) { // Validate diff --git a/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 b/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 index 64c7581862..602c09c0d1 100644 --- a/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 +++ b/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.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 void testSingleLevelQueues() throws Exception { 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 queues = new HashMap(); + 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";