YARN-9464. Support pending resource metrics in RM's RESTful API. Contributed by Prabhu Joseph.

This commit is contained in:
Abhishek Modi 2019-08-12 14:31:24 +05:30
parent 8fbf8b2eb0
commit 13a5803ccf
2 changed files with 32 additions and 7 deletions

View File

@ -41,10 +41,12 @@ public class ClusterMetricsInfo {
private long reservedMB;
private long availableMB;
private long allocatedMB;
private long pendingMB;
private long reservedVirtualCores;
private long availableVirtualCores;
private long allocatedVirtualCores;
private long pendingVirtualCores;
private int containersAllocated;
private int containersReserved;
@ -88,10 +90,12 @@ public class ClusterMetricsInfo {
this.reservedMB = metrics.getReservedMB();
this.availableMB = metrics.getAvailableMB();
this.allocatedMB = metrics.getAllocatedMB();
this.pendingMB = metrics.getPendingMB();
this.reservedVirtualCores = metrics.getReservedVirtualCores();
this.availableVirtualCores = metrics.getAvailableVirtualCores();
this.allocatedVirtualCores = metrics.getAllocatedVirtualCores();
this.pendingVirtualCores = metrics.getPendingVirtualCores();
this.containersAllocated = metrics.getAllocatedContainers();
this.containersPending = metrics.getPendingContainers();
@ -163,6 +167,10 @@ public class ClusterMetricsInfo {
return this.allocatedMB;
}
public long getPendingMB() {
return this.pendingMB;
}
public long getReservedVirtualCores() {
return this.reservedVirtualCores;
}
@ -175,6 +183,10 @@ public class ClusterMetricsInfo {
return this.allocatedVirtualCores;
}
public long getPendingVirtualCores() {
return this.pendingVirtualCores;
}
public int getContainersAllocated() {
return this.containersAllocated;
}

View File

@ -426,9 +426,11 @@ public class TestRMWebServices extends JerseyTestBase {
WebServicesTestUtils.getXmlInt(element, "reservedMB"),
WebServicesTestUtils.getXmlInt(element, "availableMB"),
WebServicesTestUtils.getXmlInt(element, "allocatedMB"),
WebServicesTestUtils.getXmlInt(element, "pendingMB"),
WebServicesTestUtils.getXmlInt(element, "reservedVirtualCores"),
WebServicesTestUtils.getXmlInt(element, "availableVirtualCores"),
WebServicesTestUtils.getXmlInt(element, "allocatedVirtualCores"),
WebServicesTestUtils.getXmlInt(element, "pendingVirtualCores"),
WebServicesTestUtils.getXmlInt(element, "totalVirtualCores"),
WebServicesTestUtils.getXmlInt(element, "containersAllocated"),
WebServicesTestUtils.getXmlInt(element, "totalMB"),
@ -446,13 +448,16 @@ public class TestRMWebServices extends JerseyTestBase {
Exception {
assertEquals("incorrect number of elements", 1, json.length());
JSONObject clusterinfo = json.getJSONObject("clusterMetrics");
assertEquals("incorrect number of elements", 25, clusterinfo.length());
assertEquals("incorrect number of elements", 27, clusterinfo.length());
verifyClusterMetrics(
clusterinfo.getInt("appsSubmitted"), clusterinfo.getInt("appsCompleted"),
clusterinfo.getInt("reservedMB"), clusterinfo.getInt("availableMB"),
clusterinfo.getInt("allocatedMB"),
clusterinfo.getInt("reservedVirtualCores"), clusterinfo.getInt("availableVirtualCores"),
clusterinfo.getInt("allocatedVirtualCores"), clusterinfo.getInt("totalVirtualCores"),
clusterinfo.getInt("allocatedMB"), clusterinfo.getInt("pendingMB"),
clusterinfo.getInt("reservedVirtualCores"),
clusterinfo.getInt("availableVirtualCores"),
clusterinfo.getInt("allocatedVirtualCores"),
clusterinfo.getInt("pendingVirtualCores"),
clusterinfo.getInt("totalVirtualCores"),
clusterinfo.getInt("containersAllocated"),
clusterinfo.getInt("totalMB"), clusterinfo.getInt("totalNodes"),
clusterinfo.getInt("lostNodes"), clusterinfo.getInt("unhealthyNodes"),
@ -462,8 +467,9 @@ public class TestRMWebServices extends JerseyTestBase {
}
public void verifyClusterMetrics(int submittedApps, int completedApps,
int reservedMB, int availableMB, int allocMB, int reservedVirtualCores,
int availableVirtualCores, int allocVirtualCores, int totalVirtualCores,
int reservedMB, int availableMB, int allocMB, int pendingMB,
int reservedVirtualCores, int availableVirtualCores,
int allocVirtualCores, int pendingVirtualCores, int totalVirtualCores,
int containersAlloc, int totalMB, int totalNodes, int lostNodes,
int unhealthyNodes, int decommissionedNodes, int rebootedNodes,
int activeNodes, int shutdownNodes) throws JSONException, Exception {
@ -486,12 +492,19 @@ public class TestRMWebServices extends JerseyTestBase {
metrics.getAvailableMB(), availableMB);
assertEquals("allocatedMB doesn't match",
metrics.getAllocatedMB(), allocMB);
assertEquals("pendingMB doesn't match",
metrics.getPendingMB(), pendingMB);
assertEquals("reservedVirtualCores doesn't match",
metrics.getReservedVirtualCores(), reservedVirtualCores);
assertEquals("availableVirtualCores doesn't match",
metrics.getAvailableVirtualCores(), availableVirtualCores);
assertEquals("pendingVirtualCores doesn't match",
metrics.getPendingVirtualCores(), pendingVirtualCores);
assertEquals("allocatedVirtualCores doesn't match",
totalVirtualCoresExpect, allocVirtualCores);
metrics.getAllocatedVirtualCores(), allocVirtualCores);
assertEquals("totalVirtualCores doesn't match",
totalVirtualCoresExpect, totalVirtualCores);
assertEquals("containersAllocated doesn't match", 0, containersAlloc);
assertEquals("totalMB doesn't match", totalMBExpect, totalMB);
assertEquals(