X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fraft%2FTestActorFactory.java;h=50a3c98131a4f06bbde84a5346386d74e379de0e;hp=c71c8b7de4fd8f204aa7667eea5103644527d0d5;hb=dcc9827eab4f95b8e35820e8355066ff105d2720;hpb=73f17e3e80b4e08ead5dc71065555994240a5c78 diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/TestActorFactory.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/TestActorFactory.java index c71c8b7de4..50a3c98131 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/TestActorFactory.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/TestActorFactory.java @@ -22,6 +22,7 @@ import akka.testkit.javadsl.TestKit; import akka.util.Timeout; import com.google.common.base.Stopwatch; import com.google.common.util.concurrent.Uninterruptibles; +import java.time.Duration; import java.util.LinkedList; import java.util.List; import java.util.concurrent.TimeUnit; @@ -51,7 +52,7 @@ public class TestActorFactory implements AutoCloseable { List createdActors = new LinkedList<>(); private static int actorCount = 1; - public TestActorFactory(ActorSystem system) { + public TestActorFactory(final ActorSystem system) { this.system = system; } @@ -61,7 +62,7 @@ public class TestActorFactory implements AutoCloseable { * @param props the actor Props * @return the ActorRef */ - public ActorRef createActor(Props props) { + public ActorRef createActor(final Props props) { ActorRef actorRef = system.actorOf(props); return addActor(actorRef, true); } @@ -73,7 +74,7 @@ public class TestActorFactory implements AutoCloseable { * @param actorId name of actor * @return the ActorRef */ - public ActorRef createActor(Props props, String actorId) { + public ActorRef createActor(final Props props, final String actorId) { ActorRef actorRef = system.actorOf(props, actorId); return addActor(actorRef, true); } @@ -85,7 +86,7 @@ public class TestActorFactory implements AutoCloseable { * @param actorId name of actor * @return the ActorRef */ - public ActorRef createActorNoVerify(Props props, String actorId) { + public ActorRef createActorNoVerify(final Props props, final String actorId) { ActorRef actorRef = system.actorOf(props, actorId); return addActor(actorRef, false); } @@ -99,7 +100,7 @@ public class TestActorFactory implements AutoCloseable { * @return the ActorRef */ @SuppressWarnings("unchecked") - public TestActorRef createTestActor(Props props, String actorId) { + public TestActorRef createTestActor(final Props props, final String actorId) { InvalidActorNameException lastError = null; for (int i = 0; i < 10; i++) { try { @@ -122,12 +123,12 @@ public class TestActorFactory implements AutoCloseable { * @return the TestActorRef */ @SuppressWarnings("unchecked") - public TestActorRef createTestActor(Props props) { + public TestActorRef createTestActor(final Props props) { TestActorRef actorRef = TestActorRef.create(system, props); return (TestActorRef) addActor(actorRef, true); } - private ActorRef addActor(T actorRef, boolean verify) { + private ActorRef addActor(final T actorRef, final boolean verify) { createdActors.add(actorRef); if (verify) { verifyActorReady(actorRef); @@ -137,7 +138,7 @@ public class TestActorFactory implements AutoCloseable { } @SuppressWarnings("checkstyle:IllegalCatch") - private void verifyActorReady(ActorRef actorRef) { + private void verifyActorReady(final ActorRef actorRef) { // Sometimes we see messages go to dead letters soon after creation - it seems the actor isn't quite // in a state yet to receive messages or isn't actually created yet. This seems to happen with // actorSelection so, to alleviate it, we use an actorSelection and send an Identify message with @@ -168,26 +169,26 @@ public class TestActorFactory implements AutoCloseable { * @param prefix the name prefix * @return the actor name */ - public String generateActorId(String prefix) { + public String generateActorId(final String prefix) { return prefix + actorCount++; } - public void killActor(ActorRef actor, TestKit kit) { + public void killActor(final ActorRef actor, final TestKit kit) { killActor(actor, kit, true); } - private void killActor(ActorRef actor, TestKit kit, boolean remove) { + private void killActor(final ActorRef actor, final TestKit kit, final boolean remove) { LOG.info("Killing actor {}", actor); kit.watch(actor); actor.tell(PoisonPill.getInstance(), ActorRef.noSender()); - kit.expectTerminated(kit.duration("5 seconds"), actor); + kit.expectTerminated(Duration.ofSeconds(5), actor); if (remove) { createdActors.remove(actor); } } - public String createTestActorPath(String actorId) { + public String createTestActorPath(final String actorId) { return "akka://test/user/" + actorId; }