From aa9e5b5b1ae60c00db9f2312ff56bb1e621d951c Mon Sep 17 00:00:00 2001 From: Karthik Kambatla Date: Fri, 10 Jan 2014 16:40:45 +0000 Subject: [PATCH] YARN-1033. Expose RM active/standby state to Web UI and REST API (kasha) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1557183 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 2 ++ .../resourcemanager/webapp/AboutBlock.java | 1 + .../resourcemanager/webapp/dao/ClusterInfo.java | 7 +++++++ .../webapp/TestRMWebServices.java | 16 +++++++++++----- .../src/site/apt/ResourceManagerRest.apt.vm | 2 ++ 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 38ccb0e9412..404b377568c 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -43,6 +43,8 @@ Release 2.4.0 - UNRELEASED YARN-1490. Introduced the ability to make ResourceManager optionally not kill all containers when an ApplicationMaster exits. (Jian He via vinodkv) + YARN-1033. Expose RM active/standby state to Web UI and REST API (kasha) + IMPROVEMENTS YARN-7. Support CPU resource for DistributedShell. (Junping Du via llu) 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/AboutBlock.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AboutBlock.java index 6eed4bfa93c..91b5cc10194 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AboutBlock.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AboutBlock.java @@ -43,6 +43,7 @@ public class AboutBlock extends HtmlBlock { info("Cluster overview"). _("Cluster ID:", cinfo.getClusterId()). _("ResourceManager state:", cinfo.getState()). + _("ResourceManager HA state:", cinfo.getHAState()). _("ResourceManager started on:", Times.format(cinfo.getStartedOn())). _("ResourceManager version:", cinfo.getRMBuildVersion() + " on " + cinfo.getRMVersionBuiltOn()). 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/ClusterInfo.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/ClusterInfo.java index 2da79605e21..c96d73ed1dc 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/ClusterInfo.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/ClusterInfo.java @@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; +import org.apache.hadoop.ha.HAServiceProtocol; import org.apache.hadoop.service.Service.STATE; import org.apache.hadoop.util.VersionInfo; import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; @@ -33,6 +34,7 @@ public class ClusterInfo { protected long id; protected long startedOn; protected STATE state; + protected HAServiceProtocol.HAServiceState haState; protected String resourceManagerVersion; protected String resourceManagerBuildVersion; protected String resourceManagerVersionBuiltOn; @@ -48,6 +50,7 @@ public class ClusterInfo { this.id = ts; this.state = rm.getServiceState(); + this.haState = rm.getRMContext().getHAServiceState(); this.startedOn = ts; this.resourceManagerVersion = YarnVersionInfo.getVersion(); this.resourceManagerBuildVersion = YarnVersionInfo.getBuildVersion(); @@ -61,6 +64,10 @@ public class ClusterInfo { return this.state.toString(); } + public String getHAState() { + return this.haState.toString(); + } + public String getRMVersion() { return this.resourceManagerVersion; } 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/TestRMWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java index 1ea2b0cdf0e..4f1208cd145 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java @@ -29,6 +29,7 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.ha.HAServiceProtocol; import org.apache.hadoop.service.Service.STATE; import org.apache.hadoop.util.VersionInfo; import org.apache.hadoop.yarn.api.records.QueueState; @@ -267,6 +268,7 @@ public class TestRMWebServices extends JerseyTest { verifyClusterGeneric(WebServicesTestUtils.getXmlLong(element, "id"), WebServicesTestUtils.getXmlLong(element, "startedOn"), WebServicesTestUtils.getXmlString(element, "state"), + WebServicesTestUtils.getXmlString(element, "haState"), WebServicesTestUtils.getXmlString(element, "hadoopVersionBuiltOn"), WebServicesTestUtils.getXmlString(element, "hadoopBuildVersion"), WebServicesTestUtils.getXmlString(element, "hadoopVersion"), @@ -282,9 +284,10 @@ public class TestRMWebServices extends JerseyTest { Exception { assertEquals("incorrect number of elements", 1, json.length()); JSONObject info = json.getJSONObject("clusterInfo"); - assertEquals("incorrect number of elements", 9, info.length()); + assertEquals("incorrect number of elements", 10, info.length()); verifyClusterGeneric(info.getLong("id"), info.getLong("startedOn"), - info.getString("state"), info.getString("hadoopVersionBuiltOn"), + info.getString("state"), info.getString("haState"), + info.getString("hadoopVersionBuiltOn"), info.getString("hadoopBuildVersion"), info.getString("hadoopVersion"), info.getString("resourceManagerVersionBuiltOn"), info.getString("resourceManagerBuildVersion"), @@ -293,9 +296,10 @@ public class TestRMWebServices extends JerseyTest { } public void verifyClusterGeneric(long clusterid, long startedon, - String state, String hadoopVersionBuiltOn, String hadoopBuildVersion, - String hadoopVersion, String resourceManagerVersionBuiltOn, - String resourceManagerBuildVersion, String resourceManagerVersion) { + String state, String haState, String hadoopVersionBuiltOn, + String hadoopBuildVersion, String hadoopVersion, + String resourceManagerVersionBuiltOn, String resourceManagerBuildVersion, + String resourceManagerVersion) { assertEquals("clusterId doesn't match: ", ResourceManager.getClusterTimeStamp(), clusterid); @@ -303,6 +307,8 @@ public class TestRMWebServices extends JerseyTest { ResourceManager.getClusterTimeStamp(), startedon); assertTrue("stated doesn't match: " + state, state.matches(STATE.INITED.toString())); + assertTrue("HA state doesn't match: " + haState, + haState.matches("INITIALIZING")); WebServicesTestUtils.checkStringMatch("hadoopVersionBuiltOn", VersionInfo.getDate(), hadoopVersionBuiltOn); 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 8f7300a54f3..73902912571 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 @@ -62,6 +62,8 @@ ResourceManager REST API's. *---------------+--------------+-------------------------------+ | state | string | The ResourceManager state - valid values are: NOTINITED, INITED, STARTED, STOPPED| *---------------+--------------+-------------------------------+ +| haState | string | The ResourceManager HA state - valid values are: INITIALIZING, ACTIVE, STANDBY, STOPPED| +*---------------+--------------+-------------------------------+ | resourceManagerVersion | string | Version of the ResourceManager | *---------------+--------------+-------------------------------+ | resourceManagerBuildVersion | string | ResourceManager build string with build version, user, and checksum |