kaijchen commented on code in PR #811:
URL: https://github.com/apache/ratis/pull/811#discussion_r1080912913
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java:
##########
@@ -685,6 +687,22 @@ private synchronized void
sendStartLeaderElectionToHigherPriorityPeer(RaftPeerId
});
}
+ boolean sendStartLeaderElection(FollowerInfo followerInfo) {
+ final RaftPeerId followerId = followerInfo.getPeer().getId();
+ final TermIndex leaderLastEntry = server.getState().getLastEntry();
+ if (leaderLastEntry == null) {
Review Comment:
I don't think `leaderLastEntry` could be null because line 386 here:
https://github.com/apache/ratis/blob/77a9949f98d6c80a8c1466887763d44fb64c9ccc/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java#L378-L390
However, it's good to check just in case.
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java:
##########
@@ -685,6 +687,22 @@ private synchronized void
sendStartLeaderElectionToHigherPriorityPeer(RaftPeerId
});
}
+ boolean sendStartLeaderElection(FollowerInfo followerInfo) {
+ final RaftPeerId followerId = followerInfo.getPeer().getId();
+ final TermIndex leaderLastEntry = server.getState().getLastEntry();
+ if (leaderLastEntry == null) {
+ sendStartLeaderElection(followerId, null);
+ return true;
+ }
+
+ final long followerMatchIndex = followerInfo.getMatchIndex();
+ if (followerMatchIndex >= leaderLastEntry.getIndex()) {
Review Comment:
Same, I don't think `followerMatchIndex` can be greater than
`leaderLastEntry.getIndex()`.
But it's okay to check just in case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]