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%2FOSGiDistributedDataStore.java;h=d365097f3bb8c0ca44f9ce418e81a0c87fb728e9;hp=0811137efa99d7e859d963309ec192e33dbe2aa1;hb=901c6bb2c8321739b54c4b20c32ef214fe02102e;hpb=88192bd72decaef3fa28071ed68987e8a83f36b0 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 0811137efa..d365097f3b 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 @@ -107,26 +107,23 @@ public final class OSGiDistributedDataStore { private static final Logger LOG = LoggerFactory.getLogger(OSGiDistributedDataStore.class); - @Reference - DOMSchemaService schemaService = null; - @Reference - ActorSystemProvider actorSystemProvider = null; - @Reference - DatastoreContextIntrospectorFactory introspectorFactory = null; - @Reference - DatastoreSnapshotRestore snapshotRestore = null; - @Reference - ModuleShardConfigProvider configProvider = null; - @Reference(target = "(component.factory=" + OSGiDOMStore.FACTORY_NAME + ")") - ComponentFactory datastoreFactory = null; - + private final ComponentFactory datastoreFactory; private DatastoreState configDatastore; private DatastoreState operDatastore; @Activate - void activate(final Map properties) { - configDatastore = createDatastore(LogicalDatastoreType.CONFIGURATION, "distributed-config", properties, null); - operDatastore = createDatastore(LogicalDatastoreType.OPERATIONAL, "distributed-operational", properties, + public OSGiDistributedDataStore(@Reference final DOMSchemaService schemaService, + @Reference final ActorSystemProvider actorSystemProvider, + @Reference final DatastoreContextIntrospectorFactory introspectorFactory, + @Reference final DatastoreSnapshotRestore snapshotRestore, + @Reference final ModuleShardConfigProvider configProvider, + @Reference(target = "(component.factory=" + OSGiDOMStore.FACTORY_NAME + ")") + final ComponentFactory datastoreFactory, final Map properties) { + this.datastoreFactory = requireNonNull(datastoreFactory); + configDatastore = createDatastore(schemaService, actorSystemProvider, snapshotRestore, introspectorFactory, + LogicalDatastoreType.CONFIGURATION, "distributed-config", properties, null); + operDatastore = createDatastore(schemaService, actorSystemProvider, snapshotRestore, introspectorFactory, + LogicalDatastoreType.OPERATIONAL, "distributed-operational", properties, new ConfigurationImpl(configProvider)); } @@ -145,14 +142,16 @@ public final class OSGiDistributedDataStore { configDatastore = null; } - private DatastoreState createDatastore(final LogicalDatastoreType datastoreType, final String serviceType, - final Map properties, final Configuration config) { + private DatastoreState createDatastore(final DOMSchemaService schemaService, + final ActorSystemProvider actorSystemProvider, final DatastoreSnapshotRestore snapshotRestore, + final DatastoreContextIntrospectorFactory introspectorFactory, final LogicalDatastoreType datastoreType, + final String serviceType, final Map properties,final Configuration config) { LOG.info("Distributed Datastore type {} starting", datastoreType); - final DatastoreContextIntrospector introspector = introspectorFactory.newInstance(datastoreType, properties); - final AbstractDataStore datastore = DistributedDataStoreFactory.createInstance(actorSystemProvider, + final var introspector = introspectorFactory.newInstance(datastoreType, properties); + final var datastore = DistributedDataStoreFactory.createInstance(actorSystemProvider, introspector.getContext(), introspector, snapshotRestore, config); datastore.setCloseable(schemaService.registerSchemaContextListener(datastore)); - final DatastoreState state = new DatastoreState(introspector, datastoreType, datastore, serviceType); + final var state = new DatastoreState(introspector, datastoreType, datastore, serviceType); Futures.addCallback(datastore.initialSettleFuture(), state, // Note we are invoked from shard manager and therefore could block it, hence the round-trip to executor