public class AppendRequest extends Message
Instances also provide the leader's lease timeout value (if any),
which is used to commit read-only transactions, as well as a leader timestamp
which should be reflected back in the corresponding AppendResponse
.
Constructor and Description |
---|
AppendRequest(int clusterId,
String senderId,
String recipientId,
long term,
Timestamp leaderTimestamp,
Timestamp leaderLeaseTimeout,
long leaderCommit,
long prevLogTerm,
long prevLogIndex)
Constructor for a "probe" that does not contain a log entry.
|
AppendRequest(int clusterId,
String senderId,
String recipientId,
long term,
Timestamp leaderTimestamp,
Timestamp leaderLeaseTimeout,
long leaderCommit,
long prevLogTerm,
long prevLogIndex,
long logEntryTerm,
ByteBuffer mutationData)
Constructor for a request that contains an actual log entry.
|
Modifier and Type | Method and Description |
---|---|
protected int |
calculateSize(int version)
Calculate an upper bound on the number of bytes required by
writeTo() . |
long |
getLeaderCommit()
Get leader's commit index.
|
Timestamp |
getLeaderLeaseTimeout() |
Timestamp |
getLeaderTimestamp() |
long |
getLogEntryTerm() |
ByteBuffer |
getMutationData()
Get the serialized data for the log entry, if any.
|
long |
getPrevLogIndex() |
long |
getPrevLogTerm() |
boolean |
isLeaderMessage()
Determine whether this message is only sent by leaders.
|
boolean |
isProbe() |
String |
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.
|
calculateSize, calculateSize, calculateSize, decode, decodeProtocolVersion, encode, getBoolean, getByteBuffer, getClusterId, getCurrentProtocolVersion, getRecipientId, getSenderId, getString, getTerm, getTimestamp, putBoolean, putByteBuffer, putString, putTimestamp
public AppendRequest(int clusterId, String senderId, String recipientId, long term, Timestamp leaderTimestamp, Timestamp leaderLeaseTimeout, long leaderCommit, long prevLogTerm, long prevLogIndex)
Note that leaderCommit
is limited to prevLogIndex
by this constructor, because we can't guarantee
that the omitted log entry at prevLogIndex + 1
matches whatever the follower has in its log.
clusterId
- cluster IDsenderId
- identity of senderrecipientId
- identity of recipientterm
- sender's current termleaderTimestamp
- leader's timestamp for this requestleaderLeaseTimeout
- earliest leader timestamp at which leader could be deposed (or null)leaderCommit
- current commit index for senderprevLogTerm
- term of the log entry just prior to this oneprevLogIndex
- index of the log entry just prior to this onepublic AppendRequest(int clusterId, String senderId, String recipientId, long term, Timestamp leaderTimestamp, Timestamp leaderLeaseTimeout, long leaderCommit, long prevLogTerm, long prevLogIndex, long logEntryTerm, ByteBuffer mutationData)
clusterId
- cluster IDsenderId
- identity of senderrecipientId
- identity of recipientterm
- sender's current termleaderTimestamp
- leader's timestamp for this requestleaderLeaseTimeout
- earliest leader timestamp at which leader could be deposed (or null)leaderCommit
- current commit index for senderprevLogTerm
- term of the log entry just prior to this oneprevLogIndex
- index of the log entry just prior to this onelogEntryTerm
- term of this log entrymutationData
- log entry serialized mutations, or null if follower should have the data alreadypublic Timestamp getLeaderTimestamp()
public Timestamp getLeaderLeaseTimeout()
public long getLeaderCommit()
For probe requests, this value is limited to the value returned by getPrevLogIndex()
.
public long getPrevLogTerm()
public long getPrevLogIndex()
public boolean isProbe()
public long getLogEntryTerm()
public ByteBuffer getMutationData()
This method may only be invoked once.
IllegalStateException
- if this method has already been invokedpublic boolean isLeaderMessage()
Message
isLeaderMessage
in class Message
public void visit(MessageSwitch handler)
Message
public void writeTo(ByteBuffer dest, int version)
Message
protected int calculateSize(int version)
Message
writeTo()
.calculateSize
in class Message
version
- protocol encoding versionCopyright © 2022. All rights reserved.