public class CommitResponse extends Message
CommitRequest.
If the request was successful, the leader returns the term and index of the log entry that, when committed (in the Raft sense), allows the transaction to be committed. This suffices for read-write transactions, because the log entry corresponds directly to the transaction's mutations.
In order to support linearizable semantics for read-only transactions, which do not create new log entries, in addition
a minimum leader lease timeout value is included; the transaction can then
be committed after receiving an AppendRequest whose leader lease timeout is at least this high. In most cases, such an AppendRequest will have already been received,
so the transaction can be committed with a single round trip.
| Constructor and Description |
|---|
CommitResponse(int clusterId,
String senderId,
String recipientId,
long term,
long txId,
long commitTerm,
long commitIndex)
Constructor for success case, when there is no minimum leader lease timeout required for commit
(read-write transaction, or read-only transaction occurring within the current leader lease timeout).
|
CommitResponse(int clusterId,
String senderId,
String recipientId,
long term,
long txId,
long commitTerm,
long commitIndex,
Timestamp commitLeaderLeaseTimeout)
Constructor for success case when a minimum leader lease timeout is required for commit (read-only transaction
when leader has not heard from a majority of followers in at least a minimum election timeout.
|
CommitResponse(int clusterId,
String senderId,
String recipientId,
long term,
long txId,
String errorMessage)
Constructor for error case.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
calculateSize()
Calculate an upper bound on the number of bytes required by
writeTo(). |
long |
getCommitIndex()
Get the commit index for the transaction.
|
Timestamp |
getCommitLeaderLeaseTimeout()
Get the minimum required leader lease timeout value to commit, if any.
|
long |
getCommitTerm()
Get the commit term for the transaction.
|
String |
getErrorMessage()
Get the error message in case of failure.
|
long |
getTxId()
Get the sender's ID for the transaction.
|
boolean |
isLeaderMessage()
Determine whether this message is only sent by leaders.
|
boolean |
isSuccess()
Determine whether the request was successful.
|
String |
toString() |
void |
visit(MessageSwitch handler)
Apply the visitor pattern based on this instance's type.
|
void |
writeTo(ByteBuffer dest)
Serialize this instance into the given buffer.
|
calculateSize, calculateSize, calculateSize, decode, encode, getBoolean, getByteBuffer, getClusterId, getReads, getRecipientId, getSenderId, getString, getTerm, getTimestamp, getWrites, putBoolean, putByteBuffer, putReads, putString, putTimestamp, putWritespublic CommitResponse(int clusterId,
String senderId,
String recipientId,
long term,
long txId,
long commitTerm,
long commitIndex)
clusterId - cluster IDsenderId - sending node identityrecipientId - identity of recipientterm - current termtxId - recipient's original transaction IDcommitTerm - transaction commit termcommitIndex - transaction commit indexpublic CommitResponse(int clusterId,
String senderId,
String recipientId,
long term,
long txId,
long commitTerm,
long commitIndex,
Timestamp commitLeaderLeaseTimeout)
clusterId - cluster IDsenderId - sending node identityrecipientId - identity of recipientterm - current termtxId - recipient's original transaction IDcommitTerm - transaction commit termcommitIndex - transaction commit indexcommitLeaderLeaseTimeout - minimum leader lease time required for commit, or null for nonepublic CommitResponse(int clusterId,
String senderId,
String recipientId,
long term,
long txId,
String errorMessage)
clusterId - cluster IDsenderId - sending node identityrecipientId - identity of recipientterm - current termtxId - recipient's original transaction IDerrorMessage - failure error messagepublic long getTxId()
public boolean isSuccess()
public long getCommitTerm()
public long getCommitIndex()
public Timestamp getCommitLeaderLeaseTimeout()
public String getErrorMessage()
public boolean isLeaderMessage()
MessageisLeaderMessage in class Messagepublic void visit(MessageSwitch handler)
Messagepublic void writeTo(ByteBuffer dest)
Messageprotected int calculateSize()
MessagewriteTo().calculateSize in class MessageCopyright © 2016. All rights reserved.