Package io.permazen.kv.raft.msg
Class InstallSnapshot
java.lang.Object
io.permazen.kv.raft.msg.Message
io.permazen.kv.raft.msg.InstallSnapshot
Sent from leader to follower to with a chunk of key/value pairs that will wholesale replace the follower's key/value store.
-
Constructor Summary
ConstructorDescriptionInstallSnapshot
(int clusterId, String senderId, String recipientId, long term, long snapshotTerm, long snapshotIndex, long pairIndex, Map<String, String> snapshotConfig, boolean lastChunk, ByteBuffer data) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
calculateSize
(int version) Calculate the number of bytes required bywriteTo()
.getData()
long
long
long
boolean
boolean
Determine whether this message is only sent by leaders.toString()
void
visit
(MessageSwitch handler) Apply the visitor pattern based on this instance's type.void
writeTo
(ByteBuffer dest, int version) Serialize this instance into the given buffer.Methods inherited from class io.permazen.kv.raft.msg.Message
calculateSize, calculateSize, calculateSize, decode, decodeProtocolVersion, encode, getBoolean, getByteBuffer, getClusterId, getCurrentProtocolVersion, getRecipientId, getSenderId, getString, getTerm, getTimestamp, putBoolean, putByteBuffer, putString, putTimestamp
-
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 IDsenderId
- identity of senderrecipientId
- identity of recipientterm
- sender's current termsnapshotTerm
- term of the last log entry in the snapshotsnapshotIndex
- index of the last log entry in the snapshotsnapshotConfig
- cluster config of the last log entry in the snapshot (firstpairIndex
only)pairIndex
- index of the first key/value pair in this chunklastChunk
- true if this is the last chunk in the snapshotdata
- encoded key/value pairs
-
-
Method Details
-
getSnapshotTerm
public long getSnapshotTerm() -
getSnapshotIndex
public long getSnapshotIndex() -
getSnapshotConfig
-
getPairIndex
public long getPairIndex() -
isLastChunk
public boolean isLastChunk() -
getData
-
isLeaderMessage
public boolean isLeaderMessage()Description copied from class:Message
Determine whether this message is only sent by leaders.- Overrides:
isLeaderMessage
in classMessage
- Returns:
- true if receipt of this message implies sender is a leader
-
visit
Description copied from class:Message
Apply the visitor pattern based on this instance's type. -
writeTo
Description copied from class:Message
Serialize this instance into the given buffer. -
calculateSize
protected int calculateSize(int version) Description copied from class:Message
Calculate the number of bytes required bywriteTo()
.- Overrides:
calculateSize
in classMessage
- Parameters:
version
- protocol encoding version- Returns:
- an upper bound on the number of encoded bytes
-
toString
-