Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,10 @@ default boolean isAlive() {
* otherwise, return null.
*/
long[] getFollowerNextIndices();

/**
* @return an array of match indices of the followers if this server division is the leader;
* otherwise, return null.
*/
long[] getFollowerMatchIndices();
}
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,10 @@ long[] getFollowerNextIndices() {
return getLogAppenders().mapToLong(s -> s.getFollower().getNextIndex()).toArray();
}

long[] getFollowerMatchIndices() {
return getLogAppenders().mapToLong(s -> s.getFollower().getMatchIndex()).toArray();
}

static Map<RaftPeerId, RaftPeer> newMap(Collection<RaftPeer> peers, String str) {
Objects.requireNonNull(peers, () -> str + " == null");
final Map<RaftPeerId, RaftPeer> map = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ public long[] getFollowerNextIndices() {
.map(LeaderStateImpl::getFollowerNextIndices)
.orElse(null);
}

@Override
public long[] getFollowerMatchIndices() {
return role.getLeaderState()
.filter(leader -> isLeader())
.map(LeaderStateImpl::getFollowerMatchIndices)
.orElse(null);
}
}

private final RaftServerProxy proxy;
Expand Down
Loading