Package org.apache.kafka.connect.tools
Class MockSourceTask
java.lang.Object
org.apache.kafka.connect.source.SourceTask
org.apache.kafka.connect.tools.MockSourceTask
- All Implemented Interfaces:
Task
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.kafka.connect.source.SourceTask
SourceTask.TransactionBoundary
-
Field Summary
Fields inherited from class org.apache.kafka.connect.source.SourceTask
context, TRANSACTION_BOUNDARY_CONFIG
-
Constructor Summary
-
Method Summary
Methods inherited from class org.apache.kafka.connect.source.SourceTask
commit, commitRecord, commitRecord, initialize
-
Constructor Details
-
MockSourceTask
public MockSourceTask()
-
-
Method Details
-
version
Description copied from interface:Task
Get the version of this task. Usually this should be the same as the correspondingConnector
class's version.- Returns:
- the version, formatted as a String
-
start
Description copied from class:SourceTask
Start the Task. This should handle any configuration parsing and one-time setup of the task.- Specified by:
start
in interfaceTask
- Specified by:
start
in classSourceTask
- Parameters:
config
- initial configuration
-
poll
Description copied from class:SourceTask
Poll this source task for new records. If no data is currently available, this method should block but return control to the caller regularly (by returningnull
) in order for the task to transition to thePAUSED
state if requested to do so.The task will be
stopped
on a separate thread, and when that happens this method is expected to unblock, quickly finish up any remaining processing, and return.- Specified by:
poll
in classSourceTask
- Returns:
- a list of source records
-
stop
public void stop()Description copied from class:SourceTask
Signal this SourceTask to stop. In SourceTasks, this method only needs to signal to the task that it should stop trying to poll for new data and interrupt any outstanding poll() requests. It is not required that the task has fully stopped. Note that this method necessarily may be invoked from a different thread thanSourceTask.poll()
andSourceTask.commit()
.For example, if a task uses a
Selector
to receive data over the network, this method could set a flag that will forceSourceTask.poll()
to exit immediately and invokewakeup()
to interrupt any ongoing requests.- Specified by:
stop
in interfaceTask
- Specified by:
stop
in classSourceTask
-