kevin-wu24 commented on code in PR #22111:
URL: https://github.com/apache/kafka/pull/22111#discussion_r3311688143


##########
raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:
##########
@@ -2608,6 +2615,32 @@ private boolean hasConsistentLeader(int epoch, 
OptionalInt leaderId) {
         }
     }
 
+    /**
+     * If the local replica is an observer currently routing fetches to 
bootstrap servers,
+     * and a non-leader source's fetch response advertises the leader's 
endpoints, switch
+     * the observer back to fetching from the leader.
+     */
+    private void maybeSwitchObserverFetchToLeader(
+        int responseEpoch,
+        OptionalInt responseLeaderId,
+        Endpoints leaderEndpoints,
+        long currentTimeMs
+    ) {
+        if (!hasConsistentLeader(responseEpoch, responseLeaderId)) {
+            throw new IllegalStateException("Received request or response with 
leader " + responseLeaderId +

Review Comment:
   I followed the other usage of `hasConsistentLeader`, which uses 
`quorum.localId()`. If the local leader is empty, `hasConsistentLeader` returns 
`true`.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to