String[] siblings = proposedConf.getQueues(parentQueue); List<String> siblingQueues = siblings == null ? new ArrayList<>() : new ArrayList<>(Arrays.<String>asList(siblings));
: (parent.getQueuePath() + "." + queueName); String[] childQueueNames = conf.getQueues(fullQueueName); boolean isReservableQueue = conf.isReservable(fullQueueName); if (childQueueNames == null || childQueueNames.length == 0) {
: (parent.getQueuePath() + "." + queueName); String[] childQueueNames = conf.getQueues(fullQueueName); boolean isReservableQueue = conf.isReservable(fullQueueName); if (childQueueNames == null || childQueueNames.length == 0) {
queueName : (parent.getQueuePath() + "." + queueName); String[] childQueueNames = conf.getQueues(fullQueueName); boolean isReservableQueue = conf.isReservable(fullQueueName); boolean isAutoCreateEnabled = conf.isAutoCreateChildQueueEnabled(
@Test public void testGetSchedulerConf() throws Exception { CapacitySchedulerConfiguration orgConf = getSchedulerConf(); assertNotNull(orgConf); assertEquals(3, orgConf.getQueues("root").length); }
CapacitySchedulerConfiguration orgConf = getSchedulerConf(); assertNotNull(orgConf); assertEquals(3, orgConf.getQueues("root").length); CapacitySchedulerConfiguration newCSConf = ((CapacityScheduler) rm.getResourceScheduler()).getConfiguration(); assertEquals(4, newCSConf.getQueues("root").length); assertEquals(2, newCSConf.getQueues("root.d").length); assertEquals(25.0f, newCSConf.getNonLabeledQueueCapacity("root.d.d1"), 0.01f); assertEquals(4, newConf.getQueues("root").length);
@Test public void testRemoveMultipleQueues() throws Exception { WebResource r = resource(); ClientResponse response; stopQueue("root.b", "root.c", "root.c.c1"); // Remove root.b and root.c SchedConfUpdateInfo updateInfo = new SchedConfUpdateInfo(); updateInfo.getRemoveQueueInfo().add("root.b"); updateInfo.getRemoveQueueInfo().add("root.c"); Map<String, String> aCapacity = new HashMap<>(); aCapacity.put(CapacitySchedulerConfiguration.CAPACITY, "100"); aCapacity.put(CapacitySchedulerConfiguration.MAXIMUM_CAPACITY, "100"); QueueConfigInfo configInfo = new QueueConfigInfo("root.a", aCapacity); updateInfo.getUpdateQueueInfo().add(configInfo); response = r.path("ws").path("v1").path("cluster") .path("scheduler-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) .entity(YarnWebServiceUtils.toJson(updateInfo, SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); CapacitySchedulerConfiguration newCSConf = ((CapacityScheduler) rm.getResourceScheduler()).getConfiguration(); assertEquals(1, newCSConf.getQueues("root").length); }
@Test public void testAddWithUpdate() throws Exception { WebResource r = resource(); ClientResponse response; // Add root.d with capacity 25, reducing root.b capacity from 75 to 50. SchedConfUpdateInfo updateInfo = new SchedConfUpdateInfo(); Map<String, String> dCapacity = new HashMap<>(); dCapacity.put(CapacitySchedulerConfiguration.CAPACITY, "25"); Map<String, String> bCapacity = new HashMap<>(); bCapacity.put(CapacitySchedulerConfiguration.CAPACITY, "50"); QueueConfigInfo d = new QueueConfigInfo("root.d", dCapacity); QueueConfigInfo b = new QueueConfigInfo("root.b", bCapacity); updateInfo.getAddQueueInfo().add(d); updateInfo.getUpdateQueueInfo().add(b); response = r.path("ws").path("v1").path("cluster") .path("scheduler-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) .entity(YarnWebServiceUtils.toJson(updateInfo, SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); CapacitySchedulerConfiguration newCSConf = ((CapacityScheduler) rm.getResourceScheduler()).getConfiguration(); assertEquals(4, newCSConf.getQueues("root").length); assertEquals(25.0f, newCSConf.getNonLabeledQueueCapacity("root.d"), 0.01f); assertEquals(50.0f, newCSConf.getNonLabeledQueueCapacity("root.b"), 0.01f); }
@Test public void testRemoveQueue() throws Exception { WebResource r = resource(); ClientResponse response; stopQueue("root.a.a2"); // Remove root.a.a2 SchedConfUpdateInfo updateInfo = new SchedConfUpdateInfo(); updateInfo.getRemoveQueueInfo().add("root.a.a2"); response = r.path("ws").path("v1").path("cluster") .path("scheduler-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) .entity(YarnWebServiceUtils.toJson(updateInfo, SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); CapacitySchedulerConfiguration newCSConf = ((CapacityScheduler) rm.getResourceScheduler()).getConfiguration(); assertEquals(1, newCSConf.getQueues("root.a").length); assertEquals("a1", newCSConf.getQueues("root.a")[0]); }
@Test public void testRemoveParentQueue() throws Exception { WebResource r = resource(); ClientResponse response; stopQueue("root.c", "root.c.c1"); // Remove root.c (parent queue) SchedConfUpdateInfo updateInfo = new SchedConfUpdateInfo(); updateInfo.getRemoveQueueInfo().add("root.c"); response = r.path("ws").path("v1").path("cluster") .path("scheduler-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) .entity(YarnWebServiceUtils.toJson(updateInfo, SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); CapacitySchedulerConfiguration newCSConf = ((CapacityScheduler) rm.getResourceScheduler()).getConfiguration(); assertEquals(2, newCSConf.getQueues("root").length); assertNull(newCSConf.getQueues("root.c")); }
@Test public void testRemoveParentQueueWithCapacity() throws Exception { WebResource r = resource(); ClientResponse response; stopQueue("root.a", "root.a.a1", "root.a.a2"); // Remove root.a (parent queue) with capacity 25 SchedConfUpdateInfo updateInfo = new SchedConfUpdateInfo(); updateInfo.getRemoveQueueInfo().add("root.a"); // Set root.b capacity to 100 Map<String, String> bCapacity = new HashMap<>(); bCapacity.put(CapacitySchedulerConfiguration.CAPACITY, "100"); QueueConfigInfo b = new QueueConfigInfo("root.b", bCapacity); updateInfo.getUpdateQueueInfo().add(b); response = r.path("ws").path("v1").path("cluster") .path("scheduler-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) .entity(YarnWebServiceUtils.toJson(updateInfo, SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); CapacitySchedulerConfiguration newCSConf = ((CapacityScheduler) rm.getResourceScheduler()).getConfiguration(); assertEquals(2, newCSConf.getQueues("root").length); assertEquals(100.0f, newCSConf.getNonLabeledQueueCapacity("root.b"), 0.01f); }