Browse Source

YARN-6165. Intra-queue preemption occurs even when preemption is turned off for a specific queue. Contributed by Eric Payne

(cherry picked from commit d7762a55113a529abd6f4ecb8e6d9b0a84b56e08)
Jason Lowe 8 years ago
parent
commit
4a1187238a

+ 5 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/capacity/IntraQueueCandidatesSelector.java

@@ -112,6 +112,11 @@ public class IntraQueueCandidatesSelector extends PreemptionCandidatesSelector {
           continue;
           continue;
         }
         }
 
 
+        // Don't preempt if disabled for this queue.
+        if (leafQueue.getPreemptionDisabled()) {
+          continue;
+        }
+
         // 5. Calculate the resource to obtain per partition
         // 5. Calculate the resource to obtain per partition
         Map<String, Resource> resToObtainByPartition = fifoPreemptionComputePlugin
         Map<String, Resource> resToObtainByPartition = fifoPreemptionComputePlugin
             .getResourceDemandFromAppsPerQueue(queueName, partition);
             .getResourceDemandFromAppsPerQueue(queueName, partition);

+ 55 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/capacity/TestProportionalCapacityPreemptionPolicyIntraQueue.java

@@ -105,6 +105,61 @@ public class TestProportionalCapacityPreemptionPolicyIntraQueue
             getAppAttemptId(3))));
             getAppAttemptId(3))));
   }
   }
 
 
+  @Test
+  public void testNoIntraQueuePreemptionWithPreemptionDisabledOnQueues()
+      throws IOException {
+    /**
+     * This test has the same configuration as testSimpleIntraQueuePreemption
+     * except that preemption is disabled specifically for each queue. The
+     * purpose is to test that disabling preemption on a specific queue will
+     * avoid intra-queue preemption.
+     */
+    conf.setPreemptionDisabled("root.a", true);
+    conf.setPreemptionDisabled("root.b", true);
+    conf.setPreemptionDisabled("root.c", true);
+    conf.setPreemptionDisabled("root.d", true);
+
+    String labelsConfig = "=100,true;";
+    String nodesConfig = // n1 has no label
+        "n1= res=100";
+    String queuesConfig =
+        // guaranteed,max,used,pending,reserved
+        "root(=[100 100 80 120 0]);" + // root
+            "-a(=[11 100 11 50 0]);" + // a
+            "-b(=[40 100 38 60 0]);" + // b
+            "-c(=[20 100 10 10 0]);" + // c
+            "-d(=[29 100 20 0 0])"; // d
+
+    String appsConfig =
+        // queueName\t(priority,resource,host,expression,#repeat,reserved,
+        // pending)
+        "a\t" // app1 in a
+            + "(1,1,n1,,6,false,25);" + // app1 a
+            "a\t" // app2 in a
+            + "(1,1,n1,,5,false,25);" + // app2 a
+            "b\t" // app3 in b
+            + "(4,1,n1,,34,false,20);" + // app3 b
+            "b\t" // app4 in b
+            + "(4,1,n1,,2,false,10);" + // app4 b
+            "b\t" // app4 in b
+            + "(5,1,n1,,1,false,10);" + // app5 b
+            "b\t" // app4 in b
+            + "(6,1,n1,,1,false,10);" + // app6 in b
+            "c\t" // app1 in a
+            + "(1,1,n1,,10,false,10);" + "d\t" // app7 in c
+            + "(1,1,n1,,20,false,0)";
+
+    buildEnv(labelsConfig, nodesConfig, queuesConfig, appsConfig);
+    policy.editSchedule();
+
+    verify(mDisp, times(0)).handle(argThat(
+        new TestProportionalCapacityPreemptionPolicy.IsPreemptionRequestFor(
+            getAppAttemptId(4))));
+    verify(mDisp, times(0)).handle(argThat(
+        new TestProportionalCapacityPreemptionPolicy.IsPreemptionRequestFor(
+            getAppAttemptId(3))));
+  }
+
   @Test
   @Test
   public void testNoPreemptionForSamePriorityApps() throws IOException {
   public void testNoPreemptionForSamePriorityApps() throws IOException {
     /**
     /**