Class BaseSourceTask<P extends Partition,​O extends OffsetContext>

  • All Implemented Interfaces:
    org.apache.kafka.connect.connector.Task

    public abstract class BaseSourceTask<P extends Partition,​O extends OffsetContext>
    extends org.apache.kafka.connect.source.SourceTask
    Base class for Debezium's CDC SourceTask implementations. Provides functionality common to all connectors, such as validation of the configuration.
    Author:
    Gunnar Morling
    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • INITIAL_POLL_PERIOD_IN_MILLIS

        private static final long INITIAL_POLL_PERIOD_IN_MILLIS
      • MAX_POLL_PERIOD_IN_MILLIS

        private static final long MAX_POLL_PERIOD_IN_MILLIS
      • stateLock

        private final ReentrantLock stateLock
        Used to ensure that start(), stop() and commitRecord() calls are serialized.
      • props

        private volatile Map<String,​String> props
        Raw connector properties, kept here so they can be passed again in case of a restart.
      • lastOffset

        private volatile Map<String,​?> lastOffset
        The latest offset that has been acknowledged by the Kafka producer. Will be acknowledged with the source database in commit() (which may be a no-op depending on the connector).
      • retriableRestartWait

        private Duration retriableRestartWait
      • clock

        private final Clock clock
      • recordCounter

        private long recordCounter
      • previousOutputInstant

        private Instant previousOutputInstant
    • Constructor Detail

      • BaseSourceTask

        protected BaseSourceTask()
    • Method Detail

      • start

        public final void start​(Map<String,​String> props)
        Specified by:
        start in interface org.apache.kafka.connect.connector.Task
        Specified by:
        start in class org.apache.kafka.connect.source.SourceTask
      • start

        protected abstract ChangeEventSourceCoordinator<P,​O> start​(Configuration config)
        Called once when starting this source task.
        Parameters:
        config - the task configuration; implementations should wrap it in a dedicated implementation of CommonConnectorConfig and work with typed access to configuration properties that way
      • logStatistics

        void logStatistics​(List<org.apache.kafka.connect.source.SourceRecord> records)
      • startIfNeededAndPossible

        private boolean startIfNeededAndPossible()
        Starts this connector in case it has been stopped after a retriable error, and the backoff period has passed.
      • stop

        public final void stop()
        Specified by:
        stop in interface org.apache.kafka.connect.connector.Task
        Specified by:
        stop in class org.apache.kafka.connect.source.SourceTask
      • stop

        private void stop​(boolean restart)
      • doStop

        protected abstract void doStop()
      • commitRecord

        public void commitRecord​(org.apache.kafka.connect.source.SourceRecord record)
                          throws InterruptedException
        Overrides:
        commitRecord in class org.apache.kafka.connect.source.SourceTask
        Throws:
        InterruptedException
      • getAllConfigurationFields

        protected abstract Iterable<Field> getAllConfigurationFields()
        Returns all configuration Field supported by this source task.