Fixup "Leader should always apply modifications as local" regression
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / shardmanager / ShardInformation.java
index 5b1f1b780e879de7e4229493f418469e480d327a..ac870905adcf1e781d49da672fb7561a22d6b2f9 100644 (file)
@@ -12,7 +12,7 @@ import static java.util.Objects.requireNonNull;
 import akka.actor.ActorRef;
 import akka.actor.Props;
 import akka.serialization.Serialization;
-import com.google.common.base.Preconditions;
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Strings;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -31,12 +31,13 @@ import org.opendaylight.controller.cluster.datastore.messages.PeerUp;
 import org.opendaylight.controller.cluster.datastore.shardmanager.ShardManager.OnShardInitialized;
 import org.opendaylight.controller.cluster.datastore.shardmanager.ShardManager.OnShardReady;
 import org.opendaylight.controller.cluster.raft.RaftState;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-final class ShardInformation {
+@VisibleForTesting
+public final class ShardInformation {
     private static final Logger LOG = LoggerFactory.getLogger(ShardInformation.class);
 
     private final Set<OnShardInitialized> onShardInitializedSet = new HashSet<>();
@@ -51,7 +52,7 @@ final class ShardInformation {
     private final AtomicShardContextProvider schemaContextProvider = new AtomicShardContextProvider();
     private ActorRef actor;
 
-    private Optional<DataTree> localShardDataTree;
+    private Optional<ReadOnlyDataTree> localShardDataTree;
     private boolean leaderAvailable = false;
 
     // flag that determines if the actor is ready for business
@@ -89,7 +90,8 @@ final class ShardInformation {
         return shardName;
     }
 
-    @Nullable ActorRef getActor() {
+    @VisibleForTesting
+    @Nullable public ActorRef getActor() {
         return actor;
     }
 
@@ -101,11 +103,11 @@ final class ShardInformation {
         return shardId;
     }
 
-    void setLocalDataTree(final Optional<DataTree> dataTree) {
+    void setLocalDataTree(final Optional<ReadOnlyDataTree> dataTree) {
         this.localShardDataTree = dataTree;
     }
 
-    Optional<DataTree> getLocalShardDataTree() {
+    Optional<ReadOnlyDataTree> getLocalShardDataTree() {
         return localShardDataTree;
     }
 
@@ -277,7 +279,12 @@ final class ShardInformation {
     }
 
     void setSchemaContext(final SchemaContext schemaContext) {
-        schemaContextProvider.set(Preconditions.checkNotNull(schemaContext));
+        schemaContextProvider.set(requireNonNull(schemaContext));
+    }
+
+    @VisibleForTesting
+    Shard.AbstractBuilder<?, ?> getBuilder() {
+        return builder;
     }
 
     @Override