Skip to content

Commit 4f00815

Browse files
committed
YARN-10587. Fix AutoCreateLeafQueueCreation cap related caculation when in absolute mode. (Qi Zhu via wangda)
Change-Id: I8889c393a9f08b633c72a2e873c6f45ca12cc82b
1 parent b7384a8 commit 4f00815

3 files changed

Lines changed: 19 additions & 14 deletions

File tree

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/queuemanagement/GuaranteedOrZeroCapacityOverTimePolicy.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
.queuemanagement;
2020

2121
import org.apache.hadoop.thirdparty.com.google.common.annotations.VisibleForTesting;
22+
import org.apache.hadoop.yarn.api.records.Resource;
2223
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueueUtils;
2324
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity
2425
.QueueManagementDynamicEditPolicy;
@@ -624,7 +625,7 @@ private Map<String, QueueCapacities> deactivateLeafQueuesIfInActive(
624625

625626
QueueCapacities capacities = leafQueueEntitlements.get(
626627
leafQueue.getQueuePath());
627-
updateToZeroCapacity(capacities, nodeLabel);
628+
updateToZeroCapacity(capacities, nodeLabel, (LeafQueue)childQueue);
628629
deactivatedQueues.put(leafQueue.getQueuePath(),
629630
leafQueueTemplateCapacities);
630631
}
@@ -822,7 +823,7 @@ public AutoCreatedLeafQueueConfig getInitialLeafQueueConfiguration(
822823
updateCapacityFromTemplate(capacities, nodeLabel);
823824
activate(leafQueue, nodeLabel);
824825
} else{
825-
updateToZeroCapacity(capacities, nodeLabel);
826+
updateToZeroCapacity(capacities, nodeLabel, leafQueue);
826827
}
827828
}
828829

@@ -834,10 +835,12 @@ public AutoCreatedLeafQueueConfig getInitialLeafQueueConfiguration(
834835
}
835836

836837
private void updateToZeroCapacity(QueueCapacities capacities,
837-
String nodeLabel) {
838+
String nodeLabel, LeafQueue leafQueue) {
838839
capacities.setCapacity(nodeLabel, 0.0f);
839840
capacities.setMaximumCapacity(nodeLabel,
840841
leafQueueTemplateCapacities.getMaximumCapacity(nodeLabel));
842+
leafQueue.getQueueResourceQuotas().
843+
setConfiguredMinResource(nodeLabel, Resource.newInstance(0, 0));
841844
}
842845

843846
private void updateCapacityFromTemplate(QueueCapacities capacities,

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestAbsoluteResourceConfiguration.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,18 +231,20 @@ public void testSimpleMinMaxResourceConfigurartionPerQueue()
231231
d1.queueResourceQuotas.getEffectiveMaxResource());
232232

233233
/**
234-
* After adding child queue d2, adjustment happens and both d1 and d2 shares
235-
* resource of Managed Parent Queue
234+
* After adding child queue d2, d1 + d2 > resource
235+
* of Managed Parent queue, d2 will change to 0.
236+
* d1 will occupy all entire resource
237+
* of Managed Parent queue.
236238
*/
237239
AutoCreatedLeafQueue d2 = new AutoCreatedLeafQueue(cs, "d2", parentQueue);
238240
cs.addQueue(d2);
239241

240242
cs.getRootQueue().updateClusterResource(cs.getClusterResource(),
241243
new ResourceLimits(cs.getClusterResource()));
242244

243-
Assert.assertEquals(QUEUE_D_TEMPL_MINRES,
245+
Assert.assertEquals(Resource.newInstance(0, 0),
244246
d2.queueResourceQuotas.getConfiguredMinResource());
245-
Assert.assertEquals(Resource.newInstance(12800, 2),
247+
Assert.assertEquals(Resource.newInstance(0, 0),
246248
d2.queueResourceQuotas.getEffectiveMinResource());
247249
Assert.assertEquals(QUEUE_D_TEMPL_MAXRES,
248250
d2.queueResourceQuotas.getConfiguredMaxResource());
@@ -251,7 +253,7 @@ public void testSimpleMinMaxResourceConfigurartionPerQueue()
251253

252254
Assert.assertEquals(QUEUE_D_TEMPL_MINRES,
253255
d1.queueResourceQuotas.getConfiguredMinResource());
254-
Assert.assertEquals(Resource.newInstance(12800, 2),
256+
Assert.assertEquals(QUEUE_D_TEMPL_MINRES,
255257
d1.queueResourceQuotas.getEffectiveMinResource());
256258
Assert.assertEquals(QUEUE_D_TEMPL_MAXRES,
257259
d1.queueResourceQuotas.getConfiguredMaxResource());

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestAbsoluteResourceWithAutoQueue.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,12 @@ public void testAutoCreateLeafQueueCreation() throws Exception {
235235
3, 1);
236236

237237
final CSQueue autoCreatedLeafQueue2 = cs.getQueue(TEST_GROUPUSER2);
238-
validateCapacities((AutoCreatedLeafQueue) autoCreatedLeafQueue2,
239-
0.33332032f,
240-
0.03333203f, 1f, 0.6f);
241-
validateCapacities((AutoCreatedLeafQueue) autoCreatedLeafQueue1,
242-
0.33332032f,
243-
0.03333203f, 1f, 0.6f);
238+
validateCapacities((AutoCreatedLeafQueue) autoCreatedLeafQueue2, 0.0f,
239+
0.0f, 1f, 0.6f);
240+
validateCapacities((AutoCreatedLeafQueue) autoCreatedLeafQueue1, 0.4f,
241+
0.04f, 1f, 0.6f);
242+
validateCapacities((AutoCreatedLeafQueue) autoCreatedLeafQueue, 0.4f,
243+
0.04f, 1f, 0.6f);
244244

245245
GuaranteedOrZeroCapacityOverTimePolicy autoCreatedQueueManagementPolicy =
246246
(GuaranteedOrZeroCapacityOverTimePolicy) ((ManagedParentQueue) parentQueue)

0 commit comments

Comments
 (0)