X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fraft%2FRaftActorSnapshotMessageSupport.java;h=8b6871174180d8d372bcc2eb075ebef045ba6c3d;hb=15f11d24306fe2796411e8078a84fc82213bacf6;hp=39548dc6d5e426dad36fa5fe30eb3b5b448a7bc0;hpb=cc2566a2570ce97c5ec054fca77f380ca35b942d;p=controller.git diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorSnapshotMessageSupport.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorSnapshotMessageSupport.java index 39548dc6d5..8b68711741 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorSnapshotMessageSupport.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorSnapshotMessageSupport.java @@ -18,7 +18,6 @@ import org.apache.commons.lang3.SerializationUtils; import org.opendaylight.controller.cluster.raft.base.messages.ApplySnapshot; import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshot; import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply; -import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior; import org.opendaylight.controller.cluster.raft.client.messages.GetSnapshot; import org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply; import org.slf4j.Logger; @@ -33,7 +32,6 @@ class RaftActorSnapshotMessageSupport { static final String COMMIT_SNAPSHOT = "commit_snapshot"; private final RaftActorContext context; - private final RaftActorBehavior currentBehavior; private final RaftActorSnapshotCohort cohort; private final Logger log; @@ -53,10 +51,8 @@ class RaftActorSnapshotMessageSupport { private Duration snapshotReplyActorTimeout = Duration.create(30, TimeUnit.SECONDS); - RaftActorSnapshotMessageSupport(RaftActorContext context, RaftActorBehavior currentBehavior, - RaftActorSnapshotCohort cohort) { + RaftActorSnapshotMessageSupport(final RaftActorContext context, final RaftActorSnapshotCohort cohort) { this.context = context; - this.currentBehavior = currentBehavior; this.cohort = cohort; this.log = context.getLogger(); @@ -65,33 +61,29 @@ class RaftActorSnapshotMessageSupport { } boolean handleSnapshotMessage(Object message, ActorRef sender) { - if(message instanceof ApplySnapshot ) { + if (message instanceof ApplySnapshot ) { onApplySnapshot((ApplySnapshot) message); - return true; } else if (message instanceof SaveSnapshotSuccess) { onSaveSnapshotSuccess((SaveSnapshotSuccess) message); - return true; } else if (message instanceof SaveSnapshotFailure) { onSaveSnapshotFailure((SaveSnapshotFailure) message); - return true; } else if (message instanceof CaptureSnapshotReply) { onCaptureSnapshotReply(((CaptureSnapshotReply) message).getSnapshot()); - return true; } else if (message.equals(COMMIT_SNAPSHOT)) { - context.getSnapshotManager().commit(-1, currentBehavior); - return true; + context.getSnapshotManager().commit(-1); } else if (message instanceof GetSnapshot) { onGetSnapshot(sender); - return true; } else { return false; } + + return true; } private void onCaptureSnapshotReply(byte[] snapshotBytes) { log.debug("{}: CaptureSnapshotReply received by actor: snapshot size {}", context.getId(), snapshotBytes.length); - context.getSnapshotManager().persist(snapshotBytes, currentBehavior, context.getTotalMemory()); + context.getSnapshotManager().persist(snapshotBytes, context.getTotalMemory()); } private void onSaveSnapshotFailure(SaveSnapshotFailure saveSnapshotFailure) { @@ -106,7 +98,7 @@ class RaftActorSnapshotMessageSupport { long sequenceNumber = success.metadata().sequenceNr(); - context.getSnapshotManager().commit(sequenceNumber, currentBehavior); + context.getSnapshotManager().commit(sequenceNumber); } private void onApplySnapshot(ApplySnapshot message) { @@ -125,13 +117,13 @@ class RaftActorSnapshotMessageSupport { ActorRef snapshotReplyActor = context.actorOf(GetSnapshotReplyActor.props(captureSnapshot, ImmutableElectionTerm.copyOf(context.getTermInformation()), sender, - snapshotReplyActorTimeout, context.getId(), context.getPeerServerInfo())); + snapshotReplyActorTimeout, context.getId(), context.getPeerServerInfo(true))); cohort.createSnapshot(snapshotReplyActor); } else { Snapshot snapshot = Snapshot.create(new byte[0], Collections.emptyList(), -1, -1, -1, -1, context.getTermInformation().getCurrentTerm(), context.getTermInformation().getVotedFor(), - context.getPeerServerInfo()); + context.getPeerServerInfo(true)); sender.tell(new GetSnapshotReply(context.getId(), SerializationUtils.serialize(snapshot)), context.getActor());