dajac commented on code in PR #17233:
URL: https://github.com/apache/kafka/pull/17233#discussion_r1773244650
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/TopicMetadata.java:
##########
@@ -130,45 +107,24 @@ public String toString() {
"id=" + id +
", name=" + name +
", numPartitions=" + numPartitions +
- ", partitionRacks=" + partitionRacks +
')';
}
public static TopicMetadata fromRecord(
ConsumerGroupPartitionMetadataValue.TopicMetadata record
) {
- // Converting the data type from a list stored in the record to a map
for the topic metadata.
- Map<Integer, Set<String>> partitionRacks = new HashMap<>();
- for (ConsumerGroupPartitionMetadataValue.PartitionMetadata
partitionMetadata : record.partitionMetadata()) {
- partitionRacks.put(
- partitionMetadata.partition(),
- Collections.unmodifiableSet(new
HashSet<>(partitionMetadata.racks()))
- );
- }
-
return new TopicMetadata(
record.topicId(),
record.topicName(),
- record.numPartitions(),
- partitionRacks);
+ record.numPartitions());
}
public static TopicMetadata fromRecord(
- ShareGroupPartitionMetadataValue.TopicMetadata record
+ ShareGroupPartitionMetadataValue.TopicMetadata record
) {
- // Converting the data type from a list stored in the record to a map
for the topic metadata.
- Map<Integer, Set<String>> partitionRacks = new HashMap<>();
- for (ShareGroupPartitionMetadataValue.PartitionMetadata
partitionMetadata : record.partitionMetadata()) {
- partitionRacks.put(
- partitionMetadata.partition(),
- Collections.unmodifiableSet(new
HashSet<>(partitionMetadata.racks()))
- );
- }
-
return new TopicMetadata(
- record.topicId(),
- record.topicName(),
- record.numPartitions(),
- partitionRacks);
+ record.topicId(),
+ record.topicName(),
+ record.numPartitions());
Review Comment:
nit: ditto.
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/ModernGroup.java:
##########
@@ -389,25 +388,10 @@ public Map<String, TopicMetadata>
computeSubscriptionMetadata(
subscribedTopicNames.forEach((topicName, count) -> {
TopicImage topicImage = topicsImage.getTopic(topicName);
if (topicImage != null) {
- Map<Integer, Set<String>> partitionRacks = new HashMap<>();
- topicImage.partitions().forEach((partition,
partitionRegistration) -> {
- Set<String> racks = new HashSet<>();
- for (int replica : partitionRegistration.replicas) {
- Optional<String> rackOptional =
clusterImage.broker(replica).rack();
- // Only add the rack if it is available for the
broker/replica.
- rackOptional.ifPresent(racks::add);
- }
- // If rack information is unavailable for all replicas of
this partition,
- // no corresponding entry will be stored for it in the map.
- if (!racks.isEmpty())
- partitionRacks.put(partition, racks);
- });
-
newSubscriptionMetadata.put(topicName, new TopicMetadata(
topicImage.id(),
topicImage.name(),
- topicImage.partitions().size(),
- partitionRacks)
+ topicImage.partitions().size())
Review Comment:
nit: Could you please put the last closing parenthesis on the next line?
```
newSubscriptionMetadata.put(topicName, new TopicMetadata(
topicImage.id(),
topicImage.name(),
topicImage.partitions().size()
));
```
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/TopicMetadata.java:
##########
@@ -130,45 +107,24 @@ public String toString() {
"id=" + id +
", name=" + name +
", numPartitions=" + numPartitions +
- ", partitionRacks=" + partitionRacks +
')';
}
public static TopicMetadata fromRecord(
ConsumerGroupPartitionMetadataValue.TopicMetadata record
) {
- // Converting the data type from a list stored in the record to a map
for the topic metadata.
- Map<Integer, Set<String>> partitionRacks = new HashMap<>();
- for (ConsumerGroupPartitionMetadataValue.PartitionMetadata
partitionMetadata : record.partitionMetadata()) {
- partitionRacks.put(
- partitionMetadata.partition(),
- Collections.unmodifiableSet(new
HashSet<>(partitionMetadata.racks()))
- );
- }
-
return new TopicMetadata(
record.topicId(),
record.topicName(),
- record.numPartitions(),
- partitionRacks);
+ record.numPartitions());
Review Comment:
nit: Ditto about the closing parenthesis.
--
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]