diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebPageUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebPageUtils.java index a07baa2366f..3a26ae58890 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebPageUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebPageUtils.java @@ -95,4 +95,10 @@ public class WebPageUtils { .append(", 'mRender': parseHadoopID }]").toString(); } + public static String resourceRequestsTableInit() { + return tableInit().append(", 'aaData': resourceRequestsTableData") + .append(", bDeferRender: true").append(", bProcessing: true}") + .toString(); + } + } \ No newline at end of file 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/AppAttemptPage.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppAttemptPage.java index df5fb9e8a59..45f188782d7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppAttemptPage.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppAttemptPage.java @@ -41,8 +41,10 @@ public class AppAttemptPage extends RmView { : join("Application Attempt ", $(YarnWebParams.APPLICATION_ATTEMPT_ID))); - set(DATATABLES_ID, "containers"); + set(DATATABLES_ID, "containers resourceRequests"); set(initID(DATATABLES, "containers"), WebPageUtils.containersTableInit()); + set(initID(DATATABLES, "resourceRequests"), + WebPageUtils.resourceRequestsTableInit()); setTableStyles(html, "containers", ".queue {width:6em}", ".ui {width:8em}"); set(YarnWebParams.WEB_UI_TYPE, YarnWebParams.RM_WEB_UI); 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/RMAppAttemptBlock.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMAppAttemptBlock.java index 668269e819a..6fef3671dd4 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMAppAttemptBlock.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMAppAttemptBlock.java @@ -26,6 +26,7 @@ import static org.apache.hadoop.yarn.webapp.view.JQueryUI._TH; import java.util.Collection; import java.util.List; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; @@ -46,6 +47,7 @@ import org.apache.hadoop.yarn.util.resource.Resources; 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.TABLE; +import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY; import org.apache.hadoop.yarn.webapp.util.WebAppUtils; import org.apache.hadoop.yarn.webapp.view.InfoBlock; @@ -75,35 +77,44 @@ public class RMAppAttemptBlock extends AppAttemptBlock{ } DIV div = html.div(_INFO_WRAP); - TABLE> table = - div.h3("Total Outstanding Resource Requests: " - + getTotalResource(resourceRequests)).table( - "#ResourceRequests"); + // Requests Table + TBODY>> tbody = div + .h3("Total Outstanding Resource Requests: " + + 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(). - th(_TH, "Priority"). - th(_TH, "ResourceName"). - th(_TH, "Capability"). - th(_TH, "NumContainers"). - th(_TH, "RelaxLocality"). - th(_TH, "NodeLabelExpression"). - _(); - - boolean odd = false; - for (ResourceRequest request : resourceRequests) { - if (request.getNumContainers() == 0) { + StringBuilder resourceRequestTableData = new StringBuilder("[\n"); + for (ResourceRequest resourceRequest : resourceRequests) { + if (resourceRequest.getNumContainers() == 0) { continue; } - table.tr((odd = !odd) ? _ODD : _EVEN) - .td(String.valueOf(request.getPriority())) - .td(request.getResourceName()) - .td(String.valueOf(request.getCapability())) - .td(String.valueOf(request.getNumContainers())) - .td(String.valueOf(request.getRelaxLocality())) - .td(request.getNodeLabelExpression() == null ? "N/A" : request - .getNodeLabelExpression())._(); + resourceRequestTableData.append("[\"") + .append(String.valueOf(resourceRequest.getPriority())).append("\",\"") + .append(resourceRequest.getResourceName()).append("\",\"") + .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils + .escapeHtml(String.valueOf(resourceRequest.getCapability())))) + .append("\",\"") + .append(String.valueOf(resourceRequest.getNumContainers())) + .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._(); }