From ca9f62121e829aeb9fc67122a78ba9f673eba074 Mon Sep 17 00:00:00 2001 From: Thomas Graves Date: Tue, 17 Apr 2012 20:05:44 +0000 Subject: [PATCH] MAPREDUCE-4151. RM scheduler web page should filter apps to those that are relevant to scheduling (Jason Lowe via tgraves) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1327263 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-mapreduce-project/CHANGES.txt | 3 +++ .../resourcemanager/webapp/AppsBlock.java | 18 ++++++++++++++---- .../resourcemanager/webapp/AppsList.java | 7 ++++--- .../resourcemanager/webapp/RmController.java | 10 ++++++++++ .../resourcemanager/webapp/TestRMWebApp.java | 6 ++++++ 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index a879ce7305..e278fe3f5f 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -262,6 +262,9 @@ Release 0.23.3 - UNRELEASED ApplicationTokenSecretManager and roll it every so often. (Vinod Kumar Vavilapalli via sseth) + MAPREDUCE-4151. RM scheduler web page should filter apps to those that + are relevant to scheduling (Jason Lowe via tgraves) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlock.java b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlock.java index d517ce117a..7e8fd746d0 100644 --- a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlock.java +++ b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlock.java @@ -23,6 +23,9 @@ import static org.apache.hadoop.yarn.webapp.view.JQueryUI._PROGRESSBAR; import static org.apache.hadoop.yarn.webapp.view.JQueryUI._PROGRESSBAR_VALUE; +import java.util.Collection; +import java.util.HashSet; + 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; @@ -60,10 +63,17 @@ class AppsBlock extends HtmlBlock { th(".ui", "Tracking UI")._()._(). tbody(); int i = 0; - String reqState = $(APP_STATE); - reqState = (reqState == null ? "" : reqState); + Collection reqAppStates = null; + String reqStateString = $(APP_STATE); + if (reqStateString != null && !reqStateString.isEmpty()) { + String[] appStateStrings = reqStateString.split(","); + reqAppStates = new HashSet(appStateStrings.length); + for(String stateString : appStateStrings) { + reqAppStates.add(RMAppState.valueOf(stateString)); + } + } for (RMApp app : list.apps.values()) { - if (!reqState.isEmpty() && app.getState() != RMAppState.valueOf(reqState)) { + if (reqAppStates != null && !reqAppStates.contains(app.getState())) { continue; } AppInfo appInfo = new AppInfo(app, true); @@ -100,7 +110,7 @@ class AppsBlock extends HtmlBlock { if (list.rendering == Render.JS_ARRAY) { echo("\n"); } } diff --git a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsList.java b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsList.java index 2efcf4258f..5d0060fe43 100644 --- a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsList.java +++ b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsList.java @@ -26,6 +26,7 @@ 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; @@ -53,12 +54,12 @@ class AppsList implements ToJSON { apps = rmContext.getRMApps(); } - void toDataTableArrays(String requiredAppState, PrintWriter out) { + void toDataTableArrays(Collection requiredAppStates, PrintWriter out) { out.append('['); boolean first = true; for (RMApp app : apps.values()) { - if (requiredAppState != null && !requiredAppState.isEmpty() - && app.getState() != RMAppState.valueOf(requiredAppState)) { + if (requiredAppStates != null && + !requiredAppStates.contains(app.getState())) { continue; } AppInfo appInfo = new AppInfo(app, true); diff --git a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java index c8778b87be..74c10264ac 100644 --- a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java +++ b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java @@ -31,14 +31,17 @@ 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; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo; import org.apache.hadoop.yarn.server.security.ApplicationACLsManager; import org.apache.hadoop.yarn.util.Apps; +import org.apache.hadoop.yarn.util.StringHelper; import org.apache.hadoop.yarn.util.Times; import org.apache.hadoop.yarn.webapp.Controller; import org.apache.hadoop.yarn.webapp.ResponseInfo; +import org.apache.hadoop.yarn.webapp.YarnWebParams; import com.google.inject.Inject; @@ -123,6 +126,13 @@ public void nodes() { } public void scheduler() { + // limit applications to those in states relevant to scheduling + set(YarnWebParams.APP_STATE, StringHelper.cjoin( + RMAppState.NEW.toString(), + RMAppState.SUBMITTED.toString(), + RMAppState.ACCEPTED.toString(), + RMAppState.RUNNING.toString())); + ResourceManager rm = getInstance(ResourceManager.class); ResourceScheduler rs = rm.getResourceScheduler(); if (rs == null || rs instanceof CapacityScheduler) { diff --git a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java index 6689fd5777..588930f6ef 100644 --- a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java +++ b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java @@ -47,6 +47,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler; import org.apache.hadoop.yarn.server.security.ApplicationACLsManager; +import org.apache.hadoop.yarn.util.StringHelper; import org.apache.hadoop.yarn.webapp.WebApps; import org.apache.hadoop.yarn.webapp.YarnWebParams; import org.apache.hadoop.yarn.webapp.test.WebAppTests; @@ -93,6 +94,11 @@ public void configure(Binder binder) { rmViewInstance.set(YarnWebParams.APP_STATE, RMAppState.RUNNING.toString()); rmViewInstance.render(); WebAppTests.flushOutput(injector); + + rmViewInstance.set(YarnWebParams.APP_STATE, StringHelper.cjoin( + RMAppState.ACCEPTED.toString(), RMAppState.RUNNING.toString())); + rmViewInstance.render(); + WebAppTests.flushOutput(injector); } @Test public void testNodesPage() {