hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yu...@apache.org
Subject hadoop git commit: YARN-6864. FSPreemptionThread cleanup for readability. (Daniel Templeton via Yufei Gu)
Date Fri, 28 Jul 2017 06:20:09 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 38c6fa5c7 -> 9902be72c


YARN-6864. FSPreemptionThread cleanup for readability. (Daniel Templeton via Yufei Gu)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/9902be72
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/9902be72
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/9902be72

Branch: refs/heads/trunk
Commit: 9902be72cbf7a170caa5cb1f13c227d881a39064
Parents: 38c6fa5
Author: Yufei Gu <yufei@apache.org>
Authored: Thu Jul 27 23:19:39 2017 -0700
Committer: Yufei Gu <yufei@apache.org>
Committed: Thu Jul 27 23:19:39 2017 -0700

----------------------------------------------------------------------
 .../scheduler/fair/FSPreemptionThread.java      | 28 ++++++++++----------
 1 file changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/9902be72/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSPreemptionThread.java
----------------------------------------------------------------------
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/FSPreemptionThread.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/FSPreemptionThread.java
index efe36a6..b3e59c5 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/FSPreemptionThread.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/FSPreemptionThread.java
@@ -66,11 +66,11 @@ class FSPreemptionThread extends Thread {
     schedulerReadLock = scheduler.getSchedulerReadLock();
   }
 
+  @Override
   public void run() {
     while (!Thread.interrupted()) {
-      FSAppAttempt starvedApp;
-      try{
-        starvedApp = context.getStarvedApps().take();
+      try {
+        FSAppAttempt starvedApp = context.getStarvedApps().take();
         // Hold the scheduler readlock so this is not concurrent with the
         // update thread.
         schedulerReadLock.lock();
@@ -82,7 +82,7 @@ class FSPreemptionThread extends Thread {
         starvedApp.preemptionTriggered(delayBeforeNextStarvationCheck);
       } catch (InterruptedException e) {
         LOG.info("Preemption thread interrupted! Exiting.");
-        return;
+        Thread.currentThread().interrupt();
       }
     }
   }
@@ -112,16 +112,19 @@ class FSPreemptionThread extends Thread {
         PreemptableContainers bestContainers = null;
         List<FSSchedulerNode> potentialNodes = scheduler.getNodeTracker()
             .getNodesByResourceName(rr.getResourceName());
+        int maxAMContainers = Integer.MAX_VALUE;
+
         for (FSSchedulerNode node : potentialNodes) {
-          int maxAMContainers = bestContainers == null ?
-              Integer.MAX_VALUE : bestContainers.numAMContainers;
           PreemptableContainers preemptableContainers =
               identifyContainersToPreemptOnNode(
                   rr.getCapability(), node, maxAMContainers);
+
           if (preemptableContainers != null) {
             // This set is better than any previously identified set.
             bestContainers = preemptableContainers;
-            if (preemptableContainers.numAMContainers == 0) {
+            maxAMContainers = bestContainers.numAMContainers;
+
+            if (maxAMContainers == 0) {
               break;
             }
           }
@@ -182,13 +185,10 @@ class FSPreemptionThread extends Thread {
         return preemptableContainers;
       }
     }
-    return null;
-  }
 
-  private boolean isNodeAlreadyReserved(
-      FSSchedulerNode node, FSAppAttempt app) {
-    FSAppAttempt nodeReservedApp = node.getReservedAppSchedulable();
-    return nodeReservedApp != null && !nodeReservedApp.equals(app);
+    // Return null if the sum of all preemptable containers' resources
+    // isn't enough to satisfy the starved request.
+    return null;
   }
 
   private void trackPreemptionsAgainstNode(List<RMContainer> containers,
@@ -214,7 +214,7 @@ class FSPreemptionThread extends Thread {
   }
 
   private class PreemptContainersTask extends TimerTask {
-    private List<RMContainer> containers;
+    private final List<RMContainer> containers;
 
     PreemptContainersTask(List<RMContainer> containers) {
       this.containers = containers;


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message