ahuang98 commented on code in PR #18240:
URL: https://github.com/apache/kafka/pull/18240#discussion_r1918935598


##########
raft/src/main/java/org/apache/kafka/raft/QuorumState.java:
##########
@@ -562,6 +656,25 @@ public void transitionToCandidate() {
         ));
     }
 
+    private void checkValidTransitionToCandidate() {
+        if (isObserver()) {
+            throw new IllegalStateException(
+                String.format(
+                    "Cannot transition to Candidate since the local id (%s) 
and directory id (%s) " +
+                        "is not one of the voters %s",
+                    localId,
+                    localDirectoryId,
+                    partitionState.lastVoterSet()
+                )
+            );
+        }
+        // Only Prospective is allowed to transition to Candidate
+        if (!isProspective()) {
+            throw new IllegalStateException("Cannot transition to Candidate 
since the local broker.id=" + localId +
+                " is state " + state);

Review Comment:
   I'll convert



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