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


##########
src/java/org/apache/cassandra/utils/MBeanWrapper.java:
##########
@@ -33,62 +38,144 @@
  */
 public interface MBeanWrapper
 {
-    static final Logger logger = LoggerFactory.getLogger(MBeanWrapper.class);
+    Logger logger = LoggerFactory.getLogger(MBeanWrapper.class);
 
-    static final MBeanWrapper instance = 
Boolean.getBoolean("org.apache.cassandra.disable_mbean_registration") ?
-                                         new NoOpMBeanWrapper() :
-                                         new PlatformMBeanWrapper();
+    MBeanWrapper instance = create();
+    String IS_DISABLED_MBEAN_REGISTRATION = 
"org.apache.cassandra.disable_mbean_registration";
+    String IS_IN_JVM_DTEST = "org.apache.cassandra.is_in_jvm_dtest";
+    String MBEAN_REGISTRATION_CLASS = 
"org.apache.cassandra.mbean_registration_class";
+
+    static MBeanWrapper create()
+    {
+        // If we're running in the in-jvm dtest environment, always use the 
delegating
+        // mbean wrapper even if we start off with no-op, so it can be 
switched later
+        if (Boolean.getBoolean(IS_IN_JVM_DTEST))
+            return new DelegatingMbeanWrapper(getmBeanWrapper());
+
+        return getmBeanWrapper();
+    }
+
+    static MBeanWrapper getmBeanWrapper()
+    {
+        if (Boolean.getBoolean(IS_DISABLED_MBEAN_REGISTRATION))
+            return new NoOpMBeanWrapper();
+
+        String klass = System.getProperty(MBEAN_REGISTRATION_CLASS);
+        if (klass == null)
+            if (Boolean.getBoolean(IS_IN_JVM_DTEST))
+                return new NoOpMBeanWrapper();
+            else
+                return new PlatformMBeanWrapper();

Review Comment:
   Yeah - I get dinged for _including_ them so I try not to do it if it's only 
single-lined.



-- 
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