AHeise commented on a change in pull request #15304: URL: https://github.com/apache/flink/pull/15304#discussion_r686748710
########## File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/reader/split/PulsarOrderedPartitionSplitReader.java ########## @@ -0,0 +1,100 @@ +/* + * 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.flink.connector.pulsar.source.reader.split; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.connector.pulsar.common.config.ConfigurationDataCustomizer; +import org.apache.flink.connector.pulsar.source.config.SourceConfiguration; +import org.apache.flink.connector.pulsar.source.enumerator.topic.TopicPartition; +import org.apache.flink.connector.pulsar.source.reader.deserializer.PulsarDeserializationSchema; +import org.apache.flink.connector.pulsar.source.reader.source.PulsarOrderedSourceReader; +import org.apache.flink.connector.pulsar.source.split.PulsarPartitionSplit; + +import org.apache.pulsar.client.admin.PulsarAdmin; +import org.apache.pulsar.client.api.Consumer; +import org.apache.pulsar.client.api.Message; +import org.apache.pulsar.client.api.MessageId; +import org.apache.pulsar.client.api.PulsarClient; +import org.apache.pulsar.client.impl.conf.ConsumerConfigurationData; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.time.Duration; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import static org.apache.flink.connector.pulsar.common.utils.PulsarExceptionUtils.sneakyClient; + +/** + * The split reader a given {@link PulsarPartitionSplit}, it would be closed once the {@link + * PulsarOrderedSourceReader} is closed. + * + * @param <OUT> the type of the pulsar source message that would be serialized to downstream. + */ +@Internal +public class PulsarOrderedPartitionSplitReader<OUT> extends PulsarPartitionSplitReaderBase<OUT> { + private static final Logger LOG = + LoggerFactory.getLogger(PulsarOrderedPartitionSplitReader.class); + + public PulsarOrderedPartitionSplitReader( + PulsarClient pulsarClient, + PulsarAdmin pulsarAdmin, + Configuration configuration, + SourceConfiguration sourceConfiguration, + ConfigurationDataCustomizer<ConsumerConfigurationData<byte[]>> + consumerConfigurationCustomizer, + PulsarDeserializationSchema<OUT> deserializationSchema) { + super( + pulsarClient, + pulsarAdmin, + configuration, + sourceConfiguration, + consumerConfigurationCustomizer, + deserializationSchema); + } + + @Override + protected Message<byte[]> pollMessage(Duration timeout) + throws ExecutionException, InterruptedException, TimeoutException { + return pulsarConsumer.receiveAsync().get(timeout.toMillis(), TimeUnit.MILLISECONDS); Review comment: Okay thanks for the explanation. Just a last question for clarification: Even if we don't use `batchReceiveAsync`, there is some internal batching in Pulsar, such that `receiveAsync` rarely involves real I/O. -- 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]
