From 3de47ab5ea5cb75805a03010dc72e11b0cf6c173 Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Sun, 9 Jul 2017 16:08:37 -0700 Subject: [PATCH] YARN-6764. Simplify the logic in FairScheduler#attemptScheduling. Contributed by Yufei Gu. --- .../resourcemanager/scheduler/fair/FairScheduler.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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 d7791590849..b41d3f71dc5 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 @@ -1046,16 +1046,13 @@ public class FairScheduler extends Resource maxResourcesToAssign = Resources.multiply( node.getUnallocatedResource(), 0.5f); while (node.getReservedContainer() == null) { - boolean assignedContainer = false; Resource assignment = queueMgr.getRootQueue().assignContainer(node); - if (!assignment.equals(Resources.none())) { - assignedContainers++; - assignedContainer = true; - Resources.addTo(assignedResource, assignment); - } - if (!assignedContainer) { + if (assignment.equals(Resources.none())) { break; } + + assignedContainers++; + Resources.addTo(assignedResource, assignment); if (!shouldContinueAssigning(assignedContainers, maxResourcesToAssign, assignedResource)) { break;