Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added statechart to illustrate states of SourceTask

...

Current stateUnder Discussion

Discussion thread: here [Change the link from the KIP proposal email archive to your own email thread]
JIRA: here [Change the link from KAFKA-1 to your own ticket] https://lists.apache.org/thread.html/597d794a2a43b2568224d7db3a5c832e2166d2825ed7bf95102ceb25@%3Cdev.kafka.apache.org%3E

JIRA:

Jira
serverASF JIRA
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyKAFKA-7841

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

...

Add the new stopped() callback to the SourceTask interface. In the Kafka Connect runtime, call this method as the final call to the SourceTask interface once it is known that all activity on the task has indeed stopped.

Here's a diagram of the states of the SourceTask.

Image Added

The states are not formally part of the code, but there are essentially 4 states:

  • uninitialized - the SourceTask has been instantiated but not initialized. When initialize() is called by Kafka Connect, the SourceTask moves into initialized state.
  • initialized - the SourceTask has been initialized but not started. When start() is called by Kafka Connect, the SourceTask moves into running state.
  • running - the SourceTask has been started. Kafka Connect regularly calls poll() to receive records from the source system. As each record is acknowledged by Kafka (or discarded), Kafka Connect calls commitRecord(). Periodically on another thread, Kafka Connect calls commit(). When stop() is called by Kafka Connect, the SourceTask moves into stopping state.
  • stopping - The stop() call is intended to interrupt a blocking call to poll(), but it's not necessarily the case that poll() is blocking when it is called. So, any of poll(), commit() and commitRecord() can still be called. Usually, an active call to poll() completes and the current batch completes processing, followed by a final call to commit(). However, commit() is also running on another thread so the precise sequence of calls is a bit variable. When it's all quiesced, stopped() is called by Kafka Connect and the SourceTask can release all resources.

The addition in this KIP is just the call to stopped().

Compatibility, Deprecation, and Migration Plan

...