runzhiwang commented on a change in pull request #184:
URL: https://github.com/apache/incubator-ratis/pull/184#discussion_r478931548
##########
File path:
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderState.java
##########
@@ -794,12 +795,46 @@ private void replicateNewConf() {
return lists;
}
+ private void yieldLeaderToHigherPriorityPeer() {
+ if (!server.getRole().isLeader()) {
+ return;
+ }
+
+ final RaftConfiguration conf = server.getRaftConf();
+ int leaderPriority = conf.getPeer(server.getId()).getPriority();
+
+ for (LogAppender logAppender : senders.getSenders()) {
+ FollowerInfo followerInfo = logAppender.getFollower();
+ RaftPeerId followerID = followerInfo.getPeer().getId();
+ int followerPriority = conf.getPeer(followerID).getPriority();
+
+ if (followerPriority <= leaderPriority) {
+ continue;
+ }
+
+ if (followerInfo.getCommitIndex() >= raftLog.getLastCommittedIndex()) {
Review comment:
@szetszwo Thanks for review. I change to compare lastEntry, i.e.
compare the index of leader's lastEntry to the follower's matchIndex. Because
matchIndex is the lastEntry follower appended. Besides, I only compare the
index of lastEntry, because 1. if follower's lastEntry index equals to
leader's, lastEntry's term must be equal, need not to compare ; 2. leader did
not has the term of follower's lastEntry.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]