CalvinConfluent commented on code in PR #19590: URL: https://github.com/apache/kafka/pull/19590#discussion_r2077971817
########## metadata/src/main/java/org/apache/kafka/metadata/PartitionRegistration.java: ########## @@ -165,12 +164,8 @@ public PartitionRegistration build() { public final int leaderEpoch; public final int partitionEpoch; - public static boolean electionWasClean(int newLeader, int[] isr, int[] elr) { - return newLeader == NO_LEADER || Replicas.contains(isr, newLeader) || Replicas.contains(elr, newLeader); - } - - public static boolean electionFromElr(int newLeader, int[] elr) { - return Replicas.contains(elr, newLeader); + public static boolean electionWasUnclean(byte prevLeaderRecoveryState, byte nextLeaderRecoveryState) { + return prevLeaderRecoveryState == LeaderRecoveryState.RECOVERED.value() && nextLeaderRecoveryState == LeaderRecoveryState.RECOVERING.value(); Review Comment: Because we are counting the number of unclean elections, so we just count once when the state changes. -- 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