Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
Signed-off-by: OneSizeFitQuorum <[email protected]>
  • Loading branch information
OneSizeFitsQuorum committed Jan 10, 2025
1 parent bdde3ae commit 68ff863
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
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

0 comments on commit 68ff863

Please sign in to comment.