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
ConstructorsConstructorDescriptionInstallSnapshot(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 intcalculateSize(int version) Calculate the number of bytes required bywriteTo().getData()longlonglongbooleanbooleanDetermine whether this message is only sent by leaders.toString()voidvisit(MessageSwitch handler) Apply the visitor pattern based on this instance's type.voidwriteTo(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 (firstpairIndexonly)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:MessageDetermine whether this message is only sent by leaders.- Overrides:
isLeaderMessagein classMessage- Returns:
- true if receipt of this message implies sender is a leader
-
visit
Description copied from class:MessageApply the visitor pattern based on this instance's type. -
writeTo
Description copied from class:MessageSerialize this instance into the given buffer. -
calculateSize
protected int calculateSize(int version) Description copied from class:MessageCalculate the number of bytes required bywriteTo().- Overrides:
calculateSizein classMessage- Parameters:
version- protocol encoding version- Returns:
- an upper bound on the number of encoded bytes
-
toString
-