Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2DE6C200D61 for ; Tue, 19 Dec 2017 16:10:38 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 2C0E9160C1B; Tue, 19 Dec 2017 15:10:38 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 6F58D160C18 for ; Tue, 19 Dec 2017 16:10:37 +0100 (CET) Received: (qmail 71191 invoked by uid 500); 19 Dec 2017 15:10:36 -0000 Mailing-List: contact commits-help@pulsar.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pulsar.incubator.apache.org Delivered-To: mailing list commits@pulsar.incubator.apache.org Received: (qmail 71182 invoked by uid 99); 19 Dec 2017 15:10:36 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Dec 2017 15:10:36 +0000 From: GitBox To: commits@pulsar.apache.org Subject: [GitHub] ivankelly commented on a change in pull request #962: Raw Reader for Pulsar Topics Message-ID: <151369623612.19538.6356559832423960166.gitbox@gitbox.apache.org> archived-at: Tue, 19 Dec 2017 15:10:38 -0000 ivankelly commented on a change in pull request #962: Raw Reader for Pulsar Topics URL: https://github.com/apache/incubator-pulsar/pull/962#discussion_r157780399 ########## File path: pulsar-broker/src/main/java/org/apache/pulsar/client/impl/RawReaderImpl.java ########## @@ -0,0 +1,174 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pulsar.client.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.Queue; +import java.util.UUID; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.TimeUnit; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.pulsar.client.api.Consumer; +import org.apache.pulsar.client.api.ConsumerConfiguration; +import org.apache.pulsar.client.api.MessageId; +import org.apache.pulsar.client.api.PulsarClientException; +import org.apache.pulsar.client.api.RawReader; +import org.apache.pulsar.client.api.RawMessage; +import org.apache.pulsar.client.api.SubscriptionType; +import org.apache.pulsar.client.impl.PulsarClientImpl; +import org.apache.pulsar.client.impl.ConsumerImpl.SubscriptionMode; +import org.apache.pulsar.common.api.proto.PulsarApi.MessageIdData; +import org.apache.pulsar.common.util.collections.GrowableArrayBlockingQueue; +import io.netty.buffer.ByteBuf; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RawReaderImpl implements RawReader { + + final static int DEFAULT_RECEIVER_QUEUE_SIZE = 1000; + private final PulsarClientImpl client; + private final String topic; + private final String subscription; + private final ConsumerConfiguration consumerConfiguration; + private RawConsumerImpl consumer; + + public RawReaderImpl(PulsarClientImpl client, String topic, CompletableFuture consumerFuture) { + this.client = client; + this.topic = topic; + + subscription = "raw-reader"; + + consumerConfiguration = new ConsumerConfiguration(); + consumerConfiguration.setSubscriptionType(SubscriptionType.Exclusive); + consumerConfiguration.setReceiverQueueSize(DEFAULT_RECEIVER_QUEUE_SIZE); + + consumer = new RawConsumerImpl(client, topic, subscription, consumerConfiguration, + consumerFuture); + } + + @Override + public CompletableFuture seekAsync(MessageId messageId) { + return consumer.seekAsync(messageId); + } + + @Override + public CompletableFuture readNextAsync() { + return consumer.receiveRawAsync(); + } + + @Override + public CompletableFuture closeAsync() { + return consumer.closeAsync(); + } + + class RawConsumerImpl extends ConsumerImpl { Review comment: done ---------------------------------------------------------------- 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