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;
private final String serviceType;
@GuardedBy("this")
- private ComponentInstance component;
+ private ComponentInstance<OSGiDOMStore> component;
@GuardedBy("this")
private boolean stopped;
synchronized void updateProperties(final Map<String, Object> properties) {
if (introspector.update(properties)) {
+ LOG.info("Distributed Datastore type {} updating context", datastoreType);
datastore.onDatastoreContextUpdated(introspector.newContextFactory());
}
}
}
@Override
- @SuppressModernizer
public void onSuccess(final Object result) {
LOG.debug("Distributed Datastore type {} reached initial settle", datastoreType);
synchronized (this) {
if (!stopped) {
- final Dictionary<String, Object> 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);
}
}
@Reference
ModuleShardConfigProvider configProvider = null;
@Reference(target = "(component.factory=" + OSGiDOMStore.FACTORY_NAME + ")")
- ComponentFactory datastoreFactory = null;
+ ComponentFactory<OSGiDOMStore> datastoreFactory = null;
private DatastoreState configDatastore;
private DatastoreState operDatastore;
@Activate
void activate(final Map<String, Object> 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
}
private DatastoreState createDatastore(final LogicalDatastoreType datastoreType, final String serviceType,
- final Configuration config) {
+ final Map<String, Object> 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));