Skip to content

Commit c19326c

Browse files
YARN-10610. Add queuePath to RESTful API for CapacityScheduler consistent with FairScheduler queuePath. Contributed by Qi Zhu
1 parent 79a4659 commit c19326c

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerInfo.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class CapacitySchedulerInfo extends SchedulerInfo {
4949
protected float weight;
5050
protected float normalizedWeight;
5151
protected String queueName;
52+
private String queuePath;
5253
protected CapacitySchedulerQueueInfoList queues;
5354
protected QueueCapacitiesInfo capacities;
5455
protected CapacitySchedulerHealthInfo health;
@@ -69,6 +70,7 @@ public CapacitySchedulerInfo() {
6970

7071
public CapacitySchedulerInfo(CSQueue parent, CapacityScheduler cs) {
7172
this.queueName = parent.getQueueName();
73+
this.queuePath = parent.getQueuePath();
7274
this.usedCapacity = parent.getUsedCapacity() * 100;
7375
this.capacity = parent.getCapacity() * 100;
7476
float max = parent.getMaximumCapacity();
@@ -134,6 +136,10 @@ public String getQueueName() {
134136
return this.queueName;
135137
}
136138

139+
public String getQueuePath() {
140+
return this.queuePath;
141+
}
142+
137143
public ResourceInfo getMaximumAllocation() {
138144
return maximumAllocation;
139145
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerQueueInfo.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ public class CapacitySchedulerQueueInfo {
5757
@XmlTransient
5858
static final float EPSILON = 1e-8f;
5959

60-
@XmlTransient
6160
protected String queuePath;
62-
6361
protected float capacity;
6462
protected float usedCapacity;
6563
protected float maxCapacity;

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,14 @@ private class QueueInfo {
8484
float absoluteUsedCapacity;
8585
int numApplications;
8686
String queueName;
87+
private String queuePath;
8788
String state;
8889
boolean isAbsoluteResource;
8990
boolean autoCreateChildQueueEnabled;
91+
92+
public String getQueuePath() {
93+
return queuePath;
94+
}
9095
}
9196

9297
private class LeafQueueInfo extends QueueInfo {
@@ -261,7 +266,8 @@ public void verifyClusterSchedulerXML(NodeList nodes) throws Exception {
261266
WebServicesTestUtils.getXmlFloat(element, "usedCapacity"),
262267
WebServicesTestUtils.getXmlFloat(element, "capacity"),
263268
WebServicesTestUtils.getXmlFloat(element, "maxCapacity"),
264-
WebServicesTestUtils.getXmlString(element, "queueName"));
269+
WebServicesTestUtils.getXmlString(element, "queueName"),
270+
WebServicesTestUtils.getXmlString(element, "queuePath"));
265271

266272
NodeList children = element.getChildNodes();
267273
for (int j = 0; j < children.getLength(); j++) {
@@ -306,6 +312,7 @@ public void verifySubQueueXML(Element qElem, String q,
306312
qi.numApplications =
307313
WebServicesTestUtils.getXmlInt(qElem, "numApplications");
308314
qi.queueName = WebServicesTestUtils.getXmlString(qElem, "queueName");
315+
qi.queuePath = WebServicesTestUtils.getXmlString(qElem, "queuePath");
309316
qi.state = WebServicesTestUtils.getXmlString(qElem, "state");
310317
qi.autoCreateChildQueueEnabled = WebServicesTestUtils.getXmlBoolean(qElem,
311318
"autoCreateChildQueueEnabled");
@@ -362,11 +369,13 @@ private void verifyClusterScheduler(JSONObject json) throws JSONException,
362369
JSONObject info = json.getJSONObject("scheduler");
363370
assertEquals("incorrect number of elements in: " + info, 1, info.length());
364371
info = info.getJSONObject("schedulerInfo");
365-
assertEquals("incorrect number of elements in: " + info, 18, info.length());
372+
assertEquals("incorrect number of elements in: " + info, 19, info.length());
366373
verifyClusterSchedulerGeneric(info.getString("type"),
367374
(float) info.getDouble("usedCapacity"),
368375
(float) info.getDouble("capacity"),
369-
(float) info.getDouble("maxCapacity"), info.getString("queueName"));
376+
(float) info.getDouble("maxCapacity"),
377+
info.getString("queueName"),
378+
info.getString("queuePath"));
370379
JSONObject health = info.getJSONObject("health");
371380
assertNotNull(health);
372381
assertEquals("incorrect number of elements in: " + health, 3,
@@ -401,22 +410,24 @@ private void verifyClusterScheduler(JSONObject json) throws JSONException,
401410
}
402411

403412
private void verifyClusterSchedulerGeneric(String type, float usedCapacity,
404-
float capacity, float maxCapacity, String queueName) throws Exception {
413+
float capacity, float maxCapacity, String queueName, String queuePath)
414+
throws Exception {
405415

406416
assertTrue("type doesn't match", "capacityScheduler".matches(type));
407417
assertEquals("usedCapacity doesn't match", 0, usedCapacity, 1e-3f);
408418
assertEquals("capacity doesn't match", 100, capacity, 1e-3f);
409419
assertEquals("maxCapacity doesn't match", 100, maxCapacity, 1e-3f);
410420
assertTrue("queueName doesn't match", "root".matches(queueName));
421+
assertTrue("queuePath doesn't match", "root".matches(queuePath));
411422
}
412423

413424
private void verifySubQueue(JSONObject info, String q,
414425
float parentAbsCapacity, float parentAbsMaxCapacity)
415426
throws JSONException, Exception {
416-
int numExpectedElements = 33;
427+
int numExpectedElements = 34;
417428
boolean isParentQueue = true;
418429
if (!info.has("queues")) {
419-
numExpectedElements = 51;
430+
numExpectedElements = 52;
420431
isParentQueue = false;
421432
}
422433
assertEquals("incorrect number of elements", numExpectedElements, info.length());
@@ -430,6 +441,7 @@ private void verifySubQueue(JSONObject info, String q,
430441
qi.absoluteUsedCapacity = (float) info.getDouble("absoluteUsedCapacity");
431442
qi.numApplications = info.getInt("numApplications");
432443
qi.queueName = info.getString("queueName");
444+
qi.queuePath = info.getString("queuePath");
433445
qi.state = info.getString("state");
434446

435447
verifySubQueueGeneric(q, qi, parentAbsCapacity, parentAbsMaxCapacity);
@@ -502,6 +514,8 @@ private void verifySubQueueGeneric(String q, QueueInfo info,
502514
assertEquals("numApplications doesn't match", 0, info.numApplications);
503515
assertTrue("queueName doesn't match, got: " + info.queueName
504516
+ " expected: " + q, qshortName.matches(info.queueName));
517+
assertTrue("queuePath doesn't match, got: " + info.getQueuePath()
518+
+ " expected: " + q, q.matches(info.getQueuePath()));
505519
assertTrue("state doesn't match",
506520
(csConf.getState(q).toString()).matches(info.state));
507521
if (q.equals("c")) {

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesForCSWithPartitions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ private void verifySchedulerInfoJson(JSONObject json)
574574
JSONObject info = json.getJSONObject("scheduler");
575575
assertEquals("incorrect number of elements", 1, info.length());
576576
info = info.getJSONObject("schedulerInfo");
577-
assertEquals("incorrect number of elements", 18, info.length());
577+
assertEquals("incorrect number of elements", 19, info.length());
578578
JSONObject capacitiesJsonObject = info.getJSONObject(CAPACITIES);
579579
JSONArray partitionsCapsArray =
580580
capacitiesJsonObject.getJSONArray(QUEUE_CAPACITIES_BY_PARTITION);

0 commit comments

Comments
 (0)