From 42f9f9337918ebdd93cca6a5171e87825cd671ea Mon Sep 17 00:00:00 2001 From: Prabhu Joseph Date: Mon, 10 Feb 2020 15:26:46 +0530 Subject: [PATCH] YARN-10124. Remove restriction of ParentQueue capacity zero when childCapacities > 0 Signed-off-by: Prabhu Joseph --- .../resourcemanager/scheduler/capacity/ParentQueue.java | 12 +++++------- .../scheduler/capacity/TestParentQueue.java | 15 ++++++++++----- 2 files changed, 15 insertions(+), 12 deletions(-) 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/capacity/ParentQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ParentQueue.java index 8d32447..45de239 100644 --- a/hadoop-yarn-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-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ParentQueue.java @@ -190,11 +190,10 @@ void setChildQueues(Collection childQueues) { } float delta = Math.abs(1.0f - childCapacities); // crude way to check - // allow capacities being set to 0, and enforce child 0 if parent is 0 + // allow capacities being set to 0 if ((minResDefaultLabel.equals(Resources.none()) - && (queueCapacities.getCapacity() > 0) && (delta > PRECISION)) - || ((queueCapacities.getCapacity() == 0) && (childCapacities > 0))) { - throw new IllegalArgumentException("Illegal" + " capacity of " + && (queueCapacities.getCapacity() > 0) && (delta > PRECISION))) { + throw new IllegalArgumentException("Illegal capacity of " + childCapacities + " for children of queue " + queueName); } // check label capacities @@ -225,10 +224,9 @@ void setChildQueues(Collection childQueues) { .getConfiguredMinResource(nodeLabel)); } if ((minResDefaultLabel.equals(Resources.none()) && capacityByLabel > 0 - && Math.abs(1.0f - sum) > PRECISION) - || (capacityByLabel == 0) && (sum > 0)) { + && Math.abs(1.0f - sum) > PRECISION)) { throw new IllegalArgumentException( - "Illegal" + " capacity of " + sum + " for children of queue " + "Illegal capacity of " + sum + " for children of queue " + queueName + " for label=" + nodeLabel); } diff --git a/hadoop-yarn-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-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestParentQueue.java index 4ef9f7a..7cc37f9 100644 --- a/hadoop-yarn-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-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestParentQueue.java @@ -669,7 +669,7 @@ public void testQueueCapacitySettingChildZero() throws Exception { TestUtils.spyHook); } - @Test (expected=IllegalArgumentException.class) + @Test public void testQueueCapacitySettingParentZero() throws Exception { // Setup queue configs setupMultiLevelQueues(csConf); @@ -680,10 +680,15 @@ public void testQueueCapacitySettingParentZero() throws Exception { final String Q_A = CapacitySchedulerConfiguration.ROOT + "." + A; csConf.setCapacity(Q_A, 60); - Map queues = new HashMap(); - CapacitySchedulerQueueManager.parseQueue(csContext, csConf, null, - CapacitySchedulerConfiguration.ROOT, queues, queues, - TestUtils.spyHook); + Map queues = new HashMap(); + try { + CapacitySchedulerQueueManager.parseQueue(csContext, csConf, null, + CapacitySchedulerConfiguration.ROOT, queues, queues, + TestUtils.spyHook); + } catch (IllegalArgumentException e) { + fail("Failed to set Parent Queue Capacity to 0: " + e); + } + assertTrue("Failed to set Parent Queue Capacity to 0", true); } @Test -- 2.7.4 (Apple Git-66)