YARN-6752. Display reserved resources in web UI per application

(Contributed by Abdullah Yousufi via Daniel Templeton)
This commit is contained in:
Daniel Templeton 2017-07-09 19:02:31 +09:00
parent f484a6ff60
commit 0615985886
5 changed files with 42 additions and 1 deletions

View File

@ -61,6 +61,8 @@ public class AppInfo {
protected int priority;
private long allocatedCpuVcores;
private long allocatedMemoryMB;
private long reservedCpuVcores;
private long reservedMemoryMB;
protected boolean unmanagedApplication;
private String appNodeLabelExpression;
private String amNodeLabelExpression;
@ -101,6 +103,10 @@ public AppInfo(ApplicationReport app) {
.getUsedResources().getVirtualCores();
allocatedMemoryMB = app.getApplicationResourceUsageReport()
.getUsedResources().getMemorySize();
reservedCpuVcores = app.getApplicationResourceUsageReport()
.getReservedResources().getVirtualCores();
reservedMemoryMB = app.getApplicationResourceUsageReport()
.getReservedResources().getMemorySize();
}
}
progress = app.getProgress() * 100; // in percent
@ -160,6 +166,14 @@ public long getAllocatedMemoryMB() {
return allocatedMemoryMB;
}
public long getReservedCpuVcores() {
return reservedCpuVcores;
}
public long getReservedMemoryMB() {
return reservedMemoryMB;
}
public float getProgress() {
return progress;
}

View File

@ -95,6 +95,8 @@ public FairSchedulerAppsBlock(ResourceManager rm, ViewContext ctx,
th(".runningcontainer", "Running Containers").
th(".allocatedCpu", "Allocated CPU VCores").
th(".allocatedMemory", "Allocated Memory MB").
th(".reservedCpu", "Reserved CPU VCores").
th(".reservedMemory", "Reserved Memory MB").
th(".progress", "Progress").
th(".ui", "Tracking UI")._()._().
tbody();
@ -142,6 +144,10 @@ public FairSchedulerAppsBlock(ResourceManager rm, ViewContext ctx,
.valueOf(appInfo.getAllocatedVCores())).append("\",\"")
.append(appInfo.getAllocatedMB() == -1 ? "N/A" : String
.valueOf(appInfo.getAllocatedMB())).append("\",\"")
.append(appInfo.getReservedVCores() == -1 ? "N/A" : String
.valueOf(appInfo.getReservedVCores())).append("\",\"")
.append(appInfo.getReservedMB() == -1 ? "N/A" : String
.valueOf(appInfo.getReservedMB())).append("\",\"")
// Progress bar
.append("<br title='").append(percent)
.append("'> <div class='").append(C_PROGRESSBAR).append("' title='")

View File

@ -66,6 +66,8 @@ protected void renderData(Block html) {
.th(".runningcontainer", "Running Containers")
.th(".allocatedCpu", "Allocated CPU VCores")
.th(".allocatedMemory", "Allocated Memory MB")
.th(".reservedCpu", "Reserved CPU VCores")
.th(".reservedMemory", "Reserved Memory MB")
.th(".queuePercentage", "% of Queue")
.th(".clusterPercentage", "% of Cluster")
.th(".progress", "Progress")
@ -146,6 +148,12 @@ protected void renderData(Block html) {
.append(app.getAllocatedMemoryMB() == -1 ? "N/A" :
String.valueOf(app.getAllocatedMemoryMB()))
.append("\",\"")
.append(app.getReservedCpuVcores() == -1 ? "N/A" : String
.valueOf(app.getReservedCpuVcores()))
.append("\",\"")
.append(app.getReservedMemoryMB() == -1 ? "N/A" :
String.valueOf(app.getReservedMemoryMB()))
.append("\",\"")
.append(queuePercent)
.append("\",\"")
.append(clusterPercent)

View File

@ -93,6 +93,8 @@ public class AppInfo {
private String amRPCAddress;
protected long allocatedMB;
protected long allocatedVCores;
protected long reservedMB;
protected long reservedVCores;
protected int runningContainers;
protected long memorySeconds;
protected long vcoreSeconds;
@ -196,8 +198,11 @@ public AppInfo(ResourceManager rm, RMApp app, Boolean hasAccess,
.getApplicationResourceUsageReport();
if (resourceReport != null) {
Resource usedResources = resourceReport.getUsedResources();
Resource reservedResources = resourceReport.getReservedResources();
allocatedMB = usedResources.getMemorySize();
allocatedVCores = usedResources.getVirtualCores();
reservedMB = reservedResources.getMemorySize();
reservedVCores = reservedResources.getVirtualCores();
runningContainers = resourceReport.getNumUsedContainers();
queueUsagePercentage = resourceReport.getQueueUsagePercentage();
clusterUsagePercentage = resourceReport.getClusterUsagePercentage();
@ -404,6 +409,14 @@ public long getAllocatedVCores() {
return this.allocatedVCores;
}
public long getReservedMB() {
return this.reservedMB;
}
public long getReservedVCores() {
return this.reservedVCores;
}
public long getPreemptedMB() {
return preemptedResourceMB;
}

View File

@ -1528,7 +1528,7 @@ public void verifyAppsXML(NodeList nodes, RMApp app, boolean hasResourceReq)
public void verifyAppInfo(JSONObject info, RMApp app, boolean hasResourceReqs)
throws JSONException, Exception {
int expectedNumberOfElements = 34 + (hasResourceReqs ? 2 : 0);
int expectedNumberOfElements = 36 + (hasResourceReqs ? 2 : 0);
String appNodeLabelExpression = null;
String amNodeLabelExpression = null;
if (app.getApplicationSubmissionContext()