aliehsaeedii commented on code in PR #18231: URL: https://github.com/apache/kafka/pull/18231#discussion_r1890661710
########## tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java: ########## @@ -156,6 +167,158 @@ private void printGroupInfo(List<GroupListing> groups) { } } + public void describeGroups() throws ExecutionException, InterruptedException { + String group = opts.options.valueOf(opts.groupOpt); + StreamsGroupDescription description = getDescribeGroup(group); + if (description == null) + return; + boolean verbose = opts.options.has(opts.verboseOpt); + if (opts.options.has(opts.membersOpt)) { + printMembers(description, verbose); + } else if (opts.options.has(opts.stateOpt)) { + printStates(description, verbose); + } else { + printOffsets(description, verbose); + } + } + + StreamsGroupDescription getDescribeGroup(String group) throws ExecutionException, InterruptedException { + DescribeStreamsGroupsResult result = adminClient.describeStreamsGroups(List.of(group)); + Map<String, StreamsGroupDescription> descriptionMap = result.all().get(); + return descriptionMap.get(group); + } + + private void printMembers(StreamsGroupDescription description, boolean verbose) { + int groupLen = Math.max(15, description.groupId().length()); + int maxMemberIdLen = 15, maxHostLen = 15, maxClientIdLen = 15; + Collection<StreamsGroupMemberDescription> members = description.members(); + if (maybePrintEmptyGroupState(description.groupId(), description.groupState(), description.members().size())) { + for (StreamsGroupMemberDescription member : members) { + maxMemberIdLen = Math.max(maxMemberIdLen, member.memberId().length()); + maxHostLen = Math.max(maxHostLen, member.processId().length()); + maxClientIdLen = Math.max(maxClientIdLen, member.clientId().length()); + } + + if (!verbose) { + String fmt = "%" + -groupLen + "s %" + -maxMemberIdLen + "s %" + -maxHostLen + "s %" + -maxClientIdLen + "s\n" + + "%s %s %s\n\n"; Review Comment: @mjsax do you agree with this way of printing assignments? -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org