Merge -r 1420703:1420704 from trunk to branch-2. Fixes: YARN-267. Fix fair scheduler web UI. Contributed by Sandy Ryza.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1420706 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fc70cd9538
commit
30eaf879e3
|
@ -106,6 +106,8 @@ Release 2.0.3-alpha - Unreleased
|
||||||
YARN-72. NM should handle cleaning up containers when it shuts down.
|
YARN-72. NM should handle cleaning up containers when it shuts down.
|
||||||
(Sandy Ryza via tomwhite)
|
(Sandy Ryza via tomwhite)
|
||||||
|
|
||||||
|
YARN-267. Fix fair scheduler web UI. (Sandy Ryza via tomwhite)
|
||||||
|
|
||||||
Release 2.0.2-alpha - 2012-09-07
|
Release 2.0.2-alpha - 2012-09-07
|
||||||
|
|
||||||
YARN-9. Rename YARN_HOME to HADOOP_YARN_HOME. (vinodkv via acmurthy)
|
YARN-9. Rename YARN_HOME to HADOOP_YARN_HOME. (vinodkv via acmurthy)
|
||||||
|
|
|
@ -20,13 +20,14 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp;
|
||||||
|
|
||||||
import static org.apache.hadoop.yarn.util.StringHelper.join;
|
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.YarnWebParams.APP_STATE;
|
||||||
import static org.apache.hadoop.yarn.webapp.view.JQueryUI._PROGRESSBAR;
|
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR;
|
||||||
import static org.apache.hadoop.yarn.webapp.view.JQueryUI._PROGRESSBAR_VALUE;
|
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR_VALUE;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringEscapeUtils;
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
|
import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
|
||||||
|
@ -36,7 +37,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FairSchedulerInfo;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FairSchedulerInfo;
|
||||||
import org.apache.hadoop.yarn.util.Times;
|
|
||||||
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
|
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
|
||||||
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.hamlet.Hamlet.TBODY;
|
||||||
|
@ -86,44 +86,52 @@ public class FairSchedulerAppsBlock extends HtmlBlock {
|
||||||
reqAppStates.add(RMAppState.valueOf(stateString));
|
reqAppStates.add(RMAppState.valueOf(stateString));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
StringBuilder appsTableData = new StringBuilder("[\n");
|
||||||
for (RMApp app : apps.values()) {
|
for (RMApp app : apps.values()) {
|
||||||
if (reqAppStates != null && !reqAppStates.contains(app.getState())) {
|
if (reqAppStates != null && !reqAppStates.contains(app.getState())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
AppInfo appInfo = new AppInfo(app, true);
|
AppInfo appInfo = new AppInfo(app, true);
|
||||||
String percent = String.format("%.1f", appInfo.getProgress());
|
String percent = String.format("%.1f", appInfo.getProgress());
|
||||||
String startTime = Times.format(appInfo.getStartTime());
|
|
||||||
String finishTime = Times.format(appInfo.getFinishTime());
|
|
||||||
ApplicationAttemptId attemptId = app.getCurrentAppAttempt().getAppAttemptId();
|
ApplicationAttemptId attemptId = app.getCurrentAppAttempt().getAppAttemptId();
|
||||||
int fairShare = fsinfo.getAppFairShare(attemptId);
|
int fairShare = fsinfo.getAppFairShare(attemptId);
|
||||||
|
//AppID numerical value parsed by parseHadoopID in yarn.dt.plugins.js
|
||||||
|
appsTableData.append("[\"<a href='")
|
||||||
|
.append(url("app", appInfo.getAppId())).append("'>")
|
||||||
|
.append(appInfo.getAppId()).append("</a>\",\"")
|
||||||
|
.append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
|
||||||
|
appInfo.getUser()))).append("\",\"")
|
||||||
|
.append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
|
||||||
|
appInfo.getName()))).append("\",\"")
|
||||||
|
.append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
|
||||||
|
appInfo.getQueue()))).append("\",\"")
|
||||||
|
.append(fairShare).append("\",\"")
|
||||||
|
.append(appInfo.getStartTime()).append("\",\"")
|
||||||
|
.append(appInfo.getFinishTime()).append("\",\"")
|
||||||
|
.append(appInfo.getState()).append("\",\"")
|
||||||
|
.append(appInfo.getFinalStatus()).append("\",\"")
|
||||||
|
// Progress bar
|
||||||
|
.append("<br title='").append(percent)
|
||||||
|
.append("'> <div class='").append(C_PROGRESSBAR).append("' title='")
|
||||||
|
.append(join(percent, '%')).append("'> ").append("<div class='")
|
||||||
|
.append(C_PROGRESSBAR_VALUE).append("' style='")
|
||||||
|
.append(join("width:", percent, '%')).append("'> </div> </div>")
|
||||||
|
.append("\",\"<a href='");
|
||||||
|
|
||||||
|
String trackingURL =
|
||||||
|
!appInfo.isTrackingUrlReady()? "#" : appInfo.getTrackingUrlPretty();
|
||||||
|
|
||||||
|
appsTableData.append(trackingURL).append("'>")
|
||||||
|
.append(appInfo.getTrackingUI()).append("</a>\"],\n");
|
||||||
|
|
||||||
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("" + fairShare).
|
|
||||||
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())._()._();
|
|
||||||
}
|
}
|
||||||
|
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._()._();
|
tbody._()._();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@ import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
|
||||||
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.UL;
|
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.UL;
|
||||||
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
|
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
|
||||||
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
|
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
|
||||||
|
import org.apache.hadoop.yarn.webapp.view.HtmlPage.Page;
|
||||||
|
import org.apache.hadoop.yarn.webapp.view.HtmlPage._;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.servlet.RequestScoped;
|
import com.google.inject.servlet.RequestScoped;
|
||||||
|
@ -159,13 +161,16 @@ public class FairSchedulerPage extends RmView {
|
||||||
"#cs a { font-weight: normal; margin: 2px; position: relative }",
|
"#cs a { font-weight: normal; margin: 2px; position: relative }",
|
||||||
"#cs a span { font-weight: normal; font-size: 80% }",
|
"#cs a span { font-weight: normal; font-size: 80% }",
|
||||||
"#cs-wrapper .ui-widget-header { padding: 0.2em 0.5em }",
|
"#cs-wrapper .ui-widget-header { padding: 0.2em 0.5em }",
|
||||||
|
".qstats { font-weight: normal; font-size: 80%; position: absolute }",
|
||||||
|
".qlegend { font-weight: normal; padding: 0 1em; margin: 1em }",
|
||||||
"table.info tr th {width: 50%}")._(). // to center info table
|
"table.info tr th {width: 50%}")._(). // to center info table
|
||||||
script("/static/jt/jquery.jstree.js").
|
script("/static/jt/jquery.jstree.js").
|
||||||
script().$type("text/javascript").
|
script().$type("text/javascript").
|
||||||
_("$(function() {",
|
_("$(function() {",
|
||||||
" $('#cs a span').addClass('ui-corner-all').css('position', 'absolute');",
|
" $('#cs a span').addClass('ui-corner-all').css('position', 'absolute');",
|
||||||
" $('#cs').bind('loaded.jstree', function (e, data) {",
|
" $('#cs').bind('loaded.jstree', function (e, data) {",
|
||||||
" data.inst.open_all(); }).",
|
" data.inst.open_node('#pq', true);",
|
||||||
|
" }).",
|
||||||
" jstree({",
|
" jstree({",
|
||||||
" core: { animation: 188, html_titles: true },",
|
" core: { animation: 188, html_titles: true },",
|
||||||
" plugins: ['themeroller', 'html_data', 'ui'],",
|
" plugins: ['themeroller', 'html_data', 'ui'],",
|
||||||
|
@ -175,8 +180,9 @@ public class FairSchedulerPage extends RmView {
|
||||||
" });",
|
" });",
|
||||||
" $('#cs').bind('select_node.jstree', function(e, data) {",
|
" $('#cs').bind('select_node.jstree', function(e, data) {",
|
||||||
" var q = $('.q', data.rslt.obj).first().text();",
|
" var q = $('.q', data.rslt.obj).first().text();",
|
||||||
" if (q == 'root') q = '';",
|
" if (q == 'root') q = '';",
|
||||||
" $('#apps').dataTable().fnFilter(q, 3);",
|
" else q = '^' + q.substr(q.lastIndexOf('.') + 1) + '$';",
|
||||||
|
" $('#apps').dataTable().fnFilter(q, 3, true);",
|
||||||
" });",
|
" });",
|
||||||
" $('#cs').show();",
|
" $('#cs').show();",
|
||||||
"});")._();
|
"});")._();
|
||||||
|
@ -197,4 +203,19 @@ public class FairSchedulerPage extends RmView {
|
||||||
static String left(float f) {
|
static String left(float f) {
|
||||||
return String.format("left:%.1f%%", f * 100);
|
return String.format("left:%.1f%%", f * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getAppsTableColumnDefs() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
return sb
|
||||||
|
.append("[\n")
|
||||||
|
.append("{'sType':'numeric', 'aTargets': [0]")
|
||||||
|
.append(", 'mRender': parseHadoopID }")
|
||||||
|
|
||||||
|
.append("\n, {'sType':'numeric', 'aTargets': [5, 6]")
|
||||||
|
.append(", 'mRender': renderHadoopDate }")
|
||||||
|
|
||||||
|
.append("\n, {'sType':'numeric', bSearchable:false, 'aTargets': [9]")
|
||||||
|
.append(", 'mRender': parseHadoopProgress }]").toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,17 @@ public class RmView extends TwoColumnLayout {
|
||||||
.append(", bDeferRender: true")
|
.append(", bDeferRender: true")
|
||||||
.append(", bProcessing: true")
|
.append(", bProcessing: true")
|
||||||
|
|
||||||
.append("\n, aoColumnDefs: [\n")
|
.append("\n, aoColumnDefs: ")
|
||||||
|
.append(getAppsTableColumnDefs())
|
||||||
|
|
||||||
|
// Sort by id upon page load
|
||||||
|
.append(", aaSorting: [[0, 'desc']]}").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getAppsTableColumnDefs() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
return sb
|
||||||
|
.append("[\n")
|
||||||
.append("{'sType':'numeric', 'aTargets': [0]")
|
.append("{'sType':'numeric', 'aTargets': [0]")
|
||||||
.append(", 'mRender': parseHadoopID }")
|
.append(", 'mRender': parseHadoopID }")
|
||||||
|
|
||||||
|
@ -74,9 +84,6 @@ public class RmView extends TwoColumnLayout {
|
||||||
.append(", 'mRender': renderHadoopDate }")
|
.append(", 'mRender': renderHadoopDate }")
|
||||||
|
|
||||||
.append("\n, {'sType':'numeric', bSearchable:false, 'aTargets': [8]")
|
.append("\n, {'sType':'numeric', bSearchable:false, 'aTargets': [8]")
|
||||||
.append(", 'mRender': parseHadoopProgress }]")
|
.append(", 'mRender': parseHadoopProgress }]").toString();
|
||||||
|
|
||||||
// Sort by id upon page load
|
|
||||||
.append(", aaSorting: [[0, 'desc']]}").toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue