Migrate to UntypedAbstractActor
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / GetSnapshotReplyActor.java
index 1b9ca21..0e8847c 100644 (file)
@@ -11,13 +11,14 @@ 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.apache.commons.lang3.SerializationUtils;
 import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshot;
 import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply;
 import org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply;
+import org.opendaylight.controller.cluster.raft.persisted.ServerConfigurationPayload;
+import org.opendaylight.controller.cluster.raft.persisted.Snapshot;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.duration.Duration;
@@ -27,21 +28,22 @@ 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;
 
-    private GetSnapshotReplyActor(Params params) {
+    GetSnapshotReplyActor(final Params params) {
         this.params = params;
 
         getContext().setReceiveTimeout(params.receiveTimeout);
     }
 
     @Override
-    public void onReceive(Object message) {
-        if(message instanceof CaptureSnapshotReply) {
-            Snapshot snapshot = Snapshot.create(((CaptureSnapshotReply)message).getSnapshot(),
+    public void onReceive(final Object message) {
+        if (message instanceof CaptureSnapshotReply) {
+            Snapshot snapshot = Snapshot.create(
+                    ((CaptureSnapshotReply)message).getSnapshotState(),
                     params.captureSnapshot.getUnAppliedEntries(),
                     params.captureSnapshot.getLastIndex(), params.captureSnapshot.getLastTerm(),
                     params.captureSnapshot.getLastAppliedIndex(), params.captureSnapshot.getLastAppliedTerm(),
@@ -50,7 +52,7 @@ class GetSnapshotReplyActor extends UntypedActor {
 
             LOG.debug("{}: Received CaptureSnapshotReply, sending {}", params.id, snapshot);
 
-            params.replyToActor.tell(new GetSnapshotReply(params.id, SerializationUtils.serialize(snapshot)), getSelf());
+            params.replyToActor.tell(new GetSnapshotReply(params.id, snapshot), getSelf());
             getSelf().tell(PoisonPill.getInstance(), getSelf());
         } else if (message instanceof ReceiveTimeout) {
             LOG.warn("{}: Got ReceiveTimeout for inactivity - did not receive CaptureSnapshotReply within {} ms",
@@ -63,8 +65,9 @@ class GetSnapshotReplyActor extends UntypedActor {
         }
     }
 
-    public static Props props(CaptureSnapshot captureSnapshot, ElectionTerm electionTerm, ActorRef replyToActor,
-            Duration receiveTimeout, String id, ServerConfigurationPayload updatedPeerInfo) {
+    public static Props props(final CaptureSnapshot captureSnapshot, final ElectionTerm electionTerm,
+            final ActorRef replyToActor, final Duration receiveTimeout, final String id,
+            final ServerConfigurationPayload updatedPeerInfo) {
         return Props.create(GetSnapshotReplyActor.class, new Params(captureSnapshot, electionTerm, replyToActor,
                 receiveTimeout, id, updatedPeerInfo));
     }
@@ -77,8 +80,8 @@ class GetSnapshotReplyActor extends UntypedActor {
         final String id;
         final ServerConfigurationPayload peerInformation;
 
-        Params(CaptureSnapshot captureSnapshot, ElectionTerm electionTerm, ActorRef replyToActor,
-                Duration receiveTimeout, String id, ServerConfigurationPayload peerInfo) {
+        Params(final CaptureSnapshot captureSnapshot, final ElectionTerm electionTerm, final ActorRef replyToActor,
+                final Duration receiveTimeout, final String id, final ServerConfigurationPayload peerInfo) {
             this.captureSnapshot = Preconditions.checkNotNull(captureSnapshot);
             this.electionTerm = Preconditions.checkNotNull(electionTerm);
             this.replyToActor = Preconditions.checkNotNull(replyToActor);

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