diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/QueueInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/QueueInfo.java index 897b44267f1..57ea9bfe44c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/QueueInfo.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/QueueInfo.java @@ -94,6 +94,26 @@ public static QueueInfo newInstance(String queueName, float capacity, return queueInfo; } + @Private + @Unstable + public static QueueInfo newInstance(String queueName, float capacity, + float maximumCapacity, float currentCapacity, + List childQueues, List applications, + QueueState queueState, Set accessibleNodeLabels, + String defaultNodeLabelExpression, QueueStatistics queueStatistics, + boolean preemptionDisabled, + Map queueConfigurations, + boolean intraQueuePreemptionDisabled) { + QueueInfo queueInfo = QueueInfo.newInstance(queueName, capacity, + maximumCapacity, currentCapacity, + childQueues, applications, + queueState, accessibleNodeLabels, + defaultNodeLabelExpression, queueStatistics, + preemptionDisabled, queueConfigurations); + queueInfo.setIntraQueuePreemptionDisabled(intraQueuePreemptionDisabled); + return queueInfo; + } + /** * Get the name of the queue. * @return name of the queue @@ -261,4 +281,19 @@ public abstract void setDefaultNodeLabelExpression( @Unstable public abstract void setQueueConfigurations( Map queueConfigurations); + + + /** + * Get the intra-queue preemption status of the queue. + * @return if property is not in proto, return null; + * otherwise, return intra-queue preemption status of the queue + */ + @Public + @Stable + public abstract Boolean getIntraQueuePreemptionDisabled(); + + @Private + @Unstable + public abstract void setIntraQueuePreemptionDisabled( + boolean intraQueuePreemptionDisabled); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto index 07b8335d0aa..80c043fbab9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto @@ -500,6 +500,7 @@ message QueueInfoProto { optional QueueStatisticsProto queueStatistics = 10; optional bool preemptionDisabled = 11; repeated QueueConfigurationsMapProto queueConfigurationsMap = 12; + optional bool intraQueuePreemptionDisabled = 13; } message QueueConfigurationsProto { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/QueueCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/QueueCLI.java index 330b081c73a..2c3dfd01bfc 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/QueueCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/QueueCLI.java @@ -158,5 +158,11 @@ private void printQueueInfo(PrintWriter writer, QueueInfo queueInfo) { writer.print("\tPreemption : "); writer.println(preemptStatus ? "disabled" : "enabled"); } + + Boolean intraQueuePreemption = queueInfo.getIntraQueuePreemptionDisabled(); + if (intraQueuePreemption != null) { + writer.print("\tIntra-queue Preemption : "); + writer.println(intraQueuePreemption ? "disabled" : "enabled"); + } } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/ProtocolHATestBase.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/ProtocolHATestBase.java index efb198731b0..d90e1317b13 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/ProtocolHATestBase.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/ProtocolHATestBase.java @@ -666,7 +666,8 @@ public YarnClusterMetrics createFakeYarnClusterMetrics() { public QueueInfo createFakeQueueInfo() { return QueueInfo.newInstance("root", 100f, 100f, 50f, null, - createFakeAppReports(), QueueState.RUNNING, null, null, null, false); + createFakeAppReports(), QueueState.RUNNING, null, null, null, false, + null, false); } public List createFakeQueueUserACLInfoList() { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java index 3970a11653a..0f0c9bfd086 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java @@ -1700,7 +1700,8 @@ public void testGetQueueInfo() throws Exception { nodeLabels.add("GPU"); nodeLabels.add("JDK_7"); QueueInfo queueInfo = QueueInfo.newInstance("queueA", 0.4f, 0.8f, 0.5f, - null, null, QueueState.RUNNING, nodeLabels, "GPU", null, false, null); + null, null, QueueState.RUNNING, nodeLabels, "GPU", null, false, null, + false); when(client.getQueueInfo(any(String.class))).thenReturn(queueInfo); int result = cli.run(new String[] { "-status", "queueA" }); assertEquals(0, result); @@ -1716,13 +1717,14 @@ public void testGetQueueInfo() throws Exception { pw.println("\tDefault Node Label expression : " + "GPU"); pw.println("\tAccessible Node Labels : " + "JDK_7,GPU"); pw.println("\tPreemption : " + "enabled"); + pw.println("\tIntra-queue Preemption : " + "enabled"); pw.close(); String queueInfoStr = baos.toString("UTF-8"); Assert.assertEquals(queueInfoStr, sysOutStream.toString()); } @Test - public void testGetQueueInfoPreemptionEnabled() throws Exception { + public void testGetQueueInfoOverrideIntraQueuePreemption() throws Exception { CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration(); ReservationSystemTestUtil.setupQueueConfiguration(conf); conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, @@ -1731,9 +1733,80 @@ public void testGetQueueInfoPreemptionEnabled() throws Exception { conf.set(YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES, "org.apache.hadoop.yarn.server.resourcemanager.monitor.capacity." + "ProportionalCapacityPreemptionPolicy"); + // Turn on cluster-wide intra-queue preemption + conf.setBoolean( + CapacitySchedulerConfiguration.INTRAQUEUE_PREEMPTION_ENABLED, true); + // Disable intra-queue preemption for all queues + conf.setBoolean(CapacitySchedulerConfiguration.PREFIX + + "root.intra-queue-preemption.disable_preemption", true); + // Enable intra-queue preemption for the a1 queue + conf.setBoolean(CapacitySchedulerConfiguration.PREFIX + + "root.a.a1.intra-queue-preemption.disable_preemption", false); + MiniYARNCluster cluster = + new MiniYARNCluster("testGetQueueInfoOverrideIntraQueuePreemption", + 2, 1, 1); + + YarnClient yarnClient = null; + try { + cluster.init(conf); + cluster.start(); + final Configuration yarnConf = cluster.getConfig(); + yarnClient = YarnClient.createYarnClient(); + yarnClient.init(yarnConf); + yarnClient.start(); + + QueueCLI cli = new QueueCLI(); + cli.setClient(yarnClient); + cli.setSysOutPrintStream(sysOut); + cli.setSysErrPrintStream(sysErr); + sysOutStream.reset(); + // Get status for the root.a queue + int result = cli.run(new String[] { "-status", "a" }); + assertEquals(0, result); + String queueStatusOut = sysOutStream.toString(); + Assert.assertTrue(queueStatusOut + .contains("\tPreemption : enabled")); + // In-queue preemption is disabled at the "root.a" queue level + Assert.assertTrue(queueStatusOut + .contains("Intra-queue Preemption : disabled")); + cli = new QueueCLI(); + cli.setClient(yarnClient); + cli.setSysOutPrintStream(sysOut); + cli.setSysErrPrintStream(sysErr); + sysOutStream.reset(); + // Get status for the root.a.a1 queue + result = cli.run(new String[] { "-status", "a1" }); + assertEquals(0, result); + queueStatusOut = sysOutStream.toString(); + Assert.assertTrue(queueStatusOut + .contains("\tPreemption : enabled")); + // In-queue preemption is enabled at the "root.a.a1" queue level + Assert.assertTrue(queueStatusOut + .contains("Intra-queue Preemption : enabled")); + } finally { + // clean-up + if (yarnClient != null) { + yarnClient.stop(); + } + cluster.stop(); + cluster.close(); + } + } + + @Test + public void testGetQueueInfoPreemptionEnabled() throws Exception { + CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration(); + ReservationSystemTestUtil.setupQueueConfiguration(conf); + conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, + ResourceScheduler.class); conf.setBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS, true); + conf.set(YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES, + "org.apache.hadoop.yarn.server.resourcemanager.monitor.capacity." + + "ProportionalCapacityPreemptionPolicy"); + conf.setBoolean( + CapacitySchedulerConfiguration.INTRAQUEUE_PREEMPTION_ENABLED, true); MiniYARNCluster cluster = - new MiniYARNCluster("testReservationAPIs", 2, 1, 1); + new MiniYARNCluster("testGetQueueInfoPreemptionEnabled", 2, 1, 1); YarnClient yarnClient = null; try { @@ -1751,8 +1824,11 @@ public void testGetQueueInfoPreemptionEnabled() throws Exception { sysOutStream.reset(); int result = cli.run(new String[] { "-status", "a1" }); assertEquals(0, result); - Assert.assertTrue(sysOutStream.toString() - .contains("Preemption : enabled")); + String queueStatusOut = sysOutStream.toString(); + Assert.assertTrue(queueStatusOut + .contains("\tPreemption : enabled")); + Assert.assertTrue(queueStatusOut + .contains("Intra-queue Preemption : enabled")); } finally { // clean-up if (yarnClient != null) { @@ -1792,8 +1868,11 @@ public void testGetQueueInfoPreemptionDisabled() throws Exception { sysOutStream.reset(); int result = cli.run(new String[] { "-status", "a1" }); assertEquals(0, result); - Assert.assertTrue(sysOutStream.toString() - .contains("Preemption : disabled")); + String queueStatusOut = sysOutStream.toString(); + Assert.assertTrue(queueStatusOut + .contains("\tPreemption : disabled")); + Assert.assertTrue(queueStatusOut + .contains("Intra-queue Preemption : disabled")); } } @@ -1801,7 +1880,7 @@ public void testGetQueueInfoPreemptionDisabled() throws Exception { public void testGetQueueInfoWithEmptyNodeLabel() throws Exception { QueueCLI cli = createAndGetQueueCLI(); QueueInfo queueInfo = QueueInfo.newInstance("queueA", 0.4f, 0.8f, 0.5f, - null, null, QueueState.RUNNING, null, null, null, true, null); + null, null, QueueState.RUNNING, null, null, null, true, null, true); when(client.getQueueInfo(any(String.class))).thenReturn(queueInfo); int result = cli.run(new String[] { "-status", "queueA" }); assertEquals(0, result); @@ -1818,6 +1897,7 @@ public void testGetQueueInfoWithEmptyNodeLabel() throws Exception { + NodeLabel.DEFAULT_NODE_LABEL_PARTITION); pw.println("\tAccessible Node Labels : "); pw.println("\tPreemption : " + "disabled"); + pw.println("\tIntra-queue Preemption : " + "disabled"); pw.close(); String queueInfoStr = baos.toString("UTF-8"); Assert.assertEquals(queueInfoStr, sysOutStream.toString()); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueInfoPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueInfoPBImpl.java index 1d2a6dd4645..f7351399c65 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueInfoPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueInfoPBImpl.java @@ -500,4 +500,17 @@ public void setQueueConfigurations( this.queueConfigurations.putAll(queueConfigurations); } + @Override + public Boolean getIntraQueuePreemptionDisabled() { + QueueInfoProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasIntraQueuePreemptionDisabled()) ? p + .getIntraQueuePreemptionDisabled() : null; + } + + @Override + public void setIntraQueuePreemptionDisabled( + boolean intraQueuePreemptionDisabled) { + maybeInitBuilder(); + builder.setIntraQueuePreemptionDisabled(intraQueuePreemptionDisabled); + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPBImplRecords.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPBImplRecords.java index 1d3bf034c32..5998dd0bfd7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPBImplRecords.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPBImplRecords.java @@ -390,7 +390,7 @@ public static void setup() throws Exception { // it is recursive(has sub queues) typeValueCache.put(QueueInfo.class, QueueInfo.newInstance("root", 1.0f, 1.0f, 0.1f, null, null, QueueState.RUNNING, ImmutableSet.of("x", "y"), - "x && y", null, false)); + "x && y", null, false, null, false)); generateByNewInstance(QueueStatistics.class); generateByNewInstance(QueueUserACLInfo.class); generateByNewInstance(YarnClusterMetrics.class); diff --git a/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 b/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 index 44fa736945d..5b6932e6403 100644 --- a/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 +++ b/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 @@ -114,8 +114,8 @@ public int compare(TempAppPerPartition ta1, TempAppPerPartition ta2) { continue; } - // Don't preempt if disabled for this queue. - if (leafQueue.getPreemptionDisabled()) { + // Don't preempt if intra-queue preemption is disabled for this queue. + if (leafQueue.getIntraQueuePreemptionDisabled()) { continue; } 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/capacity/AbstractCSQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractCSQueue.java index d7c452a1ffc..e3050859c57 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractCSQueue.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractCSQueue.java @@ -94,6 +94,9 @@ new HashMap(); volatile boolean reservationsContinueLooking; private volatile boolean preemptionDisabled; + // Indicates if the in-queue preemption setting is ever disabled within the + // hierarchy of this queue. + private boolean intraQueuePreemptionDisabledInHierarchy; // Track resource usage-by-label like used-resource/pending-resource, etc. volatile ResourceUsage queueUsage; @@ -339,6 +342,8 @@ void setupQueueConfigs(Resource clusterResource) csContext.getConfiguration().getReservationContinueLook(); this.preemptionDisabled = isQueueHierarchyPreemptionDisabled(this); + this.intraQueuePreemptionDisabledInHierarchy = + isIntraQueueHierarchyPreemptionDisabled(this); this.priority = csContext.getConfiguration().getQueuePriority( getQueuePath()); @@ -429,6 +434,8 @@ protected QueueInfo getQueueInfo() { queueInfo.setCurrentCapacity(getUsedCapacity()); queueInfo.setQueueStatistics(getQueueStatistics()); queueInfo.setPreemptionDisabled(preemptionDisabled); + queueInfo.setIntraQueuePreemptionDisabled( + getIntraQueuePreemptionDisabled()); queueInfo.setQueueConfigurations(getQueueConfigurations()); return queueInfo; } @@ -543,6 +550,16 @@ public boolean getReservationContinueLooking() { public boolean getPreemptionDisabled() { return preemptionDisabled; } + + @Private + public boolean getIntraQueuePreemptionDisabled() { + return intraQueuePreemptionDisabledInHierarchy || preemptionDisabled; + } + + @Private + public boolean getIntraQueuePreemptionDisabledInHierarchy() { + return intraQueuePreemptionDisabledInHierarchy; + } @Private public QueueCapacities getQueueCapacities() { @@ -560,12 +577,13 @@ public ResourceUsage getQueueResourceUsage() { } /** - * The specified queue is preemptable if system-wide preemption is turned on - * unless any queue in the qPath hierarchy has explicitly turned - * preemption off. - * NOTE: Preemptability is inherited from a queue's parent. - * - * @return true if queue has preemption disabled, false otherwise + * The specified queue is cross-queue preemptable if system-wide cross-queue + * preemption is turned on unless any queue in the qPath hierarchy + * has explicitly turned cross-queue preemption off. + * NOTE: Cross-queue preemptability is inherited from a queue's parent. + * + * @param q queue to check preemption state + * @return true if queue has cross-queue preemption disabled, false otherwise */ private boolean isQueueHierarchyPreemptionDisabled(CSQueue q) { CapacitySchedulerConfiguration csConf = csContext.getConfiguration(); @@ -592,7 +610,42 @@ private boolean isQueueHierarchyPreemptionDisabled(CSQueue q) { return csConf.getPreemptionDisabled(q.getQueuePath(), parentQ.getPreemptionDisabled()); } - + + /** + * The specified queue is intra-queue preemptable if + * 1) system-wide intra-queue preemption is turned on + * 2) no queue in the qPath hierarchy has explicitly turned off intra + * queue preemption. + * NOTE: Intra-queue preemptability is inherited from a queue's parent. + * + * @param q queue to check intra-queue preemption state + * @return true if queue has intra-queue preemption disabled, false otherwise + */ + private boolean isIntraQueueHierarchyPreemptionDisabled(CSQueue q) { + CapacitySchedulerConfiguration csConf = csContext.getConfiguration(); + boolean systemWideIntraQueuePreemption = + csConf.getBoolean( + CapacitySchedulerConfiguration.INTRAQUEUE_PREEMPTION_ENABLED, + CapacitySchedulerConfiguration + .DEFAULT_INTRAQUEUE_PREEMPTION_ENABLED); + // Intra-queue preemption is disabled for this queue if the system-wide + // intra-queue preemption flag is false + if (!systemWideIntraQueuePreemption) return true; + + // Check if this is the root queue and the root queue's intra-queue + // preemption disable switch is set + CSQueue parentQ = q.getParent(); + if (parentQ == null) { + return csConf.getIntraQueuePreemptionDisabled(q.getQueuePath(), false); + } + + // At this point, the master preemption switch is enabled down to this + // queue's level. Determine whether or not intra-queue preemption is enabled + // down to this queu's level and return that value. + return csConf.getIntraQueuePreemptionDisabled(q.getQueuePath(), + parentQ.getIntraQueuePreemptionDisabledInHierarchy()); + } + private Resource getCurrentLimitResource(String nodePartition, Resource clusterResource, ResourceLimits currentResourceLimits, SchedulingMode schedulingMode) { 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/capacity/CSQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CSQueue.java index 3a17d1b057d..95d8d9b1182 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CSQueue.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CSQueue.java @@ -275,7 +275,21 @@ public void attachContainer(Resource clusterResource, * @return true if disable_preemption is set, false if not */ public boolean getPreemptionDisabled(); - + + /** + * Check whether intra-queue preemption is disabled for this queue + * @return true if either intra-queue preemption or inter-queue preemption + * is disabled for this queue, false if neither is disabled. + */ + public boolean getIntraQueuePreemptionDisabled(); + + /** + * Determines whether or not the intra-queue preemption disabled switch is set + * at any level in this queue's hierarchy. + * @return state of the intra-queue preemption switch at this queue level + */ + public boolean getIntraQueuePreemptionDisabledInHierarchy(); + /** * Get QueueCapacities of this queue * @return queueCapacities 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/capacity/CapacitySchedulerConfiguration.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerConfiguration.java index bfead359340..1e22e0b7ed4 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerConfiguration.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerConfiguration.java @@ -1116,6 +1116,21 @@ public boolean getPreemptionDisabled(String queue, boolean defaultVal) { return preemptionDisabled; } + /** + * Indicates whether intra-queue preemption is disabled on the specified queue + * + * @param queue queue path to query + * @param defaultVal used as default if the property is not set in the + * configuration + * @return true if preemption is disabled on queue, false otherwise + */ + public boolean getIntraQueuePreemptionDisabled(String queue, + boolean defaultVal) { + return + getBoolean(getQueuePrefix(queue) + INTRA_QUEUE_PREEMPTION_CONFIG_PREFIX + + QUEUE_PREEMPTION_DISABLED, defaultVal); + } + /** * Get configured node labels in a given queuePath */ diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/CapacitySchedulerPage.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/CapacitySchedulerPage.java index ebbfb782741..bff7522bb42 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/CapacitySchedulerPage.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/CapacitySchedulerPage.java @@ -184,6 +184,8 @@ private void renderCommonLeafQueueInfo(ResponseInfo ri) { _("Accessible Node Labels:", StringUtils.join(",", lqinfo.getNodeLabels())). _("Ordering Policy: ", lqinfo.getOrderingPolicyInfo()). _("Preemption:", lqinfo.getPreemptionDisabled() ? "disabled" : "enabled"). + _("Intra-queue Preemption:", lqinfo.getIntraQueuePreemptionDisabled() + ? "disabled" : "enabled"). _("Default Node Label Expression:", lqinfo.getDefaultNodeLabelExpression() == null ? NodeLabel.DEFAULT_NODE_LABEL_PARTITION diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerLeafQueueInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerLeafQueueInfo.java index 7dcdf582225..c3b56c10a5a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerLeafQueueInfo.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerLeafQueueInfo.java @@ -46,6 +46,7 @@ protected ResourceInfo usedAMResource; protected ResourceInfo userAMResourceLimit; protected boolean preemptionDisabled; + protected boolean intraQueuePreemptionDisabled; protected String defaultNodeLabelExpression; protected int defaultPriority; @@ -68,6 +69,7 @@ AMResourceLimit = new ResourceInfo(q.getAMResourceLimit()); usedAMResource = new ResourceInfo(q.getQueueResourceUsage().getAMUsed()); preemptionDisabled = q.getPreemptionDisabled(); + intraQueuePreemptionDisabled = q.getIntraQueuePreemptionDisabled(); orderingPolicyInfo = q.getOrderingPolicy().getInfo(); defaultNodeLabelExpression = q.getDefaultNodeLabelExpression(); defaultPriority = q.getDefaultApplicationPriority().getPriority(); @@ -141,6 +143,10 @@ public ResourceInfo getUserAMResourceLimit() { public boolean getPreemptionDisabled() { return preemptionDisabled; } + + public boolean getIntraQueuePreemptionDisabled() { + return intraQueuePreemptionDisabled; + } public String getOrderingPolicyInfo() { return orderingPolicyInfo; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestConfigurationMutationACLPolicies.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestConfigurationMutationACLPolicies.java index 398e90921e3..9a23c1d180e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestConfigurationMutationACLPolicies.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestConfigurationMutationACLPolicies.java @@ -67,7 +67,7 @@ public void setUp() throws IOException { private void mockQueue(String queueName, MutableConfScheduler scheduler) throws IOException { QueueInfo queueInfo = QueueInfo.newInstance(queueName, 0, 0, 0, null, null, - null, null, null, null, false); + null, null, null, null, false, null, false); when(scheduler.getQueueInfo(eq(queueName), anyBoolean(), anyBoolean())) .thenReturn(queueInfo); Queue queue = mock(Queue.class); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerApplicationAttempt.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerApplicationAttempt.java index fa16effd25f..17f9d235c31 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerApplicationAttempt.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerApplicationAttempt.java @@ -165,7 +165,7 @@ private Queue createQueue(String name, Queue parent) { private Queue createQueue(String name, Queue parent, float capacity) { QueueMetrics metrics = QueueMetrics.forQueue(name, parent, false, conf); QueueInfo queueInfo = QueueInfo.newInstance(name, capacity, 1.0f, 0, null, - null, QueueState.RUNNING, null, "", null, false); + null, QueueState.RUNNING, null, "", null, false, null, false); ActiveUsersManager activeUsersManager = new ActiveUsersManager(metrics); Queue queue = mock(Queue.class); when(queue.getMetrics()).thenReturn(metrics); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java index 8f97ea494ee..115373b3671 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java @@ -3980,7 +3980,7 @@ private AbstractCSQueue createQueue(String name, Queue parent, float capacity, float absCap) { CSQueueMetrics metrics = CSQueueMetrics.forQueue(name, parent, false, cs.getConf()); QueueInfo queueInfo = QueueInfo.newInstance(name, capacity, 1.0f, 0, null, - null, QueueState.RUNNING, null, "", null, false); + null, QueueState.RUNNING, null, "", null, false, null, false); ActiveUsersManager activeUsersManager = new ActiveUsersManager(metrics); AbstractCSQueue queue = mock(AbstractCSQueue.class); when(queue.getMetrics()).thenReturn(metrics); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java index 95f7c024e2b..dc15d04ae03 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java @@ -351,7 +351,7 @@ private void verifySubQueue(JSONObject info, String q, int numExpectedElements = 18; boolean isParentQueue = true; if (!info.has("queues")) { - numExpectedElements = 31; + numExpectedElements = 32; isParentQueue = false; } assertEquals("incorrect number of elements", numExpectedElements, info.length()); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/CapacityScheduler.md b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/CapacityScheduler.md index 0449e88b74b..5814e391835 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/CapacityScheduler.md +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/CapacityScheduler.md @@ -228,6 +228,7 @@ The following configuration parameters can be configured in yarn-site.xml to con | Property | Description | |:---- |:---- | | `yarn.scheduler.capacity..disable_preemption` | This configuration can be set to `true` to selectively disable preemption of application containers submitted to a given queue. This property applies only when system wide preemption is enabled by configuring `yarn.resourcemanager.scheduler.monitor.enable` to *true* and `yarn.resourcemanager.scheduler.monitor.policies` to *ProportionalCapacityPreemptionPolicy*. If this property is not set for a queue, then the property value is inherited from the queue's parent. Default value is false. +| `yarn.scheduler.capacity..intra-queue-preemption.disable_preemption` | This configuration can be set to *true* to selectively disable intra-queue preemption of application containers submitted to a given queue. This property applies only when system wide preemption is enabled by configuring `yarn.resourcemanager.scheduler.monitor.enable` to *true*, `yarn.resourcemanager.scheduler.monitor.policies` to *ProportionalCapacityPreemptionPolicy*, and `yarn.resourcemanager.monitor.capacity.preemption.intra-queue-preemption.enabled` to *true*. If this property is not set for a queue, then the property value is inherited from the queue's parent. Default value is *false*. ###Reservation Properties @@ -383,4 +384,4 @@ Updating a Container (Experimental - API may change in the future) The **DECREASE_RESOURCE** and **DEMOTE_EXECUTION_TYPE** container updates are automatic - the AM does not explicitly have to ask the NM to decrease the resources of the container. The other update types require the AM to explicitly ask the NM to update the container. - If the **yarn.resourcemanager.auto-update.containers** configuration parameter is set to **true** (false by default), The RM will ensure that all container updates are automatic. \ No newline at end of file + If the **yarn.resourcemanager.auto-update.containers** configuration parameter is set to **true** (false by default), The RM will ensure that all container updates are automatic.