You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by sc...@apache.org on 2025/05/01 14:41:47 UTC
(kafka) branch trunk updated: MINOR: printing share group describe result in sorted order (#19599)
This is an automated email from the ASF dual-hosted git repository.
schofielaj pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 9e7e9a8ff6f MINOR: printing share group describe result in sorted order (#19599)
9e7e9a8ff6f is described below
commit 9e7e9a8ff6fab103defec6acbb06a2588977f2e4
Author: Chirag Wadhwa <cw...@confluent.io>
AuthorDate: Thu May 1 20:11:41 2025 +0530
MINOR: printing share group describe result in sorted order (#19599)
This PR sorts the information that is printed when kafka-share-groups.sh
--describe is used
Reviewers: Andrew Schofield <as...@confluent.io>
---
.../kafka/tools/consumer/group/ShareGroupCommand.java | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommand.java b/tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommand.java
index cfe3fee5812..7d53514a250 100644
--- a/tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommand.java
+++ b/tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommand.java
@@ -44,6 +44,7 @@ import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -426,7 +427,12 @@ public class ShareGroupCommand {
private void printOffsets(TreeMap<String, Entry<ShareGroupDescription, Collection<SharePartitionOffsetInformation>>> offsets, boolean verbose) {
offsets.forEach((groupId, tuple) -> {
- Collection<SharePartitionOffsetInformation> offsetsInfo = tuple.getValue();
+ Collection<SharePartitionOffsetInformation> offsetsInfo = tuple.getValue().stream()
+ .sorted(Comparator
+ .comparing((SharePartitionOffsetInformation info) -> info.topic)
+ .thenComparingInt(info -> info.partition))
+ .toList();
+
String fmt = printOffsetFormat(groupId, offsetsInfo, verbose);
if (verbose) {
@@ -496,7 +502,10 @@ public class ShareGroupCommand {
descriptions.forEach((groupId, description) -> {
int groupLen = Math.max(15, groupId.length());
int maxConsumerIdLen = 15, maxHostLen = 15, maxClientIdLen = 15;
- Collection<ShareMemberDescription> members = description.members();
+ Collection<ShareMemberDescription> members = description.members()
+ .stream()
+ .sorted(Comparator.comparing(ShareMemberDescription::consumerId))
+ .toList();
if (maybePrintEmptyGroupState(groupId, description.groupState(), description.members().size())) {
for (ShareMemberDescription member : members) {
maxConsumerIdLen = Math.max(maxConsumerIdLen, member.consumerId().length());