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%2FElectionTerm.java;h=9f0d02edb9d5aa111b841f0972c0d82ca07a7df8;hb=61e85d54cfcd70053993f910092eba1ab3fcc850;hp=2cf39b59f19e81fcfeeb7bcec83c020e848acd27;hpb=cf5be659d906cc80d52647cb516bbab435156742;p=controller.git diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ElectionTerm.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ElectionTerm.java index 2cf39b59f1..9f0d02edb9 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ElectionTerm.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ElectionTerm.java @@ -8,8 +8,6 @@ package org.opendaylight.controller.cluster.raft; -import java.util.concurrent.atomic.AtomicLong; - /** * ElectionTerm contains information about a RaftActors election term. *

@@ -23,7 +21,7 @@ public interface ElectionTerm { * latest term server has seen (initialized to 0 * on first boot, increases monotonically) */ - AtomicLong getCurrentTerm(); + long getCurrentTerm(); /** * candidateId that received vote in current @@ -32,12 +30,25 @@ public interface ElectionTerm { String getVotedFor(); /** - * Called when we need to update the current term either because we received - * a message from someone with a more uptodate term or because we just voted - * for someone + * To be called mainly when we are recovering in-memory election state from + * persistent storage + * + * @param currentTerm + * @param votedFor + */ + void update(long currentTerm, String votedFor); + + /** + * To be called when we need to update the current term either because we + * received a message from someone with a more up-to-date term or because we + * just voted for someone + *

+ * This information needs to be persisted so that on recovery the replica + * can start itself in the right term and know if it has already voted in + * that term or not * * @param currentTerm * @param votedFor */ - void update(AtomicLong currentTerm, String votedFor); + void updateAndPersist(long currentTerm, String votedFor); }