Fix modernization issues
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / shardmanager / ShardInformation.java
index b2ac96e1641e81d9a7dd3430601840db2bdb0c4d..270c99d86cb58396d36815748a1ff4fa96624aec 100644 (file)
@@ -7,10 +7,12 @@
  */
 package org.opendaylight.controller.cluster.datastore.shardmanager;
 
+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;
@@ -18,7 +20,7 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
-import javax.annotation.Nullable;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
 import org.opendaylight.controller.cluster.datastore.Shard;
@@ -29,7 +31,7 @@ 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;
@@ -49,7 +51,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
@@ -77,9 +79,8 @@ final class ShardInformation {
     }
 
     Props newProps() {
-        Preconditions.checkNotNull(builder);
-        Props props = builder.id(shardId).peerAddresses(initialPeerAddresses).datastoreContext(datastoreContext)
-                .schemaContextProvider(schemaContextProvider).props();
+        Props props = requireNonNull(builder).id(shardId).peerAddresses(initialPeerAddresses)
+                .datastoreContext(datastoreContext).schemaContextProvider(schemaContextProvider).props();
         builder = null;
         return props;
     }
@@ -88,8 +89,7 @@ final class ShardInformation {
         return shardName;
     }
 
-    @Nullable
-    ActorRef getActor() {
+    @Nullable ActorRef getActor() {
         return actor;
     }
 
@@ -101,11 +101,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,6 +277,20 @@ final class ShardInformation {
     }
 
     void setSchemaContext(final SchemaContext schemaContext) {
-        schemaContextProvider.set(Preconditions.checkNotNull(schemaContext));
+        schemaContextProvider.set(requireNonNull(schemaContext));
+    }
+
+    @VisibleForTesting
+    Shard.AbstractBuilder<?, ?> getBuilder() {
+        return builder;
     }
+
+    @Override
+    public String toString() {
+        return "ShardInformation [shardId=" + shardId + ", leaderAvailable=" + leaderAvailable + ", actorInitialized="
+                + actorInitialized + ", followerSyncStatus=" + followerSyncStatus + ", role=" + role + ", leaderId="
+                + leaderId + ", activeMember=" + activeMember + "]";
+    }
+
+
 }