Add unit test for FrontedMetadata memory leaks
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / shardmanager / AbstractShardManagerCreator.java
index b236a05e05f2acab37f1e2588878d4bec949d91f..eb6ebb3d6220164290b24c8dbbe7d4d6e58869f6 100644 (file)
@@ -10,17 +10,19 @@ 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;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
 import org.opendaylight.controller.cluster.datastore.utils.PrimaryShardInfoFutureCache;
 
 public abstract class AbstractShardManagerCreator<T extends AbstractShardManagerCreator<T>> {
     private ClusterWrapper cluster;
     private Configuration configuration;
     private DatastoreContextFactory datastoreContextFactory;
-    private CountDownLatch waitTillReadyCountdownLatch;
+    private AbstractDataStore distributedDataStore;
+    private CountDownLatch waitTillReadyCountDownLatch;
     private PrimaryShardInfoFutureCache primaryShardInfoCache;
     private DatastoreSnapshot restoreFromSnapshot;
     private volatile boolean sealed;
@@ -42,9 +44,9 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
         return cluster;
     }
 
-    public T cluster(ClusterWrapper cluster) {
+    public T cluster(ClusterWrapper newCluster) {
         checkSealed();
-        this.cluster = cluster;
+        this.cluster = newCluster;
         return self();
     }
 
@@ -52,9 +54,9 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
         return configuration;
     }
 
-    public T configuration(Configuration configuration) {
+    public T configuration(Configuration newConfiguration) {
         checkSealed();
-        this.configuration = configuration;
+        this.configuration = newConfiguration;
         return self();
     }
 
@@ -62,19 +64,29 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
         return datastoreContextFactory;
     }
 
-    public T datastoreContextFactory(DatastoreContextFactory datastoreContextFactory) {
+    public T datastoreContextFactory(final DatastoreContextFactory newDatastoreContextFactory) {
         checkSealed();
-        this.datastoreContextFactory = datastoreContextFactory;
+        this.datastoreContextFactory = Preconditions.checkNotNull(newDatastoreContextFactory);
         return self();
     }
 
-    CountDownLatch getWaitTillReadyCountdownLatch() {
-        return waitTillReadyCountdownLatch;
+    AbstractDataStore getDistributedDataStore() {
+        return distributedDataStore;
     }
 
-    public T waitTillReadyCountdownLatch(CountDownLatch waitTillReadyCountdownLatch) {
+    public T distributedDataStore(final AbstractDataStore newDistributedDataStore) {
         checkSealed();
-        this.waitTillReadyCountdownLatch = waitTillReadyCountdownLatch;
+        this.distributedDataStore = newDistributedDataStore;
+        return self();
+    }
+
+    CountDownLatch getWaitTillReadyCountDownLatch() {
+        return waitTillReadyCountDownLatch;
+    }
+
+    public T waitTillReadyCountDownLatch(CountDownLatch newWaitTillReadyCountDownLatch) {
+        checkSealed();
+        this.waitTillReadyCountDownLatch = newWaitTillReadyCountDownLatch;
         return self();
     }
 
@@ -82,9 +94,9 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
         return primaryShardInfoCache;
     }
 
-    public T primaryShardInfoCache(PrimaryShardInfoFutureCache primaryShardInfoCache) {
+    public T primaryShardInfoCache(PrimaryShardInfoFutureCache newPrimaryShardInfoCache) {
         checkSealed();
-        this.primaryShardInfoCache = primaryShardInfoCache;
+        this.primaryShardInfoCache = newPrimaryShardInfoCache;
         return self();
     }
 
@@ -92,9 +104,9 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
         return restoreFromSnapshot;
     }
 
-    public T restoreFromSnapshot(DatastoreSnapshot restoreFromSnapshot) {
+    public T restoreFromSnapshot(DatastoreSnapshot newRestoreFromSnapshot) {
         checkSealed();
-        this.restoreFromSnapshot = restoreFromSnapshot;
+        this.restoreFromSnapshot = newRestoreFromSnapshot;
         return self();
     }
 
@@ -103,7 +115,8 @@ 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(waitTillReadyCountdownLatch, "waitTillReadyCountdownLatch 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");
     }
 
@@ -111,4 +124,4 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
         verify();
         return Props.create(ShardManager.class, this);
     }
-}
\ No newline at end of file
+}