diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 0023635204..dc966e98fb 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -146,6 +146,9 @@ Release 2.0.3-alpha - Unreleased YARN-272. Fair scheduler log messages try to print objects without overridden toString methods. (sandyr via tucu) + YARN-278. Fair scheduler maxRunningApps config causes no apps to make + progress. (sandyr via tucu) + Release 2.0.2-alpha - 2012-09-07 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/FSLeafQueue.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/FSLeafQueue.java index 8b3e13420b..1b466a66bd 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/FSLeafQueue.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/FSLeafQueue.java @@ -177,7 +177,9 @@ public Resource assignContainer(FSSchedulerNode node, boolean reserved) { Collections.sort(appScheds, comparator); for (AppSchedulable sched: appScheds) { - return sched.assignContainer(node, reserved); + if (sched.getRunnable()) { + return sched.assignContainer(node, reserved); + } } return Resources.none(); 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 44e1cca93d..e43897ae15 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 @@ -161,6 +161,13 @@ private ApplicationAttemptId createSchedulingRequest(int memory, String queueId, scheduler.allocate(id, ask, new ArrayList()); return id; } + + private void createSchedulingRequestExistingApplication(int memory, int priority, ApplicationAttemptId attId) { + List ask = new ArrayList(); + ResourceRequest request = createResourceRequest(memory, "*", priority, 1); + ask.add(request); + scheduler.allocate(attId, ask, new ArrayList()); + } // TESTS @@ -1125,4 +1132,59 @@ public void testMultipleContainersWaitingForReservation() { assertEquals(0, scheduler.applications.get(attId2).getCurrentReservation().getMemory()); } + + @Test + public void testUserMaxRunningApps() throws Exception { + // Set max running apps + Configuration conf = createConfiguration(); + conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE); + scheduler.reinitialize(conf, resourceManager.getRMContext()); + + PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE)); + out.println(""); + out.println(""); + out.println(""); + out.println("1"); + out.println(""); + out.println(""); + out.close(); + + QueueManager queueManager = scheduler.getQueueManager(); + queueManager.initialize(); + + // Add a node + RMNode node1 = MockNodes.newNodeInfo(1, Resources.createResource(8192)); + NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1); + scheduler.handle(nodeEvent1); + + // Request for app 1 + ApplicationAttemptId attId1 = createSchedulingRequest(1024, "queue1", + "user1", 1); + + scheduler.update(); + NodeUpdateSchedulerEvent updateEvent = new NodeUpdateSchedulerEvent(node1, + new ArrayList(), new ArrayList()); + scheduler.handle(updateEvent); + + // App 1 should be running + assertEquals(1, scheduler.applications.get(attId1).getLiveContainers().size()); + + ApplicationAttemptId attId2 = createSchedulingRequest(1024, "queue1", + "user1", 1); + + scheduler.update(); + scheduler.handle(updateEvent); + + // App 2 should not be running + assertEquals(0, scheduler.applications.get(attId2).getLiveContainers().size()); + + // Request another container for app 1 + createSchedulingRequestExistingApplication(1024, 1, attId1); + + scheduler.update(); + scheduler.handle(updateEvent); + + // Request should be fulfilled + assertEquals(2, scheduler.applications.get(attId1).getLiveContainers().size()); + } }