dajac commented on code in PR #15205:
URL: https://github.com/apache/kafka/pull/15205#discussion_r1458581509
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/consumer/ConsumerGroupMember.java:
##########
@@ -571,15 +577,29 @@ public ConsumerGroupDescribeResponseData.Member
asConsumerGroupDescribeMember(As
}
private static List<ConsumerGroupDescribeResponseData.TopicPartitions>
topicPartitionsFromMap(
- Map<Uuid, Set<Integer>> partitions
+ Map<Uuid, Set<Integer>> partitions,
+ Map<String, TopicMetadata> subscriptionMetadata
) {
return partitions.entrySet().stream().map(
item -> new ConsumerGroupDescribeResponseData.TopicPartitions()
.setTopicId(item.getKey())
+ .setTopicName(lookupTopicNameById(item.getKey(),
subscriptionMetadata))
.setPartitions(new ArrayList<>(item.getValue()))
).collect(Collectors.toList());
}
+ private static String lookupTopicNameById(
+ Uuid topicId,
+ Map<String, TopicMetadata> subscriptionMetadata
+ ) {
+ for (TopicMetadata topicMetadata : subscriptionMetadata.values()) {
+ if (topicId.equals(topicMetadata.id())) {
+ return topicMetadata.name();
+ }
+ }
+ throw UNKNOWN_TOPIC_ID.exception("The subscription metadata does not
contain " + topicId);
Review Comment:
I am not sure about this. It means that when a topic is delete and the group
has not been updated yet, it won't be possible to describe it. An alternative
would be to directly remove the topic from the assignment. It will be
eventually removed anyway. What do you think?
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/consumer/ConsumerGroupMember.java:
##########
@@ -571,15 +577,29 @@ public ConsumerGroupDescribeResponseData.Member
asConsumerGroupDescribeMember(As
}
private static List<ConsumerGroupDescribeResponseData.TopicPartitions>
topicPartitionsFromMap(
- Map<Uuid, Set<Integer>> partitions
+ Map<Uuid, Set<Integer>> partitions,
+ Map<String, TopicMetadata> subscriptionMetadata
) {
return partitions.entrySet().stream().map(
item -> new ConsumerGroupDescribeResponseData.TopicPartitions()
.setTopicId(item.getKey())
+ .setTopicName(lookupTopicNameById(item.getKey(),
subscriptionMetadata))
.setPartitions(new ArrayList<>(item.getValue()))
).collect(Collectors.toList());
}
+ private static String lookupTopicNameById(
+ Uuid topicId,
+ Map<String, TopicMetadata> subscriptionMetadata
+ ) {
+ for (TopicMetadata topicMetadata : subscriptionMetadata.values()) {
+ if (topicId.equals(topicMetadata.id())) {
+ return topicMetadata.name();
+ }
+ }
Review Comment:
This is pretty bad, isn't it? I was wondering if we could use the
MetadataImage instead. It would allow us to get the name based on the id.
--
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]