From a23e8b092912998ede1865ec612adb4b7dcca460 Mon Sep 17 00:00:00 2001 From: Robert Joseph Evans Date: Fri, 16 Nov 2012 20:56:08 +0000 Subject: [PATCH] YARN-151. Browser thinks RM main page JS is taking too long (Ravi Prakash via bobby) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1410564 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 + .../webapps/static/yarn.dt.plugins.js | 8 +++ .../resourcemanager/webapp/AppsBlock.java | 68 +++++++++++-------- .../server/resourcemanager/webapp/RmView.java | 22 ++++-- 4 files changed, 66 insertions(+), 35 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 5bdc50215a..ba36e06790 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -172,6 +172,9 @@ Release 0.23.6 - UNRELEASED YARN-214. RMContainerImpl does not handle event EXPIRE at state RUNNING (jeagles via bobby) + YARN-151. Browser thinks RM main page JS is taking too long + (Ravi Prakash via bobby) + Release 0.23.5 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/yarn.dt.plugins.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/yarn.dt.plugins.js index 17c1b27d0c..5d78aaaf7f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/yarn.dt.plugins.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/yarn.dt.plugins.js @@ -106,3 +106,11 @@ function parseHadoopID(data, type, full) { var splits = data.split('_'); return splits[parseInt(splits.length-1)].split('<')[0]; } + +function parseHadoopProgress(data, type, full) { + if (type === 'display') { + return data; + } + //Return the title attribute for 'sort', 'filter', 'type' and undefined + return data.split("'")[1]; +} 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/AppsBlock.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlock.java index 12d5554e9c..fad5dd8259 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlock.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlock.java @@ -20,12 +20,13 @@ import static org.apache.hadoop.yarn.util.StringHelper.join; import static org.apache.hadoop.yarn.webapp.YarnWebParams.APP_STATE; -import static org.apache.hadoop.yarn.webapp.view.JQueryUI._PROGRESSBAR; -import static org.apache.hadoop.yarn.webapp.view.JQueryUI._PROGRESSBAR_VALUE; +import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR; +import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR_VALUE; import java.util.Collection; import java.util.HashSet; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo; @@ -72,41 +73,50 @@ class AppsBlock extends HtmlBlock { reqAppStates.add(RMAppState.valueOf(stateString)); } } + StringBuilder appsTableData = new StringBuilder("[\n"); for (RMApp app : list.apps.values()) { if (reqAppStates != null && !reqAppStates.contains(app.getState())) { continue; } AppInfo appInfo = new AppInfo(app, true); String percent = String.format("%.1f", appInfo.getProgress()); - String startTime = Times.format(appInfo.getStartTime()); - String finishTime = Times.format(appInfo.getFinishTime()); - tbody. - tr(). - td(). - br().$title(appInfo.getAppIdNum())._(). // for sorting - a(url("app", appInfo.getAppId()), appInfo.getAppId())._(). - td(appInfo.getUser()). - td(appInfo.getName()). - td(appInfo.getQueue()). - td(). - br().$title(String.valueOf(appInfo.getStartTime()))._(). - _(startTime)._(). - td(). - br().$title(String.valueOf(appInfo.getFinishTime()))._(). - _(finishTime)._(). - td(appInfo.getState()). - td(appInfo.getFinalStatus()). - td(). - br().$title(percent)._(). // for sorting - div(_PROGRESSBAR). - $title(join(percent, '%')). // tooltip - div(_PROGRESSBAR_VALUE). - $style(join("width:", percent, '%'))._()._()._(). - td(). - a(!appInfo.isTrackingUrlReady()? - "#" : appInfo.getTrackingUrlPretty(), appInfo.getTrackingUI())._()._(); + //AppID numerical value parsed by parseHadoopID in yarn.dt.plugins.js + appsTableData.append("[\"") + .append(appInfo.getAppId()).append("\",\"") + .append(StringEscapeUtils.escapeHtml(appInfo.getUser())) + .append("\",\"") + .append(StringEscapeUtils.escapeHtml(appInfo.getName())) + .append("\",\"") + .append(StringEscapeUtils.escapeHtml(appInfo.getQueue())) + .append("\",\"") + .append(appInfo.getStartTime()).append("\",\"") + .append(appInfo.getFinishTime()).append("\",\"") + .append(appInfo.getState()).append("\",\"") + .append(appInfo.getFinalStatus()).append("\",\"") + // Progress bar + .append("
").append("
") + .append("\",\"") + .append(appInfo.getTrackingUI()).append("\"],\n"); + if (list.rendering != Render.HTML && ++i >= 20) break; } + if(appsTableData.charAt(appsTableData.length() - 2) == ',') { + appsTableData.delete(appsTableData.length()-2, appsTableData.length()-1); + } + appsTableData.append("]"); + html.script().$type("text/javascript"). + _("var appsTableData=" + appsTableData)._(); + tbody._()._(); if (list.rendering == Render.JS_ARRAY) { 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/RmView.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmView.java index aca94996cf..0ad1190100 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmView.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmView.java @@ -62,13 +62,23 @@ protected Class content() { private String appsTableInit() { AppsList list = getInstance(AppsList.class); // id, user, name, queue, starttime, finishtime, state, status, progress, ui - StringBuilder init = tableInit(). - append(", aoColumns:[{sType:'title-numeric'}, null, null, null, "). - append("{sType:'title-numeric'}, {sType:'title-numeric'} , null, "). - append("null,{sType:'title-numeric', bSearchable:false}, null]"); + StringBuilder init = tableInit() + .append(", 'aaData': appsTableData") + .append(", bDeferRender: true") + .append(", bProcessing: true") - // Sort by id upon page load - init.append(", aaSorting: [[0, 'desc']]"); + .append("\n, aoColumnDefs: [\n") + .append("{'sType':'numeric', 'aTargets': [0]") + .append(", 'mRender': parseHadoopID }") + + .append("\n, {'sType':'numeric', 'aTargets': [4, 5]") + .append(", 'mRender': renderHadoopDate }") + + .append("\n, {'sType':'numeric', bSearchable:false, 'aTargets': [8]") + .append(", 'mRender': parseHadoopProgress }]") + + // Sort by id upon page load + .append(", aaSorting: [[0, 'desc']]"); String rows = $("rowlimit"); int rowLimit = rows.isEmpty() ? MAX_DISPLAY_ROWS : Integer.parseInt(rows);