lucasbru commented on code in PR #18231:
URL: https://github.com/apache/kafka/pull/18231#discussion_r1910610974


##########
tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:
##########
@@ -205,23 +206,23 @@ private void printMembers(StreamsGroupDescription 
description, boolean verbose)
                     System.out.printf(fmt, "GROUP", "MEMBER", "PROCESS", 
"CLIENT-ID", "ACTIVE-TASKS", "STANDBY-TASKS", "WARMUP-TASKS");
                     for (StreamsGroupMemberDescription member : members) {
                         System.out.printf(fmt, description.groupId(), 
member.memberId(), member.processId(), member.clientId(),
-                            
getTopicPartitions(member.assignment().activeTasks()).stream().map(tp -> 
tp.topic() + ":" + tp.partition()).collect(Collectors.joining(",")),
-                            
getTopicPartitions(member.assignment().standbyTasks()).stream().map(tp -> 
tp.topic() + ":" + tp.partition()).collect(Collectors.joining(",")),
-                            
getTopicPartitions(member.assignment().warmupTasks()).stream().map(tp -> 
tp.topic() + ":" + tp.partition()).collect(Collectors.joining(",")));
+                            
member.assignment().activeTasks().stream().map(taskId -> taskId.subtopologyId() 
+ ":" + taskId.partitions()).collect(Collectors.joining(",")),

Review Comment:
   I wonder how readable this will be. I think it will look something like this:
   
   ```
   ACTIVE-TASKS STANDBY-TASKS WARMUP-TASKS
   subtopology1:[1, 2, 3],subtopology2:[1] subtopology1:[1] subtopology2:[9]
   ```
   
   Have you thought about how to make this more readable?
   
   How are you testing these changes?
   



##########
tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:
##########
@@ -205,23 +206,23 @@ private void printMembers(StreamsGroupDescription 
description, boolean verbose)
                     System.out.printf(fmt, "GROUP", "MEMBER", "PROCESS", 
"CLIENT-ID", "ACTIVE-TASKS", "STANDBY-TASKS", "WARMUP-TASKS");
                     for (StreamsGroupMemberDescription member : members) {
                         System.out.printf(fmt, description.groupId(), 
member.memberId(), member.processId(), member.clientId(),
-                            
getTopicPartitions(member.assignment().activeTasks()).stream().map(tp -> 
tp.topic() + ":" + tp.partition()).collect(Collectors.joining(",")),
-                            
getTopicPartitions(member.assignment().standbyTasks()).stream().map(tp -> 
tp.topic() + ":" + tp.partition()).collect(Collectors.joining(",")),
-                            
getTopicPartitions(member.assignment().warmupTasks()).stream().map(tp -> 
tp.topic() + ":" + tp.partition()).collect(Collectors.joining(",")));
+                            
member.assignment().activeTasks().stream().map(taskId -> taskId.subtopologyId() 
+ ":" + taskId.partitions()).collect(Collectors.joining(",")),
+                            
member.assignment().standbyTasks().stream().map(taskId -> 
taskId.subtopologyId() + ":" + 
taskId.partitions()).collect(Collectors.joining(",")),
+                            
member.assignment().warmupTasks().stream().map(taskId -> taskId.subtopologyId() 
+ ":" + taskId.partitions()).collect(Collectors.joining(",")));
                     }
                 } else {
-                    String fmt = "%" + -groupLen + "s %-15s%" + 
-maxMemberIdLen + "s %s %15s %" + -maxHostLen + "s %" + -maxClientIdLen + "s\n"
+                    String fmt = "%" + -groupLen + "s %-15s% %-15s%" + 
-maxMemberIdLen + "s %s %15s %" + -maxHostLen + "s %" + -maxClientIdLen + "s\n"
                         + "%s %s %s %s %s %s\n\n";
-                    System.out.printf(fmt, "GROUP", "TARGET-ASSIGNMENT-EPOCH", 
"MEMBER", "MEMBER-PROTOCOL", "MEMBER-EPOCH", "PROCESS", "CLIENT",
+                    System.out.printf(fmt, "GROUP", "TARGET-ASSIGNMENT-EPOCH", 
"TOPOLOGY-EPOCH", "MEMBER", "MEMBER-PROTOCOL", "MEMBER-EPOCH", "PROCESS", 
"CLIENT",

Review Comment:
   Your column seems to be 15 characters, but TARGET-ASSIGNMENT-EPOCH is >20 
character. WOn't this look misaligned?



##########
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";
+                    System.out.printf(fmt, "GROUP", "MEMBER", "PROCESS", 
"CLIENT-ID", "ACTIVE-TASKS", "STANDBY-TASKS", "WARMUP-TASKS");
+                    for (StreamsGroupMemberDescription member : members) {
+                        System.out.printf(fmt, description.groupId(), 
member.memberId(), member.processId(), member.clientId(),
+                            
getTopicPartitions(member.assignment().activeTasks()).stream().map(tp -> 
tp.topic() + ":" + tp.partition()).collect(Collectors.joining(",")),
+                            
getTopicPartitions(member.assignment().standbyTasks()).stream().map(tp -> 
tp.topic() + ":" + tp.partition()).collect(Collectors.joining(",")),
+                            
getTopicPartitions(member.assignment().warmupTasks()).stream().map(tp -> 
tp.topic() + ":" + tp.partition()).collect(Collectors.joining(",")));
+                    }
+                } else {
+                    String fmt = "%" + -groupLen + "s %-15s%" + 
-maxMemberIdLen + "s %s %15s %" + -maxHostLen + "s %" + -maxClientIdLen + "s\n"
+                        + "%s %s %s %s %s %s\n\n";

Review Comment:
   Same here. If we cannot align this data in columns, we probably need to 
represent it in one line, but then we cannot differentiate between the task 
types (active, standby, warm-up) using column headers, but in the line.



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

Reply via email to