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 ElectionTermcopyOf(ElectionTerm from) longReturns the current leader's Raft term.Returns the id of the candidate that this server voted for in current term.toString()voidThis method updates the in-memory election term state.voidupdateAndPersist(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:ElectionTermReturns the current leader's Raft term.- Specified by:
getCurrentTermin interfaceElectionTerm- Returns:
- the current leader's Raft term.
-
getVotedFor
Description copied from interface:ElectionTermReturns the id of the candidate that this server voted for in current term.- Specified by:
getVotedForin interfaceElectionTerm- Returns:
- candidate id that received the vote or null if no candidate was voted for.
-
update
Description copied from interface:ElectionTermThis method updates the in-memory election term state. This method should be called when recovering election state from persistent storage.- Specified by:
updatein interfaceElectionTerm- Parameters:
newTerm- the election term.newVotedFor- the candidate id that was voted for.
-
updateAndPersist
Description copied from interface:ElectionTermThis 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:
updateAndPersistin interfaceElectionTerm- Parameters:
newTerm- the election term.newVotedFor- the candidate id that was voted for.
-
toString
-
copyOf
-