Use java.util.Optional in ShardLeaderStateChanged and PrimaryShardInfo 95/36695/4
authorRobert Varga <rovarga@cisco.com>
Wed, 23 Mar 2016 20:42:04 +0000 (21:42 +0100)
committerTom Pantelis <tpanteli@brocade.com>
Wed, 30 Mar 2016 15:50:35 +0000 (15:50 +0000)
This migrates to using Java 8 Optional instead of Guava. It also changes the
constructor conventions as Optional is recommended to be used in short-lived
scenarios (e.g. return type, not argument).

Change-Id: I85db0e02b6c247efd8a84262ee7d05159cf926f8
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContextFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryShardInfo.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ShardLeaderStateChanged.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardInformation.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/PrimaryShardInfoFutureCacheTest.java

index d8dda25..225f3c2 100644 (file)
@@ -9,9 +9,9 @@ package org.opendaylight.controller.cluster.datastore;
 
 import akka.actor.ActorSelection;
 import akka.dispatch.OnComplete;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.util.Collection;
+import java.util.Optional;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicLong;
index 474c794..6030117 100644 (file)
@@ -67,7 +67,6 @@ import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply;
 import org.opendaylight.controller.cluster.raft.messages.ServerRemoved;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.CompositeModificationByteStringPayload;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.CompositeModificationPayload;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
