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 / ElectionTerm.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.cluster.raft;
10
11 /**
12  * ElectionTerm contains information about a RaftActors election term.
13  * <p>
14  * This information includes the last known current term of the RaftActor
15  * and which peer was voted for by the RaftActor in that term
16  * <p>
17  * This class ensures that election term information is persisted
18  */
19 public interface ElectionTerm {
20     /**
21      * latest term server has seen (initialized to 0
22      * on first boot, increases monotonically)
23      */
24     long getCurrentTerm();
25
26     /**
27      * candidateId that received vote in current
28      * term (or null if none)
29      */
30     String getVotedFor();
31
32     /**
33      * Called when we need to update the current term either because we received
34      * a message from someone with a more uptodate term or because we just voted
35      * for someone
36      *
37      * @param currentTerm
38      * @param votedFor
39      */
40     void update(long currentTerm, String votedFor);
41
42     /**
43      *
44      * @param currentTerm
45      * @param votedFor
46      */
47     void updateAndPersist(long currentTerm, String votedFor);
48 }