YARN-4607. Pagination support for AppAttempt page TotalOutstandingResource Requests table. Contributed by Bibin A Chundatt

(cherry picked from commit 1e6f92977dc5431b117745feb5a3491e88a559c0)
This commit is contained in:
Rohith Sharma K S 2016-04-04 08:09:29 +05:30
parent 20e808d83e
commit c8271cd117
3 changed files with 45 additions and 26 deletions

View File

@ -95,4 +95,10 @@ private static String getContainersTableColumnDefs() {
.append(", 'mRender': parseHadoopID }]").toString(); .append(", 'mRender': parseHadoopID }]").toString();
} }
public static String resourceRequestsTableInit() {
return tableInit().append(", 'aaData': resourceRequestsTableData")
.append(", bDeferRender: true").append(", bProcessing: true}")
.toString();
}
} }

View File

@ -41,8 +41,10 @@ protected void preHead(Page.HTML<_> html) {
: join("Application Attempt ", : join("Application Attempt ",
$(YarnWebParams.APPLICATION_ATTEMPT_ID))); $(YarnWebParams.APPLICATION_ATTEMPT_ID)));
set(DATATABLES_ID, "containers"); set(DATATABLES_ID, "containers resourceRequests");
set(initID(DATATABLES, "containers"), WebPageUtils.containersTableInit()); set(initID(DATATABLES, "containers"), WebPageUtils.containersTableInit());
set(initID(DATATABLES, "resourceRequests"),
WebPageUtils.resourceRequestsTableInit());
setTableStyles(html, "containers", ".queue {width:6em}", ".ui {width:8em}"); setTableStyles(html, "containers", ".queue {width:6em}", ".ui {width:8em}");
set(YarnWebParams.WEB_UI_TYPE, YarnWebParams.RM_WEB_UI); set(YarnWebParams.WEB_UI_TYPE, YarnWebParams.RM_WEB_UI);

View File

@ -26,6 +26,7 @@
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
@ -46,6 +47,7 @@
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet; import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV; import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE; import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
import org.apache.hadoop.yarn.webapp.util.WebAppUtils; import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
import org.apache.hadoop.yarn.webapp.view.InfoBlock; import org.apache.hadoop.yarn.webapp.view.InfoBlock;
@ -75,35 +77,44 @@ private void createResourceRequestsTable(Block html) {
} }
DIV<Hamlet> div = html.div(_INFO_WRAP); DIV<Hamlet> div = html.div(_INFO_WRAP);
TABLE<DIV<Hamlet>> table = // Requests Table
div.h3("Total Outstanding Resource Requests: " TBODY<TABLE<DIV<Hamlet>>> tbody = div
+ getTotalResource(resourceRequests)).table( .h3("Total Outstanding Resource Requests: "
"#ResourceRequests"); + getTotalResource(resourceRequests))
.table("#resourceRequests").thead().tr().th(".priority", "Priority")
.th(".resource", "ResourceName").th(".capacity", "Capability")
.th(".containers", "NumContainers")
.th(".relaxlocality", "RelaxLocality")
.th(".labelexpression", "NodeLabelExpression")._()._().tbody();
table.tr(). StringBuilder resourceRequestTableData = new StringBuilder("[\n");
th(_TH, "Priority"). for (ResourceRequest resourceRequest : resourceRequests) {
th(_TH, "ResourceName"). if (resourceRequest.getNumContainers() == 0) {
th(_TH, "Capability").
th(_TH, "NumContainers").
th(_TH, "RelaxLocality").
th(_TH, "NodeLabelExpression").
_();
boolean odd = false;
for (ResourceRequest request : resourceRequests) {
if (request.getNumContainers() == 0) {
continue; continue;
} }
table.tr((odd = !odd) ? _ODD : _EVEN) resourceRequestTableData.append("[\"")
.td(String.valueOf(request.getPriority())) .append(String.valueOf(resourceRequest.getPriority())).append("\",\"")
.td(request.getResourceName()) .append(resourceRequest.getResourceName()).append("\",\"")
.td(String.valueOf(request.getCapability())) .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils
.td(String.valueOf(request.getNumContainers())) .escapeHtml(String.valueOf(resourceRequest.getCapability()))))
.td(String.valueOf(request.getRelaxLocality())) .append("\",\"")
.td(request.getNodeLabelExpression() == null ? "N/A" : request .append(String.valueOf(resourceRequest.getNumContainers()))
.getNodeLabelExpression())._(); .append("\",\"")
.append(String.valueOf(resourceRequest.getRelaxLocality()))
.append("\",\"")
.append(resourceRequest.getNodeLabelExpression() == null ? "N/A"
: resourceRequest.getNodeLabelExpression())
.append("\"],\n");
} }
table._(); if (resourceRequestTableData
.charAt(resourceRequestTableData.length() - 2) == ',') {
resourceRequestTableData.delete(resourceRequestTableData.length() - 2,
resourceRequestTableData.length() - 1);
}
resourceRequestTableData.append("]");
html.script().$type("text/javascript")
._("var resourceRequestsTableData=" + resourceRequestTableData)._();
tbody._()._();
div._(); div._();
} }