Fix bug in ReplicatedLogImpl#removeFrom and use akka-persistence for removing entries
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / behaviors / Candidate.java
index 13f5f1d7a49ac8388da4a2926590d0ba0edcdd57..0c23db4c8a0184af45461ddfd3ec214ce117c460 100644 (file)
@@ -123,7 +123,7 @@ public class Candidate extends AbstractRaftActorBehavior {
             // set currentTerm = T, convert to follower (ยง5.1)
             // This applies to all RPC messages and responses
             if (rpc.getTerm() > context.getTermInformation().getCurrentTerm()) {
-                context.getTermInformation().update(rpc.getTerm(), null);
+                context.getTermInformation().updateAndPersist(rpc.getTerm(), null);
                 return RaftState.Follower;
             }
         }
@@ -153,7 +153,7 @@ public class Candidate extends AbstractRaftActorBehavior {
 
         // Increment the election term and vote for self
         long currentTerm = context.getTermInformation().getCurrentTerm();
-        context.getTermInformation().update(currentTerm + 1, context.getId());
+        context.getTermInformation().updateAndPersist(currentTerm + 1, context.getId());
 
         context.getLogger().debug("Starting new term " + (currentTerm+1));