Class CommitRequest

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

public class CommitRequest extends Message
Sent from followers to leaders to start the commit of a transaction.
  • Constructor Details

    • CommitRequest

      public CommitRequest(int clusterId, String senderId, String recipientId, long term, long txId, long baseTerm, long baseIndex, ByteBuffer readsData, ByteBuffer mutationData)
      Constructor.
      Parameters:
      clusterId - cluster ID
      senderId - identity of sender
      recipientId - identity of recipient
      term - sender's current term
      txId - sender's transaction ID
      baseTerm - term of the log entry on which the transaction is based
      baseIndex - index of the log entry on which the transaction is based
      readsData - keys read during the transaction
      mutationData - transaction mutations, or null for none (i.e., read only transaction)
  • Method Details

    • getTxId

      public long getTxId()
    • getBaseTerm

      public long getBaseTerm()
    • getBaseIndex

      public long getBaseIndex()
    • getReadsData

      public ByteBuffer getReadsData()
    • isReadOnly

      public boolean isReadOnly()
      Determine whether this instance represents a read-only transaction.
      Returns:
      true if there is no writes data, otherwise false
    • getMutationData

      public ByteBuffer getMutationData()
      Get the transaction's mutations.

      This method may only be invoked once.

      Returns:
      transaction mutations, or null if transaction is read-only
      Throws:
      IllegalStateException - if this method has already been invoked
    • 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