Class ImmutableElectionTerm
java.lang.Object
org.opendaylight.controller.cluster.raft.ImmutableElectionTerm
- All Implemented Interfaces:
ElectionTerm
Immutable implementation of ElectionTerm.
- Author:
- Thomas Pantelis
-
Method Summary
Modifier and TypeMethodDescriptionstatic ElectionTerm
copyOf
(ElectionTerm from) long
Returns the current leader's Raft term.Returns the id of the candidate that this server voted for in current term.toString()
void
This method updates the in-memory election term state.void
updateAndPersist
(long newTerm, String newVotedFor) This method updates the in-memory election term state and persists it so it can be recovered on next restart.
-
Method Details
-
getCurrentTerm
public long getCurrentTerm()Description copied from interface:ElectionTerm
Returns the current leader's Raft term.- Specified by:
getCurrentTerm
in interfaceElectionTerm
- Returns:
- the current leader's Raft term.
-
getVotedFor
Description copied from interface:ElectionTerm
Returns the id of the candidate that this server voted for in current term.- Specified by:
getVotedFor
in interfaceElectionTerm
- Returns:
- candidate id that received the vote or null if no candidate was voted for.
-
update
Description copied from interface:ElectionTerm
This method updates the in-memory election term state. This method should be called when recovering election state from persistent storage.- Specified by:
update
in interfaceElectionTerm
- Parameters:
newTerm
- the election term.newVotedFor
- the candidate id that was voted for.
-
updateAndPersist
Description copied from interface:ElectionTerm
This method updates the in-memory election term state and persists it so it can be recovered on next restart. This method should be called when starting a new election or when a Raft RPC message is received with a higher term.- Specified by:
updateAndPersist
in interfaceElectionTerm
- Parameters:
newTerm
- the election term.newVotedFor
- the candidate id that was voted for.
-
toString
-
copyOf
-