-
Notifications
You must be signed in to change notification settings - Fork 14.5k
KAFKA-19459: List internal topics for the user #20157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
KAFKA-19459: List internal topics for the user #20157
Conversation
…c-version-mismatch
…c-version-mismatch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lucliu1108: Thanks for the patch.
printError("Retrieving internal topics is not supported by the broker version. " + | ||
"Use 'kafka-topics.sh' to list and delete the group's internal topics.", Optional.of(e.getCause())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we combine the internal topics message into printError
?
List<String> internalTopics = new ArrayList<>(); | ||
try { | ||
Set<String> allTopics = adminClient.listTopics().names().get(); | ||
for (String topic : allTopics) { | ||
for (String groupId : groupIds) { | ||
if (isInferredInternalTopic(topic, groupId)) { | ||
internalTopics.add(topic); | ||
break; | ||
} | ||
} | ||
} | ||
System.out.println("Internal Topics: (" + String.join(",", internalTopics) + ")."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use the stream api to align the style with this whole class.
For example:
List<String> internalTopics = new ArrayList<>(); | |
try { | |
Set<String> allTopics = adminClient.listTopics().names().get(); | |
for (String topic : allTopics) { | |
for (String groupId : groupIds) { | |
if (isInferredInternalTopic(topic, groupId)) { | |
internalTopics.add(topic); | |
break; | |
} | |
} | |
} | |
System.out.println("Internal Topics: (" + String.join(",", internalTopics) + ")."); | |
String internalTopics; | |
try { | |
Set<String> allTopics = adminClient.listTopics().names().get(); | |
internalTopics = allTopics.stream() | |
.filter(topic -> groupIds.stream().anyMatch(groupId -> isInferredInternalTopic(topic, groupId))) | |
.collect(Collectors.joining(",")); | |
System.out.println("Internal Topics: (" + internalTopics + ")."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment! Just revised the method:
- use Stream API
- Combine print internal topics in the
printError
message.
For the Kafka Stream group commands, if delete topic requests fail due to version mismatch, user will have to remove the topics manually by first retrieving the relevant internal topics.
To assist the user, the internal topic names are now included as part of the error message, so that the user could delete the internal topics associated with this application directly.
Reviewer: @aliehsaeedii