fvaleri commented on code in PR #24320:
URL: https://github.com/apache/kafka/pull/24320#discussion_r4683841834


##########
metadata/src/main/java/org/apache/kafka/image/TopicDelta.java:
##########
@@ -180,6 +222,12 @@ public LocalReplicaChanges localChanges(int brokerId) {
         Map<TopicPartition, LocalReplicaChanges.PartitionInfo> followers = new 
HashMap<>();
         Map<String, Uuid> topicIds = new HashMap<>();
         Map<TopicIdPartition, Uuid> directoryIds = new HashMap<>();
+        Map<Uuid, LocalReplicaChanges.MirrorTopicState> mirrorTopicChanges = 
new HashMap<>();
+
+        LocalReplicaChanges.MirrorTopicState mirrorTopicState = 
mirrorTopicStateChange(image);

Review Comment:
   A mirror desired-state change is topic-level metadata, but it triggers work 
only on brokers that currently lead partitions of that topic. For this reason, 
we could benefit from an extra TopicsDelta filtering method that uses brokerId 
to filter out desired-state change for non locally led partitions. 
   
   ```java
   public Map<TopicPartition, TopicImage.Mirror> localMirrorTopicChanges(int 
brokerId) {
       Map<TopicPartition, TopicImage.Mirror> changes = new HashMap<>();
   
       for (TopicDelta topicDelta : changedTopics.values()) {
           TopicImage previousImage = image.getTopic(topicDelta.id());
   
           topicDelta.mirrorTopicStateChange(previousImage).ifPresent(mirror ->
               topicDelta.localLeaderPartitions(brokerId).forEach(tp ->
                   changes.put(tp, mirror)
               )
           );
       }
   
       return changes;
   }
   ```
   
   The caller would be the future MirrorMetadataManager, that on cluster 
metadata update event won't have to apply this filtering logic. This way, 
mirror state changes handling would be consistent with how we handle replica 
assignment changes. 
   
   WDYT?



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