Interface Reader

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  Reader.State
      The possible states of a reader.
    • Method Detail

      • name

        String name()
        Get the name of this reader.
        Returns:
        the reader's name; never null
      • state

        Reader.State state()
        Get the current state of this reader.
        Returns:
        the state; never null
      • uponCompletion

        void uponCompletion​(Runnable handler)
        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.

        Parameters:
        handler - the function; may not be null
      • initialize

        default void initialize()
        Perform any initialization of the reader before being started. This method should be called exactly once before start() is called, and it should block until all initialization is completed.
      • destroy

        default void destroy()
        After the reader has stopped, there may still be some resources we want left available until the connector task is destroyed. This method is used to clean up those remaining resources upon shutdown. This method is effectively the opposite of initialize(), performing any de-initialization of the reader entity before shutdown. This method should be called exactly once after stop() is called, and it should block until all de-initialization is completed.
      • start

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

        This method does nothing if it is already running.

      • poll

        List<org.apache.kafka.connect.source.SourceRecord> poll()
                                                         throws InterruptedException
        Poll for the next batch of source records. This method returns null only when all records generated by this reader have been processed, following the natural or explicit stopping of this reader. Note that this method may block if no additional records are available but the reader may produce more, thus callers should call this method continually until this method returns null.
        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
        org.apache.kafka.connect.errors.ConnectException - if there is an error while this reader is running