From 2d1237cbb07489fae49a4b3048341b1cc873364c Mon Sep 17 00:00:00 2001 From: Jason Darrell Lowe Date: Thu, 6 Dec 2012 15:39:30 +0000 Subject: [PATCH] YARN-258. RM web page UI shows Invalid Date for start and finish times. Contributed by Ravi Prakash git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1417948 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 + .../hadoop/yarn/webapp/view/JQueryUI.java | 19 ---- .../apache/hadoop/yarn/webapp/view/Jsons.java | 56 ---------- .../resourcemanager/webapp/AppsBlock.java | 22 ++-- .../resourcemanager/webapp/AppsList.java | 101 ------------------ .../webapp/FairSchedulerAppsBlock.java | 21 ++-- .../resourcemanager/webapp/RmController.java | 4 - .../server/resourcemanager/webapp/RmView.java | 17 +-- 8 files changed, 19 insertions(+), 224 deletions(-) delete mode 100644 hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/view/Jsons.java delete mode 100644 hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsList.java diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 72e75b76962..6ba341a385c 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -203,6 +203,9 @@ Release 0.23.6 - UNRELEASED YARN-251. Proxy URI generation fails for blank tracking URIs (Tom White via jlowe) + YARN-258. RM web page UI shows Invalid Date for start and finish times + (Ravi Prakash via jlowe) + Release 0.23.5 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/view/JQueryUI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/view/JQueryUI.java index da334eb9e16..115338eb07c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/view/JQueryUI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/view/JQueryUI.java @@ -28,17 +28,6 @@ import static org.apache.hadoop.yarn.util.StringHelper.*; import org.apache.hadoop.yarn.webapp.hamlet.HamletSpec.HTML; public class JQueryUI extends HtmlBlock { - // Render choices (mostly for dataTables) - public enum Render { - /** small (<~100 rows) table as html, most gracefully degradable */ - HTML, - /** medium (<~2000 rows) table as js array */ - JS_ARRAY, - /** large (<~10000 rows) table loading from server */ - JS_LOAD, - /** huge (>~10000 rows) table processing from server */ - JS_SERVER - }; // UI params public static final String ACCORDION = "ui.accordion"; @@ -197,12 +186,4 @@ public class JQueryUI extends HtmlBlock { append("sPaginationType: 'full_numbers', iDisplayLength:20, "). append("aLengthMenu:[20, 40, 60, 80, 100]"); } - - public static StringBuilder tableInitProgress(StringBuilder init, - long numCells) { - return init.append(", bProcessing:true, "). - append("oLanguage:{sProcessing:'Processing "). - append(numCells).append(" cells..."). - append("

'}"); - } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/view/Jsons.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/view/Jsons.java deleted file mode 100644 index 8e1794062bd..00000000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/view/Jsons.java +++ /dev/null @@ -1,56 +0,0 @@ -/** -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package org.apache.hadoop.yarn.webapp.view; - -import java.io.PrintWriter; - -import static org.apache.hadoop.yarn.util.StringHelper.*; -import static org.apache.hadoop.yarn.webapp.view.JQueryUI.*; - -/** - * JSON helpers - */ -public class Jsons { - public static final String _SEP = "\",\""; - - public static PrintWriter appendProgressBar(PrintWriter out, String pct) { - return out.append("
"). - append("

").append("<\\/div><\\/div>"); - } - - public static PrintWriter appendProgressBar(PrintWriter out, - float progress) { - return appendProgressBar(out, String.format("%.1f", progress)); - } - - public static PrintWriter appendSortable(PrintWriter out, Object value) { - return out.append("
"); - } - - public static PrintWriter appendLink(PrintWriter out, Object anchor, - String prefix, String... parts) { - String anchorText = String.valueOf(anchor); - return out.append("").append(anchorText).append("<\\/a>"); - } -} 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 fad5dd82591..e90edae89aa 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 @@ -25,26 +25,27 @@ import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR_VALUE; import java.util.Collection; import java.util.HashSet; +import java.util.concurrent.ConcurrentMap; import org.apache.commons.lang.StringEscapeUtils; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.server.resourcemanager.RMContext; 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; -import org.apache.hadoop.yarn.util.Times; 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.TBODY; import org.apache.hadoop.yarn.webapp.view.HtmlBlock; -import org.apache.hadoop.yarn.webapp.view.JQueryUI.Render; import com.google.inject.Inject; class AppsBlock extends HtmlBlock { - final AppsList list; + final ConcurrentMap apps; - @Inject AppsBlock(AppsList list, ViewContext ctx) { +@Inject AppsBlock(RMContext rmContext, ViewContext ctx) { super(ctx); - this.list = list; + apps = rmContext.getRMApps(); } @Override public void render(Block html) { @@ -63,7 +64,6 @@ class AppsBlock extends HtmlBlock { th(".progress", "Progress"). th(".ui", "Tracking UI")._()._(). tbody(); - int i = 0; Collection reqAppStates = null; String reqStateString = $(APP_STATE); if (reqStateString != null && !reqStateString.isEmpty()) { @@ -74,7 +74,7 @@ class AppsBlock extends HtmlBlock { } } StringBuilder appsTableData = new StringBuilder("[\n"); - for (RMApp app : list.apps.values()) { + for (RMApp app : apps.values()) { if (reqAppStates != null && !reqAppStates.contains(app.getState())) { continue; } @@ -108,7 +108,6 @@ class AppsBlock extends HtmlBlock { appsTableData.append(trackingURL).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); @@ -118,12 +117,5 @@ class AppsBlock extends HtmlBlock { _("var appsTableData=" + appsTableData)._(); tbody._()._(); - - if (list.rendering == Render.JS_ARRAY) { - echo("\n"); - } } } 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/AppsList.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsList.java deleted file mode 100644 index 415f915cd5f..00000000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsList.java +++ /dev/null @@ -1,101 +0,0 @@ -/** -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package org.apache.hadoop.yarn.server.resourcemanager.webapp; - -import static org.apache.commons.lang.StringEscapeUtils.escapeHtml; -import static org.apache.commons.lang.StringEscapeUtils.escapeJavaScript; -import static org.apache.hadoop.yarn.webapp.view.Jsons._SEP; -import static org.apache.hadoop.yarn.webapp.view.Jsons.appendLink; -import static org.apache.hadoop.yarn.webapp.view.Jsons.appendProgressBar; -import static org.apache.hadoop.yarn.webapp.view.Jsons.appendSortable; - -import java.io.PrintWriter; -import java.util.Collection; -import java.util.concurrent.ConcurrentMap; - -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.server.resourcemanager.RMContext; -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; -import org.apache.hadoop.yarn.util.Times; -import org.apache.hadoop.yarn.webapp.Controller.RequestContext; -import org.apache.hadoop.yarn.webapp.ToJSON; -import org.apache.hadoop.yarn.webapp.view.JQueryUI.Render; - -import com.google.inject.Inject; -import com.google.inject.servlet.RequestScoped; - -// So we only need to do asm.getApplications once in a request -@RequestScoped -class AppsList implements ToJSON { - final RequestContext rc; - final ConcurrentMap apps; - Render rendering; - - @Inject AppsList(RequestContext ctx, RMContext rmContext) { - rc = ctx; - apps = rmContext.getRMApps(); - } - - void toDataTableArrays(Collection requiredAppStates, PrintWriter out) { - out.append('['); - boolean first = true; - for (RMApp app : apps.values()) { - if (requiredAppStates != null && - !requiredAppStates.contains(app.getState())) { - continue; - } - AppInfo appInfo = new AppInfo(app, true); - String startTime = Times.format(appInfo.getStartTime()); - String finishTime = Times.format(appInfo.getFinishTime()); - if (first) { - first = false; - } else { - out.append(",\n"); - } - out.append("[\""); - appendSortable(out, appInfo.getAppIdNum()); - appendLink(out, appInfo.getAppId(), rc.prefix(), "app", - appInfo.getAppId()).append(_SEP). - append(escapeHtml(appInfo.getUser())).append(_SEP). - append(escapeJavaScript(escapeHtml(appInfo.getName()))).append(_SEP). - append(escapeHtml(appInfo.getQueue())).append(_SEP); - appendSortable(out, appInfo.getStartTime()). - append(startTime).append(_SEP); - appendSortable(out, appInfo.getFinishTime()). - append(finishTime).append(_SEP). - append(appInfo.getState()).append(_SEP). - append(appInfo.getFinalStatus()).append(_SEP); - appendProgressBar(out, appInfo.getProgress()).append(_SEP); - appendLink(out, appInfo.getTrackingUI(), rc.prefix(), - !appInfo.isTrackingUrlReady() ? - "#" : appInfo.getTrackingUrlPretty()). - append("\"]"); - } - out.append(']'); - } - - @Override - public void toJSON(PrintWriter out) { - out.print("{\"aaData\":"); - toDataTableArrays(null, out); - out.print("}\n"); - } -} 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/FairSchedulerAppsBlock.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/FairSchedulerAppsBlock.java index efbe64a5b78..9860e18dac3 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/FairSchedulerAppsBlock.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/FairSchedulerAppsBlock.java @@ -25,8 +25,11 @@ import static org.apache.hadoop.yarn.webapp.view.JQueryUI._PROGRESSBAR_VALUE; import java.util.Collection; import java.util.HashSet; +import java.util.concurrent.ConcurrentMap; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.server.resourcemanager.RMContext; import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState; @@ -38,7 +41,6 @@ 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.TBODY; import org.apache.hadoop.yarn.webapp.view.HtmlBlock; -import org.apache.hadoop.yarn.webapp.view.JQueryUI.Render; import com.google.inject.Inject; @@ -47,15 +49,15 @@ import com.google.inject.Inject; * scheduler as part of the fair scheduler page. */ public class FairSchedulerAppsBlock extends HtmlBlock { - final AppsList list; + final ConcurrentMap apps; final FairSchedulerInfo fsinfo; - @Inject public FairSchedulerAppsBlock(AppsList list, + @Inject public FairSchedulerAppsBlock(RMContext rmContext, ResourceManager rm, ViewContext ctx) { super(ctx); - this.list = list; FairScheduler scheduler = (FairScheduler) rm.getResourceScheduler(); fsinfo = new FairSchedulerInfo(scheduler); + apps = rmContext.getRMApps(); } @Override public void render(Block html) { @@ -75,7 +77,6 @@ public class FairSchedulerAppsBlock extends HtmlBlock { th(".progress", "Progress"). th(".ui", "Tracking UI")._()._(). tbody(); - int i = 0; Collection reqAppStates = null; String reqStateString = $(APP_STATE); if (reqStateString != null && !reqStateString.isEmpty()) { @@ -85,7 +86,7 @@ public class FairSchedulerAppsBlock extends HtmlBlock { reqAppStates.add(RMAppState.valueOf(stateString)); } } - for (RMApp app : list.apps.values()) { + for (RMApp app : apps.values()) { if (reqAppStates != null && !reqAppStates.contains(app.getState())) { continue; } @@ -122,15 +123,7 @@ public class FairSchedulerAppsBlock extends HtmlBlock { td(). a(!appInfo.isTrackingUrlReady()? "#" : appInfo.getTrackingUrlPretty(), appInfo.getTrackingUI())._()._(); - if (list.rendering != Render.HTML && ++i >= 20) break; } tbody._()._(); - - if (list.rendering == Render.JS_ARRAY) { - echo("\n"); - } } } 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/RmController.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java index 753e197af01..a4826e806c9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java @@ -93,8 +93,4 @@ public class RmController extends Controller { public void submit() { setTitle("Application Submission Not Allowed"); } - - public void json() { - renderJSON(AppsList.class); - } } 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 0ad11901007..f9ad7825575 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 @@ -60,9 +60,8 @@ public class RmView extends TwoColumnLayout { } private String appsTableInit() { - AppsList list = getInstance(AppsList.class); // id, user, name, queue, starttime, finishtime, state, status, progress, ui - StringBuilder init = tableInit() + return tableInit() .append(", 'aaData': appsTableData") .append(", bDeferRender: true") .append(", bProcessing: true") @@ -78,18 +77,6 @@ public class RmView extends TwoColumnLayout { .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); - if (list.apps.size() < rowLimit) { - list.rendering = Render.HTML; - return init.append('}').toString(); - } - if (list.apps.size() > MAX_FAST_ROWS) { - tableInitProgress(init, list.apps.size() * 6); - } - list.rendering = Render.JS_ARRAY; - return init.append(", aaData:appsData}").toString(); + .append(", aaSorting: [[0, 'desc']]}").toString(); } }