YARN-9644. First RMContext object is always leaked during switch over. Contributed by Bibin A Chundatt.

This commit is contained in:
Sunil G 2019-07-02 12:18:16 +05:30
parent 0c8813f135
commit e966edd025
2 changed files with 16 additions and 6 deletions

View File

@ -25,6 +25,7 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import javax.management.NotCompliantMBeanException; import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
import javax.management.StandardMBean; import javax.management.StandardMBean;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -43,6 +44,7 @@ public class RMNMInfo implements RMNMInfoBeans {
LoggerFactory.getLogger(RMNMInfo.class); LoggerFactory.getLogger(RMNMInfo.class);
private RMContext rmContext; private RMContext rmContext;
private ResourceScheduler scheduler; private ResourceScheduler scheduler;
private ObjectName mbeanObjectName;
/** /**
* Constructor for RMNMInfo registers the bean with JMX. * Constructor for RMNMInfo registers the bean with JMX.
@ -57,13 +59,16 @@ public class RMNMInfo implements RMNMInfoBeans {
StandardMBean bean; StandardMBean bean;
try { try {
bean = new StandardMBean(this, RMNMInfoBeans.class); bean = new StandardMBean(this, RMNMInfoBeans.class);
MBeans.register("ResourceManager", "RMNMInfo", bean); mbeanObjectName = MBeans.register("ResourceManager", "RMNMInfo", bean);
} catch (NotCompliantMBeanException e) { } catch (NotCompliantMBeanException e) {
LOG.warn("Error registering RMNMInfo MBean", e); LOG.warn("Error registering RMNMInfo MBean", e);
} }
LOG.info("Registered RMNMInfo MBean"); LOG.info("Registered RMNMInfo MBean");
} }
public void unregister() {
MBeans.unregister(mbeanObjectName);
}
static class InfoMap extends LinkedHashMap<String, Object> { static class InfoMap extends LinkedHashMap<String, Object> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@ -641,6 +641,7 @@ public class ResourceManager extends CompositeService
private ResourceManager rm; private ResourceManager rm;
private boolean fromActive = false; private boolean fromActive = false;
private StandByTransitionRunnable standByTransitionRunnable; private StandByTransitionRunnable standByTransitionRunnable;
private RMNMInfo rmnmInfo;
RMActiveServices(ResourceManager rm) { RMActiveServices(ResourceManager rm) {
super("RMActiveServices"); super("RMActiveServices");
@ -845,7 +846,7 @@ public class ResourceManager extends CompositeService
addService(proxyCAManager); addService(proxyCAManager);
rmContext.setProxyCAManager(proxyCAManager); rmContext.setProxyCAManager(proxyCAManager);
new RMNMInfo(rmContext, scheduler); rmnmInfo = new RMNMInfo(rmContext, scheduler);
if (conf.getBoolean(YarnConfiguration.YARN_API_SERVICES_ENABLE, if (conf.getBoolean(YarnConfiguration.YARN_API_SERVICES_ENABLE,
false)) { false)) {
@ -924,6 +925,10 @@ public class ResourceManager extends CompositeService
super.serviceStop(); super.serviceStop();
DefaultMetricsSystem.shutdown(); DefaultMetricsSystem.shutdown();
// unregister rmnmInfo bean
if (rmnmInfo != null) {
rmnmInfo.unregister();
}
if (rmContext != null) { if (rmContext != null) {
RMStateStore store = rmContext.getStateStore(); RMStateStore store = rmContext.getStateStore();
try { try {
@ -1182,9 +1187,9 @@ public class ResourceManager extends CompositeService
params.put("com.sun.jersey.config.property.packages", apiPackages); params.put("com.sun.jersey.config.property.packages", apiPackages);
} }
Builder<ApplicationMasterService> builder = Builder<ResourceManager> builder =
WebApps WebApps
.$for("cluster", ApplicationMasterService.class, masterService, .$for("cluster", ResourceManager.class, this,
"ws") "ws")
.with(conf) .with(conf)
.withServlet("API-Service", "/app/*", .withServlet("API-Service", "/app/*",