This is an automated email from the ASF dual-hosted git repository.

sunilg pushed a commit to branch branch-3.2
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-3.2 by this push:
     new d18986e  YARN-9644. First RMContext object is always leaked during 
switch over. Contributed by Bibin A Chundatt.
d18986e is described below

commit d18986e4e89bd4bb3600e95b4690fd32f54a41e5
Author: Sunil G <sun...@apache.org>
AuthorDate: Thu Jul 4 11:05:54 2019 +0530

    YARN-9644. First RMContext object is always leaked during switch over. 
Contributed by Bibin A Chundatt.
---
 .../apache/hadoop/yarn/server/resourcemanager/RMNMInfo.java   | 11 ++++++++---
 .../hadoop/yarn/server/resourcemanager/ResourceManager.java   | 11 ++++++++---
 2 files changed, 16 insertions(+), 6 deletions(-)

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 1b7ddd3..18cf6f0 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.apache.commons.logging.Log;
@@ -42,6 +43,7 @@ public class RMNMInfo implements RMNMInfoBeans {
   private static final Log LOG = LogFactory.getLog(RMNMInfo.class);
   private RMContext rmContext;
   private ResourceScheduler scheduler;
+  private ObjectName mbeanObjectName;
 
   /**
    * Constructor for RMNMInfo registers the bean with JMX.
@@ -55,14 +57,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<String, Object> {
     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 16f019f..b395d0f 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
@@ -630,6 +630,7 @@ public class ResourceManager extends CompositeService
     private ResourceManager rm;
     private boolean fromActive = false;
     private StandByTransitionRunnable standByTransitionRunnable;
+    private RMNMInfo rmnmInfo;
 
     RMActiveServices(ResourceManager rm) {
       super("RMActiveServices");
@@ -830,7 +831,7 @@ public class ResourceManager extends CompositeService
         LOG.info("Initialized Federation membership.");
       }
 
-      new RMNMInfo(rmContext, scheduler);
+      rmnmInfo = new RMNMInfo(rmContext, scheduler);
 
       if (conf.getBoolean(YarnConfiguration.YARN_API_SERVICES_ENABLE,
           false)) {
@@ -899,6 +900,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 {
@@ -1156,9 +1161,9 @@ public class ResourceManager extends CompositeService
       params.put("com.sun.jersey.config.property.packages", apiPackages);
     }
 
-    Builder<ApplicationMasterService> builder = 
+    Builder<ResourceManager> builder =
         WebApps
-            .$for("cluster", ApplicationMasterService.class, masterService,
+            .$for("cluster", ResourceManager.class, this,
                 "ws")
             .with(conf)
             .withServlet("API-Service", "/app/*",


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to