From 1456adb9e12b1d2fabb90d4db18faea5df166711 Mon Sep 17 00:00:00 2001 From: Thomas Graves Date: Wed, 30 Jan 2013 15:18:40 +0000 Subject: [PATCH] YARN-343. Capacity Scheduler maximum-capacity value -1 is invalid (Xuan Gong via tgraves) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1440460 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../capacity/CapacitySchedulerConfiguration.java | 5 +++++ .../scheduler/capacity/TestCapacityScheduler.java | 12 ++++++++++++ 3 files changed, 20 insertions(+) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 2c8ef1bc277..30fb46ae831 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -260,6 +260,9 @@ Release 0.23.7 - UNRELEASED BUG FIXES + YARN-343. Capacity Scheduler maximum-capacity value -1 is invalid (Xuan + Gong via tgraves) + Release 0.23.6 - UNRELEASED INCOMPATIBLE CHANGES 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/CapacitySchedulerConfiguration.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/CapacitySchedulerConfiguration.java index a2a0bebf3d8..10906a48bd3 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/CapacitySchedulerConfiguration.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/CapacitySchedulerConfiguration.java @@ -99,6 +99,9 @@ public class CapacitySchedulerConfiguration extends Configuration { @Private public static final float MAXIMUM_CAPACITY_VALUE = 100; + @Private + public static final float DEFAULT_MAXIMUM_CAPACITY_VALUE = -1.0f; + @Private public static final int DEFAULT_USER_LIMIT = 100; @@ -206,6 +209,8 @@ public class CapacitySchedulerConfiguration extends Configuration { public float getMaximumCapacity(String queue) { float maxCapacity = getFloat(getQueuePrefix(queue) + MAXIMUM_CAPACITY, MAXIMUM_CAPACITY_VALUE); + maxCapacity = (maxCapacity == DEFAULT_MAXIMUM_CAPACITY_VALUE) ? + MAXIMUM_CAPACITY_VALUE : maxCapacity; return maxCapacity; } 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/TestCapacityScheduler.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/TestCapacityScheduler.java index b7ada58c91c..d3a7b0c35f7 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/TestCapacityScheduler.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/TestCapacityScheduler.java @@ -243,6 +243,18 @@ public class TestCapacityScheduler { LOG.info("Setup top-level queues a and b"); } + @Test + public void testMaximumCapacitySetup() { + float delta = 0.0000001f; + CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration(); + assertEquals(CapacitySchedulerConfiguration.MAXIMUM_CAPACITY_VALUE,conf.getMaximumCapacity(A),delta); + conf.setMaximumCapacity(A, 50.0f); + assertEquals(50.0f, conf.getMaximumCapacity(A),delta); + conf.setMaximumCapacity(A, -1); + assertEquals(CapacitySchedulerConfiguration.MAXIMUM_CAPACITY_VALUE,conf.getMaximumCapacity(A),delta); + } + + @Test public void testRefreshQueues() throws Exception { CapacityScheduler cs = new CapacityScheduler();