diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/JAXBContextResolver.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/JAXBContextResolver.java index 5f5e1ef..7d7a347 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/JAXBContextResolver.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/JAXBContextResolver.java @@ -53,7 +53,8 @@ public JAXBContextResolver() throws Exception { NodesInfo.class, RemoteExceptionData.class, CapacitySchedulerQueueInfoList.class, ResourceInfo.class, UsersInfo.class, UserInfo.class, ApplicationStatisticsInfo.class, - StatisticsItemInfo.class, CapacitySchedulerHealthInfo.class }; + StatisticsItemInfo.class, CapacitySchedulerHealthInfo.class, + FairSchedulerQueueInfoList.class}; // these dao classes need root unwrapping final Class[] rootUnwrappedTypes = { NewApplication.class, ApplicationSubmissionContextInfo.class, diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/FairSchedulerQueueInfo.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/FairSchedulerQueueInfo.java index 5fbfe51..cf27f5d 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/FairSchedulerQueueInfo.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/FairSchedulerQueueInfo.java @@ -19,7 +19,6 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao; -import java.util.ArrayList; import java.util.Collection; import javax.xml.bind.annotation.XmlAccessType; @@ -61,7 +60,7 @@ private String queueName; private String schedulingPolicy; - private Collection childQueues; + private FairSchedulerQueueInfoList childQueues; public FairSchedulerQueueInfo() { } @@ -95,7 +94,7 @@ public FairSchedulerQueueInfo(FSQueue queue, FairScheduler scheduler) { maxApps = allocConf.getQueueMaxApps(queueName); - childQueues = new ArrayList(); + childQueues = new FairSchedulerQueueInfoList(); if (allocConf.isReservable(queueName) && !allocConf.getShowReservationAsQueues(queueName)) { return; @@ -104,9 +103,11 @@ public FairSchedulerQueueInfo(FSQueue queue, FairScheduler scheduler) { Collection children = queue.getChildQueues(); for (FSQueue child : children) { if (child instanceof FSLeafQueue) { - childQueues.add(new FairSchedulerLeafQueueInfo((FSLeafQueue)child, scheduler)); + childQueues.addToQueueInfoList( + new FairSchedulerLeafQueueInfo((FSLeafQueue)child, scheduler)); } else { - childQueues.add(new FairSchedulerQueueInfo(child, scheduler)); + childQueues.addToQueueInfoList( + new FairSchedulerQueueInfo(child, scheduler)); } } } @@ -191,6 +192,6 @@ public String getSchedulingPolicy() { } public Collection getChildQueues() { - return childQueues; + return childQueues.getQueueInfoList(); } } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/FairSchedulerQueueInfoList.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/FairSchedulerQueueInfoList.java new file mode 100644 index 0000000..113e9a1 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/FairSchedulerQueueInfoList.java @@ -0,0 +1,46 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao; + +import java.util.ArrayList; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class FairSchedulerQueueInfoList { + protected ArrayList queue; + + public FairSchedulerQueueInfoList() { + queue = new ArrayList<>(); + } + + public ArrayList getQueueInfoList() { + return this.queue; + } + + public boolean addToQueueInfoList(FairSchedulerQueueInfo e) { + return this.queue.add(e); + } + + public FairSchedulerQueueInfo getQueueInfo(int i) { + return this.queue.get(i); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesFairScheduler.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesFairScheduler.java index 21ca6a7..46af875 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesFairScheduler.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesFairScheduler.java @@ -27,8 +27,10 @@ import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler; +import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.QueueManager; import org.apache.hadoop.yarn.webapp.GenericExceptionHandler; import org.apache.hadoop.yarn.webapp.JerseyTestBase; +import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; import org.junit.Test; @@ -99,6 +101,29 @@ public void testClusterSchedulerSlash() throws JSONException, Exception { verifyClusterScheduler(json); } + @Test + public void testClusterSchedulerWithSubQueues() throws JSONException, + Exception { + FairScheduler scheduler = (FairScheduler)rm.getResourceScheduler(); + QueueManager queueManager = scheduler.getQueueManager(); + // create LeafQueue + queueManager.getLeafQueue("root.q.subqueue1", true); + queueManager.getLeafQueue("root.q.subqueue2", true); + + WebResource r = resource(); + ClientResponse response = r.path("ws").path("v1").path("cluster") + .path("scheduler").accept(MediaType.APPLICATION_JSON) + .get(ClientResponse.class); + assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + JSONObject json = response.getEntity(JSONObject.class); + JSONArray subQueueInfo = json.getJSONObject("scheduler") + .getJSONObject("schedulerInfo").getJSONObject("rootQueue") + .getJSONObject("childQueues").getJSONArray("queue") + .getJSONObject(1).getJSONObject("childQueues").getJSONArray("queue"); + // subQueueInfo is consist of subqueue1 and subqueue2 info + assertEquals(2, subQueueInfo.length()); + } + private void verifyClusterScheduler(JSONObject json) throws JSONException, Exception { assertEquals("incorrect number of elements", 1, json.length()); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/ResourceManagerRest.md hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/ResourceManagerRest.md index c3fd9b8..e02596c 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/ResourceManagerRest.md +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/ResourceManagerRest.md @@ -1044,43 +1044,16 @@ Response Body: "scheduler": { "schedulerInfo": { "rootQueue": { - "childQueues": [ - { - "clusterResources": { - "memory": 8192, - "vCores": 8 - }, - "fairResources": { - "memory": 0, - "vCores": 0 - }, - "maxApps": 2147483647, - "maxResources": { - "memory": 8192, - "vCores": 8 - }, - "minResources": { - "memory": 0, - "vCores": 0 - }, - "numActiveApps": 0, - "numPendingApps": 0, - "queueName": "root.default", - "schedulingPolicy": "fair", - "type": "fairSchedulerLeafQueueInfo", - "usedResources": { - "memory": 0, - "vCores": 0 - } - }, - { - "childQueues": { + "childQueues": { + "queue": [ + { + "childQueues": null, "clusterResources": { "memory": 8192, "vCores": 8 }, "fairResources": { - "memory": 10000, + "memory": 0, "vCores": 0 }, "maxApps": 2147483647, @@ -1089,46 +1062,81 @@ Response Body: "vCores": 8 }, "minResources": { - "memory": 5000, + "memory": 0, "vCores": 0 }, "numActiveApps": 0, "numPendingApps": 0, - "queueName": "root.sample_queue.sample_sub_queue", + "queueName": "root.default", "schedulingPolicy": "fair", - "type": [ - "fairSchedulerLeafQueueInfo" - ], + "type": "fairSchedulerLeafQueueInfo", "usedResources": { "memory": 0, "vCores": 0 } }, - "clusterResources": { - "memory": 8192, - "vCores": 8 - }, - "fairResources": { - "memory": 10000, - "vCores": 0 - }, - "maxApps": 50, - "maxResources": { - "memory": 8192, - "vCores": 0 - }, - "minResources": { - "memory": 10000, - "vCores": 0 - }, - "queueName": "root.sample_queue", - "schedulingPolicy": "fair", - "usedResources": { - "memory": 0, - "vCores": 0 + { + "childQueues": { + "queue": [ + { + "childQueues": null, + "clusterResources": { + "memory": 8192, + "vCores": 8 + }, + "fairResources": { + "memory": 10000, + "vCores": 0 + }, + "maxApps": 2147483647, + "maxResources": { + "memory": 8192, + "vCores": 8 + }, + "minResources": { + "memory": 5000, + "vCores": 0 + }, + "numActiveApps": 0, + "numPendingApps": 0, + "queueName": "root.sample_queue.sample_sub_queue", + "schedulingPolicy": "fair", + "type": [ + "fairSchedulerLeafQueueInfo" + ], + "usedResources": { + "memory": 0, + "vCores": 0 + } + } + ] + }, + "clusterResources": { + "memory": 8192, + "vCores": 8 + }, + "fairResources": { + "memory": 10000, + "vCores": 0 + }, + "maxApps": 50, + "maxResources": { + "memory": 8192, + "vCores": 0 + }, + "minResources": { + "memory": 10000, + "vCores": 0 + }, + "queueName": "root.sample_queue", + "schedulingPolicy": "fair", + "usedResources": { + "memory": 0, + "vCores": 0 + } } - } - ], + ], + }, "clusterResources": { "memory": 8192, "vCores": 8