ahuang98 commented on code in PR #18240: URL: https://github.com/apache/kafka/pull/18240#discussion_r1895898210
########## raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java: ########## @@ -657,14 +657,40 @@ private void flushLeaderLog(LeaderState<T> state, long currentTimeMs) { } private boolean maybeTransitionToLeader(CandidateState state, long currentTimeMs) { - if (state.isVoteGranted()) { + if (state.epochElection().isVoteGranted()) { onBecomeLeader(currentTimeMs); return true; } else { return false; } } + private boolean maybeTransitionToCandidate(ProspectiveState state, long currentTimeMs) { + if (state.epochElection().isVoteGranted()) { + transitionToCandidate(currentTimeMs); + return true; + } else { + return false; + } + } + + /** + * Only applies to VotingStates (Prospective or Candidate). If enough votes were granted + * then this method is called to transition the state forward - either from Prospective to Candidate + * or from Candidate to Leader. + * @return true if the state transitioned forward, false otherwise + */ + private boolean maybeTransitionForward(NomineeState state, long currentTimeMs) { Review Comment: open to what you think, this definitely isn't necessary but I thought this could help reduce the complexity of handleVoteResponse (this is called in a 3rd level of conditional statements) -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org