You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2017/10/24 18:15:23 UTC
[GitHub] merlimat commented on a change in pull request #849: Implement seekToBeginning()/end operations in Kafka consumer wrapper
merlimat commented on a change in pull request #849: Implement seekToBeginning()/end operations in Kafka consumer wrapper
URL: https://github.com/apache/incubator-pulsar/pull/849#discussion_r146647835
##########
File path: pulsar-client-kafka-compat/pulsar-client-kafka/src/main/java/org/apache/kafka/clients/consumer/PulsarKafkaConsumer.java
##########
@@ -383,17 +394,57 @@ public void commitAsync(Map<TopicPartition, OffsetAndMetadata> offsets, OffsetCo
@Override
public void seek(TopicPartition partition, long offset) {
- throw new UnsupportedOperationException();
+ MessageId msgId = MessageIdUtils.getMessageId(offset);
+ org.apache.pulsar.client.api.Consumer c = consumers.get(partition);
+ if (c == null) {
+ throw new IllegalArgumentException("Cannot seek on a partition where we are not subscribed");
+ }
+
+ try {
+ c.seek(msgId);
+ } catch (PulsarClientException e) {
+ throw new RuntimeException(e);
+ }
}
@Override
public void seekToBeginning(Collection<TopicPartition> partitions) {
- throw new UnsupportedOperationException();
+ List<CompletableFuture<Void>> futures = new ArrayList<>();
+
+ if (partitions.isEmpty()) {
+ partitions = consumers.keySet();
+ }
+
+ for (TopicPartition tp : partitions) {
+ org.apache.pulsar.client.api.Consumer c = consumers.get(tp);
+ if (c == null) {
+ throw new IllegalArgumentException("Cannot seek on a partition where we are not subscribed");
Review comment:
Sure, this was more of a sanity-check, but makes sense to be consistent and always use the future
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services