*/
package org.opendaylight.controller.cluster.datastore.shardmanager;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.Props;
-import com.google.common.base.Preconditions;
-import java.util.concurrent.CountDownLatch;
+import com.google.common.util.concurrent.SettableFuture;
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.persisted.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.utils.PrimaryShardInfoFutureCache;
+import org.opendaylight.yangtools.yang.common.Empty;
public abstract class AbstractShardManagerCreator<T extends AbstractShardManagerCreator<T>> {
+ private SettableFuture<Empty> readinessFuture;
private ClusterWrapper cluster;
private Configuration configuration;
private DatastoreContextFactory datastoreContextFactory;
private AbstractDataStore distributedDataStore;
- private CountDownLatch waitTillReadyCountDownLatch;
private PrimaryShardInfoFutureCache primaryShardInfoCache;
private DatastoreSnapshot restoreFromSnapshot;
private volatile boolean sealed;
}
protected final void checkSealed() {
- Preconditions.checkState(!sealed, "Builder is already sealed - further modifications are not allowed");
+ checkState(!sealed, "Builder is already sealed - further modifications are not allowed");
}
ClusterWrapper getCluster() {
return cluster;
}
- public T cluster(ClusterWrapper newCluster) {
+ public T cluster(final ClusterWrapper newCluster) {
checkSealed();
this.cluster = newCluster;
return self();
return configuration;
}
- public T configuration(Configuration newConfiguration) {
+ public T configuration(final Configuration newConfiguration) {
checkSealed();
this.configuration = newConfiguration;
return self();
public T datastoreContextFactory(final DatastoreContextFactory newDatastoreContextFactory) {
checkSealed();
- this.datastoreContextFactory = Preconditions.checkNotNull(newDatastoreContextFactory);
+ this.datastoreContextFactory = requireNonNull(newDatastoreContextFactory);
return self();
}
return distributedDataStore;
}
- public T distributedDataStore(final AbstractDataStore distributedDataStore) {
+ public T distributedDataStore(final AbstractDataStore newDistributedDataStore) {
checkSealed();
- this.distributedDataStore = distributedDataStore;
+ this.distributedDataStore = newDistributedDataStore;
return self();
}
- CountDownLatch getWaitTillReadyCountDownLatch() {
- return waitTillReadyCountDownLatch;
+ SettableFuture<Empty> getReadinessFuture() {
+ return readinessFuture;
}
- public T waitTillReadyCountDownLatch(CountDownLatch newWaitTillReadyCountDownLatch) {
+ public T readinessFuture(final SettableFuture<Empty> newReadinessFuture) {
checkSealed();
- this.waitTillReadyCountDownLatch = newWaitTillReadyCountDownLatch;
+ this.readinessFuture = newReadinessFuture;
return self();
}
return primaryShardInfoCache;
}
- public T primaryShardInfoCache(PrimaryShardInfoFutureCache newPrimaryShardInfoCache) {
+ public T primaryShardInfoCache(final PrimaryShardInfoFutureCache newPrimaryShardInfoCache) {
checkSealed();
this.primaryShardInfoCache = newPrimaryShardInfoCache;
return self();
return restoreFromSnapshot;
}
- public T restoreFromSnapshot(DatastoreSnapshot newRestoreFromSnapshot) {
+ public T restoreFromSnapshot(final DatastoreSnapshot newRestoreFromSnapshot) {
checkSealed();
this.restoreFromSnapshot = newRestoreFromSnapshot;
return self();
protected void verify() {
sealed = true;
- 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");
+ requireNonNull(cluster, "cluster should not be null");
+ requireNonNull(configuration, "configuration should not be null");
+ requireNonNull(datastoreContextFactory, "datastoreContextFactory should not be null");
+ requireNonNull(distributedDataStore, "distributedDataStore should not be null");
+ requireNonNull(readinessFuture, "readinessFuture should not be null");
+ requireNonNull(primaryShardInfoCache, "primaryShardInfoCache should not be null");
}
public Props props() {