aliehsaeedii commented on code in PR #24321:
URL: https://github.com/apache/kafka/pull/24321#discussion_r4644448006
##########
tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:
##########
@@ -1064,7 +1072,7 @@ private static void maybePrintEmptyGroupState(String
group, GroupState state) {
if (state == GroupState.DEAD) {
printError("Streams group '" + group + "' does not exist.",
Optional.empty());
} else if (state == GroupState.EMPTY) {
- printError("Streams group '" + group + "' has no active
members.", Optional.empty());
+ System.err.println("\nStreams group '" + group + "' has no
active members.");
Review Comment:
The leading newline matches `kafka-consumer-groups`, which prints the same
notice to stderr as `"\nConsumer group '...' has no active members."`. Keeping
the two tools consistent.
##########
tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:
##########
@@ -430,8 +430,8 @@ private void printStates(StreamsGroupDescription
description, boolean verbose) {
private void printOffsets(StreamsGroupDescription description, boolean
verbose) throws ExecutionException, InterruptedException {
Map<TopicPartition, OffsetsInfo> offsets = getOffsets(description);
- if (isGroupStateValid(description.groupState(),
description.members().size())) {
- maybePrintEmptyGroupState(description.groupId(),
description.groupState());
+ maybePrintEmptyGroupState(description.groupId(),
description.groupState());
+ if (isGroupStateValid(description.groupState(), offsets.size())) {
Review Comment:
Agreed. The rebalancing warning and a `NotReady` notice are part of
KAFKA-21592, so I'll do them in that follow-up.
##########
tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:
##########
@@ -430,8 +430,8 @@ private void printStates(StreamsGroupDescription
description, boolean verbose) {
private void printOffsets(StreamsGroupDescription description, boolean
verbose) throws ExecutionException, InterruptedException {
Map<TopicPartition, OffsetsInfo> offsets = getOffsets(description);
- if (isGroupStateValid(description.groupState(),
description.members().size())) {
- maybePrintEmptyGroupState(description.groupId(),
description.groupState());
+ maybePrintEmptyGroupState(description.groupId(),
description.groupState());
+ if (isGroupStateValid(description.groupState(), offsets.size())) {
Review Comment:
The parameter of `isGroupStateValid` is `numRows` and its javadoc says "the
number of rows associated with the group", so offset rows is what it is meant
to get; passing the member count was the odd one. `kafka-consumer-groups` also
decides on the number of rows.
##########
tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:
##########
@@ -462,6 +462,14 @@ Map<TopicPartition, OffsetsInfo>
getOffsets(StreamsGroupDescription description)
for (StreamsGroupMemberDescription memberDescription : members) {
allTp.addAll(getTopicPartitions(memberDescription.assignment().activeTasks(),
description));
}
+ // Also include partitions that have committed offsets but are not
assigned to any member,
+ // e.g., when the group is empty, so that their committed offsets
are still shown.
+ Map<TopicPartition, OffsetAndMetadata> committedOffsets =
getCommittedOffsets(description.groupId());
+ committedOffsets.forEach((tp, offsetAndMetadata) -> {
+ if (offsetAndMetadata != null) {
+ allTp.add(tp);
+ }
+ });
Review Comment:
`getCommittedOffsets` only keeps offsets for the topology's source and
repartition topics, so stale offsets for other topics never reach
`listOffsets`. Deleted or leaderless partitions are handled in #24193
(KAFKA-21457), which filters them out before `listOffsets`.
--
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]