YARN-278. Fair scheduler maxRunningApps config causes no apps to make progress. (sandyr via tucu)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1424989 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Alejandro Abdelnur 2012-12-21 16:07:11 +00:00
parent 39ec437268
commit f121d1e333
3 changed files with 68 additions and 1 deletions

View File

@ -146,6 +146,9 @@ Release 2.0.3-alpha - Unreleased
YARN-272. Fair scheduler log messages try to print objects without YARN-272. Fair scheduler log messages try to print objects without
overridden toString methods. (sandyr via tucu) 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 Release 2.0.2-alpha - 2012-09-07
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -177,7 +177,9 @@ public Resource assignContainer(FSSchedulerNode node, boolean reserved) {
Collections.sort(appScheds, comparator); Collections.sort(appScheds, comparator);
for (AppSchedulable sched: appScheds) { for (AppSchedulable sched: appScheds) {
return sched.assignContainer(node, reserved); if (sched.getRunnable()) {
return sched.assignContainer(node, reserved);
}
} }
return Resources.none(); return Resources.none();

View File

@ -161,6 +161,13 @@ private ApplicationAttemptId createSchedulingRequest(int memory, String queueId,
scheduler.allocate(id, ask, new ArrayList<ContainerId>()); scheduler.allocate(id, ask, new ArrayList<ContainerId>());
return id; return id;
} }
private void createSchedulingRequestExistingApplication(int memory, int priority, ApplicationAttemptId attId) {
List<ResourceRequest> ask = new ArrayList<ResourceRequest>();
ResourceRequest request = createResourceRequest(memory, "*", priority, 1);
ask.add(request);
scheduler.allocate(attId, ask, new ArrayList<ContainerId>());
}
// TESTS // TESTS
@ -1125,4 +1132,59 @@ public void testMultipleContainersWaitingForReservation() {
assertEquals(0, assertEquals(0,
scheduler.applications.get(attId2).getCurrentReservation().getMemory()); 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("<?xml version=\"1.0\"?>");
out.println("<allocations>");
out.println("<user name=\"user1\">");
out.println("<maxRunningApps>1</maxRunningApps>");
out.println("</user>");
out.println("</allocations>");
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<ContainerStatus>(), new ArrayList<ContainerStatus>());
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());
}
} }