- public static DistributedDataStore createInstance(String name, SchemaService schemaService){
- ActorSystem actorSystem = ActorSystemFactory.getInstance();
- final DistributedDataStore dataStore =
- new DistributedDataStore(actorSystem, name, new ClusterWrapperImpl(actorSystem), new ConfigurationImpl("module-shards.conf", "modules.conf"));
- schemaService
- .registerSchemaServiceListener(dataStore);
+ private static final String ACTOR_SYSTEM_NAME = "opendaylight-cluster-data";
+ private static final String CONFIGURATION_NAME = "odl-cluster-data";
+ private static ActorSystem actorSystem = null;
+ private static final Set<DistributedDataStore> createdInstances = new HashSet<>(2);
+ private static final Logger LOG = LoggerFactory.getLogger(DistributedDataStoreFactory.class);
+
+ public static synchronized DistributedDataStore createInstance(SchemaService schemaService,
+ DatastoreContext datastoreContext, BundleContext bundleContext) {
+
+ LOG.info("Create data store instance of type : {}", datastoreContext.getDataStoreType());
+
+ DatastoreContextIntrospector introspector = new DatastoreContextIntrospector(datastoreContext);
+ DatastoreContextConfigAdminOverlay overlay = new DatastoreContextConfigAdminOverlay(
+ introspector, bundleContext);
+
+ ActorSystem actorSystem = getActorSystem(bundleContext, datastoreContext.getConfigurationReader());
+ Configuration config = new ConfigurationImpl("module-shards.conf", "modules.conf");
+ final DistributedDataStore dataStore = new DistributedDataStore(actorSystem,
+ new ClusterWrapperImpl(actorSystem), config, introspector.getContext());
+
+ overlay.setListener(dataStore);
+
+ ShardStrategyFactory.setConfiguration(config);
+ schemaService.registerSchemaContextListener(dataStore);
+
+ dataStore.setCloseable(overlay);
+ dataStore.waitTillReady();
+
+ createdInstances.add(dataStore);