X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fraft%2FRaftActorRecoverySupport.java;h=ae7fdeadbc12a657c6e6c33189a1b7e36c16d687;hp=0a37ef7a466725eb963aa6253b71c04b217deb10;hb=b8c6400766f7324dd57d059bd48e435569fe1a27;hpb=11dadddb4d9ba26ae0b1795921c7a218a6d893c2 diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupport.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupport.java index 0a37ef7a46..ae7fdeadbc 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupport.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupport.java @@ -20,7 +20,6 @@ import org.opendaylight.controller.cluster.raft.base.messages.ApplyLogEntries; import org.opendaylight.controller.cluster.raft.base.messages.ApplySnapshot; import org.opendaylight.controller.cluster.raft.base.messages.DeleteEntries; import org.opendaylight.controller.cluster.raft.base.messages.UpdateElectionTerm; -import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior; import org.slf4j.Logger; /** @@ -30,7 +29,6 @@ import org.slf4j.Logger; */ class RaftActorRecoverySupport { private final RaftActorContext context; - private final RaftActorBehavior currentBehavior; private final RaftActorRecoveryCohort cohort; private int currentRecoveryBatchCount; @@ -40,10 +38,8 @@ class RaftActorRecoverySupport { private Stopwatch recoveryTimer; private final Logger log; - RaftActorRecoverySupport(RaftActorContext context, RaftActorBehavior currentBehavior, - RaftActorRecoveryCohort cohort) { + RaftActorRecoverySupport(final RaftActorContext context, final RaftActorRecoveryCohort cohort) { this.context = context; - this.currentBehavior = currentBehavior; this.cohort = cohort; this.log = context.getLogger(); } @@ -95,7 +91,7 @@ class RaftActorRecoverySupport { // Delete all the akka snapshots as they will not be needed persistentProvider.deleteSnapshots(new SnapshotSelectionCriteria(scala.Long.MaxValue(), - scala.Long.MaxValue())); + scala.Long.MaxValue(), 0L, 0L)); // Since we cleaned out the journal, we need to re-write the current election info. context.getTermInformation().updateAndPersist(context.getTermInformation().getCurrentTerm(), @@ -167,7 +163,7 @@ class RaftActorRecoverySupport { // The replicated log can be used later on to retrieve this snapshot // when we need to install it on a peer - context.setReplicatedLog(ReplicatedLogImpl.newInstance(snapshot, context, currentBehavior)); + context.setReplicatedLog(ReplicatedLogImpl.newInstance(snapshot, context)); context.setLastApplied(snapshot.getLastAppliedIndex()); context.setCommitIndex(snapshot.getLastAppliedIndex()); context.getTermInformation().update(snapshot.getElectionTerm(), snapshot.getElectionVotedFor()); @@ -177,6 +173,10 @@ class RaftActorRecoverySupport { // Apply the snapshot to the actors state cohort.applyRecoverySnapshot(snapshot.getState()); + if (snapshot.getServerConfiguration() != null) { + context.updatePeerIds(snapshot.getServerConfiguration()); + } + timer.stop(); log.info("Recovery snapshot applied for {} in {}: snapshotIndex={}, snapshotTerm={}, journal-size={}", context.getId(), timer.toString(), replicatedLog().getSnapshotIndex(), @@ -263,7 +263,7 @@ class RaftActorRecoverySupport { replicatedLog().getSnapshotTerm(), replicatedLog().size()); } - private boolean isServerConfigurationPayload(ReplicatedLogEntry repLogEntry){ + private static boolean isServerConfigurationPayload(ReplicatedLogEntry repLogEntry){ return (repLogEntry.getData() instanceof ServerConfigurationPayload); } }