|
26 | 26 | import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; |
27 | 27 | import org.apache.hadoop.yarn.api.records.ContainerId; |
28 | 28 | import org.apache.hadoop.yarn.api.records.NodeId; |
| 29 | +import org.apache.hadoop.yarn.api.records.Resource; |
29 | 30 | import org.apache.hadoop.yarn.conf.YarnConfiguration; |
30 | 31 | import org.apache.hadoop.yarn.server.resourcemanager.MockAM; |
31 | 32 | import org.apache.hadoop.yarn.server.resourcemanager.MockNM; |
|
38 | 39 | import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; |
39 | 40 | import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer; |
40 | 41 | import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerState; |
| 42 | +import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceLimits; |
41 | 43 | import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler; |
42 | 44 | import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerAppReport; |
43 | 45 | import org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler; |
@@ -74,6 +76,28 @@ public static <E> Set<E> toSet(E... elements) { |
74 | 76 | return set; |
75 | 77 | } |
76 | 78 |
|
| 79 | + public static CapacitySchedulerConfiguration getConfigWithInheritedAccessibleNodeLabel( |
| 80 | + Configuration config) { |
| 81 | + CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration( |
| 82 | + config); |
| 83 | + |
| 84 | + // Define top-level queues |
| 85 | + conf.setQueues(CapacitySchedulerConfiguration.ROOT, |
| 86 | + new String[] { "a"}); |
| 87 | + |
| 88 | + conf.setCapacityByLabel(A, RMNodeLabelsManager.NO_LABEL, 100f); |
| 89 | + conf.setCapacityByLabel(A, "newLabel", 100f); |
| 90 | + conf.setAccessibleNodeLabels(A, toSet("newLabel")); |
| 91 | + conf.setAllowZeroCapacitySum(A, true); |
| 92 | + |
| 93 | + // Define 2nd-level queues |
| 94 | + conf.setQueues(A, new String[] { "a1" }); |
| 95 | + conf.setCapacityByLabel(A1, RMNodeLabelsManager.NO_LABEL, 100f); |
| 96 | + |
| 97 | + return conf; |
| 98 | + } |
| 99 | + |
| 100 | + |
77 | 101 | /* |
78 | 102 | * Queue structure: |
79 | 103 | * root (*) |
@@ -368,6 +392,28 @@ public void testChildAccessibleNodeLabelsWeightMode() throws Exception { |
368 | 392 | rm.close(); |
369 | 393 | } |
370 | 394 |
|
| 395 | + /** |
| 396 | + * Tests whether weight is correctly reset to -1. See YARN-11016 for further details. |
| 397 | + * @throws IOException if reinitialization fails |
| 398 | + */ |
| 399 | + @Test() |
| 400 | + public void testAccessibleNodeLabelsInheritanceNoWeightMode() throws IOException { |
| 401 | + CapacitySchedulerConfiguration newConf = getConfigWithInheritedAccessibleNodeLabel(conf); |
| 402 | + |
| 403 | + MockRM rm = new MockRM(newConf); |
| 404 | + CapacityScheduler cs = |
| 405 | + (CapacityScheduler) rm.getRMContext().getScheduler(); |
| 406 | + |
| 407 | + Resource clusterResource = Resource.newInstance(1024, 2); |
| 408 | + cs.getRootQueue().updateClusterResource(clusterResource, new ResourceLimits(clusterResource)); |
| 409 | + |
| 410 | + try { |
| 411 | + cs.reinitialize(newConf, rm.getRMContext()); |
| 412 | + } catch (Exception e) { |
| 413 | + Assert.fail("Reinitialization failed with " + e); |
| 414 | + } |
| 415 | + } |
| 416 | + |
371 | 417 | @Test |
372 | 418 | public void testQueueInfoWeight() throws Exception { |
373 | 419 | MockRM rm = new MockRM(conf); |
|
0 commit comments