josefk31 commented on code in PR #22111:
URL: https://github.com/apache/kafka/pull/22111#discussion_r3202184412


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

Review Comment:
   Nit: slightly more descriptive name might be a tad better - for example 
`maybeSwitchObserverToFetchFromLeader`. 



##########
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:
   Nit: we might also wish to include `quorum.localIdOrSentinel` in the 
exception message for convenience. 



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