dengziming commented on a change in pull request #18145:
URL: https://github.com/apache/flink/pull/18145#discussion_r791789358
##########
File path:
flink-connectors/flink-connector-kafka/src/main/java/org/apache/flink/connector/kafka/source/enumerator/KafkaSourceEnumerator.java
##########
@@ -558,25 +533,100 @@ public PartitionOffsetsRetrieverImpl(
}
}
+ /**
+ * List offsets for the specified partitions and OffsetSpec. This
operation enables to find
+ * the beginning offset, end offset as well as the offset matching a
timestamp in
+ * partitions.
+ *
+ * @see KafkaAdminClient#listOffsets(Map)
+ * @param topicPartitionOffsets The mapping from partition to the
OffsetSpec to look up.
+ * @return The list offsets result.
+ */
+ private Map<TopicPartition, ListOffsetsResult.ListOffsetsResultInfo>
listOffsets(
+ Map<TopicPartition, OffsetSpec> topicPartitionOffsets) {
+ try {
+ return adminClient
+ .listOffsets(topicPartitionOffsets)
+ .all()
+ .thenApply(
+ result -> {
+ Map<TopicPartition,
ListOffsetsResult.ListOffsetsResultInfo>
+ offsets = new HashMap<>();
+ result.forEach(
+ (tp, listOffsetsResultInfo) -> {
+ if (listOffsetsResultInfo !=
null) {
+ offsets.put(tp,
listOffsetsResultInfo);
+ }
+ });
+ return offsets;
+ })
+ .get();
+ } catch (InterruptedException e) {
+ throw new FlinkRuntimeException(
Review comment:
Thank you for this reminder, I also find there is another
`InterruptedException` ad `committedOffsets` so I revised it too.
--
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]