philipnee commented on code in PR #15525:
URL: https://github.com/apache/kafka/pull/15525#discussion_r1548574194
##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:
##########
@@ -1141,21 +1146,29 @@ private Map<TopicPartition, Long>
beginningOrEndOffset(Collection<TopicPartition
if (partitions.isEmpty()) {
return Collections.emptyMap();
}
+
Map<TopicPartition, Long> timestampToSearch = partitions
- .stream()
- .collect(Collectors.toMap(Function.identity(), tp ->
timestamp));
+ .stream()
+ .collect(Collectors.toMap(Function.identity(), tp ->
timestamp));
Timer timer = time.timer(timeout);
ListOffsetsEvent listOffsetsEvent = new ListOffsetsEvent(
- timestampToSearch,
- false,
- timer);
- Map<TopicPartition, OffsetAndTimestamp> offsetAndTimestampMap =
applicationEventHandler.addAndGet(
- listOffsetsEvent,
- timer);
- return offsetAndTimestampMap
- .entrySet()
- .stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e ->
e.getValue().offset()));
+ timestampToSearch,
+ timer,
+ false);
+
+ Map<TopicPartition, OffsetAndTimestampInternal>
offsetAndTimestampMap;
+ if (timeout.isZero()) {
+ applicationEventHandler.add(listOffsetsEvent);
Review Comment:
hi @lianetm thanks for the comment. There's a ticket to align the behavior
of the two apis per your suggestions there. The plan is to do that in a
separated pr. https://issues.apache.org/jira/browse/KAFKA-16433
Back to your first comment, it is not immediately obvious to see why people
use these two apis with zero timeout. The only thing sensible thing it does to
updating the local highwatermark as you mentioned. I think it is worth
addressing this ambiguity after 4.0 release. So I'll leave a comment per your
request.
--
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]