Class ImmutableElectionTerm

java.lang.Object
org.opendaylight.controller.cluster.raft.ImmutableElectionTerm
All Implemented Interfaces:
ElectionTerm

public final class ImmutableElectionTerm extends Object implements ElectionTerm
Immutable implementation of ElectionTerm.
Author:
Thomas Pantelis
  • Method Details

    • getCurrentTerm

      public long getCurrentTerm()
      Description copied from interface: ElectionTerm
      Returns the current leader's Raft term.
      Specified by:
      getCurrentTerm in interface ElectionTerm
      Returns:
      the current leader's Raft term.
    • getVotedFor

      public String getVotedFor()
      Description copied from interface: ElectionTerm
      Returns the id of the candidate that this server voted for in current term.
      Specified by:
      getVotedFor in interface ElectionTerm
      Returns:
      candidate id that received the vote or null if no candidate was voted for.
    • update

      public void update(long newTerm, String newVotedFor)
      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 interface ElectionTerm
      Parameters:
      newTerm - the election term.
      newVotedFor - the candidate id that was voted for.
    • updateAndPersist

      public void updateAndPersist(long newTerm, String newVotedFor)
      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 interface ElectionTerm
      Parameters:
      newTerm - the election term.
      newVotedFor - the candidate id that was voted for.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • copyOf

      public static ElectionTerm copyOf(ElectionTerm from)