Class InstallSnapshot

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

public class InstallSnapshot extends Message
Sent from leader to follower to with a chunk of key/value pairs that will wholesale replace the follower's key/value store.
  • Constructor Details

    • InstallSnapshot

      public InstallSnapshot(int clusterId, String senderId, String recipientId, long term, long snapshotTerm, long snapshotIndex, long pairIndex, Map<String,String> snapshotConfig, boolean lastChunk, ByteBuffer data)
      Constructor.
      Parameters:
      clusterId - cluster ID
      senderId - identity of sender
      recipientId - identity of recipient
      term - sender's current term
      snapshotTerm - term of the last log entry in the snapshot
      snapshotIndex - index of the last log entry in the snapshot
      snapshotConfig - cluster config of the last log entry in the snapshot (first pairIndex only)
      pairIndex - index of the first key/value pair in this chunk
      lastChunk - true if this is the last chunk in the snapshot
      data - encoded key/value pairs
  • Method Details

    • getSnapshotTerm

      public long getSnapshotTerm()
    • getSnapshotIndex

      public long getSnapshotIndex()
    • getSnapshotConfig

      public Map<String,String> getSnapshotConfig()
    • getPairIndex

      public long getPairIndex()
    • isLastChunk

      public boolean isLastChunk()
    • getData

      public ByteBuffer getData()
    • isLeaderMessage

      public boolean isLeaderMessage()
      Description copied from class: Message
      Determine whether this message is only sent by leaders.
      Overrides:
      isLeaderMessage in class Message
      Returns:
      true if receipt of this message implies sender is a leader
    • 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