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

View File

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

View File

@ -66,6 +66,8 @@ public class RMAppsBlock extends AppsBlock {
.th(".runningcontainer", "Running Containers") .th(".runningcontainer", "Running Containers")
.th(".allocatedCpu", "Allocated CPU VCores") .th(".allocatedCpu", "Allocated CPU VCores")
.th(".allocatedMemory", "Allocated Memory MB") .th(".allocatedMemory", "Allocated Memory MB")
.th(".reservedCpu", "Reserved CPU VCores")
.th(".reservedMemory", "Reserved Memory MB")
.th(".queuePercentage", "% of Queue") .th(".queuePercentage", "% of Queue")
.th(".clusterPercentage", "% of Cluster") .th(".clusterPercentage", "% of Cluster")
.th(".progress", "Progress") .th(".progress", "Progress")
@ -146,6 +148,12 @@ public class RMAppsBlock extends AppsBlock {
.append(app.getAllocatedMemoryMB() == -1 ? "N/A" : .append(app.getAllocatedMemoryMB() == -1 ? "N/A" :
String.valueOf(app.getAllocatedMemoryMB())) String.valueOf(app.getAllocatedMemoryMB()))
.append("\",\"") .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(queuePercent)
.append("\",\"") .append("\",\"")
.append(clusterPercent) .append(clusterPercent)

View File

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

View File

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