Package io.permazen.kv.raft.msg
Class CommitRequest
java.lang.Object
io.permazen.kv.raft.msg.Message
io.permazen.kv.raft.msg.CommitRequest
Sent from followers to leaders to start the commit of a transaction.
-
Constructor Summary
ConstructorsConstructorDescriptionCommitRequest(int clusterId, String senderId, String recipientId, long term, long txId, long baseTerm, long baseIndex, ByteBuffer readsData, ByteBuffer mutationData) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected intcalculateSize(int version) Calculate the number of bytes required bywriteTo().longlongGet the transaction's mutations.longgetTxId()booleanDetermine whether this instance represents a read-only transaction.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, isLeaderMessage, putBoolean, putByteBuffer, putString, putTimestamp
-
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 IDsenderId- identity of senderrecipientId- identity of recipientterm- sender's current termtxId- sender's transaction IDbaseTerm- term of the log entry on which the transaction is basedbaseIndex- index of the log entry on which the transaction is basedreadsData- keys read during the transactionmutationData- 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
-
isReadOnly
public boolean isReadOnly()Determine whether this instance represents a read-only transaction.- Returns:
- true if there is no writes data, otherwise false
-
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
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
-