Fix testLeaderAndFollowerEntityOwnersReassignedAfterShutdown failure
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / GetSnapshotReplyActor.java
index ca09823a12cdbc56cc90489841a7236f7c6763a2..203a61233d3df2d8c95da39701f746e31e5df1a4 100644 (file)
@@ -14,10 +14,11 @@ import akka.actor.ReceiveTimeout;
 import akka.actor.UntypedActor;
 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;
@@ -40,16 +41,18 @@ class GetSnapshotReplyActor extends UntypedActor {
 
     @Override
     public void onReceive(Object message) {
-        if(message instanceof CaptureSnapshotReply) {
-            Snapshot snapshot = Snapshot.create(((CaptureSnapshotReply)message).getSnapshot(),
+        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(),
-                    params.electionTerm.getCurrentTerm(), params.electionTerm.getVotedFor());
+                    params.electionTerm.getCurrentTerm(), params.electionTerm.getVotedFor(),
+                    params.peerInformation);
 
             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,9 +66,9 @@ class GetSnapshotReplyActor extends UntypedActor {
     }
 
     public static Props props(CaptureSnapshot captureSnapshot, ElectionTerm electionTerm, ActorRef replyToActor,
-            Duration receiveTimeout, String id) {
+            Duration receiveTimeout, String id, ServerConfigurationPayload updatedPeerInfo) {
         return Props.create(GetSnapshotReplyActor.class, new Params(captureSnapshot, electionTerm, replyToActor,
-                receiveTimeout, id));
+                receiveTimeout, id, updatedPeerInfo));
     }
 
     private static final class Params {
@@ -74,14 +77,16 @@ class GetSnapshotReplyActor extends UntypedActor {
         final ElectionTerm electionTerm;
         final Duration receiveTimeout;
         final String id;
+        final ServerConfigurationPayload peerInformation;
 
         Params(CaptureSnapshot captureSnapshot, ElectionTerm electionTerm, ActorRef replyToActor,
-                Duration receiveTimeout, String id) {
+                Duration receiveTimeout, String id, ServerConfigurationPayload peerInfo) {
             this.captureSnapshot = Preconditions.checkNotNull(captureSnapshot);
             this.electionTerm = Preconditions.checkNotNull(electionTerm);
             this.replyToActor = Preconditions.checkNotNull(replyToActor);
             this.receiveTimeout = Preconditions.checkNotNull(receiveTimeout);
             this.id = Preconditions.checkNotNull(id);
+            this.peerInformation = peerInfo;
         }
     }
 }