diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMNMInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMNMInfo.java index 4a5da029fd4..8f1cda94a7c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMNMInfo.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMNMInfo.java @@ -25,6 +25,7 @@ import java.util.LinkedHashMap; import java.util.List; import javax.management.NotCompliantMBeanException; +import javax.management.ObjectName; import javax.management.StandardMBean; import org.slf4j.Logger; @@ -43,6 +44,7 @@ public class RMNMInfo implements RMNMInfoBeans { LoggerFactory.getLogger(RMNMInfo.class); private RMContext rmContext; private ResourceScheduler scheduler; + private ObjectName mbeanObjectName; /** * Constructor for RMNMInfo registers the bean with JMX. @@ -56,14 +58,17 @@ public class RMNMInfo implements RMNMInfoBeans { StandardMBean bean; try { - bean = new StandardMBean(this,RMNMInfoBeans.class); - MBeans.register("ResourceManager", "RMNMInfo", bean); + bean = new StandardMBean(this, RMNMInfoBeans.class); + mbeanObjectName = MBeans.register("ResourceManager", "RMNMInfo", bean); } catch (NotCompliantMBeanException e) { - LOG.warn("Error registering RMNMInfo MBean", e); + LOG.warn("Error registering RMNMInfo MBean", e); } LOG.info("Registered RMNMInfo MBean"); } + public void unregister() { + MBeans.unregister(mbeanObjectName); + } static class InfoMap extends LinkedHashMap { private static final long serialVersionUID = 1L; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java index c795bfaa797..6244b77ed5e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java @@ -641,6 +641,7 @@ public class ResourceManager extends CompositeService private ResourceManager rm; private boolean fromActive = false; private StandByTransitionRunnable standByTransitionRunnable; + private RMNMInfo rmnmInfo; RMActiveServices(ResourceManager rm) { super("RMActiveServices"); @@ -845,7 +846,7 @@ public class ResourceManager extends CompositeService addService(proxyCAManager); rmContext.setProxyCAManager(proxyCAManager); - new RMNMInfo(rmContext, scheduler); + rmnmInfo = new RMNMInfo(rmContext, scheduler); if (conf.getBoolean(YarnConfiguration.YARN_API_SERVICES_ENABLE, false)) { @@ -924,6 +925,10 @@ public class ResourceManager extends CompositeService super.serviceStop(); DefaultMetricsSystem.shutdown(); + // unregister rmnmInfo bean + if (rmnmInfo != null) { + rmnmInfo.unregister(); + } if (rmContext != null) { RMStateStore store = rmContext.getStateStore(); try { @@ -1182,9 +1187,9 @@ public class ResourceManager extends CompositeService params.put("com.sun.jersey.config.property.packages", apiPackages); } - Builder builder = + Builder builder = WebApps - .$for("cluster", ApplicationMasterService.class, masterService, + .$for("cluster", ResourceManager.class, this, "ws") .with(conf) .withServlet("API-Service", "/app/*",