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
This commit is contained in:
Thomas Graves 2012-04-17 20:05:44 +00:00
parent b89b6bd75f
commit ca9f62121e
5 changed files with 37 additions and 7 deletions

View File

@ -262,6 +262,9 @@ Release 0.23.3 - UNRELEASED
ApplicationTokenSecretManager and roll it every so often. (Vinod Kumar ApplicationTokenSecretManager and roll it every so often. (Vinod Kumar
Vavilapalli via sseth) Vavilapalli via sseth)
MAPREDUCE-4151. RM scheduler web page should filter apps to those that
are relevant to scheduling (Jason Lowe via tgraves)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -23,6 +23,9 @@
import static org.apache.hadoop.yarn.webapp.view.JQueryUI._PROGRESSBAR; 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._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.RMApp;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo;
@ -60,10 +63,17 @@ class AppsBlock extends HtmlBlock {
th(".ui", "Tracking UI")._()._(). th(".ui", "Tracking UI")._()._().
tbody(); tbody();
int i = 0; int i = 0;
String reqState = $(APP_STATE); Collection<RMAppState> reqAppStates = null;
reqState = (reqState == null ? "" : reqState); String reqStateString = $(APP_STATE);
if (reqStateString != null && !reqStateString.isEmpty()) {
String[] appStateStrings = reqStateString.split(",");
reqAppStates = new HashSet<RMAppState>(appStateStrings.length);
for(String stateString : appStateStrings) {
reqAppStates.add(RMAppState.valueOf(stateString));
}
}
for (RMApp app : list.apps.values()) { for (RMApp app : list.apps.values()) {
if (!reqState.isEmpty() && app.getState() != RMAppState.valueOf(reqState)) { if (reqAppStates != null && !reqAppStates.contains(app.getState())) {
continue; continue;
} }
AppInfo appInfo = new AppInfo(app, true); AppInfo appInfo = new AppInfo(app, true);
@ -100,7 +110,7 @@ class AppsBlock extends HtmlBlock {
if (list.rendering == Render.JS_ARRAY) { if (list.rendering == Render.JS_ARRAY) {
echo("<script type='text/javascript'>\n", echo("<script type='text/javascript'>\n",
"var appsData="); "var appsData=");
list.toDataTableArrays(reqState, writer()); list.toDataTableArrays(reqAppStates, writer());
echo("\n</script>\n"); echo("\n</script>\n");
} }
} }

View File

@ -26,6 +26,7 @@
import static org.apache.hadoop.yarn.webapp.view.Jsons.appendSortable; import static org.apache.hadoop.yarn.webapp.view.Jsons.appendSortable;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.Collection;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
@ -53,12 +54,12 @@ class AppsList implements ToJSON {
apps = rmContext.getRMApps(); apps = rmContext.getRMApps();
} }
void toDataTableArrays(String requiredAppState, PrintWriter out) { void toDataTableArrays(Collection<RMAppState> requiredAppStates, PrintWriter out) {
out.append('['); out.append('[');
boolean first = true; boolean first = true;
for (RMApp app : apps.values()) { for (RMApp app : apps.values()) {
if (requiredAppState != null && !requiredAppState.isEmpty() if (requiredAppStates != null &&
&& app.getState() != RMAppState.valueOf(requiredAppState)) { !requiredAppStates.contains(app.getState())) {
continue; continue;
} }
AppInfo appInfo = new AppInfo(app, true); AppInfo appInfo = new AppInfo(app, true);

View File

@ -31,14 +31,17 @@
import org.apache.hadoop.yarn.server.resourcemanager.RMContext; import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; 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.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.ResourceScheduler;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; 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.resourcemanager.webapp.dao.AppInfo;
import org.apache.hadoop.yarn.server.security.ApplicationACLsManager; import org.apache.hadoop.yarn.server.security.ApplicationACLsManager;
import org.apache.hadoop.yarn.util.Apps; 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.util.Times;
import org.apache.hadoop.yarn.webapp.Controller; import org.apache.hadoop.yarn.webapp.Controller;
import org.apache.hadoop.yarn.webapp.ResponseInfo; import org.apache.hadoop.yarn.webapp.ResponseInfo;
import org.apache.hadoop.yarn.webapp.YarnWebParams;
import com.google.inject.Inject; import com.google.inject.Inject;
@ -123,6 +126,13 @@ public void nodes() {
} }
public void scheduler() { 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); ResourceManager rm = getInstance(ResourceManager.class);
ResourceScheduler rs = rm.getResourceScheduler(); ResourceScheduler rs = rm.getResourceScheduler();
if (rs == null || rs instanceof CapacityScheduler) { if (rs == null || rs instanceof CapacityScheduler) {

View File

@ -47,6 +47,7 @@
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration; 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.resourcemanager.scheduler.fifo.FifoScheduler;
import org.apache.hadoop.yarn.server.security.ApplicationACLsManager; 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.WebApps;
import org.apache.hadoop.yarn.webapp.YarnWebParams; import org.apache.hadoop.yarn.webapp.YarnWebParams;
import org.apache.hadoop.yarn.webapp.test.WebAppTests; 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.set(YarnWebParams.APP_STATE, RMAppState.RUNNING.toString());
rmViewInstance.render(); rmViewInstance.render();
WebAppTests.flushOutput(injector); 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() { @Test public void testNodesPage() {