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, wait
onSnapshotPersisted
protected Config cfg
protected TaskContext context
public void prepare(Config config, TaskContext ctx)
INode
public java.lang.String getConsumerGroup(TaskContext ctx)
ctx
- Instance of TaskContext
public 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()
ISource
public void restoreSnapshot(Snapshot snapshot)
CheckpointableTask
restoreSnapshot
in interface CheckpointableTask
public void takeSnapshot(Snapshot snapshot)
CheckpointableTask
Snapshot
should be updated in this method with new valuestakeSnapshot
in interface CheckpointableTask
public void onCheckpointPropagated(Snapshot snapshot)
CheckpointableTask
onCheckpointPropagated
in interface CheckpointableTask
public void initSnapshot(Snapshot snapshot)
CheckpointableTask
initSnapshot
in interface CheckpointableTask