From e6de10d0a6363bdaf767a7bdac7ad908d7786718 Mon Sep 17 00:00:00 2001 From: Rohith Sharma K S Date: Wed, 14 Mar 2018 09:42:20 +0530 Subject: [PATCH] YARN-8022. ResourceManager UI cluster/app/ page fails to render. Contributed by Tarun Parimi. --- .../hadoop/yarn/server/webapp/AppBlock.java | 120 ++++++++---------- 1 file changed, 56 insertions(+), 64 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppBlock.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppBlock.java index 4a47bf181c..8600b7252b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppBlock.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppBlock.java @@ -109,8 +109,7 @@ protected void render(Block html) { final GetApplicationReportRequest request = GetApplicationReportRequest.newInstance(appID); if (callerUGI == null) { - appReport = - appBaseProt.getApplicationReport(request).getApplicationReport(); + appReport = getApplicationReport(request); } else { appReport = callerUGI.doAs( new PrivilegedExceptionAction () { @@ -143,14 +142,19 @@ public ApplicationReport run() throws Exception { try { final GetApplicationAttemptsRequest request = GetApplicationAttemptsRequest.newInstance(appID); - attempts = callerUGI.doAs( + if (callerUGI == null) { + attempts = getApplicationAttemptsReport(request); + } else { + attempts = callerUGI.doAs( new PrivilegedExceptionAction>() { @Override - public Collection run() throws Exception { + public Collection run() + throws Exception { return getApplicationAttemptsReport(request); } }); + } } catch (Exception e) { String message = "Failed to read the attempts of the application " + appID + "."; @@ -204,36 +208,55 @@ public Collection run() throws Exception { String schedulerPath = WebAppUtils.getResolvedRMWebAppURLWithScheme(conf) + "/cluster/scheduler?openQueues=" + app.getQueue(); + generateOverviewTable(app, schedulerPath, webUiType, appReport); + + createApplicationMetricsTable(html); + + html.__(InfoBlock.class); + + generateApplicationTable(html, callerUGI, attempts); + + } + + /** + * Generate overview table for app web page. + * @param app app info. + * @param schedulerPath schedule path. + * @param webUiType web ui type. + * @param appReport app report. + */ + private void generateOverviewTable(AppInfo app, String schedulerPath, + String webUiType, ApplicationReport appReport) { ResponseInfo overviewTable = info("Application Overview") - .__("User:", schedulerPath, app.getUser()) - .__("Name:", app.getName()) - .__("Application Type:", app.getType()) - .__("Application Tags:", - app.getApplicationTags() == null ? "" : app.getApplicationTags()) - .__("Application Priority:", clarifyAppPriority(app.getPriority())) - .__( - "YarnApplicationState:", - app.getAppState() == null ? UNAVAILABLE : clarifyAppState(app - .getAppState())) - .__("Queue:", schedulerPath, app.getQueue()) - .__("FinalStatus Reported by AM:", - clairfyAppFinalStatus(app.getFinalAppStatus())) - .__("Started:", Times.format(app.getStartedTime())) - .__( - "Elapsed:", - StringUtils.formatTime(Times.elapsed(app.getStartedTime(), - app.getFinishedTime()))) - .__( - "Tracking URL:", - app.getTrackingUrl() == null - || app.getTrackingUrl().equals(UNAVAILABLE) ? null : root_url(app - .getTrackingUrl()), - app.getTrackingUrl() == null - || app.getTrackingUrl().equals(UNAVAILABLE) ? "Unassigned" : app - .getAppState() == YarnApplicationState.FINISHED - || app.getAppState() == YarnApplicationState.FAILED - || app.getAppState() == YarnApplicationState.KILLED ? "History" - : "ApplicationMaster"); + .__("User:", schedulerPath, app.getUser()) + .__("Name:", app.getName()) + .__("Application Type:", app.getType()) + .__("Application Tags:", + app.getApplicationTags() == null ? "" : app.getApplicationTags()) + .__("Application Priority:", clarifyAppPriority(app.getPriority())) + .__( + "YarnApplicationState:", + app.getAppState() == null ? UNAVAILABLE : clarifyAppState(app + .getAppState())) + .__("Queue:", schedulerPath, app.getQueue()) + .__("FinalStatus Reported by AM:", + clairfyAppFinalStatus(app.getFinalAppStatus())) + .__("Started:", Times.format(app.getStartedTime())) + .__( + "Elapsed:", + StringUtils.formatTime(Times.elapsed(app.getStartedTime(), + app.getFinishedTime()))) + .__( + "Tracking URL:", + app.getTrackingUrl() == null + || app.getTrackingUrl().equals(UNAVAILABLE) ? null : root_url(app + .getTrackingUrl()), + app.getTrackingUrl() == null + || app.getTrackingUrl().equals(UNAVAILABLE) ? "Unassigned" : app + .getAppState() == YarnApplicationState.FINISHED + || app.getAppState() == YarnApplicationState.FAILED + || app.getAppState() == YarnApplicationState.KILLED ? "History" + : "ApplicationMaster"); if (webUiType != null && webUiType.equals(YarnWebParams.RM_WEB_UI)) { LogAggregationStatus status = getLogAggregationStatus(); @@ -265,37 +288,6 @@ public Collection run() throws Exception { overviewTable.__("AM container Node Label expression:", app.getAmNodeLabelExpression() == null ? "" : app.getAmNodeLabelExpression()); - - try { - final GetApplicationAttemptsRequest request = - GetApplicationAttemptsRequest.newInstance(appID); - if (callerUGI == null) { - attempts = appBaseProt.getApplicationAttempts(request) - .getApplicationAttemptList(); - } else { - attempts = callerUGI.doAs( - new PrivilegedExceptionAction> () { - @Override - public Collection run() throws Exception { - return appBaseProt.getApplicationAttempts(request) - .getApplicationAttemptList(); - } - }); - } - } catch (Exception e) { - String message = - "Failed to read the attempts of the application " + appID + "."; - LOG.error(message, e); - html.p().__(message).__(); - return; - } - - createApplicationMetricsTable(html); - - html.__(InfoBlock.class); - - generateApplicationTable(html, callerUGI, attempts); - } protected void generateApplicationTable(Block html,