public class AppendResponse extends Message
AppendRequest
.
Also contains information about the follower's log.
Constructor and Description |
---|
AppendResponse(int clusterId,
String senderId,
String recipientId,
long term,
Timestamp leaderTimestamp,
boolean success,
long matchIndex,
long lastLogIndex)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected int |
calculateSize(int version)
Calculate an upper bound on the number of bytes required by
writeTo() . |
long |
getLastLogIndex()
Get the index of the last log entry in the follower's log.
|
Timestamp |
getLeaderTimestamp()
Get the
leaderTimestamp from the corresponding AppendRequest . |
long |
getMatchIndex()
Get the index of the most recent log entry known to match leader.
|
boolean |
isSuccess()
Determine whether the request was successful, i.e., the previous log entry term and index matched.
|
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, isLeaderMessage, putBoolean, putByteBuffer, putString, putTimestamp
public AppendResponse(int clusterId, String senderId, String recipientId, long term, Timestamp leaderTimestamp, boolean success, long matchIndex, long lastLogIndex)
clusterId
- cluster IDsenderId
- identity of senderrecipientId
- identity of recipientterm
- sender's current termleaderTimestamp
- copy of AppendRequest.getLeaderTimestamp()
success
- if request successfully matchedmatchIndex
- highest known matching log indexlastLogIndex
- index of follower's last log entrypublic Timestamp getLeaderTimestamp()
leaderTimestamp
from the corresponding AppendRequest
.AppendRequest.getLeaderTimestamp()
public boolean isSuccess()
public long getMatchIndex()
public long getLastLogIndex()
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 © 2019. All rights reserved.