junrao commented on code in PR #19590:
URL: https://github.com/apache/kafka/pull/19590#discussion_r2078023602


##########
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:
   Hmm, I still don't quite understand. Suppose that we have two consecutive 
unclean elections for the same partition, the metric should show a count of 2 
instead of 1 for UncleanLeaderElectionsPerSec, right? 



-- 
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

Reply via email to