muralibasani commented on code in PR #24193:
URL: https://github.com/apache/kafka/pull/24193#discussion_r4620083672
##########
tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:
##########
@@ -470,31 +473,66 @@ Map<TopicPartition, OffsetsInfo>
getOffsets(StreamsGroupDescription description)
earliest.put(tp, OffsetSpec.earliest());
latest.put(tp, OffsetSpec.latest());
}
- Map<TopicPartition, ListOffsetsResult.ListOffsetsResultInfo>
earliestResult = adminClient.listOffsets(
+ Map<TopicPartition, ListOffsetsResult.ListOffsetsResultInfo>
earliestResult = offsetsOfExistingTopics(adminClient.listOffsets(
earliest,
withTimeoutMs(new ListOffsetsOptions())
- ).all().get();
- Map<TopicPartition, ListOffsetsResult.ListOffsetsResultInfo>
latestResult = adminClient.listOffsets(
+ ), allTp);
+ Map<TopicPartition, ListOffsetsResult.ListOffsetsResultInfo>
latestResult = offsetsOfExistingTopics(adminClient.listOffsets(
latest,
withTimeoutMs(new ListOffsetsOptions())
- ).all().get();
+ ), allTp);
Map<TopicPartition, OffsetAndMetadata> committedOffsets =
getCommittedOffsets(description.groupId());
Map<TopicPartition, OffsetsInfo> output = new HashMap<>();
for (Map.Entry<TopicPartition,
ListOffsetsResult.ListOffsetsResultInfo> tp : earliestResult.entrySet()) {
+ if (!latestResult.containsKey(tp.getKey())) {
+ continue;
+ }
final Optional<Long> currentOffset =
committedOffsets.containsKey(tp.getKey()) ?
Optional.of(committedOffsets.get(tp.getKey()).offset()) : Optional.empty();
final Optional<Integer> leaderEpoch =
committedOffsets.containsKey(tp.getKey()) ?
committedOffsets.get(tp.getKey()).leaderEpoch() : Optional.empty();
final long lag = currentOffset.map(current ->
latestResult.get(tp.getKey()).offset() - current).orElseGet(() ->
latestResult.get(tp.getKey()).offset() -
earliestResult.get(tp.getKey()).offset());
output.put(tp.getKey(),
new OffsetsInfo(
currentOffset,
leaderEpoch,
- latestResult.get(tp.getKey()).offset(),
- lag));
+ Optional.of(latestResult.get(tp.getKey()).offset()),
+ Optional.of(lag)));
+ }
+ // Partitions of a deleted topic have no log-end offset or lag,
but still show their committed offset.
+ for (TopicPartition tp : allTp) {
Review Comment:
Done, single loop over allTp.
--
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]