X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FDistributedDataStore.java;h=434efc9111f48e3910af12386d3cd1d4f5e7360a;hp=107c959112fbc34398ae48b144752a8b28c99e41;hb=3927509ec3ecfa32a51b725d2b7155d425f5b877;hpb=c31509c7a6630e54a9f9749a643fed5e1a1ad380 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java index 107c959112..434efc9111 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java @@ -12,8 +12,10 @@ import akka.actor.ActorSystem; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import org.opendaylight.controller.cluster.datastore.identifiers.ShardManagerIdentifier; +import org.opendaylight.controller.cluster.datastore.jmx.mbeans.DatastoreConfigurationMXBeanImpl; import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory; import org.opendaylight.controller.cluster.datastore.utils.ActorContext; +import org.opendaylight.controller.cluster.datastore.utils.Dispatchers; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; import org.opendaylight.controller.sal.core.spi.data.DOMStore; @@ -39,6 +41,10 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, Au private final ActorContext actorContext; + private AutoCloseable closeable; + + private DatastoreConfigurationMXBeanImpl datastoreConfigMXBean; + public DistributedDataStore(ActorSystem actorSystem, ClusterWrapper cluster, Configuration configuration, DatastoreContext datastoreContext) { Preconditions.checkNotNull(actorSystem, "actorSystem should not be null"); @@ -52,16 +58,27 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, Au LOG.info("Creating ShardManager : {}", shardManagerId); + String shardDispatcher = + new Dispatchers(actorSystem.dispatchers()).getDispatcherPath(Dispatchers.DispatcherType.Shard); + actorContext = new ActorContext(actorSystem, actorSystem.actorOf( ShardManager.props(cluster, configuration, datastoreContext) - .withMailbox(ActorContext.MAILBOX), shardManagerId ), + .withDispatcher(shardDispatcher).withMailbox(ActorContext.MAILBOX), shardManagerId ), cluster, configuration, datastoreContext); + + datastoreConfigMXBean = new DatastoreConfigurationMXBeanImpl(datastoreContext.getDataStoreMXBeanType()); + datastoreConfigMXBean.setContext(datastoreContext); + datastoreConfigMXBean.registerMBean(); } public DistributedDataStore(ActorContext actorContext) { this.actorContext = Preconditions.checkNotNull(actorContext, "actorContext should not be null"); } + public void setCloseable(AutoCloseable closeable) { + this.closeable = closeable; + } + @SuppressWarnings("unchecked") @Override public >> @@ -111,7 +128,17 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, Au } @Override - public void close() throws Exception { + public void close() { + datastoreConfigMXBean.unregisterMBean(); + + if(closeable != null) { + try { + closeable.close(); + } catch (Exception e) { + LOG.debug("Error closing insance", e); + } + } + actorContext.shutdown(); }