From ac954486c5102b8fbbc4229a0d3a512bcc7013c0 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Mon, 23 May 2016 15:54:42 +0000 Subject: [PATCH] YARN-5055. max apps per user can be larger than max per queue. Contributed by Eric Badger --- .../resourcemanager/scheduler/capacity/LeafQueue.java | 4 ++-- .../scheduler/capacity/TestApplicationLimits.java | 9 +++++---- .../webapp/TestRMWebServicesCapacitySched.java | 5 +++-- 3 files changed, 10 insertions(+), 8 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/LeafQueue.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/LeafQueue.java index fbcb91c453..d562f34238 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/LeafQueue.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/LeafQueue.java @@ -175,8 +175,8 @@ public class LeafQueue extends AbstractCSQueue { maxApplications = (int) (maxSystemApps * queueCapacities.getAbsoluteCapacity()); } - maxApplicationsPerUser = - (int)(maxApplications * (userLimit / 100.0f) * userLimitFactor); + maxApplicationsPerUser = Math.min(maxApplications, + (int)(maxApplications * (userLimit / 100.0f) * userLimitFactor)); maxAMResourcePerQueuePercent = conf.getMaximumApplicationMasterResourcePerQueuePercent(getQueuePath()); 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/TestApplicationLimits.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/TestApplicationLimits.java index e668d94ecd..8a3051b0f5 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/TestApplicationLimits.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/TestApplicationLimits.java @@ -326,8 +326,9 @@ public class TestApplicationLimits { queue.getAbsoluteCapacity()); assertEquals(expectedMaxApps, queue.getMaxApplications()); - int expectedMaxAppsPerUser = (int)(expectedMaxApps * - (queue.getUserLimit()/100.0f) * queue.getUserLimitFactor()); + int expectedMaxAppsPerUser = Math.min(expectedMaxApps, + (int)(expectedMaxApps * (queue.getUserLimit()/100.0f) * + queue.getUserLimitFactor())); assertEquals(expectedMaxAppsPerUser, queue.getMaxApplicationsPerUser()); // should default to global setting if per queue setting not set @@ -377,8 +378,8 @@ public class TestApplicationLimits { assertEquals(9999, (int)csConf.getMaximumApplicationsPerQueue(queue.getQueuePath())); assertEquals(9999, queue.getMaxApplications()); - expectedMaxAppsPerUser = (int)(9999 * - (queue.getUserLimit()/100.0f) * queue.getUserLimitFactor()); + expectedMaxAppsPerUser = Math.min(9999, (int)(9999 * + (queue.getUserLimit()/100.0f) * queue.getUserLimitFactor())); assertEquals(expectedMaxAppsPerUser, queue.getMaxApplicationsPerUser()); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java index 12f0c8b2a5..9379367740 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java @@ -438,8 +438,9 @@ public class TestRMWebServicesCapacitySched extends JerseyTestBase { int maxSystemApps = csConf.getMaximumSystemApplications(); int expectedMaxApps = (int)(maxSystemApps * (info.absoluteCapacity/100)); - int expectedMaxAppsPerUser = - (int)(expectedMaxApps * (info.userLimit/100.0f) * info.userLimitFactor); + int expectedMaxAppsPerUser = Math.min(expectedMaxApps, + (int)(expectedMaxApps * (info.userLimit/100.0f) * + info.userLimitFactor)); // TODO: would like to use integer comparisons here but can't due to // roundoff errors in absolute capacity calculations