Migrate to UntypedAbstractActor 02/65902/12
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 6 Apr 2018 12:15:35 +0000 (14:15 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 21 Aug 2018 17:39:09 +0000 (19:39 +0200)
As per the 2.4-to-2.5 migration guide using UntypedAbstractActor
UntypedActor is our cheapest migration option. This requires
updating MeteringBehavior to integrate with Receive.

Change-Id: I692f723dffc966bb7e117124b7a0cd714572ab4f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
17 files changed:
opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ClientActor.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/GetSnapshotReplyActor.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupportTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/DoNothingActor.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/EchoActor.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/MessageCollectorActor.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/QuarantinedMonitorActor.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/common/actor/MeteredBoundedMailboxTest.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TerminationMonitor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ForwardingActor.java
opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/DummyShard.java
opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/DummyShardManager.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/TerminationMonitor.java
opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderConfigTest.java

index 11857b9..e16f363 100644 (file)
@@ -5,23 +5,22 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.cluster.example;
 
 import akka.actor.ActorRef;
 import akka.actor.Props;
-import akka.actor.UntypedActor;
+import akka.actor.UntypedAbstractActor;
 import org.opendaylight.controller.cluster.example.messages.KeyValue;
 import org.opendaylight.controller.cluster.example.messages.KeyValueSaved;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ClientActor extends UntypedActor {
+public class ClientActor extends UntypedAbstractActor {
     private static final Logger LOG = LoggerFactory.getLogger(ClientActor.class);
 
     private final ActorRef target;
 
-    public ClientActor(ActorRef target) {
+    public ClientActor(final ActorRef target) {
         this.target = target;
     }
 
@@ -29,7 +28,8 @@ public class ClientActor extends UntypedActor {
         return Props.create(ClientActor.class, target);
     }
 
-    @Override public void onReceive(Object message) {
+    @Override
+    public void onReceive(final Object message) {
         if (message instanceof KeyValue) {
             target.tell(message, getSelf());
         } else if (message instanceof KeyValueSaved) {
index 89b4544..0e8847c 100644 (file)
@@ -11,7 +11,7 @@ import akka.actor.ActorRef;
 import akka.actor.PoisonPill;
 import akka.actor.Props;
 import akka.actor.ReceiveTimeout;
-import akka.actor.UntypedActor;
+import akka.actor.UntypedAbstractActor;
 import com.google.common.base.Preconditions;
 import java.util.concurrent.TimeoutException;
 import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshot;
@@ -28,7 +28,7 @@ import scala.concurrent.duration.Duration;
  *
  * @author Thomas Pantelis
  */
-class GetSnapshotReplyActor extends UntypedActor {
+class GetSnapshotReplyActor extends UntypedAbstractActor {
     private static final Logger LOG = LoggerFactory.getLogger(GetSnapshotReplyActor.class);
 
     private final Params params;
index b1231d6..97ab20a 100644 (file)
@@ -15,9 +15,9 @@ import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorAct
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectFirstMatching;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectMatching;
 
+import akka.actor.AbstractActor;
 import akka.actor.ActorRef;
 import akka.actor.Props;
-import akka.actor.UntypedActor;
 import akka.dispatch.Dispatchers;
 import akka.testkit.TestActorRef;
 import akka.testkit.javadsl.TestKit;
@@ -1469,7 +1469,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         assertEquals("Server config", Sets.newHashSet(expected), Sets.newHashSet(payload.getServerConfig()));
     }
 
-    private static RaftActorContextImpl newFollowerContext(String id, TestActorRef<? extends UntypedActor> actor) {
+    private static RaftActorContextImpl newFollowerContext(String id, TestActorRef<? extends AbstractActor> actor) {
         DefaultConfigParamsImpl configParams = new DefaultConfigParamsImpl();
         configParams.setHeartBeatInterval(new FiniteDuration(100, TimeUnit.MILLISECONDS));
         configParams.setElectionTimeoutFactor(100000);
index 4a73aad..1080aad 100644 (file)
@@ -5,13 +5,13 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.cluster.raft.utils;
 
-import akka.actor.UntypedActor;
+import akka.actor.UntypedAbstractActor;
 
-public class DoNothingActor extends UntypedActor {
-    @Override public void onReceive(Object message) {
+public class DoNothingActor extends UntypedAbstractActor {
+    @Override
+    public void onReceive(final Object message) throws Exception {
 
     }
 }
index 1a730f9..bd0c6bf 100644 (file)
@@ -5,18 +5,16 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.cluster.raft.utils;
 
-import akka.actor.UntypedActor;
+import akka.actor.UntypedAbstractActor;
 
 /**
  * The EchoActor simply responds back with the same message that it receives.
  */
-public class EchoActor extends UntypedActor {
-
+public class EchoActor extends UntypedAbstractActor {
     @Override
-    public void onReceive(Object message) {
+    public void onReceive(final Object message) {
         getSender().tell(message, getSelf());
     }
 }
index d234913..861c04c 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.controller.cluster.raft.utils;
 
 import akka.actor.ActorRef;
 import akka.actor.Props;
-import akka.actor.UntypedActor;
+import akka.actor.UntypedAbstractActor;
 import akka.dispatch.ControlMessage;
 import akka.pattern.Patterns;
 import akka.util.Timeout;
@@ -30,7 +30,7 @@ import scala.concurrent.Future;
 import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
-public class MessageCollectorActor extends UntypedActor {
+public class MessageCollectorActor extends UntypedAbstractActor {
     private static final String ARE_YOU_READY = "ARE_YOU_READY";
     public static final String GET_ALL_MESSAGES = "messages";
 
index 2ed5a24..52df6ab 100644 (file)
@@ -9,7 +9,7 @@
 package org.opendaylight.controller.cluster.common.actor;
 
 import akka.actor.Props;
-import akka.actor.UntypedActor;
+import akka.actor.UntypedAbstractActor;
 import akka.japi.Effect;
 import akka.remote.ThisActorSystemQuarantinedEvent;
 import org.slf4j.Logger;
@@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
  * @author Gary Wu gary.wu1@huawei.com
  *
  */
-public class QuarantinedMonitorActor extends UntypedActor {
+public class QuarantinedMonitorActor extends UntypedAbstractActor {
 
     private static final Logger LOG = LoggerFactory.getLogger(QuarantinedMonitorActor.class);
 
index 9c909e5..673b4b1 100644 (file)
@@ -11,7 +11,7 @@ import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.actor.DeadLetter;
 import akka.actor.Props;
-import akka.actor.UntypedActor;
+import akka.actor.UntypedAbstractActor;
 import akka.testkit.TestKit;
 import com.typesafe.config.ConfigFactory;
 import java.util.concurrent.TimeUnit;
@@ -73,7 +73,7 @@ public class MeteredBoundedMailboxTest {
     /**
      * For testing.
      */
-    public static class PingPongActor extends UntypedActor {
+    public static class PingPongActor extends UntypedAbstractActor {
 
         ReentrantLock lock;
 
index c596f12..d449ebc 100644 (file)
@@ -5,16 +5,15 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.cluster.datastore;
 
 import akka.actor.Terminated;
-import akka.actor.UntypedActor;
+import akka.actor.UntypedAbstractActor;
 import org.opendaylight.controller.cluster.common.actor.Monitor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class TerminationMonitor extends UntypedActor {
+public class TerminationMonitor extends UntypedAbstractActor {
     private static final Logger LOG = LoggerFactory.getLogger(TerminationMonitor.class);
     public static final String ADDRESS = "termination-monitor";
 
@@ -23,7 +22,7 @@ public class TerminationMonitor extends UntypedActor {
     }
 
     @Override
-    public void onReceive(Object message) {
+    public void onReceive(final Object message) {
         if (message instanceof Terminated) {
             Terminated terminated = (Terminated) message;
             LOG.debug("Actor terminated : {}", terminated.actor());
index c767eb2..21af2c4 100644 (file)
@@ -12,7 +12,7 @@ import akka.actor.PoisonPill;
 import akka.actor.Props;
 import akka.actor.ReceiveTimeout;
 import akka.actor.Status.Failure;
-import akka.actor.UntypedActor;
+import akka.actor.UntypedAbstractActor;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
@@ -34,7 +34,7 @@ import scala.concurrent.duration.Duration;
  *
  * @author Thomas Pantelis
  */
-final class ShardManagerGetSnapshotReplyActor extends UntypedActor {
+final class ShardManagerGetSnapshotReplyActor extends UntypedAbstractActor {
     private static final Logger LOG = LoggerFactory.getLogger(ShardManagerGetSnapshotReplyActor.class);
 
     private final Set<String> remainingShardNames;
index ba7295b..066be88 100644 (file)
@@ -16,7 +16,7 @@ import static org.opendaylight.controller.cluster.datastore.DataStoreVersions.CU
 
 import akka.actor.ActorSelection;
 import akka.actor.Props;
-import akka.actor.UntypedActor;
+import akka.actor.UntypedAbstractActor;
 import akka.dispatch.Dispatchers;
 import akka.dispatch.Futures;
 import akka.testkit.TestActorRef;
@@ -308,7 +308,7 @@ public class ThreePhaseCommitCohortProxyTest extends AbstractActorTest {
         assertEquals("canCommit", expected, actual);
     }
 
-    private static class CohortActor extends UntypedActor {
+    private static class CohortActor extends UntypedAbstractActor {
         private final Builder builder;
         private final AtomicInteger canCommitCount = new AtomicInteger();
         private final AtomicInteger commitCount = new AtomicInteger();
index 89a50b8..22cc77f 100644 (file)
@@ -23,7 +23,7 @@ import akka.actor.ActorSelection;
 import akka.actor.ActorSystem;
 import akka.actor.Address;
 import akka.actor.Props;
-import akka.actor.UntypedActor;
+import akka.actor.UntypedAbstractActor;
 import akka.dispatch.Futures;
 import akka.japi.Creator;
 import akka.testkit.TestActorRef;
@@ -73,7 +73,7 @@ public class ActorContextTest extends AbstractActorTest {
     private static class TestMessage {
     }
 
-    private static final class MockShardManager extends UntypedActor {
+    private static final class MockShardManager extends UntypedAbstractActor {
 
         private final boolean found;
         private final ActorRef actorRef;
index 790d644..64631fe 100644 (file)
@@ -5,13 +5,12 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.cluster.datastore.utils;
 
 import akka.actor.ActorRef;
-import akka.actor.UntypedActor;
+import akka.actor.UntypedAbstractActor;
 
-public final class ForwardingActor extends UntypedActor {
+public final class ForwardingActor extends UntypedAbstractActor {
     private final ActorRef target;
 
     private ForwardingActor(final ActorRef target) {
@@ -22,5 +21,4 @@ public final class ForwardingActor extends UntypedActor {
     public void onReceive(final Object obj) {
         target.forward(obj, context());
     }
-
 }
index c5a3a03..62eb392 100644 (file)
@@ -9,7 +9,7 @@
 package org.opendaylight.controller.dummy.datastore;
 
 import akka.actor.Props;
-import akka.actor.UntypedActor;
+import akka.actor.UntypedAbstractActor;
 import com.google.common.base.Stopwatch;
 import java.util.concurrent.TimeUnit;
 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
@@ -23,7 +23,7 @@ import org.opendaylight.controller.cluster.raft.messages.RequestVoteReply;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class DummyShard extends UntypedActor {
+public class DummyShard extends UntypedAbstractActor {
     private static final Logger LOG = LoggerFactory.getLogger(DummyShard.class);
 
     private final Configuration configuration;
index a25a081..05f8336 100644 (file)
@@ -5,25 +5,24 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.dummy.datastore;
 
-import akka.actor.ActorContext;
 import akka.actor.Props;
-import akka.actor.UntypedActor;
+import akka.actor.UntypedAbstractActor;
 
-public class DummyShardManager extends UntypedActor {
-    public DummyShardManager(Configuration configuration, String memberName, String[] shardNames,
-            String type) {
-        new DummyShardsCreator(configuration, context(), memberName, shardNames, type).create();
+public class DummyShardManager extends UntypedAbstractActor {
+    public DummyShardManager(final Configuration configuration, final String memberName, final String[] shardNames,
+            final String type) {
+        new DummyShardsCreator(configuration, getContext(), memberName, shardNames, type).create();
     }
 
     @Override
-    public void onReceive(Object message) {
+    public void onReceive(final Object message) {
 
     }
 
-    public static Props props(Configuration configuration, String memberName, String[] shardNames, String type) {
+    public static Props props(final Configuration configuration, final String memberName, final String[] shardNames,
+            final String type) {
         return Props.create(DummyShardManager.class, configuration, memberName, shardNames, type);
     }
 
@@ -34,8 +33,8 @@ public class DummyShardManager extends UntypedActor {
         private final String[] shardNames;
         private final String type;
 
-        DummyShardsCreator(Configuration configuration, ActorContext actorSystem, String memberName,
-                String[] shardNames, String type) {
+        DummyShardsCreator(final Configuration configuration, final ActorContext actorSystem, final String memberName,
+                final String[] shardNames, final String type) {
             this.configuration = configuration;
             this.actorSystem = actorSystem;
             this.memberName = memberName;
index 1272389..6590941 100644 (file)
@@ -9,12 +9,12 @@
 package org.opendaylight.controller.remote.rpc;
 
 import akka.actor.Terminated;
-import akka.actor.UntypedActor;
+import akka.actor.UntypedAbstractActor;
 import org.opendaylight.controller.cluster.common.actor.Monitor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class TerminationMonitor extends UntypedActor {
+public class TerminationMonitor extends UntypedAbstractActor {
     private static final Logger LOG = LoggerFactory.getLogger(TerminationMonitor.class);
 
     public TerminationMonitor() {
index a6be665..41de6a4 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.controller.remote.rpc;
 
 import akka.actor.ActorSystem;
 import akka.actor.Props;
-import akka.actor.UntypedActor;
+import akka.actor.UntypedAbstractActor;
 import akka.testkit.TestActorRef;
 import com.typesafe.config.Config;
 import com.typesafe.config.ConfigFactory;
@@ -78,7 +78,7 @@ public class RemoteRpcProviderConfigTest {
         Assert.assertEquals(expectedTimeout.toMillis(), config.getMailBoxPushTimeout().toMillis());
     }
 
-    public static class ConfigTestActor extends UntypedActor {
+    public static class ConfigTestActor extends UntypedAbstractActor {
 
         private final Config actorSystemConfig;
 

©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.