Class AppendResponse

java.lang.Object
io.permazen.kv.raft.msg.Message
io.permazen.kv.raft.msg.AppendResponse

public class AppendResponse extends Message
Sent from a follower to a leader in response to an AppendRequest.

Also contains information about the follower's log.

  • Constructor Details

    • AppendResponse

      public AppendResponse(int clusterId, String senderId, String recipientId, long term, Timestamp leaderTimestamp, boolean success, long matchIndex, long lastLogIndex)
      Constructor.
      Parameters:
      clusterId - cluster ID
      senderId - identity of sender
      recipientId - identity of recipient
      term - sender's current term
      leaderTimestamp - copy of AppendRequest.getLeaderTimestamp()
      success - if request successfully matched
      matchIndex - highest known matching log index
      lastLogIndex - index of follower's last log entry
  • Method Details

    • getLeaderTimestamp

      public Timestamp getLeaderTimestamp()
      Get the leaderTimestamp from the corresponding AppendRequest.
      Returns:
      request leader timestamp
      See Also:
    • isSuccess

      public boolean isSuccess()
      Determine whether the request was successful, i.e., the previous log entry term and index matched.
      Returns:
      true if the corresponding request matched
    • getMatchIndex

      public long getMatchIndex()
      Get the index of the most recent log entry known to match leader. In case of a successful request, this will be equal to the log entry sent (or the previous log entry in case of a probe). In case of a failed request, this will be equal to the follower's state machine last applied index.
      Returns:
      highest known matching log entry index
    • getLastLogIndex

      public long getLastLogIndex()
      Get the index of the last log entry in the follower's log.
      Returns:
      last log entry index
    • visit

      public void visit(MessageSwitch handler)
      Description copied from class: Message
      Apply the visitor pattern based on this instance's type.
      Specified by:
      visit in class Message
      Parameters:
      handler - target for visit
    • writeTo

      public void writeTo(ByteBuffer dest, int version)
      Description copied from class: Message
      Serialize this instance into the given buffer.
      Overrides:
      writeTo in class Message
      Parameters:
      dest - destination for encoded data
      version - protocol encoding version number
    • calculateSize

      protected int calculateSize(int version)
      Description copied from class: Message
      Calculate an upper bound on the number of bytes required by writeTo().
      Overrides:
      calculateSize in class Message
      Parameters:
      version - protocol encoding version
      Returns:
      an upper bound on the number of encoded bytes
    • toString

      public String toString()
      Specified by:
      toString in class Message