X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FMemberNode.java;h=b3fff4c6d77307f084ffb53d003e3eb6dff44f74;hb=33877f41ffc3f8eb36ad8490315419b90817d26e;hp=faa482496c889a876c47e7826560375cdee508c8;hpb=35235f427f3a056f85fe83ddd1133e67540328f7;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/MemberNode.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/MemberNode.java index faa482496c..b3fff4c6d7 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/MemberNode.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/MemberNode.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.cluster.datastore; +import static java.util.Objects.requireNonNull; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -17,23 +18,22 @@ import akka.cluster.Cluster; import akka.cluster.ClusterEvent.CurrentClusterState; import akka.cluster.Member; import akka.cluster.MemberStatus; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; import com.google.common.base.Stopwatch; -import com.google.common.collect.Sets; import com.google.common.util.concurrent.Uninterruptibles; import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; +import java.util.HashSet; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.concurrent.TimeUnit; import org.opendaylight.controller.cluster.access.concepts.MemberName; import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier; -import org.opendaylight.controller.cluster.datastore.utils.ActorContext; +import org.opendaylight.controller.cluster.datastore.utils.ActorUtils; import org.opendaylight.controller.cluster.raft.client.messages.GetOnDemandRaftState; import org.opendaylight.controller.cluster.raft.client.messages.OnDemandRaftState; import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.slf4j.LoggerFactory; import scala.concurrent.Await; import scala.concurrent.Future; @@ -132,15 +132,15 @@ public class MemberNode { public static void verifyRaftState(final AbstractDataStore datastore, final String shardName, final RaftStateVerifier verifier) throws Exception { - ActorContext actorContext = datastore.getActorContext(); + ActorUtils actorUtils = datastore.getActorUtils(); - Future future = actorContext.findLocalShardAsync(shardName); + Future future = actorUtils.findLocalShardAsync(shardName); ActorRef shardActor = Await.result(future, FiniteDuration.create(10, TimeUnit.SECONDS)); AssertionError lastError = null; Stopwatch sw = Stopwatch.createStarted(); while (sw.elapsed(TimeUnit.SECONDS) <= 5) { - OnDemandRaftState raftState = (OnDemandRaftState)actorContext + OnDemandRaftState raftState = (OnDemandRaftState)actorUtils .executeOperation(shardActor, GetOnDemandRaftState.INSTANCE); try { @@ -157,10 +157,10 @@ public class MemberNode { public static void verifyRaftPeersPresent(final AbstractDataStore datastore, final String shardName, final String... peerMemberNames) throws Exception { - final Set peerIds = Sets.newHashSet(); + final Set peerIds = new HashSet<>(); for (String p: peerMemberNames) { peerIds.add(ShardIdentifier.create(shardName, MemberName.forName(p), - datastore.getActorContext().getDataStoreName()).toString()); + datastore.getActorUtils().getDataStoreName()).toString()); } verifyRaftState(datastore, shardName, raftState -> assertEquals("Peers for shard " + shardName, peerIds, @@ -170,7 +170,7 @@ public class MemberNode { public static void verifyNoShardPresent(final AbstractDataStore datastore, final String shardName) { Stopwatch sw = Stopwatch.createStarted(); while (sw.elapsed(TimeUnit.SECONDS) <= 5) { - Optional shardReply = datastore.getActorContext().findLocalShard(shardName); + Optional shardReply = datastore.getActorUtils().findLocalShard(shardName); if (!shardReply.isPresent()) { return; } @@ -188,7 +188,7 @@ public class MemberNode { private boolean useAkkaArtery = true; private String[] waitForshardLeader = new String[0]; private String testName; - private SchemaContext schemaContext; + private EffectiveModelContext schemaContext; private boolean createOperDatastore = true; private DatastoreContext.Builder datastoreContextBuilder = DatastoreContext.newBuilder() .shardHeartbeatIntervalInMillis(300).shardElectionTimeoutFactor(30); @@ -262,7 +262,7 @@ public class MemberNode { * * @return this Builder */ - public Builder schemaContext(final SchemaContext newSchemaContext) { + public Builder schemaContext(final EffectiveModelContext newSchemaContext) { this.schemaContext = newSchemaContext; return this; } @@ -278,9 +278,9 @@ public class MemberNode { } public MemberNode build() throws Exception { - Preconditions.checkNotNull(moduleShardsConfig, "moduleShardsConfig must be specified"); - Preconditions.checkNotNull(akkaConfig, "akkaConfig must be specified"); - Preconditions.checkNotNull(testName, "testName must be specified"); + requireNonNull(moduleShardsConfig, "moduleShardsConfig must be specified"); + requireNonNull(akkaConfig, "akkaConfig must be specified"); + requireNonNull(testName, "testName must be specified"); if (schemaContext == null) { schemaContext = SchemaContextHelper.full();