diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 316de3953ed..1d373136784 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -287,6 +287,8 @@ Release 2.0.5-beta - UNRELEASED YARN-507. Add interface visibility and stability annotations to FS interfaces/classes. (kkambatl via tucu) + YARN-637. FS: maxAssign is not honored. (kkambatl via tucu) + Release 2.0.4-alpha - 2013-04-25 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/fair/FairScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java index 15f3eba65e8..4593c41e352 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java @@ -832,6 +832,7 @@ public class FairScheduler implements ResourceScheduler { if (Resources.greaterThan(RESOURCE_CALCULATOR, clusterCapacity, queueMgr.getRootQueue().assignContainer(node), Resources.none())) { + assignedContainers++; assignedContainer = true; } if (!assignedContainer) { break; } 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/fair/TestFairScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java index b26f4c1162a..d2598be69f2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java @@ -1382,6 +1382,37 @@ public class TestFairScheduler { assertEquals(1, app2.getLiveContainers().size()); } + @Test(timeout = 3000) + public void testMaxAssign() throws AllocationConfigurationException { + // set required scheduler configs + scheduler.assignMultiple = true; + scheduler.getQueueManager().getLeafQueue("root.default") + .setPolicy(SchedulingPolicy.getDefault()); + + RMNode node = MockNodes.newNodeInfo(1, Resources.createResource(16384)); + NodeAddedSchedulerEvent nodeEvent = new NodeAddedSchedulerEvent(node); + NodeUpdateSchedulerEvent updateEvent = new NodeUpdateSchedulerEvent(node); + scheduler.handle(nodeEvent); + + ApplicationAttemptId attId = + createSchedulingRequest(1024, "root.default", "user", 8); + FSSchedulerApp app = scheduler.applications.get(attId); + + // set maxAssign to 2: only 2 containers should be allocated + scheduler.maxAssign = 2; + scheduler.update(); + scheduler.handle(updateEvent); + assertEquals("Incorrect number of containers allocated", 2, app + .getLiveContainers().size()); + + // set maxAssign to -1: all remaining containers should be allocated + scheduler.maxAssign = -1; + scheduler.update(); + scheduler.handle(updateEvent); + assertEquals("Incorrect number of containers allocated", 8, app + .getLiveContainers().size()); + } + /** * Test to verify the behavior of * {@link FSQueue#assignContainer(FSSchedulerNode)})