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 16c1468c0c2..f033adcf1b0 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 @@ -171,8 +171,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 fb48dec4a21..6c0d95f7f67 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 @@ -324,8 +324,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 @@ -375,8 +376,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 12f0c8b2a55..9379367740c 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