YARN-6257. Fix CapacityScheduler REST API JSON output.
Contributed By Tao Yang
This commit is contained in:
parent
9d7a9031a5
commit
8fb00c3fce
@ -25,15 +25,14 @@
|
|||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class CapacitySchedulerHealthInfo {
|
public class CapacitySchedulerHealthInfo {
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public static class OperationInformation {
|
public static class OperationInformation {
|
||||||
|
String operation;
|
||||||
String nodeId;
|
String nodeId;
|
||||||
String containerId;
|
String containerId;
|
||||||
String queue;
|
String queue;
|
||||||
@ -41,7 +40,9 @@ public static class OperationInformation {
|
|||||||
OperationInformation() {
|
OperationInformation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
OperationInformation(SchedulerHealth.DetailedInformation di) {
|
OperationInformation(String operation,
|
||||||
|
SchedulerHealth.DetailedInformation di) {
|
||||||
|
this.operation = operation;
|
||||||
this.nodeId = di.getNodeId() == null ? "N/A" : di.getNodeId().toString();
|
this.nodeId = di.getNodeId() == null ? "N/A" : di.getNodeId().toString();
|
||||||
this.containerId =
|
this.containerId =
|
||||||
di.getContainerId() == null ? "N/A" : di.getContainerId().toString();
|
di.getContainerId() == null ? "N/A" : di.getContainerId().toString();
|
||||||
@ -59,6 +60,10 @@ public String getContainerId() {
|
|||||||
public String getQueue() {
|
public String getQueue() {
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getOperation() {
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@ -90,7 +95,7 @@ public ResourceInfo getResources() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
long lastrun;
|
long lastrun;
|
||||||
Map<String, OperationInformation> operationsInfo;
|
List<OperationInformation> operationsInfo;
|
||||||
List<LastRunDetails> lastRunDetails;
|
List<LastRunDetails> lastRunDetails;
|
||||||
|
|
||||||
CapacitySchedulerHealthInfo() {
|
CapacitySchedulerHealthInfo() {
|
||||||
@ -100,18 +105,22 @@ public long getLastrun() {
|
|||||||
return lastrun;
|
return lastrun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<OperationInformation> getOperationsInfo() {
|
||||||
|
return operationsInfo;
|
||||||
|
}
|
||||||
|
|
||||||
CapacitySchedulerHealthInfo(CapacityScheduler cs) {
|
CapacitySchedulerHealthInfo(CapacityScheduler cs) {
|
||||||
SchedulerHealth ht = cs.getSchedulerHealth();
|
SchedulerHealth ht = cs.getSchedulerHealth();
|
||||||
lastrun = ht.getLastSchedulerRunTime();
|
lastrun = ht.getLastSchedulerRunTime();
|
||||||
operationsInfo = new HashMap<>();
|
operationsInfo = new ArrayList<>();
|
||||||
operationsInfo.put("last-allocation",
|
operationsInfo.add(new OperationInformation("last-allocation",
|
||||||
new OperationInformation(ht.getLastAllocationDetails()));
|
ht.getLastAllocationDetails()));
|
||||||
operationsInfo.put("last-release",
|
operationsInfo.add(
|
||||||
new OperationInformation(ht.getLastReleaseDetails()));
|
new OperationInformation("last-release", ht.getLastReleaseDetails()));
|
||||||
operationsInfo.put("last-preemption",
|
operationsInfo.add(new OperationInformation("last-preemption",
|
||||||
new OperationInformation(ht.getLastPreemptionDetails()));
|
ht.getLastPreemptionDetails()));
|
||||||
operationsInfo.put("last-reservation",
|
operationsInfo.add(new OperationInformation("last-reservation",
|
||||||
new OperationInformation(ht.getLastReservationDetails()));
|
ht.getLastReservationDetails()));
|
||||||
|
|
||||||
lastRunDetails = new ArrayList<>();
|
lastRunDetails = new ArrayList<>();
|
||||||
lastRunDetails.add(new LastRunDetails("releases", ht.getReleaseCount(), ht
|
lastRunDetails.add(new LastRunDetails("releases", ht.getReleaseCount(), ht
|
||||||
|
@ -329,6 +329,10 @@ private void verifyClusterScheduler(JSONObject json) throws JSONException,
|
|||||||
JSONObject health = info.getJSONObject("health");
|
JSONObject health = info.getJSONObject("health");
|
||||||
assertNotNull(health);
|
assertNotNull(health);
|
||||||
assertEquals("incorrect number of elements", 3, health.length());
|
assertEquals("incorrect number of elements", 3, health.length());
|
||||||
|
JSONArray operationsInfo = health.getJSONArray("operationsInfo");
|
||||||
|
assertEquals("incorrect number of elements", 4, operationsInfo.length());
|
||||||
|
JSONArray lastRunDetails = health.getJSONArray("lastRunDetails");
|
||||||
|
assertEquals("incorrect number of elements", 3, lastRunDetails.length());
|
||||||
|
|
||||||
JSONArray arr = info.getJSONObject("queues").getJSONArray("queue");
|
JSONArray arr = info.getJSONObject("queues").getJSONArray("queue");
|
||||||
assertEquals("incorrect number of elements", 2, arr.length());
|
assertEquals("incorrect number of elements", 2, arr.length());
|
||||||
|
@ -311,6 +311,7 @@ The capacity scheduler supports hierarchical queues. This one request will print
|
|||||||
| maxCapacity | float | Configured maximum queue capacity in percentage relative to its parent queue |
|
| maxCapacity | float | Configured maximum queue capacity in percentage relative to its parent queue |
|
||||||
| queueName | string | Name of the queue |
|
| queueName | string | Name of the queue |
|
||||||
| queues | array of queues(JSON)/zero or more queue objects(XML) | A collection of queue resources |
|
| queues | array of queues(JSON)/zero or more queue objects(XML) | A collection of queue resources |
|
||||||
|
| health | A single health object | The health metrics of capacity scheduler. This metrics existed since 2.8.0, but the output was not well formatted. Hence users can not make use of this field cleanly, this is optimized from 3.2.0 onwards. |
|
||||||
|
|
||||||
### Elements of the queues object for a Parent queue
|
### Elements of the queues object for a Parent queue
|
||||||
|
|
||||||
@ -361,6 +362,31 @@ The capacity scheduler supports hierarchical queues. This one request will print
|
|||||||
| memory | int | The amount of memory used (in MB) |
|
| memory | int | The amount of memory used (in MB) |
|
||||||
| vCores | int | The number of virtual cores |
|
| vCores | int | The number of virtual cores |
|
||||||
|
|
||||||
|
### Elements of the health object in schedulerInfo:
|
||||||
|
|
||||||
|
| Item | Data Type | Description |
|
||||||
|
|:---- |:---- |:---- |
|
||||||
|
| lastrun | long | The time in which application started (in ms since epoch) |
|
||||||
|
| operationsInfo | array of operations(JSON)/operation objects(XML) | A collection of operation objects |
|
||||||
|
| lastRunDetails | array of lastRunDetails(JSON)/lastRunDetail objects(XML) | A collection of lastRunDetail objects |
|
||||||
|
|
||||||
|
### Elements of the operation object in health:
|
||||||
|
|
||||||
|
| Item | Data Type | Description |
|
||||||
|
|:---- |:---- |:---- |
|
||||||
|
| operation | string | The type of operation |
|
||||||
|
| nodeId | string | The id of the node to which the operation relates |
|
||||||
|
| containerId | string | The id of the container to which the operation relates |
|
||||||
|
| queue | string | The name of the queue to which the operation relates |
|
||||||
|
|
||||||
|
### Elements of the lastRunDetail object in health:
|
||||||
|
|
||||||
|
| Item | Data Type | Description |
|
||||||
|
|:---- |:---- |:---- |
|
||||||
|
| operation | string | The type of operation |
|
||||||
|
| count | long | The id of the node to which the operation relates |
|
||||||
|
| resources | A single resource object | The resources to which the operation relates |
|
||||||
|
|
||||||
#### Response Examples
|
#### Response Examples
|
||||||
|
|
||||||
**JSON response**
|
**JSON response**
|
||||||
@ -632,6 +658,61 @@ Response Body:
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"health": {
|
||||||
|
"lastrun": 1326381444693,
|
||||||
|
"operationsInfo": [
|
||||||
|
{
|
||||||
|
"operation": "last-allocation",
|
||||||
|
"nodeId": "N/A",
|
||||||
|
"containerId": "N/A",
|
||||||
|
"queue": "N/A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"operation": "last-release",
|
||||||
|
"nodeId": "host.domain.com:8041",
|
||||||
|
"containerId": "container_1326821518301_0005_01_000001",
|
||||||
|
"queue": "root.default"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"operation": "last-preemption",
|
||||||
|
"nodeId": "N/A",
|
||||||
|
"containerId": "N/A",
|
||||||
|
"queue": "N/A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"operation": "last-reservation",
|
||||||
|
"nodeId": "N/A",
|
||||||
|
"containerId": "N/A",
|
||||||
|
"queue": "N/A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"lastRunDetails": [
|
||||||
|
{
|
||||||
|
"operation": "releases",
|
||||||
|
"count": 0,
|
||||||
|
"resources": {
|
||||||
|
"memory": 0,
|
||||||
|
"vCores": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"operation": "allocations",
|
||||||
|
"count": 0,
|
||||||
|
"resources": {
|
||||||
|
"memory": 0,
|
||||||
|
"vCores": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"operation": "reservations",
|
||||||
|
"count": 0,
|
||||||
|
"resources": {
|
||||||
|
"memory": 0,
|
||||||
|
"vCores": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"type": "capacityScheduler",
|
"type": "capacityScheduler",
|
||||||
"usedCapacity": 0.0
|
"usedCapacity": 0.0
|
||||||
}
|
}
|
||||||
@ -894,6 +975,57 @@ Response Body:
|
|||||||
</resourcesUsed>
|
</resourcesUsed>
|
||||||
</queue>
|
</queue>
|
||||||
</queues>
|
</queues>
|
||||||
|
<health>
|
||||||
|
<lastrun>1326381444693</lastrun>
|
||||||
|
<operationsInfo>
|
||||||
|
<operation>last-allocation</operation>
|
||||||
|
<nodeId>N/A</nodeId>
|
||||||
|
<containerId>N/A</containerId>
|
||||||
|
<queue>N/A</queue>
|
||||||
|
</operationsInfo>
|
||||||
|
<operationsInfo>
|
||||||
|
<operation>last-release</operation>
|
||||||
|
<nodeId>host.domain.com:8041</nodeId>
|
||||||
|
<containerId>container_1326821518301_0005_01_000001</containerId>
|
||||||
|
<queue>root.default</queue>
|
||||||
|
</operationsInfo>
|
||||||
|
<operationsInfo>
|
||||||
|
<operation>last-preemption</operation>
|
||||||
|
<nodeId>N/A</nodeId>
|
||||||
|
<containerId>N/A</containerId>
|
||||||
|
<queue>N/A</queue>
|
||||||
|
</operationsInfo>
|
||||||
|
<operationsInfo>
|
||||||
|
<operation>last-reservation</operation>
|
||||||
|
<nodeId>N/A</nodeId>
|
||||||
|
<containerId>N/A</containerId>
|
||||||
|
<queue>N/A</queue>
|
||||||
|
</operationsInfo>
|
||||||
|
<lastRunDetails>
|
||||||
|
<operation>releases</operation>
|
||||||
|
<count>0</count>
|
||||||
|
<resources>
|
||||||
|
<memory>0</memory>
|
||||||
|
<vCores>0</vCores>
|
||||||
|
</resources>
|
||||||
|
</lastRunDetails>
|
||||||
|
<lastRunDetails>
|
||||||
|
<operation>allocations</operation>
|
||||||
|
<count>0</count>
|
||||||
|
<resources>
|
||||||
|
<memory>0</memory>
|
||||||
|
<vCores>0</vCores>
|
||||||
|
</resources>
|
||||||
|
</lastRunDetails>
|
||||||
|
<lastRunDetails>
|
||||||
|
<operation>reservations</operation>
|
||||||
|
<count>0</count>
|
||||||
|
<resources>
|
||||||
|
<memory>0</memory>
|
||||||
|
<vCores>0</vCores>
|
||||||
|
</resources>
|
||||||
|
</lastRunDetails>
|
||||||
|
</health>
|
||||||
</schedulerInfo>
|
</schedulerInfo>
|
||||||
</scheduler>
|
</scheduler>
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user