hachikuji commented on a change in pull request #10393: URL: https://github.com/apache/kafka/pull/10393#discussion_r606332415
########## File path: raft/src/main/java/org/apache/kafka/raft/UnattachedState.java ########## @@ -88,6 +93,16 @@ public boolean hasElectionTimeoutExpired(long currentTimeMs) { return highWatermark; } + @Override + public boolean canGrantVote(int candidateId, boolean isLogUpToDate) { + Review comment: nit: unneeded newline ########## File path: raft/src/main/java/org/apache/kafka/raft/FollowerState.java ########## @@ -139,6 +145,13 @@ public void setFetchingSnapshot(Optional<RawSnapshotWriter> fetchingSnapshot) th this.fetchingSnapshot = fetchingSnapshot; } + @Override + public boolean canGrantVote(int candidateId, boolean isLogUpToDate) { + log.debug("Rejecting vote request from candidate {} since we already have a leader {} on that epoch", Review comment: nit: ".. in epoch {}"? Similarly for other logs. ########## File path: raft/src/main/java/org/apache/kafka/raft/CandidateState.java ########## @@ -235,6 +240,12 @@ public int epoch() { return highWatermark; } + @Override + public boolean canGrantVote(int candidateId, boolean isLogUpToDate) { Review comment: Might be worth a comment about the behavior when `candidateId` is equal to `localId`. Although the candidate votes for itself, this vote is implicit and not "granted." ########## File path: raft/src/main/java/org/apache/kafka/raft/EpochState.java ########## @@ -25,6 +25,14 @@ return Optional.empty(); } + /** + * Decide whether to grant a vote to a candidate, it is the responsibility of the caller to invoke + * {@link QuorumState##transitionToVoted(int, int)} if vote is granted. + * Review comment: nit: can you document the parameters? ########## File path: raft/src/main/java/org/apache/kafka/raft/ResignedState.java ########## @@ -125,6 +131,12 @@ public long remainingElectionTimeMs(long currentTimeMs) { return preferredSuccessors; } + @Override + public boolean grantVote(int candidateId, Supplier<Boolean> logComparator) { + log.debug("Rejecting vote request since we have resigned as candidate/leader in this epoch"); + return false; Review comment: Filed this one: https://issues.apache.org/jira/browse/KAFKA-12607. -- 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: us...@infra.apache.org