@@ -289,9 +288,8 @@ public class Shard extends RaftActor {
 
     @Override
     protected LeaderStateChanged newLeaderStateChanged(String memberId, String leaderId, short leaderPayloadVersion) {
-        return new ShardLeaderStateChanged(memberId, leaderId,
-                isLeader() ? Optional.<DataTree>of(store.getDataTree()) : Optional.<DataTree>absent(),
-                leaderPayloadVersion);
+        return isLeader() ? new ShardLeaderStateChanged(memberId, leaderId, store.getDataTree(), leaderPayloadVersion)
+                : new ShardLeaderStateChanged(memberId, leaderId, leaderPayloadVersion);
     }
 
     protected void onDatastoreContext(DatastoreContext context) {
index cad0a45..27d2475 100644 (file)
@@ -8,8 +8,8 @@
 package org.opendaylight.controller.cluster.datastore.messages;
 
 import akka.actor.ActorSelection;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
+import java.util.Optional;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 
@@ -21,15 +21,21 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 public class PrimaryShardInfo {
     private final ActorSelection primaryShardActor;
     private final short primaryShardVersion;
-    private final Optional<DataTree> localShardDataTree;
+    private final DataTree localShardDataTree;
 
     public PrimaryShardInfo(@Nonnull ActorSelection primaryShardActor, short primaryShardVersion,
-            @Nonnull Optional<DataTree> localShardDataTree) {
+            @Nonnull DataTree localShardDataTree) {
         this.primaryShardActor = Preconditions.checkNotNull(primaryShardActor);
         this.primaryShardVersion = primaryShardVersion;
         this.localShardDataTree = Preconditions.checkNotNull(localShardDataTree);
     }
 
+    public PrimaryShardInfo(@Nonnull ActorSelection primaryShardActor, short primaryShardVersion) {
+        this.primaryShardActor = Preconditions.checkNotNull(primaryShardActor);
+        this.primaryShardVersion = primaryShardVersion;
+        this.localShardDataTree = null;
+    }
+
     /**
      * Returns an ActorSelection representing the primary shard actor.
      */
@@ -49,6 +55,6 @@ public class PrimaryShardInfo {
      * to the caller. Otherwise the Optional value is absent.
      */
     public @Nonnull Optional<DataTree> getLocalShardDataTree() {
-        return localShardDataTree;
+        return Optional.ofNullable(localShardDataTree);
     }
 }
index 20b7d81..84585f4 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.controller.cluster.datastore.messages;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
+import java.util.Optional;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.cluster.notifications.LeaderStateChanged;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
@@ -22,15 +22,21 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
  */
 public class ShardLeaderStateChanged extends LeaderStateChanged {
 
-    private final Optional<DataTree> localShardDataTree;
+    private final DataTree localShardDataTree;
 
     public ShardLeaderStateChanged(@Nonnull String memberId, @Nonnull String leaderId,
-            @Nonnull Optional<DataTree> localShardDataTree, short leaderPayloadVersion) {
+            @Nonnull DataTree localShardDataTree, short leaderPayloadVersion) {
         super(memberId, leaderId, leaderPayloadVersion);
         this.localShardDataTree = Preconditions.checkNotNull(localShardDataTree);
     }
 
+    public ShardLeaderStateChanged(@Nonnull String memberId, @Nonnull String leaderId,
+            short leaderPayloadVersion) {
+        super(memberId, leaderId, leaderPayloadVersion);
+        this.localShardDataTree = null;
+    }
+
     public @Nonnull Optional<DataTree> getLocalShardDataTree() {
-        return localShardDataTree;
+        return Optional.ofNullable(localShardDataTree);
     }
 }
index 42636ca..8f42ea4 100644 (file)
@@ -10,13 +10,13 @@ package org.opendaylight.controller.cluster.datastore.shardmanager;
 import akka.actor.ActorRef;
 import akka.actor.Props;
 import akka.serialization.Serialization;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.Set;
 import javax.annotation.Nullable;
 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
index 71e6b64..1bcdd3b 100644 (file)
@@ -234,8 +234,8 @@ public class ActorContext {
     private PrimaryShardInfo onPrimaryShardFound(String shardName, String primaryActorPath,
             short primaryVersion, DataTree localShardDataTree) {
         ActorSelection actorSelection = actorSystem.actorSelection(primaryActorPath);
-        PrimaryShardInfo info = new PrimaryShardInfo(actorSelection, primaryVersion,
-                Optional.fromNullable(localShardDataTree));
+        PrimaryShardInfo info = localShardDataTree == null ? new PrimaryShardInfo(actorSelection, primaryVersion) :
+            new PrimaryShardInfo(actorSelection, primaryVersion, localShardDataTree);
         primaryShardInfoCache.putSuccessful(shardName, info);
         return info;
     }
index ec96cf4..9446ec3 100644 (file)
@@ -26,7 +26,6 @@ import akka.testkit.JavaTestKit;
 import akka.util.Timeout;
 import com.codahale.metrics.MetricRegistry;
 import com.codahale.metrics.Timer;
-import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.typesafe.config.Config;
@@ -75,7 +74,6 @@ import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -304,7 +302,7 @@ public abstract class AbstractTransactionProxyTest {
     protected Future<PrimaryShardInfo> primaryShardInfoReply(ActorSystem actorSystem, ActorRef actorRef,
             short transactionVersion) {
         return Futures.successful(new PrimaryShardInfo(actorSystem.actorSelection(actorRef.path()),
-                transactionVersion, Optional.<DataTree>absent()));
+                transactionVersion));
     }
 
     protected ActorRef setupActorContextWithoutInitialCreateTransaction(ActorSystem actorSystem, String shardName) {
index 31cde96..7b3ba2f 100644 (file)
@@ -667,8 +667,8 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
         doReturn(getSystem().actorSelection(shardActorRef.path())).
                 when(mockActorContext).actorSelection(shardActorRef.path().toString());
 
-        Optional<DataTree> mockDataTree = createDataTree();
-        DataTreeModification mockModification = mockDataTree.get().takeSnapshot().newModification();
+        DataTree mockDataTree = createDataTree();
+        DataTreeModification mockModification = mockDataTree.takeSnapshot().newModification();
         doThrow(new RuntimeException("mock")).when(mockModification).ready();
 
         doReturn(Futures.successful(newPrimaryShardInfo(shardActorRef, mockDataTree))).
@@ -788,13 +788,12 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
     }
 
     private PrimaryShardInfo newPrimaryShardInfo(ActorRef actorRef){
-        return new PrimaryShardInfo(getSystem().actorSelection(actorRef.path()), DataStoreVersions.CURRENT_VERSION,
-                Optional.<DataTree>absent());
+        return new PrimaryShardInfo(getSystem().actorSelection(actorRef.path()), DataStoreVersions.CURRENT_VERSION);
     }
 
-    private PrimaryShardInfo newPrimaryShardInfo(ActorRef actorRef, Optional<DataTree> dataTreeOptional){
+    private PrimaryShardInfo newPrimaryShardInfo(ActorRef actorRef, DataTree dataTree){
         return new PrimaryShardInfo(getSystem().actorSelection(actorRef.path()), DataStoreVersions.CURRENT_VERSION,
-                dataTreeOptional);
+                dataTree);
     }
 
 
@@ -884,14 +883,14 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
                 expected, (end-start)), (end - start) <= expected);
     }
 
