T - The type of elements deserialized from Pulsar messages, and emitted into
the Flink data stream.public class PulsarFetcher<T> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected org.apache.pulsar.client.impl.conf.ClientConfigurationData |
clientConf |
protected PulsarDeserializationSchema<T> |
deserializer |
protected Set<TopicRange> |
excludeStartMessageIds |
protected PulsarMetadataReader |
metadataReader |
protected int |
pollTimeoutMs |
protected Map<String,Object> |
readerConf |
protected Map<TopicRange,org.apache.pulsar.client.api.MessageId> |
seedTopicsWithInitialOffsets |
protected org.apache.flink.streaming.api.functions.source.SourceFunction.SourceContext<T> |
sourceContext
The source context to emit records and watermarks to.
|
protected List<PulsarTopicState<T>> |
subscribedPartitionStates
All partitions (and their state) that this fetcher is subscribed to.
|
protected ClosableBlockingQueue<PulsarTopicState<T>> |
unassignedPartitionsQueue
Queue of partitions that are not yet assigned to any reader thread for consuming.
|
protected org.apache.flink.api.common.eventtime.WatermarkOutput |
watermarkOutput
Wrapper around our SourceContext for allowing the
WatermarkGenerator
to emit watermarks and mark idleness. |
| Constructor and Description |
|---|
PulsarFetcher(org.apache.flink.streaming.api.functions.source.SourceFunction.SourceContext<T> sourceContext,
Map<TopicRange,org.apache.pulsar.client.api.MessageId> seedTopicsWithInitialOffsets,
org.apache.flink.util.SerializedValue<org.apache.flink.api.common.eventtime.WatermarkStrategy<T>> watermarkStrategy,
org.apache.flink.streaming.runtime.tasks.ProcessingTimeService processingTimeProvider,
long autoWatermarkInterval,
ClassLoader userCodeClassLoader,
org.apache.flink.streaming.api.operators.StreamingRuntimeContext runtimeContext,
org.apache.pulsar.client.impl.conf.ClientConfigurationData clientConf,
Map<String,Object> readerConf,
int pollTimeoutMs,
PulsarDeserializationSchema<T> deserializer,
PulsarMetadataReader metadataReader,
org.apache.flink.metrics.MetricGroup consumerMetricGroup,
boolean useMetrics) |
PulsarFetcher(org.apache.flink.streaming.api.functions.source.SourceFunction.SourceContext<T> sourceContext,
Map<TopicRange,org.apache.pulsar.client.api.MessageId> seedTopicsWithInitialOffsets,
Set<TopicRange> excludeStartMessageIds,
org.apache.flink.util.SerializedValue<org.apache.flink.api.common.eventtime.WatermarkStrategy<T>> watermarkStrategy,
org.apache.flink.streaming.runtime.tasks.ProcessingTimeService processingTimeProvider,
long autoWatermarkInterval,
ClassLoader userCodeClassLoader,
org.apache.flink.streaming.api.operators.StreamingRuntimeContext runtimeContext,
org.apache.pulsar.client.impl.conf.ClientConfigurationData clientConf,
Map<String,Object> readerConf,
int pollTimeoutMs,
int commitMaxRetries,
PulsarDeserializationSchema<T> deserializer,
PulsarMetadataReader metadataReader,
org.apache.flink.metrics.MetricGroup consumerMetricGroup,
boolean useMetrics) |
| Modifier and Type | Method and Description |
|---|---|
void |
addDiscoveredTopics(Set<TopicRange> newTopics) |
void |
cancel() |
void |
commitOffsetToPulsar(Map<TopicRange,org.apache.pulsar.client.api.MessageId> offset,
PulsarCommitCallback offsetCommitCallback) |
Map<TopicRange,ReaderThread<T>> |
createAndStartReaderThread(List<PulsarTopicState<T>> states,
ExceptionProxy exceptionProxy) |
protected ReaderThread<T> |
createReaderThread(ExceptionProxy exceptionProxy,
PulsarTopicState state) |
protected void |
doCommitOffsetToPulsar(Map<TopicRange,org.apache.pulsar.client.api.MessageId> offset,
PulsarCommitCallback offsetCommitCallback) |
protected void |
emitRecordsWithTimestamps(T record,
PulsarTopicState<T> partitionState,
org.apache.pulsar.client.api.MessageId offset,
long pulsarEventTimestamp)
Emits a record attaching a timestamp to it.
|
PulsarMetadataReader |
getMetaDataReader() |
protected List<PulsarTopicState<T>> |
getSubscribedTopicStates() |
Map<TopicRange,org.apache.pulsar.client.api.MessageId> |
removeEarliestAndLatest(Map<TopicRange,org.apache.pulsar.client.api.MessageId> offset) |
void |
runFetchLoop() |
Map<TopicRange,org.apache.pulsar.client.api.MessageId> |
snapshotCurrentState()
Takes a snapshot of the partition offsets.
|
protected final org.apache.flink.streaming.api.functions.source.SourceFunction.SourceContext<T> sourceContext
protected final Map<TopicRange,org.apache.pulsar.client.api.MessageId> seedTopicsWithInitialOffsets
protected final Set<TopicRange> excludeStartMessageIds
protected final List<PulsarTopicState<T>> subscribedPartitionStates
protected final ClosableBlockingQueue<PulsarTopicState<T>> unassignedPartitionsQueue
All partitions added to this queue are guaranteed to have been added
to subscribedPartitionStates already.
protected final org.apache.pulsar.client.impl.conf.ClientConfigurationData clientConf
protected final PulsarDeserializationSchema<T> deserializer
protected final int pollTimeoutMs
protected final PulsarMetadataReader metadataReader
protected final org.apache.flink.api.common.eventtime.WatermarkOutput watermarkOutput
WatermarkGenerator
to emit watermarks and mark idleness.public PulsarFetcher(org.apache.flink.streaming.api.functions.source.SourceFunction.SourceContext<T> sourceContext, Map<TopicRange,org.apache.pulsar.client.api.MessageId> seedTopicsWithInitialOffsets, org.apache.flink.util.SerializedValue<org.apache.flink.api.common.eventtime.WatermarkStrategy<T>> watermarkStrategy, org.apache.flink.streaming.runtime.tasks.ProcessingTimeService processingTimeProvider, long autoWatermarkInterval, ClassLoader userCodeClassLoader, org.apache.flink.streaming.api.operators.StreamingRuntimeContext runtimeContext, org.apache.pulsar.client.impl.conf.ClientConfigurationData clientConf, Map<String,Object> readerConf, int pollTimeoutMs, PulsarDeserializationSchema<T> deserializer, PulsarMetadataReader metadataReader, org.apache.flink.metrics.MetricGroup consumerMetricGroup, boolean useMetrics) throws Exception
Exceptionpublic PulsarFetcher(org.apache.flink.streaming.api.functions.source.SourceFunction.SourceContext<T> sourceContext, Map<TopicRange,org.apache.pulsar.client.api.MessageId> seedTopicsWithInitialOffsets, Set<TopicRange> excludeStartMessageIds, org.apache.flink.util.SerializedValue<org.apache.flink.api.common.eventtime.WatermarkStrategy<T>> watermarkStrategy, org.apache.flink.streaming.runtime.tasks.ProcessingTimeService processingTimeProvider, long autoWatermarkInterval, ClassLoader userCodeClassLoader, org.apache.flink.streaming.api.operators.StreamingRuntimeContext runtimeContext, org.apache.pulsar.client.impl.conf.ClientConfigurationData clientConf, Map<String,Object> readerConf, int pollTimeoutMs, int commitMaxRetries, PulsarDeserializationSchema<T> deserializer, PulsarMetadataReader metadataReader, org.apache.flink.metrics.MetricGroup consumerMetricGroup, boolean useMetrics) throws Exception
Exceptionprotected void emitRecordsWithTimestamps(T record, PulsarTopicState<T> partitionState, org.apache.pulsar.client.api.MessageId offset, long pulsarEventTimestamp)
record - The record to emitpartitionState - The state of the pulsar partition from which the record was fetchedoffset - The offset of the corresponding pulsar recordpulsarEventTimestamp - The timestamp of the pulsar recordpublic void commitOffsetToPulsar(Map<TopicRange,org.apache.pulsar.client.api.MessageId> offset, PulsarCommitCallback offsetCommitCallback) throws InterruptedException
InterruptedExceptionprotected void doCommitOffsetToPulsar(Map<TopicRange,org.apache.pulsar.client.api.MessageId> offset, PulsarCommitCallback offsetCommitCallback) throws InterruptedException
InterruptedExceptionpublic Map<TopicRange,org.apache.pulsar.client.api.MessageId> removeEarliestAndLatest(Map<TopicRange,org.apache.pulsar.client.api.MessageId> offset)
public void addDiscoveredTopics(Set<TopicRange> newTopics) throws IOException, ClassNotFoundException
IOExceptionClassNotFoundExceptionpublic Map<TopicRange,org.apache.pulsar.client.api.MessageId> snapshotCurrentState()
Important: This method must be called under the checkpoint lock.
public Map<TopicRange,ReaderThread<T>> createAndStartReaderThread(List<PulsarTopicState<T>> states, ExceptionProxy exceptionProxy)
protected List<PulsarTopicState<T>> getSubscribedTopicStates()
protected ReaderThread<T> createReaderThread(ExceptionProxy exceptionProxy, PulsarTopicState state)
public PulsarMetadataReader getMetaDataReader()
Copyright © 2019–2021 The Apache Software Foundation. All rights reserved.