From 2f6b393543048fa98a24b491802b7ca51451ab28 Mon Sep 17 00:00:00 2001 From: Sanford Ryza Date: Wed, 20 Nov 2013 00:47:18 +0000 Subject: [PATCH] YARN-1407. RM Web UI and REST APIs should uniformly use YarnApplicationState (Sandy Ryza) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1543675 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../server/resourcemanager/webapp/AppsBlock.java | 10 +++++----- .../webapp/FairSchedulerAppsBlock.java | 8 ++++---- .../server/resourcemanager/webapp/NavBlock.java | 4 ++-- .../server/resourcemanager/webapp/RmController.java | 13 ++++++------- .../server/resourcemanager/webapp/dao/AppInfo.java | 13 +++++++------ .../applicationsmanager/MockAsm.java | 6 +++--- .../server/resourcemanager/webapp/TestRMWebApp.java | 8 +++++--- .../src/site/apt/ResourceManagerRest.apt.vm | 2 +- 9 files changed, 36 insertions(+), 31 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index ae6162ef03..e9f1df342e 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -156,6 +156,9 @@ Release 2.3.0 - UNRELEASED YARN-1419. TestFifoScheduler.testAppAttemptMetrics fails intermittently under jdk7 (Jonathan Eagles via jlowe) + YARN-1407. RM Web UI and REST APIs should uniformly use + YarnApplicationState (Sandy Ryza) + Release 2.2.1 - UNRELEASED INCOMPATIBLE CHANGES 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 ab4c5dfcba..cec95ac228 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 @@ -29,9 +29,9 @@ import org.apache.commons.lang.StringEscapeUtils; import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.YarnApplicationState; 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.webapp.hamlet.Hamlet; import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE; @@ -65,18 +65,18 @@ class AppsBlock extends HtmlBlock { th(".progress", "Progress"). th(".ui", "Tracking UI")._()._(). tbody(); - Collection reqAppStates = null; + Collection reqAppStates = null; String reqStateString = $(APP_STATE); if (reqStateString != null && !reqStateString.isEmpty()) { String[] appStateStrings = reqStateString.split(","); - reqAppStates = new HashSet(appStateStrings.length); + reqAppStates = new HashSet(appStateStrings.length); for(String stateString : appStateStrings) { - reqAppStates.add(RMAppState.valueOf(stateString)); + reqAppStates.add(YarnApplicationState.valueOf(stateString)); } } StringBuilder appsTableData = new StringBuilder("[\n"); for (RMApp app : apps.values()) { - if (reqAppStates != null && !reqAppStates.contains(app.getState())) { + if (reqAppStates != null && !reqAppStates.contains(app.createApplicationState())) { continue; } AppInfo appInfo = new AppInfo(app, true); 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 7ce59cb74a..406d7307d7 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 @@ -30,10 +30,10 @@ import org.apache.commons.lang.StringEscapeUtils; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.YarnApplicationState; 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.fair.FairScheduler; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FairSchedulerInfo; @@ -77,13 +77,13 @@ public class FairSchedulerAppsBlock extends HtmlBlock { th(".progress", "Progress"). th(".ui", "Tracking UI")._()._(). tbody(); - Collection reqAppStates = null; + Collection reqAppStates = null; String reqStateString = $(APP_STATE); if (reqStateString != null && !reqStateString.isEmpty()) { String[] appStateStrings = reqStateString.split(","); - reqAppStates = new HashSet(appStateStrings.length); + reqAppStates = new HashSet(appStateStrings.length); for(String stateString : appStateStrings) { - reqAppStates.add(RMAppState.valueOf(stateString)); + reqAppStates.add(YarnApplicationState.valueOf(stateString)); } } StringBuilder appsTableData = new StringBuilder("[\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/NavBlock.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NavBlock.java index f31e06b8eb..ce8fd9e226 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NavBlock.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NavBlock.java @@ -18,7 +18,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp; -import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState; +import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.webapp.hamlet.Hamlet; import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV; import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.LI; @@ -38,7 +38,7 @@ public class NavBlock extends HtmlBlock { li().a(url("apps"), "Applications"). ul(); subAppsList.li()._(); - for (RMAppState state : RMAppState.values()) { + for (YarnApplicationState state : YarnApplicationState.values()) { subAppsList. li().a(url("apps", state.toString()), state.toString())._(); } 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 cec16f3bb5..f186bf498b 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 @@ -21,8 +21,8 @@ import static org.apache.hadoop.yarn.util.StringHelper.join; import static org.apache.hadoop.yarn.webapp.YarnWebParams.QUEUE_NAME; +import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; -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.scheduler.fair.FairScheduler; @@ -62,12 +62,11 @@ 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.NEW_SAVING.toString(), - RMAppState.SUBMITTED.toString(), - RMAppState.ACCEPTED.toString(), - RMAppState.RUNNING.toString(), - RMAppState.FINISHING.toString())); + YarnApplicationState.NEW.toString(), + YarnApplicationState.NEW_SAVING.toString(), + YarnApplicationState.SUBMITTED.toString(), + YarnApplicationState.ACCEPTED.toString(), + YarnApplicationState.RUNNING.toString())); ResourceManager rm = getInstance(ResourceManager.class); ResourceScheduler rs = rm.getResourceScheduler(); 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/dao/AppInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppInfo.java index 0a408df543..295e1f3a41 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppInfo.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppInfo.java @@ -30,6 +30,7 @@ import org.apache.hadoop.yarn.api.records.Container; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.Resource; +import org.apache.hadoop.yarn.api.records.YarnApplicationState; 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; @@ -58,7 +59,7 @@ public class AppInfo { protected String user; protected String name; protected String queue; - protected RMAppState state; + protected YarnApplicationState state; protected FinalApplicationStatus finalStatus; protected float progress; protected String trackingUI; @@ -88,12 +89,12 @@ public AppInfo(RMApp app, Boolean hasAccess) { if (app != null) { String trackingUrl = app.getTrackingUrl(); - this.state = app.getState(); + this.state = app.createApplicationState(); this.trackingUrlIsNotReady = trackingUrl == null || trackingUrl.isEmpty() - || RMAppState.NEW == this.state - || RMAppState.NEW_SAVING == this.state - || RMAppState.SUBMITTED == this.state - || RMAppState.ACCEPTED == this.state; + || YarnApplicationState.NEW == this.state + || YarnApplicationState.NEW_SAVING == this.state + || YarnApplicationState.SUBMITTED == this.state + || YarnApplicationState.ACCEPTED == this.state; this.trackingUI = this.trackingUrlIsNotReady ? "UNASSIGNED" : (app .getFinishTime() == 0 ? "ApplicationMaster" : "History"); if (!trackingUrlIsNotReady) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java index 73b9cf75cd..b90c711c3d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java @@ -168,8 +168,8 @@ public static RMApp newApplication(int i) { final long start = 123456 + i * 1000; final long finish = 234567 + i * 1000; final String type = YarnConfiguration.DEFAULT_APPLICATION_TYPE; - RMAppState[] allStates = RMAppState.values(); - final RMAppState state = allStates[i % allStates.length]; + YarnApplicationState[] allStates = YarnApplicationState.values(); + final YarnApplicationState state = allStates[i % allStates.length]; final int maxAppAttempts = i % 1000; return new ApplicationBase() { @Override @@ -210,7 +210,7 @@ public String getTrackingUrl() { return null; } @Override - public RMAppState getState() { + public YarnApplicationState createApplicationState() { return state; } @Override diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java index aa2d6c6360..74dc95a6a7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java @@ -32,6 +32,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.NodeState; +import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.server.resourcemanager.MockNodes; import org.apache.hadoop.yarn.server.resourcemanager.RMContext; @@ -39,7 +40,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.MockAsm; 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.rmnode.RMNode; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; @@ -93,12 +93,14 @@ public void configure(Binder binder) { } }); RmView rmViewInstance = injector.getInstance(RmView.class); - rmViewInstance.set(YarnWebParams.APP_STATE, RMAppState.RUNNING.toString()); + rmViewInstance.set(YarnWebParams.APP_STATE, + YarnApplicationState.RUNNING.toString()); rmViewInstance.render(); WebAppTests.flushOutput(injector); rmViewInstance.set(YarnWebParams.APP_STATE, StringHelper.cjoin( - RMAppState.ACCEPTED.toString(), RMAppState.RUNNING.toString())); + YarnApplicationState.ACCEPTED.toString(), + YarnApplicationState.RUNNING.toString())); rmViewInstance.render(); WebAppTests.flushOutput(injector); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/apt/ResourceManagerRest.apt.vm b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/apt/ResourceManagerRest.apt.vm index fff16541ed..8f7300a54f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/apt/ResourceManagerRest.apt.vm +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/apt/ResourceManagerRest.apt.vm @@ -1445,7 +1445,7 @@ _01_000001 *---------------+--------------+--------------------------------+ | queue | string | The queue the application was submitted to| *---------------+--------------+--------------------------------+ -| state | string | The application state according to the ResourceManager - valid values are: NEW, SUBMITTED, ACCEPTED, RUNNING, FINISHED, FAILED, KILLED| +| state | string | The application state according to the ResourceManager - valid values are members of the YarnApplicationState enum: NEW, NEW_SAVING, SUBMITTED, ACCEPTED, RUNNING, FINISHED, FAILED, KILLED| *---------------+--------------+--------------------------------+ | finalStatus | string | The final status of the application if finished - reported by the application itself - valid values are: UNDEFINED, SUCCEEDED, FAILED, KILLED| *---------------+--------------+--------------------------------+