X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FOSGiDistributedDataStore.java;h=0811137efa99d7e859d963309ec192e33dbe2aa1;hb=2dedb8231e13abe55d6b75eb532d23dbe536e168;hp=cfcffbfd489fe0a8d91ed2b197736a2cd6e0942b;hpb=1b8b80be1a8c7dbc3de11d8e4e283a755fa9a14f;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/OSGiDistributedDataStore.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/OSGiDistributedDataStore.java index cfcffbfd48..0811137efa 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/OSGiDistributedDataStore.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/OSGiDistributedDataStore.java @@ -12,17 +12,15 @@ import static java.util.Objects.requireNonNull; import com.google.common.annotations.Beta; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; -import java.util.Dictionary; -import java.util.Hashtable; import java.util.Map; import org.checkerframework.checker.lock.qual.GuardedBy; -import org.gaul.modernizer_maven_annotations.SuppressModernizer; import org.opendaylight.controller.cluster.ActorSystemProvider; import org.opendaylight.controller.cluster.datastore.config.Configuration; import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl; import org.opendaylight.controller.cluster.datastore.config.ModuleShardConfigProvider; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.osgi.framework.FrameworkUtil; import org.osgi.service.component.ComponentFactory; import org.osgi.service.component.ComponentInstance; import org.osgi.service.component.annotations.Activate; @@ -53,7 +51,7 @@ public final class OSGiDistributedDataStore { private final String serviceType; @GuardedBy("this") - private ComponentInstance component; + private ComponentInstance component; @GuardedBy("this") private boolean stopped; @@ -67,6 +65,7 @@ public final class OSGiDistributedDataStore { synchronized void updateProperties(final Map properties) { if (introspector.update(properties)) { + LOG.info("Distributed Datastore type {} updating context", datastoreType); datastore.onDatastoreContextUpdated(introspector.newContextFactory()); } } @@ -86,17 +85,15 @@ public final class OSGiDistributedDataStore { } @Override - @SuppressModernizer public void onSuccess(final Object result) { LOG.debug("Distributed Datastore type {} reached initial settle", datastoreType); synchronized (this) { if (!stopped) { - final Dictionary dict = new Hashtable<>(); - dict.put(OSGiDOMStore.DATASTORE_TYPE_PROP, datastoreType); - dict.put(OSGiDOMStore.DATASTORE_INST_PROP, datastore); - dict.put("type", serviceType); - component = datastoreFactory.newInstance(dict); + component = datastoreFactory.newInstance(FrameworkUtil.asDictionary(Map.of( + OSGiDOMStore.DATASTORE_TYPE_PROP, datastoreType, + OSGiDOMStore.DATASTORE_INST_PROP, datastore, + "type", serviceType))); LOG.info("Distributed Datastore type {} started", datastoreType); } } @@ -121,17 +118,16 @@ public final class OSGiDistributedDataStore { @Reference ModuleShardConfigProvider configProvider = null; @Reference(target = "(component.factory=" + OSGiDOMStore.FACTORY_NAME + ")") - ComponentFactory datastoreFactory = null; + ComponentFactory datastoreFactory = null; private DatastoreState configDatastore; private DatastoreState operDatastore; @Activate void activate(final Map properties) { - configDatastore = createDatastore(LogicalDatastoreType.CONFIGURATION, "distributed-config", null); - operDatastore = createDatastore(LogicalDatastoreType.OPERATIONAL, "distributed-operational", + configDatastore = createDatastore(LogicalDatastoreType.CONFIGURATION, "distributed-config", properties, null); + operDatastore = createDatastore(LogicalDatastoreType.OPERATIONAL, "distributed-operational", properties, new ConfigurationImpl(configProvider)); - modified(properties); } @Modified @@ -150,9 +146,9 @@ public final class OSGiDistributedDataStore { } private DatastoreState createDatastore(final LogicalDatastoreType datastoreType, final String serviceType, - final Configuration config) { + final Map properties, final Configuration config) { LOG.info("Distributed Datastore type {} starting", datastoreType); - final DatastoreContextIntrospector introspector = introspectorFactory.newInstance(datastoreType); + final DatastoreContextIntrospector introspector = introspectorFactory.newInstance(datastoreType, properties); final AbstractDataStore datastore = DistributedDataStoreFactory.createInstance(actorSystemProvider, introspector.getContext(), introspector, snapshotRestore, config); datastore.setCloseable(schemaService.registerSchemaContextListener(datastore));