squah-confluent commented on code in PR #20000:
URL: https://github.com/apache/kafka/pull/20000#discussion_r2594744175


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/UniformHomogeneousAssignmentBuilder.java:
##########
@@ -101,6 +113,24 @@ public class UniformHomogeneousAssignmentBuilder {
         this.unassignedPartitions = new ArrayList<>();
 
         this.targetAssignment = new HashMap<>();
+        this.partitionRacks = new HashMap<>();
+
+        Set<String> allMemberRacks = new HashSet<>();
+        for (String memberId : groupSpec.memberIds()) {
+            
groupSpec.memberSubscription(memberId).rackId().ifPresent(allMemberRacks::add);
+        }
+
+        Set<String> allPartitionRacks = new HashSet<>();
+        for (Uuid topicId : this.subscribedTopicIds) {
+            int partitionCount = 
subscribedTopicDescriber.numPartitions(topicId);
+            for (int partitionId = 0; partitionId < partitionCount; 
partitionId++) {
+                Set<String> racks = 
subscribedTopicDescriber.racksForPartition(topicId, partitionId);
+                partitionRacks.put(new TopicIdPartition(topicId, partitionId), 
racks);
+                allPartitionRacks.addAll(racks);
+            }
+        }

Review Comment:
   A lot of the constructor cost is in gathering the racks of all partitions. 
@dajac mentioned we could try shortcutting the rack-aware part if no members 
have racks.
   
   Or we could also check if no members have racks matching any broker, since 
clients can misconfigure their racks. The number of racks is <= the number of 
brokers, which is small and we can collect the set of broker racks cheaply from 
the `MetadataImage` underlying the `SubscribedTopicDescriber`.



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