Skip to content

Commit

Permalink
YARN-4477. FairScheduler: Handle condition which can result in an inf…
Browse files Browse the repository at this point in the history
…inite loop in attemptScheduling. (Tao Jie via asuresh)
  • Loading branch information
xslogic committed Dec 22, 2015
1 parent 0087734 commit e88422d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
3 changes: 3 additions & 0 deletions hadoop-yarn-project/CHANGES.txt
Expand Up @@ -1173,6 +1173,9 @@ Release 2.8.0 - UNRELEASED
YARN-4454. NM to nodelabel mapping going wrong after RM restart.
(Bibin A Chundatt via wangda)

YARN-4477. FairScheduler: Handle condition which can result in an
infinite loop in attemptScheduling. (Tao Jie via asuresh)

Release 2.7.3 - UNRELEASED

INCOMPATIBLE CHANGES
Expand Down
Expand Up @@ -458,8 +458,9 @@ public Container createContainer(
* the container is {@code alreadyReserved} on the node, simply
* update relevant bookeeping. This dispatches ro relevant handlers
* in {@link FSSchedulerNode}..
* return whether reservation was possible with the current threshold limits
*/
private void reserve(Priority priority, FSSchedulerNode node,
private boolean reserve(Priority priority, FSSchedulerNode node,
Container container, NodeType type, boolean alreadyReserved) {

if (!reservationExceedsThreshold(node, type)) {
Expand All @@ -477,7 +478,9 @@ private void reserve(Priority priority, FSSchedulerNode node,
node.reserveResource(this, priority, rmContainer);
setReservation(node);
}
return true;
}
return false;
}

private boolean reservationExceedsThreshold(FSSchedulerNode node,
Expand Down Expand Up @@ -627,10 +630,9 @@ private Resource assignContainer(
return container.getResource();
}

if (isReservable(container)) {
// The desired container won't fit here, so reserve
reserve(request.getPriority(), node, container, type, reserved);

// The desired container won't fit here, so reserve
if (isReservable(container) &&
reserve(request.getPriority(), node, container, type, reserved)) {
return FairScheduler.CONTAINER_RESERVED;
} else {
if (LOG.isDebugEnabled()) {
Expand Down
Expand Up @@ -981,6 +981,43 @@ public void testRackLocalAppReservationThreshold() throws Exception {
scheduler.getSchedulerApp(attId).getNumReservations(null, true));
}

@Test (timeout = 5000)
public void testReservationThresholdWithAssignMultiple() throws Exception {
// set reservable-nodes to 0 which make reservation exceed
conf.setFloat(FairSchedulerConfiguration.RESERVABLE_NODES, 0f);
conf.setBoolean(FairSchedulerConfiguration.ASSIGN_MULTIPLE, true);
scheduler.init(conf);
scheduler.start();
scheduler.reinitialize(conf, resourceManager.getRMContext());

// Add two node
RMNode node1 =
MockNodes
.newNodeInfo(1, Resources.createResource(4096, 4), 1, "127.0.0.1");
NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
scheduler.handle(nodeEvent1);
RMNode node2 =
MockNodes
.newNodeInfo(2, Resources.createResource(4096, 4), 1, "127.0.0.2");
NodeAddedSchedulerEvent nodeEvent2 = new NodeAddedSchedulerEvent(node2);
scheduler.handle(nodeEvent2);

//create one request and assign containers
ApplicationAttemptId attId = createSchedulingRequest(1024, "queue1", "user1", 10);
scheduler.update();
scheduler.handle(new NodeUpdateSchedulerEvent(node1));
scheduler.update();
scheduler.handle(new NodeUpdateSchedulerEvent(node2));

// Verify capacity allocation
assertEquals(8192, scheduler.getQueueManager().getQueue("queue1").
getResourceUsage().getMemory());

// Verify number of reservations have decremented
assertEquals(0,
scheduler.getSchedulerApp(attId).getNumReservations(null, true));
}

@Test (timeout = 500000)
public void testContainerReservationAttemptExceedingQueueMax()
throws Exception {
Expand Down Expand Up @@ -4152,6 +4189,7 @@ public void testQueueMaxAMShareDefault() throws Exception {
@Test
public void testQueueMaxAMShareWithContainerReservation() throws Exception {
conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
conf.setFloat(FairSchedulerConfiguration.RESERVABLE_NODES, 1f);
PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
out.println("<?xml version=\"1.0\"?>");
out.println("<allocations>");
Expand Down

0 comments on commit e88422d

Please sign in to comment.