diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerHealthInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerHealthInfo.java index 652c91b..2751a14 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerHealthInfo.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerHealthInfo.java @@ -25,15 +25,14 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; @XmlAccessorType(XmlAccessType.FIELD) public class CapacitySchedulerHealthInfo { @XmlAccessorType(XmlAccessType.FIELD) public static class OperationInformation { + String operation; String nodeId; String containerId; String queue; @@ -41,7 +40,9 @@ 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.containerId = di.getContainerId() == null ? "N/A" : di.getContainerId().toString(); @@ -90,7 +91,7 @@ public ResourceInfo getResources() { } long lastrun; - Map operationsInfo; + List operationsInfo; List lastRunDetails; CapacitySchedulerHealthInfo() { @@ -103,15 +104,15 @@ public long getLastrun() { CapacitySchedulerHealthInfo(CapacityScheduler cs) { SchedulerHealth ht = cs.getSchedulerHealth(); lastrun = ht.getLastSchedulerRunTime(); - operationsInfo = new HashMap<>(); - operationsInfo.put("last-allocation", - new OperationInformation(ht.getLastAllocationDetails())); - operationsInfo.put("last-release", - new OperationInformation(ht.getLastReleaseDetails())); - operationsInfo.put("last-preemption", - new OperationInformation(ht.getLastPreemptionDetails())); - operationsInfo.put("last-reservation", - new OperationInformation(ht.getLastReservationDetails())); + operationsInfo = new ArrayList<>(); + operationsInfo.add(new OperationInformation("last-allocation", + ht.getLastAllocationDetails())); + operationsInfo.add( + new OperationInformation("last-release", ht.getLastReleaseDetails())); + operationsInfo.add(new OperationInformation("last-preemption", + ht.getLastPreemptionDetails())); + operationsInfo.add(new OperationInformation("last-reservation", + ht.getLastReservationDetails())); lastRunDetails = new ArrayList<>(); lastRunDetails.add(new LastRunDetails("releases", ht.getReleaseCount(), ht diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java index 1108f1a..79fd05e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java @@ -329,6 +329,10 @@ private void verifyClusterScheduler(JSONObject json) throws JSONException, JSONObject health = info.getJSONObject("health"); assertNotNull(health); 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"); assertEquals("incorrect number of elements", 2, arr.length()); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/ResourceManagerRest.md b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/ResourceManagerRest.md index 7c1f418..505590f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/ResourceManagerRest.md +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/ResourceManagerRest.md @@ -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 | | queueName | string | Name of the queue | | 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 object was exited but can't be actually used as the operationsInfo made illegal JSON data in 2.8.0 and 2.8.1, and was corrected from 2.8.2| ### 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) | | 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 **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", "usedCapacity": 0.0 } @@ -894,6 +975,57 @@ Response Body: + + 1326381444693 + + last-allocation + N/A + N/A + N/A + + + last-release + host.domain.com:8041 + container_1326821518301_0005_01_000001 + root.default + + + last-preemption + N/A + N/A + N/A + + + last-reservation + N/A + N/A + N/A + + + releases + 0 + + 0 + 0 + + + + allocations + 0 + + 0 + 0 + + + + reservations + 0 + + 0 + 0 + + + ```