public abstract class KafkaSource<K,V> extends java.lang.Object implements CheckpointableTask, ISource
| Modifier and Type | Field and Description |
|---|---|
protected Config |
cfg |
protected TaskContext |
context |
| Constructor and Description |
|---|
KafkaSource() |
| Modifier and Type | Method and Description |
|---|---|
void |
execute()
Execute without an incoming message
|
java.lang.String |
getConsumerGroup(TaskContext ctx)
This method returns the consumer group for this consumer.
|
abstract java.util.Properties |
getConsumerProperties() |
<any> |
getKafkaConsumer()
This method can be used to get the kafka consumer instance, which is created in
prepare(Config, TaskContext) method. |
abstract java.time.Duration |
getPollingTimeout() |
abstract java.util.Set<java.lang.String> |
getTopics() |
void |
initSnapshot(Snapshot snapshot)
This method could be used to predefine packers
|
void |
onCheckpointPropagated(Snapshot snapshot)
This method will be called immediately after task report it's version to the checkpoint master
|
void |
prepare(Config config,
TaskContext ctx)
Prepare the task to be executed
|
void |
restoreSnapshot(Snapshot snapshot)
This method will be called when task is initializing
|
void |
takeSnapshot(Snapshot snapshot)
Snapshot should be updated in this method with new values |
abstract void |
writeRecord(<any> kafkaRecord) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitonSnapshotPersistedprotected Config cfg
protected TaskContext context
public void prepare(Config config, TaskContext ctx)
INodepublic java.lang.String getConsumerGroup(TaskContext ctx)
ctx - Instance of TaskContextpublic abstract java.util.Properties getConsumerProperties()
public abstract java.util.Set<java.lang.String> getTopics()
public abstract void writeRecord(<any> kafkaRecord)
public abstract java.time.Duration getPollingTimeout()
public <any> getKafkaConsumer()
prepare(Config, TaskContext) method.public void execute()
ISourcepublic void restoreSnapshot(Snapshot snapshot)
CheckpointableTaskrestoreSnapshot in interface CheckpointableTaskpublic void takeSnapshot(Snapshot snapshot)
CheckpointableTaskSnapshot should be updated in this method with new valuestakeSnapshot in interface CheckpointableTaskpublic void onCheckpointPropagated(Snapshot snapshot)
CheckpointableTaskonCheckpointPropagated in interface CheckpointableTaskpublic void initSnapshot(Snapshot snapshot)
CheckpointableTaskinitSnapshot in interface CheckpointableTask