public abstract class FlinkKafkaConsumerBase<T> extends RichParallelSourceFunction<T> implements org.apache.flink.runtime.state.CheckpointListener, CheckpointedAsynchronously<HashMap<KafkaTopicPartition,Long>>, org.apache.flink.api.java.typeutils.ResultTypeQueryable<T>
SourceFunction.SourceContext<T>| Modifier and Type | Field and Description |
|---|---|
protected KeyedDeserializationSchema<T> |
deserializer
The schema to convert between Kafka#s byte messages, and Flink's objects
|
static int |
MAX_NUM_PENDING_CHECKPOINTS
The maximum number of pending non-committed checkpoints to track, to avoid memory leaks
|
protected HashMap<KafkaTopicPartition,Long> |
offsetsState
The offsets of the last returned elements
|
protected org.apache.commons.collections.map.LinkedMap |
pendingCheckpoints
Data for pending but uncommitted checkpoints
|
protected HashMap<KafkaTopicPartition,Long> |
restoreToOffset
The offsets to restore to, if the consumer restores state from a checkpoint
|
protected boolean |
running
Flag indicating whether the consumer is still running
|
| Constructor and Description |
|---|
FlinkKafkaConsumerBase(KeyedDeserializationSchema<T> deserializer,
Properties props)
Creates a new Flink Kafka Consumer, using the given type of fetcher and offset handler.
|
| Modifier and Type | Method and Description |
|---|---|
protected static <T> List<T> |
assignPartitions(List<T> partitions,
int numConsumers,
int consumerIndex) |
protected abstract void |
commitOffsets(HashMap<KafkaTopicPartition,Long> checkpointOffsets) |
org.apache.flink.api.common.typeinfo.TypeInformation<T> |
getProducedType() |
static void |
logPartitionInfo(List<KafkaTopicPartition> partitionInfos)
Method to log partition information.
|
void |
notifyCheckpointComplete(long checkpointId) |
void |
restoreState(HashMap<KafkaTopicPartition,Long> restoredOffsets) |
HashMap<KafkaTopicPartition,Long> |
snapshotState(long checkpointId,
long checkpointTimestamp) |
close, getIterationRuntimeContext, getRuntimeContext, open, setRuntimeContextclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcancel, runpublic static final int MAX_NUM_PENDING_CHECKPOINTS
protected final KeyedDeserializationSchema<T> deserializer
protected final org.apache.commons.collections.map.LinkedMap pendingCheckpoints
protected transient HashMap<KafkaTopicPartition,Long> offsetsState
protected transient HashMap<KafkaTopicPartition,Long> restoreToOffset
protected volatile boolean running
public FlinkKafkaConsumerBase(KeyedDeserializationSchema<T> deserializer, Properties props)
To determine which kink of fetcher and offset handler to use, please refer to the docs at the beginnign of this class.
deserializer - The deserializer to turn raw byte messages into Java/Scala objects.props - The properties that are used to configure both the fetcher and the offset handler.public HashMap<KafkaTopicPartition,Long> snapshotState(long checkpointId, long checkpointTimestamp) throws Exception
snapshotState in interface Checkpointed<HashMap<KafkaTopicPartition,Long>>Exceptionpublic void restoreState(HashMap<KafkaTopicPartition,Long> restoredOffsets)
restoreState in interface Checkpointed<HashMap<KafkaTopicPartition,Long>>public void notifyCheckpointComplete(long checkpointId)
throws Exception
notifyCheckpointComplete in interface org.apache.flink.runtime.state.CheckpointListenerExceptionprotected abstract void commitOffsets(HashMap<KafkaTopicPartition,Long> checkpointOffsets) throws Exception
Exceptionpublic org.apache.flink.api.common.typeinfo.TypeInformation<T> getProducedType()
getProducedType in interface org.apache.flink.api.java.typeutils.ResultTypeQueryable<T>protected static <T> List<T> assignPartitions(List<T> partitions, int numConsumers, int consumerIndex)
public static void logPartitionInfo(List<KafkaTopicPartition> partitionInfos)
partitionInfos - List of subscribed partitionsCopyright © 2014–2016 The Apache Software Foundation. All rights reserved.