Search in sources :

Example 1 with ResourceRequestInfo

use of org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceRequestInfo in project hadoop by apache.

the class RMAppAttemptBlock method createResourceRequestsTable.

private void createResourceRequestsTable(Block html) {
    AppInfo app = new AppInfo(rm, rm.getRMContext().getRMApps().get(this.appAttemptId.getApplicationId()), true, WebAppUtils.getHttpSchemePrefix(conf));
    List<ResourceRequestInfo> resourceRequests = app.getResourceRequests();
    if (resourceRequests == null || resourceRequests.isEmpty()) {
        return;
    }
    DIV<Hamlet> div = html.div(_INFO_WRAP);
    // Requests Table
    TBODY<TABLE<DIV<Hamlet>>> 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();
    StringBuilder resourceRequestTableData = new StringBuilder("[\n");
    for (ResourceRequestInfo resourceRequest : resourceRequests) {
        if (resourceRequest.getNumContainers() == 0) {
            continue;
        }
        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");
    }
    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._();
}
Also used : Hamlet(org.apache.hadoop.yarn.webapp.hamlet.Hamlet) TABLE(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE) ResourceRequestInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceRequestInfo) AppInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo)

Aggregations

AppInfo (org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo)1 ResourceRequestInfo (org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceRequestInfo)1 Hamlet (org.apache.hadoop.yarn.webapp.hamlet.Hamlet)1 TABLE (org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE)1