JeetKunDoug commented on code in PR #2318:
URL: https://github.com/apache/cassandra/pull/2318#discussion_r1191360560


##########
src/java/org/apache/cassandra/utils/MBeanWrapper.java:
##########
@@ -170,6 +186,125 @@ public void unregisterMBean(ObjectName mbeanName, 
OnException onException)
         }
     }
 
+    static class InstanceMBeanWrapper implements MBeanWrapper
+    {
+        private final MBeanServer mbs;
+        public final UUID id = UUID.randomUUID();
+
+        public InstanceMBeanWrapper(String hostname)
+        {
+            mbs = MBeanServerFactory.createMBeanServer(hostname + "-" + id);
+        }
+
+        public void registerMBean(Object obj, ObjectName mbeanName, 
OnException onException)
+        {
+            try
+            {
+                mbs.registerMBean(obj, mbeanName);
+            }
+            catch (Exception e)
+            {
+                onException.handler.accept(e);
+            }
+        }
+
+        public boolean isRegistered(ObjectName mbeanName, OnException 
onException)
+        {
+            try
+            {
+                return mbs.isRegistered(mbeanName);
+            }
+            catch (Exception e)
+            {
+                onException.handler.accept(e);
+            }
+            return false;
+        }
+
+        public void unregisterMBean(ObjectName mbeanName, OnException 
onException)
+        {
+            try
+            {
+                mbs.unregisterMBean(mbeanName);
+            }
+            catch (Exception e)
+            {
+                onException.handler.accept(e);
+            }
+        }
+
+        public MBeanServer getMBeanServer()
+        {
+            return mbs;
+        }
+
+        public void close() {
+            mbs.queryNames(null, null).forEach(name -> {
+                try {
+                    if 
(!name.getCanonicalName().contains("MBeanServerDelegate"))
+                        mbs.unregisterMBean(name);
+                } catch (Throwable e) {
+                    logger.debug("Could not unregister mbean {}", 
name.getCanonicalName());

Review Comment:
   The in-jvm dtest enables debug logging everywhere anyway, and I don't 
actually think this is a `warn`-level thing as the whole JMX infrastructure 
gets shut down eventually anyway.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to