X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-common-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fcommon%2Futil%2Fjmx%2FThreadExecutorStatsMXBeanImpl.java;h=3de49ae296f391bfa9b33afb3524a3ed4e0cc3ae;hb=34bc6ec632529a0dfe419aa7404bb42a456fbc96;hp=58677103c2df020fd7ac3fdaaa38353a59a328a4;hpb=65292f0c7ee04222ccaaa9c9dcf9ece4438dc96e;p=controller.git
diff --git a/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/ThreadExecutorStatsMXBeanImpl.java b/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/ThreadExecutorStatsMXBeanImpl.java
index 58677103c2..3de49ae296 100644
--- a/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/ThreadExecutorStatsMXBeanImpl.java
+++ b/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/ThreadExecutorStatsMXBeanImpl.java
@@ -44,25 +44,47 @@ public class ThreadExecutorStatsMXBeanImpl extends AbstractMXBean
this.executor = Preconditions.checkNotNull(executor);
}
+ private static ThreadExecutorStatsMXBeanImpl createInternal(final Executor executor,
+ final String mBeanName, final String mBeanType, final String mBeanCategory) {
+ if (executor instanceof ThreadPoolExecutor) {
+ final ThreadExecutorStatsMXBeanImpl ret = new ThreadExecutorStatsMXBeanImpl(
+ (ThreadPoolExecutor) executor, mBeanName, mBeanType, mBeanCategory);
+ return ret;
+ }
+
+ LOG.info("Executor {} is not supported", executor);
+ return null;
+ }
+
/**
- * Create a new bean for the statistics, which is already registered.
+ * Creates a new bean if the backing executor is a ThreadPoolExecutor and registers it.
*
- * @param executor
- * @param mBeanName
- * @param mBeanType
- * @param mBeanCategory
- * @return
+ * @param executor the backing {@link Executor}
+ * @param mBeanName Used as the name
property in the bean's ObjectName.
+ * @param mBeanType Used as the type
property in the bean's ObjectName.
+ * @param mBeanCategory Used as the Category
property in the bean's ObjectName.
+ * @return a registered ThreadExecutorStatsMXBeanImpl instance if the backing executor
+ * is a ThreadPoolExecutor, otherwise null.
*/
public static ThreadExecutorStatsMXBeanImpl create(final Executor executor, final String mBeanName,
final String mBeanType, @Nullable final String mBeanCategory) {
- if (executor instanceof ThreadPoolExecutor) {
- final ThreadExecutorStatsMXBeanImpl ret = new ThreadExecutorStatsMXBeanImpl((ThreadPoolExecutor) executor, mBeanName, mBeanType, mBeanCategory);
+ ThreadExecutorStatsMXBeanImpl ret = createInternal(executor, mBeanName, mBeanType, mBeanCategory);
+ if(ret != null) {
ret.registerMBean();
- return ret;
}
- LOG.info("Executor {} is not supported", executor);
- return null;
+ return ret;
+ }
+
+ /**
+ * Creates a new bean if the backing executor is a ThreadPoolExecutor.
+ *
+ * @param executor the backing {@link Executor}
+ * @return a ThreadExecutorStatsMXBeanImpl instance if the backing executor
+ * is a ThreadPoolExecutor, otherwise null.
+ */
+ public static ThreadExecutorStatsMXBeanImpl create(final Executor executor) {
+ return createInternal(executor, "", "", null);
}
@Override