Cache MapJoiner
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / jmx / mbeans / shard / ShardMBeanFactory.java
index 946e525a6d0019418fd00e310064b0f78487485a..08632a8535e58f6185ce568b80a3683b3a3e773b 100644 (file)
@@ -7,41 +7,21 @@
  */
 package org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard;
 
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.cluster.datastore.Shard;
 
 /**
- * @author Basheeruddin syedbahm@cisco.com
+ * Factory for creating ShardStats mbeans.
  *
+ * @author Basheeruddin syedbahm@cisco.com
  */
 public class ShardMBeanFactory {
 
-    private static final Logger LOG = LoggerFactory.getLogger(ShardMBeanFactory.class);
-
-    private static Cache<String,ShardStats> shardMBeansCache =
-                                      CacheBuilder.newBuilder().weakValues().build();
-
-    public static ShardStats getShardStatsMBean(final String shardName, final String mxBeanType) {
-        final String finalMXBeanType = mxBeanType != null ? mxBeanType : "DistDataStore";
-        try {
-            return shardMBeansCache.get(shardName, new Callable<ShardStats>() {
-                @Override
-                public ShardStats call() throws Exception {
-                    ShardStats shardStatsMBeanImpl = new ShardStats(shardName, finalMXBeanType);
-                    shardStatsMBeanImpl.registerMBean();
-                    return shardStatsMBeanImpl;
-                }
-            });
-        } catch(ExecutionException e) {
-            LOG.error(String.format("Could not create MXBean for shard: %s", shardName), e);
-            // Just return an instance that isn't registered.
-            return new ShardStats(shardName, finalMXBeanType);
-        }
+    public static ShardStats getShardStatsMBean(final String shardName, final String mxBeanType,
+            @Nonnull final Shard shard) {
+        String finalMXBeanType = mxBeanType != null ? mxBeanType : "DistDataStore";
+        ShardStats shardStatsMBeanImpl = new ShardStats(shardName, finalMXBeanType, shard);
+        shardStatsMBeanImpl.registerMBean();
+        return shardStatsMBeanImpl;
     }
 }