Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

RATIS-2237 Add getFollowerMatchIndices interface for DivisionInfo #1210

Merged
merged 1 commit into from
Jan 13, 2025
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