Skip to content

Commit

Permalink
problem with queue resources vs different ResourceCalculator implemen…
Browse files Browse the repository at this point in the history
…tations

Change-Id: I11bfab5920fde8a5a3f42cfcc21a2120382f93de
  • Loading branch information
tomicooler committed Jun 7, 2023
1 parent 9f1e23c commit 1d67335
Show file tree
Hide file tree
Showing 4 changed files with 4,046 additions and 4 deletions.
Expand Up @@ -108,13 +108,13 @@ public TestRMWebServicesCapacitySched() {
@Override
public void setUp() throws Exception {
super.setUp();
rm = createMockRM(new CapacitySchedulerConfiguration(
new Configuration(false)));
rm = createMockRM(setupQueueConfiguration(new CapacitySchedulerConfiguration(
new Configuration(false))));
GuiceServletConfig.setInjector(
Guice.createInjector(new WebServletModule(rm)));
}

public static void setupQueueConfiguration(
public CapacitySchedulerConfiguration setupQueueConfiguration(
CapacitySchedulerConfiguration config) {

// Define top-level queues
Expand Down Expand Up @@ -167,6 +167,7 @@ public static void setupQueueConfiguration(
config.setAutoCreateChildQueueEnabled(a1C, true);
config.setInt(PREFIX + a1C + DOT + AUTO_CREATED_LEAF_QUEUE_TEMPLATE_PREFIX
+ DOT + CAPACITY, 50);
return config;
}

@Test
Expand Down Expand Up @@ -407,7 +408,6 @@ public static WebAppDescriptor createWebAppDescriptor() {
}

public static MockRM createMockRM(CapacitySchedulerConfiguration csConf) {
setupQueueConfiguration(csConf);
YarnConfiguration conf = new YarnConfiguration(csConf);
conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
ResourceScheduler.class);
Expand Down
Expand Up @@ -40,6 +40,7 @@
import org.apache.hadoop.yarn.webapp.JerseyTestBase;
import org.junit.Test;

import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfigGeneratorForTest.createConfiguration;
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestRMWebServicesCapacitySched.assertJsonResponse;
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestRMWebServicesCapacitySched.createMockRM;
Expand Down Expand Up @@ -169,6 +170,53 @@ public void testSchedulerResponseWeightModeWithAutoCreatedQueues()
"webapp/scheduler-response-WeightModeWithAutoCreatedQueues-After.json");
}

@Test
public void testDefaultVSDominantResourceCalculator()
throws Exception {
Map<String, String> conf = new HashMap<>();
boolean dominant = false; // TODO change this for test
if (dominant) {
conf.put("yarn.scheduler.capacity.resource-calculator", "org.apache.hadoop.yarn.util.resource.DominantResourceCalculator");
}
conf.put("yarn.scheduler.capacity.legacy-queue-mode.enabled", "true");
conf.put("yarn.scheduler.capacity.root.queues", "a, b");
conf.put("yarn.scheduler.capacity.root.a.capacity", "[memory=4096,vcores=8]");
conf.put("yarn.scheduler.capacity.root.b.capacity", "[memory=12288,vcores=8]");
conf.put("yarn.scheduler.capacity.root.b.queues", "b1, b2");
conf.put("yarn.scheduler.capacity.root.b.b1.capacity", "[memory=3072,vcores=6]");
conf.put("yarn.scheduler.capacity.root.b.b2.capacity", "[memory=9216,vcores=2]");

/*
DefaultResourceCalculator DominantResourceCalculator
capacity absoluteCapacity maxApps capacity absoluteCapacity maxApps
root.a 0.25 0.25 2500 0.5 0.5 5000
root.b 0.75 0.75 0.75 0.75
root.b.b1 0.25 0.1875 1875 0.5 0.375 3750
root.b.b2 0.75 0.5625 5625 0.75 0.5625 5625
I don't see any reason why the ResourceCalculator abstraction should affect the capacity/absoluteCapacity or any other property of the queue queues in the hierarchy.
The cluster resource should be shared amongst the queues based on the individual resource types. The effectiveMin/Max resource should be a concrete value for each
resource type. The absoluteCapacity could be calculated based only one resource type (memory), and every other calculated property should be based on that.
The DominantResourceCalculator is useful when the whole cluster is utilised by apps with multiple users (https://cs.stanford.edu/~matei/papers/2011/nsdi_drf.pdf)
Hopefully these are based on the effectiveMin/Max resources and the requested resources and no calculated property is involved (e.g.: absoluteCapacity/capacity).
*/


Configuration configuration = createConfiguration(conf);
initResourceManager(configuration);
rm.registerNode("h1:1234", 16384, 16);

if (dominant) {
assertJsonResponse(sendRequest(),
"webapp/scheduler-response-dominant-rc.json");
} else {
assertJsonResponse(sendRequest(),
"webapp/scheduler-response-default-rc.json");
}
}

private void initAutoQueueHandler(int nodeMemory) throws Exception {
CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
autoQueueHandler = cs.getCapacitySchedulerQueueManager();
Expand Down

0 comments on commit 1d67335

Please sign in to comment.