-    private void completeOperationLocal(TransactionProxyOperation operation, Optional<DataTree> dataTreeOptional){
+    private void completeOperationLocal(TransactionProxyOperation operation, DataTree dataTree){
         ActorSystem actorSystem = getSystem();
         ActorRef shardActorRef = actorSystem.actorOf(Props.create(DoNothingActor.class));
 
         doReturn(actorSystem.actorSelection(shardActorRef.path())).
                 when(mockActorContext).actorSelection(shardActorRef.path().toString());
 
-        doReturn(Futures.successful(newPrimaryShardInfo(shardActorRef, dataTreeOptional))).
+        doReturn(Futures.successful(newPrimaryShardInfo(shardActorRef, dataTree))).
                 when(mockActorContext).findPrimaryShardAsync(eq(DefaultShardStrategy.DEFAULT_SHARD));
 
         TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, READ_WRITE);
@@ -907,21 +906,19 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
                 expected, (end-start)), (end - start) <= expected);
     }
 
-    private static Optional<DataTree> createDataTree(){
+    private static DataTree createDataTree(){
         DataTree dataTree = mock(DataTree.class);
-        Optional<DataTree> dataTreeOptional = Optional.of(dataTree);
         DataTreeSnapshot dataTreeSnapshot = mock(DataTreeSnapshot.class);
         DataTreeModification dataTreeModification = mock(DataTreeModification.class);
 
         doReturn(dataTreeSnapshot).when(dataTree).takeSnapshot();
         doReturn(dataTreeModification).when(dataTreeSnapshot).newModification();
 
-        return dataTreeOptional;
+        return dataTree;
     }
 
-    private static Optional<DataTree> createDataTree(NormalizedNode<?, ?> readResponse){
+    private static DataTree createDataTree(NormalizedNode<?, ?> readResponse){
         DataTree dataTree = mock(DataTree.class);
-        Optional<DataTree> dataTreeOptional = Optional.of(dataTree);
         DataTreeSnapshot dataTreeSnapshot = mock(DataTreeSnapshot.class);
         DataTreeModification dataTreeModification = mock(DataTreeModification.class);
 
@@ -929,7 +926,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
         doReturn(dataTreeModification).when(dataTreeSnapshot).newModification();
         doReturn(Optional.of(readResponse)).when(dataTreeModification).readNode(any(YangInstanceIdentifier.class));
 
-        return dataTreeOptional;
+        return dataTree;
     }
 
 
index 4a49e88..1ac21da 100644 (file)
@@ -36,7 +36,6 @@ import akka.testkit.JavaTestKit;
 import akka.testkit.TestActorRef;
 import akka.util.Timeout;
 import com.google.common.base.Function;
-import com.google.common.base.Optional;
 import com.google.common.base.Stopwatch;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
@@ -398,7 +397,7 @@ public class ShardManagerTest extends AbstractActorTest {
             shardManager.tell(new ActorInitialized(), mockShardActor);
 
             DataTree mockDataTree = mock(DataTree.class);
-            shardManager.tell(new ShardLeaderStateChanged(memberId, memberId, Optional.of(mockDataTree),
+            shardManager.tell(new ShardLeaderStateChanged(memberId, memberId, mockDataTree,
                     DataStoreVersions.CURRENT_VERSION), getRef());
 
             MessageCollectorActor.expectFirstMatching(mockShardActor, RegisterRoleChangeListener.class);
@@ -455,8 +454,7 @@ public class ShardManagerTest extends AbstractActorTest {
             shardManager.tell(new RoleChangeNotification(memberId1,
                     RaftState.Candidate.name(), RaftState.Follower.name()), mockShardActor);
             short leaderVersion = DataStoreVersions.CURRENT_VERSION - 1;
-            shardManager.tell(new ShardLeaderStateChanged(memberId1, memberId2, Optional.<DataTree>absent(),
-                    leaderVersion), mockShardActor);
+            shardManager.tell(new ShardLeaderStateChanged(memberId1, memberId2, leaderVersion), mockShardActor);
 
             shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, false), getRef());
 
@@ -512,7 +510,7 @@ public class ShardManagerTest extends AbstractActorTest {
             expectMsgClass(duration("5 seconds"), NoShardLeaderException.class);
 
             DataTree mockDataTree = mock(DataTree.class);
-            shardManager.tell(new ShardLeaderStateChanged(memberId, memberId, Optional.of(mockDataTree),
+            shardManager.tell(new ShardLeaderStateChanged(memberId, memberId, mockDataTree,
                     DataStoreVersions.CURRENT_VERSION), mockShardActor);
 
             shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, false), getRef());
@@ -552,7 +550,7 @@ public class ShardManagerTest extends AbstractActorTest {
             expectNoMsg(FiniteDuration.create(150, TimeUnit.MILLISECONDS));
 
             DataTree mockDataTree = mock(DataTree.class);
-            shardManager.tell(new ShardLeaderStateChanged(memberId, memberId, Optional.of(mockDataTree),
+            shardManager.tell(new ShardLeaderStateChanged(memberId, memberId, mockDataTree,
                     DataStoreVersions.CURRENT_VERSION), mockShardActor);
 
             LocalPrimaryShardFound primaryFound = expectMsgClass(duration("5 seconds"), LocalPrimaryShardFound.class);
@@ -683,7 +681,7 @@ public class ShardManagerTest extends AbstractActorTest {
             String memberId2 = "member-2-shard-astronauts-" + shardMrgIDSuffix;
             short leaderVersion = DataStoreVersions.CURRENT_VERSION - 1;
             shardManager2.tell(new ShardLeaderStateChanged(memberId2, memberId2,
-                    Optional.of(mock(DataTree.class)), leaderVersion), mockShardActor2);
+                    mock(DataTree.class), leaderVersion), mockShardActor2);
             shardManager2.tell(new RoleChangeNotification(memberId2,
                     RaftState.Candidate.name(), RaftState.Leader.name()), mockShardActor2);
 
@@ -753,10 +751,10 @@ public class ShardManagerTest extends AbstractActorTest {
             String memberId2 = "member-2-shard-default-" + shardMrgIDSuffix;
             String memberId1 = "member-1-shard-default-" + shardMrgIDSuffix;
             shardManager1.tell(new ShardLeaderStateChanged(memberId1, memberId2,
-                Optional.of(mock(DataTree.class)), DataStoreVersions.CURRENT_VERSION), mockShardActor1);
+                mock(DataTree.class), DataStoreVersions.CURRENT_VERSION), mockShardActor1);
             shardManager1.tell(new RoleChangeNotification(memberId1,
                 RaftState.Candidate.name(), RaftState.Follower.name()), mockShardActor1);
-            shardManager2.tell(new ShardLeaderStateChanged(memberId2, memberId2, Optional.of(mock(DataTree.class)),
+            shardManager2.tell(new ShardLeaderStateChanged(memberId2, memberId2, mock(DataTree.class),
                     DataStoreVersions.CURRENT_VERSION),
                 mockShardActor2);
             shardManager2.tell(new RoleChangeNotification(memberId2,
@@ -869,10 +867,10 @@ public class ShardManagerTest extends AbstractActorTest {
             String memberId2 = "member-2-shard-default-" + shardMrgIDSuffix;
             String memberId1 = "member-1-shard-default-" + shardMrgIDSuffix;
             shardManager1.tell(new ShardLeaderStateChanged(memberId1, memberId2,
-                Optional.of(mock(DataTree.class)), DataStoreVersions.CURRENT_VERSION), mockShardActor1);
+                mock(DataTree.class), DataStoreVersions.CURRENT_VERSION), mockShardActor1);
             shardManager1.tell(new RoleChangeNotification(memberId1,
                 RaftState.Candidate.name(), RaftState.Follower.name()), mockShardActor1);
-            shardManager2.tell(new ShardLeaderStateChanged(memberId2, memberId2, Optional.of(mock(DataTree.class)),
+            shardManager2.tell(new ShardLeaderStateChanged(memberId2, memberId2, mock(DataTree.class),
                     DataStoreVersions.CURRENT_VERSION),
                 mockShardActor2);
             shardManager2.tell(new RoleChangeNotification(memberId2,
@@ -886,7 +884,7 @@ public class ShardManagerTest extends AbstractActorTest {
             assertTrue("Unexpected primary path " + path, path.contains("member-2-shard-default-config"));
 
             primaryShardInfoCache.putSuccessful("default", new PrimaryShardInfo(system1.actorSelection(
-                    mockShardActor1.path()), DataStoreVersions.CURRENT_VERSION, Optional.<DataTree>absent()));
+                    mockShardActor1.path()), DataStoreVersions.CURRENT_VERSION));
 
             shardManager1.tell(MockClusterWrapper.
                 createUnreachableMember("member-2", "akka.tcp://cluster-test@127.0.0.1:2558"), getRef());
@@ -899,7 +897,7 @@ public class ShardManagerTest extends AbstractActorTest {
 
             assertNull("Expected primaryShardInfoCache entry removed", primaryShardInfoCache.getIfPresent("default"));
 
-            shardManager1.tell(new ShardLeaderStateChanged(memberId1, memberId1, Optional.of(mock(DataTree.class)),
+            shardManager1.tell(new ShardLeaderStateChanged(memberId1, memberId1, mock(DataTree.class),
                     DataStoreVersions.CURRENT_VERSION), mockShardActor1);
             shardManager1.tell(new RoleChangeNotification(memberId1,
                 RaftState.Follower.name(), RaftState.Leader.name()), mockShardActor1);
@@ -1010,7 +1008,7 @@ public class ShardManagerTest extends AbstractActorTest {
         verify(ready, never()).countDown();
 
         shardManager.onReceiveCommand(new ShardLeaderStateChanged(memberId, memberId,
-                Optional.of(mock(DataTree.class)), DataStoreVersions.CURRENT_VERSION));
+                mock(DataTree.class), DataStoreVersions.CURRENT_VERSION));
 
         verify(ready, times(1)).countDown();
     }
@@ -1029,7 +1027,7 @@ public class ShardManagerTest extends AbstractActorTest {
             shardManager.onReceiveCommand(MockClusterWrapper.createMemberUp("member-2", getRef().path().toString()));
 
             shardManager.onReceiveCommand(new ShardLeaderStateChanged(memberId,
-                    "member-2-shard-default-" + shardMrgIDSuffix, Optional.of(mock(DataTree.class)),
+                    "member-2-shard-default-" + shardMrgIDSuffix, mock(DataTree.class),
                     DataStoreVersions.CURRENT_VERSION));
 
             verify(ready, times(1)).countDown();
@@ -1047,7 +1045,7 @@ public class ShardManagerTest extends AbstractActorTest {
             verify(ready, never()).countDown();
 
             shardManager.onReceiveCommand(new ShardLeaderStateChanged(memberId,
-                    "member-2-shard-default-" + shardMrgIDSuffix, Optional.of(mock(DataTree.class)),
+                    "member-2-shard-default-" + shardMrgIDSuffix, mock(DataTree.class),
                     DataStoreVersions.CURRENT_VERSION));
 
             shardManager.onReceiveCommand(MockClusterWrapper.createMemberUp("member-2", getRef().path().toString()));
@@ -1458,7 +1456,7 @@ public class ShardManagerTest extends AbstractActorTest {
             String memberId2 = "member-2-shard-astronauts-" + shardMrgIDSuffix;
             short leaderVersion = DataStoreVersions.CURRENT_VERSION - 1;
             leaderShardManager.tell(new ShardLeaderStateChanged(memberId2, memberId2,
-                    Optional.of(mock(DataTree.class)), leaderVersion), mockShardLeaderActor);
+                    mock(DataTree.class), leaderVersion), mockShardLeaderActor);
             leaderShardManager.tell(new RoleChangeNotification(memberId2,
                     RaftState.Candidate.name(), RaftState.Leader.name()), mockShardLeaderActor);
 
@@ -1516,7 +1514,7 @@ public class ShardManagerTest extends AbstractActorTest {
             String newReplicaId = "member-1-shard-default-" + shardMrgIDSuffix;
             shardManager.tell(new RoleChangeNotification(newReplicaId,
                     RaftState.Candidate.name(), RaftState.Follower.name()), mockShardActor);
-            shardManager.tell(new ShardLeaderStateChanged(newReplicaId, leaderId, Optional.<DataTree>absent(),
+            shardManager.tell(new ShardLeaderStateChanged(newReplicaId, leaderId,
                     DataStoreVersions.CURRENT_VERSION), mockShardActor);
 
             shardManager.tell(new AddShardReplica(Shard.DEFAULT_NAME), getRef());
@@ -1559,7 +1557,7 @@ public class ShardManagerTest extends AbstractActorTest {
 
             shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
             shardManager.tell(new ActorInitialized(), mockShardActor);
-            shardManager.tell(new ShardLeaderStateChanged(memberId, memberId, Optional.of(mock(DataTree.class)),
+            shardManager.tell(new ShardLeaderStateChanged(memberId, memberId, mock(DataTree.class),
                     DataStoreVersions.CURRENT_VERSION), getRef());
             shardManager.tell((new RoleChangeNotification(memberId, RaftState.Candidate.name(),
                     RaftState.Leader.name())), mockShardActor);
@@ -1678,7 +1676,7 @@ public class ShardManagerTest extends AbstractActorTest {
 
             shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
             shardManager.tell(new ActorInitialized(), respondActor);
-            shardManager.tell(new ShardLeaderStateChanged(memberId, memberId, Optional.of(mock(DataTree.class)),
+            shardManager.tell(new ShardLeaderStateChanged(memberId, memberId, mock(DataTree.class),
                     DataStoreVersions.CURRENT_VERSION), getRef());
             shardManager.tell((new RoleChangeNotification(memberId, RaftState.Candidate.name(),
                     RaftState.Leader.name())), respondActor);
@@ -1754,13 +1752,13 @@ public class ShardManagerTest extends AbstractActorTest {
             String memberId2 = "member-2-shard-default-" + shardMrgIDSuffix;
             short leaderVersion = DataStoreVersions.CURRENT_VERSION - 1;
             leaderShardManager.tell(new ShardLeaderStateChanged(memberId2, memberId2,
-                    Optional.of(mock(DataTree.class)), leaderVersion), mockShardLeaderActor);
+                    mock(DataTree.class), leaderVersion), mockShardLeaderActor);
             leaderShardManager.tell(new RoleChangeNotification(memberId2,
                     RaftState.Candidate.name(), RaftState.Leader.name()), mockShardLeaderActor);
 
             String memberId1 = "member-1-shard-default-" + shardMrgIDSuffix;
             newReplicaShardManager.tell(new ShardLeaderStateChanged(memberId1, memberId2,
-                    Optional.of(mock(DataTree.class)), leaderVersion), mockShardActor);
+                    mock(DataTree.class), leaderVersion), mockShardActor);
             newReplicaShardManager.tell(new RoleChangeNotification(memberId1,
                     RaftState.Candidate.name(), RaftState.Follower.name()), mockShardActor);
 
index e9d780a..50645a2 100644 (file)
@@ -11,11 +11,9 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.mockito.Mockito.mock;
 import akka.actor.ActorSelection;
-import com.google.common.base.Optional;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
 import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import scala.concurrent.Future;
 
 /**
@@ -31,8 +29,7 @@ public class PrimaryShardInfoFutureCacheTest {
 
         assertEquals("getIfPresent", null, cache.getIfPresent("foo"));
 
-        PrimaryShardInfo shardInfo = new PrimaryShardInfo(mock(ActorSelection.class), DataStoreVersions.CURRENT_VERSION,
-                Optional.<DataTree>absent());
+        PrimaryShardInfo shardInfo = new PrimaryShardInfo(mock(ActorSelection.class), DataStoreVersions.CURRENT_VERSION);
         cache.putSuccessful("foo", shardInfo);
 
         Future<PrimaryShardInfo> future = cache.getIfPresent("foo");

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.