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


##########
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:
   Why do we need to take prevLeaderRecoveryState into consideration? If 
prevLeaderRecoveryState is RECOVERING and nextLeaderRecoveryState is also 
RECOVERING, this should still count as an unclean election, 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