Skip to content

Commit

Permalink
MINOR: Fix broken output layout of kafka-consumer-groups.sh (#17058)
Browse files Browse the repository at this point in the history
Reviewers: Andrew Schofield <aschofield@confluent.io>, Lianet Magrans <lmagrans@confluent.io>
  • Loading branch information
sasakitoa committed Sep 4, 2024
1 parent 0294b14 commit 748d202
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ static void printError(String msg, Optional<Throwable> e) {
}

static void printOffsetsToReset(Map<String, Map<TopicPartition, OffsetAndMetadata>> groupAssignmentsToReset) {
String format = "%-30s %-30s %-10s %-15s";
String format = "%n%-30s %-30s %-10s %-15s";
if (!groupAssignmentsToReset.isEmpty())
System.out.printf("\n" + format, "GROUP", "TOPIC", "PARTITION", "NEW-OFFSET");
System.out.printf(format, "GROUP", "TOPIC", "PARTITION", "NEW-OFFSET");

groupAssignmentsToReset.forEach((groupId, assignment) ->
assignment.forEach((consumerAssignment, offsetAndMetadata) ->
Expand All @@ -167,6 +167,7 @@ static void printOffsetsToReset(Map<String, Map<TopicPartition, OffsetAndMetadat
consumerAssignment.topic(),
consumerAssignment.partition(),
offsetAndMetadata.offset())));
System.out.println();
}

@SuppressWarnings("ClassFanOutComplexity")
Expand Down Expand Up @@ -338,6 +339,7 @@ private void printOffsets(Map<String, Entry<Optional<ConsumerGroupState>, Option
consumerAssignment.host.orElse(MISSING_COLUMN_VALUE), consumerAssignment.clientId.orElse(MISSING_COLUMN_VALUE)
);
}
System.out.println();
}
}
});
Expand Down Expand Up @@ -655,9 +657,9 @@ void deleteOffsets() {
printError("Encounter some unknown error: " + topLevelResult, Optional.empty());
}

String format = "%-30s %-15s %-15s";
String format = "%n%-30s %-15s %-15s";

System.out.printf("\n" + format, "TOPIC", "PARTITION", "STATUS");
System.out.printf(format, "TOPIC", "PARTITION", "STATUS");
partitionLevelResult.entrySet().stream()
.sorted(Comparator.comparing(e -> e.getKey().topic() + e.getKey().partition()))
.forEach(e -> {
Expand All @@ -669,6 +671,7 @@ void deleteOffsets() {
error != null ? "Error: :" + error.getMessage() : "Successful"
);
});
System.out.println();
}

Map<String, ConsumerGroupDescription> describeConsumerGroups(Collection<String> groupIds) throws Exception {
Expand Down

0 comments on commit 748d202

Please sign in to comment.