Class PollRequest

All Implemented Interfaces:
RaftMessage, RaftRequest

public class PollRequest extends AbstractRaftRequest
Server poll request.

Poll requests aid in the implementation of the so-called "pre-vote" protocol. They are sent by followers to all other servers prior to transitioning to the candidate state. This helps ensure that servers that can't win elections do not disrupt existing leaders when e.g. rejoining the cluster after a partition.

  • Constructor Details

    • PollRequest

      public PollRequest(long term, String candidate, long lastLogIndex, long lastLogTerm)
  • Method Details

    • builder

      public static PollRequest.Builder builder()
      Returns a new poll request builder.
      Returns:
      A new poll request builder.
    • term

      public long term()
      Returns the requesting node's current term.
      Returns:
      The requesting node's current term.
    • candidate

      public MemberId candidate()
      Returns the candidate's address.
      Returns:
      The candidate's address.
    • lastLogIndex

      public long lastLogIndex()
      Returns the candidate's last log index.
      Returns:
      The candidate's last log index.
    • lastLogTerm

      public long lastLogTerm()
      Returns the candidate's last log term.
      Returns:
      The candidate's last log term.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

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

      public MemberId from()