@Internal public class KafkaPartitionSplitReader extends Object implements SplitReader<org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]>,KafkaPartitionSplit>
SplitReader
implementation that reads records from Kafka partitions.Constructor and Description |
---|
KafkaPartitionSplitReader(Properties props,
SourceReaderContext context,
KafkaSourceReaderMetrics kafkaSourceReaderMetrics) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the split reader.
|
RecordsWithSplitIds<org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]>> |
fetch()
Fetch elements into the blocking queue for the given splits.
|
void |
handleSplitsChanges(SplitsChange<KafkaPartitionSplit> splitsChange)
Handle the split changes.
|
void |
notifyCheckpointComplete(Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> offsetsToCommit,
org.apache.kafka.clients.consumer.OffsetCommitCallback offsetCommitCallback) |
void |
wakeUp()
Wake up the split reader in case the fetcher thread is blocking in
SplitReader.fetch() . |
public KafkaPartitionSplitReader(Properties props, SourceReaderContext context, KafkaSourceReaderMetrics kafkaSourceReaderMetrics)
public RecordsWithSplitIds<org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]>> fetch() throws IOException
SplitReader
SplitReader.wakeUp()
is invoked. In that case, the
implementation may either decide to return without throwing an exception, or it can just
throw an interrupted exception. In either case, this method should be reentrant, meaning that
the next fetch call should just resume from where the last fetch call was waken up or
interrupted.fetch
in interface SplitReader<org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]>,KafkaPartitionSplit>
IOException
- when encountered IO errors, such as deserialization failures.public void handleSplitsChanges(SplitsChange<KafkaPartitionSplit> splitsChange)
SplitReader
For the consistency of internal state in SourceReaderBase, if an invalid split is added to
the reader (for example splits without any records), it should be put back into RecordsWithSplitIds
as finished splits so that SourceReaderBase could be able to clean up
resources created for it.
handleSplitsChanges
in interface SplitReader<org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]>,KafkaPartitionSplit>
splitsChange
- the split changes that the SplitReader needs to handle.public void wakeUp()
SplitReader
SplitReader.fetch()
.wakeUp
in interface SplitReader<org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]>,KafkaPartitionSplit>
public void close() throws Exception
SplitReader
close
in interface SplitReader<org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]>,KafkaPartitionSplit>
Exception
- if closing the split reader failed.public void notifyCheckpointComplete(Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> offsetsToCommit, org.apache.kafka.clients.consumer.OffsetCommitCallback offsetCommitCallback)
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.