RobertIndie commented on code in PR #21945:
URL: https://github.com/apache/pulsar/pull/21945#discussion_r1469320442
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java:
##########
@@ -775,25 +776,44 @@ public CompletableFuture<Void> seekAsync(MessageId
messageId) {
);
}
- final CompletableFuture<Void> seekFuture;
if (internalConsumer == null) {
- List<CompletableFuture<Void>> futures = new
ArrayList<>(consumers.size());
- consumers.values().forEach(consumerImpl ->
futures.add(consumerImpl.seekAsync(messageId)));
- seekFuture = FutureUtil.waitForAll(futures);
+ return seekAllAsync(consumer -> consumer.seekAsync(messageId));
} else {
- seekFuture = internalConsumer.seekAsync(messageId);
+ beforeSeek();
+ final CompletableFuture<Void> future = new CompletableFuture<>();
+ internalConsumer.seekAsync(messageId).whenComplete((__, e) ->
afterSeek(future, e));
+ return future;
}
+ }
+ @Override
+ public CompletableFuture<Void> seekAsync(long timestamp) {
+ return seekAllAsync(consumer -> consumer.seekAsync(timestamp));
+ }
+
+ private CompletableFuture<Void> seekAllAsync(Function<ConsumerImpl<T>,
CompletableFuture<Void>> seekFunc) {
+ beforeSeek();
+ final CompletableFuture<Void> future = new CompletableFuture<>();
+
FutureUtil.waitForAll(consumers.values().stream().map(seekFunc).collect(Collectors.toList()))
+ .whenComplete((__, e) -> afterSeek(future, e));
+ return future;
+ }
+
+ private void beforeSeek() {
+ duringSeek = true;
Review Comment:
What if we have the second seek happened concurrently while handling the
first seek? There seems to be a chance that the consumer still be able to
receive messages during the second concurrent seek. Should we isolate them?
--
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]