Bug 8994 - FileModuleShardConfigProvider should not use hard-coded paths
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / DistributedDataStoreFactory.java
index 4fd09914cdb6eb5185247bf51f6177064aba7337..11bbe1b168b21164107b08bebce3ebe786cd6cb1 100644 (file)
@@ -21,6 +21,8 @@ import org.slf4j.LoggerFactory;
 
 public class DistributedDataStoreFactory {
     private static final Logger LOG = LoggerFactory.getLogger(DistributedDataStoreFactory.class);
+    private static final String DEFAULT_MODULE_SHARDS_PATH = "./configuration/initial/module-shards.conf";
+    private static final String DEFAULT_MODULES_PATH = "./configuration/initial/modules.conf";
 
     /**
      * Create a data store instance.
@@ -33,13 +35,21 @@ public class DistributedDataStoreFactory {
             final DatastoreContext initialDatastoreContext, final DatastoreSnapshotRestore datastoreSnapshotRestore,
             final ActorSystemProvider actorSystemProvider, final BundleContext bundleContext) {
 
-        return createInstance((DOMSchemaService) schemaService, initialDatastoreContext, datastoreSnapshotRestore,
-            actorSystemProvider, bundleContext);
+        return createInstance(schemaService, initialDatastoreContext, datastoreSnapshotRestore,
+                actorSystemProvider, bundleContext, null);
     }
 
     public static AbstractDataStore createInstance(final DOMSchemaService schemaService,
             final DatastoreContext initialDatastoreContext, final DatastoreSnapshotRestore datastoreSnapshotRestore,
             final ActorSystemProvider actorSystemProvider, final BundleContext bundleContext) {
+        return createInstance(schemaService, initialDatastoreContext, datastoreSnapshotRestore, actorSystemProvider,
+                bundleContext, null);
+    }
+
+    public static AbstractDataStore createInstance(final DOMSchemaService schemaService,
+            final DatastoreContext initialDatastoreContext, final DatastoreSnapshotRestore datastoreSnapshotRestore,
+            final ActorSystemProvider actorSystemProvider, final BundleContext bundleContext,
+            final Configuration orgConfig) {
 
         final String datastoreName = initialDatastoreContext.getDataStoreName();
         LOG.info("Create data store instance of type : {}", datastoreName);
@@ -50,7 +60,12 @@ public class DistributedDataStoreFactory {
         final DatastoreContextConfigAdminOverlay overlay = new DatastoreContextConfigAdminOverlay(
                 introspector, bundleContext);
 
-        final Configuration config = new ConfigurationImpl("module-shards.conf", "modules.conf");
+        Configuration config;
+        if (orgConfig == null) {
+            config = new ConfigurationImpl(DEFAULT_MODULE_SHARDS_PATH, DEFAULT_MODULES_PATH);
+        } else {
+            config = orgConfig;
+        }
         final ClusterWrapper clusterWrapper = new ClusterWrapperImpl(actorSystem);
         final DatastoreContextFactory contextFactory = introspector.newContextFactory();