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=afbdbe1fe9859d15bbcf5d319112c87c5d054698;hb=3927509ec3ecfa32a51b725d2b7155d425f5b877;hpb=13b8e537dfe1cb63f9ca312894ea94a7c2d37ad6 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 afbdbe1fe9..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,6 +12,7 @@ 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; @@ -40,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"); @@ -60,12 +65,20 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, Au ShardManager.props(cluster, configuration, datastoreContext) .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 >> @@ -115,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(); }