BUG-7965 Switch distributed-data backend to a separate shard
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / shardmanager / AbstractShardManagerCreator.java
index 7dbd66909a94a740f2f87757ea0e00e88d1154bc..4dd409e85e1d0624df16df2c5519df7241fe24ce 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.cluster.datastore.shardmanager;
 import akka.actor.Props;
 import com.google.common.base.Preconditions;
 import java.util.concurrent.CountDownLatch;
+import org.opendaylight.controller.cluster.datastore.AbstractDataStore;
 import org.opendaylight.controller.cluster.datastore.ClusterWrapper;
 import org.opendaylight.controller.cluster.datastore.DatastoreContextFactory;
 import org.opendaylight.controller.cluster.datastore.config.Configuration;
@@ -20,6 +21,7 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
     private ClusterWrapper cluster;
     private Configuration configuration;
     private DatastoreContextFactory datastoreContextFactory;
+    private AbstractDataStore distributedDataStore;
     private CountDownLatch waitTillReadyCountDownLatch;
     private PrimaryShardInfoFutureCache primaryShardInfoCache;
     private DatastoreSnapshot restoreFromSnapshot;
@@ -62,9 +64,19 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
         return datastoreContextFactory;
     }
 
-    public T datastoreContextFactory(DatastoreContextFactory newDatastoreContextFactory) {
+    public T datastoreContextFactory(final DatastoreContextFactory newDatastoreContextFactory) {
         checkSealed();
-        this.datastoreContextFactory = newDatastoreContextFactory;
+        this.datastoreContextFactory = Preconditions.checkNotNull(newDatastoreContextFactory);
+        return self();
+    }
+
+    AbstractDataStore getDistributedDataStore() {
+        return distributedDataStore;
+    }
+
+    public T distributedDataStore(final AbstractDataStore distributedDataStore) {
+        checkSealed();
+        this.distributedDataStore = distributedDataStore;
         return self();
     }
 
@@ -103,6 +115,7 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
         Preconditions.checkNotNull(cluster, "cluster should not be null");
         Preconditions.checkNotNull(configuration, "configuration should not be null");
         Preconditions.checkNotNull(datastoreContextFactory, "datastoreContextFactory should not be null");
+        Preconditions.checkNotNull(distributedDataStore, "distributedDataStore should not be null");
         Preconditions.checkNotNull(waitTillReadyCountDownLatch, "waitTillReadyCountdownLatch should not be null");
         Preconditions.checkNotNull(primaryShardInfoCache, "primaryShardInfoCache should not be null");
     }