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
This commit is contained in:
Karthik Kambatla 2014-01-10 16:40:45 +00:00
parent 76fc12eadf
commit aa9e5b5b1a
5 changed files with 23 additions and 5 deletions

View File

@ -43,6 +43,8 @@ Release 2.4.0 - UNRELEASED
YARN-1490. Introduced the ability to make ResourceManager optionally not kill YARN-1490. Introduced the ability to make ResourceManager optionally not kill
all containers when an ApplicationMaster exits. (Jian He via vinodkv) 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 IMPROVEMENTS
YARN-7. Support CPU resource for DistributedShell. (Junping Du via llu) YARN-7. Support CPU resource for DistributedShell. (Junping Du via llu)

View File

@ -43,6 +43,7 @@ public class AboutBlock extends HtmlBlock {
info("Cluster overview"). info("Cluster overview").
_("Cluster ID:", cinfo.getClusterId()). _("Cluster ID:", cinfo.getClusterId()).
_("ResourceManager state:", cinfo.getState()). _("ResourceManager state:", cinfo.getState()).
_("ResourceManager HA state:", cinfo.getHAState()).
_("ResourceManager started on:", Times.format(cinfo.getStartedOn())). _("ResourceManager started on:", Times.format(cinfo.getStartedOn())).
_("ResourceManager version:", cinfo.getRMBuildVersion() + _("ResourceManager version:", cinfo.getRMBuildVersion() +
" on " + cinfo.getRMVersionBuiltOn()). " on " + cinfo.getRMVersionBuiltOn()).

View File

@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import org.apache.hadoop.ha.HAServiceProtocol;
import org.apache.hadoop.service.Service.STATE; import org.apache.hadoop.service.Service.STATE;
import org.apache.hadoop.util.VersionInfo; import org.apache.hadoop.util.VersionInfo;
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
@ -33,6 +34,7 @@ public class ClusterInfo {
protected long id; protected long id;
protected long startedOn; protected long startedOn;
protected STATE state; protected STATE state;
protected HAServiceProtocol.HAServiceState haState;
protected String resourceManagerVersion; protected String resourceManagerVersion;
protected String resourceManagerBuildVersion; protected String resourceManagerBuildVersion;
protected String resourceManagerVersionBuiltOn; protected String resourceManagerVersionBuiltOn;
@ -48,6 +50,7 @@ public class ClusterInfo {
this.id = ts; this.id = ts;
this.state = rm.getServiceState(); this.state = rm.getServiceState();
this.haState = rm.getRMContext().getHAServiceState();
this.startedOn = ts; this.startedOn = ts;
this.resourceManagerVersion = YarnVersionInfo.getVersion(); this.resourceManagerVersion = YarnVersionInfo.getVersion();
this.resourceManagerBuildVersion = YarnVersionInfo.getBuildVersion(); this.resourceManagerBuildVersion = YarnVersionInfo.getBuildVersion();
@ -61,6 +64,10 @@ public class ClusterInfo {
return this.state.toString(); return this.state.toString();
} }
public String getHAState() {
return this.haState.toString();
}
public String getRMVersion() { public String getRMVersion() {
return this.resourceManagerVersion; return this.resourceManagerVersion;
} }

View File

@ -29,6 +29,7 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ha.HAServiceProtocol;
import org.apache.hadoop.service.Service.STATE; import org.apache.hadoop.service.Service.STATE;
import org.apache.hadoop.util.VersionInfo; import org.apache.hadoop.util.VersionInfo;
import org.apache.hadoop.yarn.api.records.QueueState; import org.apache.hadoop.yarn.api.records.QueueState;
@ -267,6 +268,7 @@ public class TestRMWebServices extends JerseyTest {
verifyClusterGeneric(WebServicesTestUtils.getXmlLong(element, "id"), verifyClusterGeneric(WebServicesTestUtils.getXmlLong(element, "id"),
WebServicesTestUtils.getXmlLong(element, "startedOn"), WebServicesTestUtils.getXmlLong(element, "startedOn"),
WebServicesTestUtils.getXmlString(element, "state"), WebServicesTestUtils.getXmlString(element, "state"),
WebServicesTestUtils.getXmlString(element, "haState"),
WebServicesTestUtils.getXmlString(element, "hadoopVersionBuiltOn"), WebServicesTestUtils.getXmlString(element, "hadoopVersionBuiltOn"),
WebServicesTestUtils.getXmlString(element, "hadoopBuildVersion"), WebServicesTestUtils.getXmlString(element, "hadoopBuildVersion"),
WebServicesTestUtils.getXmlString(element, "hadoopVersion"), WebServicesTestUtils.getXmlString(element, "hadoopVersion"),
@ -282,9 +284,10 @@ public class TestRMWebServices extends JerseyTest {
Exception { Exception {
assertEquals("incorrect number of elements", 1, json.length()); assertEquals("incorrect number of elements", 1, json.length());
JSONObject info = json.getJSONObject("clusterInfo"); 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"), 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("hadoopBuildVersion"), info.getString("hadoopVersion"),
info.getString("resourceManagerVersionBuiltOn"), info.getString("resourceManagerVersionBuiltOn"),
info.getString("resourceManagerBuildVersion"), info.getString("resourceManagerBuildVersion"),
@ -293,9 +296,10 @@ public class TestRMWebServices extends JerseyTest {
} }
public void verifyClusterGeneric(long clusterid, long startedon, public void verifyClusterGeneric(long clusterid, long startedon,
String state, String hadoopVersionBuiltOn, String hadoopBuildVersion, String state, String haState, String hadoopVersionBuiltOn,
String hadoopVersion, String resourceManagerVersionBuiltOn, String hadoopBuildVersion, String hadoopVersion,
String resourceManagerBuildVersion, String resourceManagerVersion) { String resourceManagerVersionBuiltOn, String resourceManagerBuildVersion,
String resourceManagerVersion) {
assertEquals("clusterId doesn't match: ", assertEquals("clusterId doesn't match: ",
ResourceManager.getClusterTimeStamp(), clusterid); ResourceManager.getClusterTimeStamp(), clusterid);
@ -303,6 +307,8 @@ public class TestRMWebServices extends JerseyTest {
ResourceManager.getClusterTimeStamp(), startedon); ResourceManager.getClusterTimeStamp(), startedon);
assertTrue("stated doesn't match: " + state, assertTrue("stated doesn't match: " + state,
state.matches(STATE.INITED.toString())); state.matches(STATE.INITED.toString()));
assertTrue("HA state doesn't match: " + haState,
haState.matches("INITIALIZING"));
WebServicesTestUtils.checkStringMatch("hadoopVersionBuiltOn", WebServicesTestUtils.checkStringMatch("hadoopVersionBuiltOn",
VersionInfo.getDate(), hadoopVersionBuiltOn); VersionInfo.getDate(), hadoopVersionBuiltOn);

View File

@ -62,6 +62,8 @@ ResourceManager REST API's.
*---------------+--------------+-------------------------------+ *---------------+--------------+-------------------------------+
| state | string | The ResourceManager state - valid values are: NOTINITED, INITED, STARTED, STOPPED| | 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 | | resourceManagerVersion | string | Version of the ResourceManager |
*---------------+--------------+-------------------------------+ *---------------+--------------+-------------------------------+
| resourceManagerBuildVersion | string | ResourceManager build string with build version, user, and checksum | | resourceManagerBuildVersion | string | ResourceManager build string with build version, user, and checksum |