Class BlockingReader

  • All Implemented Interfaces:
    Reader
    Direct Known Subclasses:
    TimedBlockingReader

    public class BlockingReader
    extends Object
    implements Reader
    A component that blocks doing nothing until the connector task is stopped
    Author:
    Peter Goransson
    • Constructor Detail

      • BlockingReader

        public BlockingReader​(String name,
                              String runningLogMessage)
    • Method Detail

      • poll

        public List<org.apache.kafka.connect.source.SourceRecord> poll()
                                                                throws InterruptedException
        Does nothing until the connector task is shut down, but regularly returns control back to Connect in order for being paused if requested.
        Specified by:
        poll in interface Reader
        Returns:
        the list of source records that may or may not be empty; or null when there will be no more records because the reader has completely Reader.State.STOPPED.
        Throws:
        InterruptedException - if this thread is interrupted while waiting for more records
      • state

        public Reader.State state()
        Description copied from interface: Reader
        Get the current state of this reader.
        Specified by:
        state in interface Reader
        Returns:
        the state; never null
      • uponCompletion

        public void uponCompletion​(Runnable handler)
        Description copied from interface: Reader
        Set the function that should be called when this reader transitions from the Reader.State.STOPPING to Reader.State.STOPPED state, which is after all generated records have been consumed via the poll method.

        This method should only be called while the reader is in the Reader.State.STOPPED state.

        Specified by:
        uponCompletion in interface Reader
        Parameters:
        handler - the function; may not be null
      • start

        public void start()
        Description copied from interface: Reader
        Start the reader and return immediately. Once started, the SourceRecords generated by the reader can be obtained by periodically calling Reader.poll() until that method returns null.

        This method does nothing if it is already running.

        Specified by:
        start in interface Reader
      • name

        public String name()
        Description copied from interface: Reader
        Get the name of this reader.
        Specified by:
        name in interface Reader
        Returns:
        the reader's name; never null