Class SplitFetcherManager<E,​SplitT extends SourceSplit>

  • Direct Known Subclasses:
    SingleThreadFetcherManager

    @PublicEvolving
    public abstract class SplitFetcherManager<E,​SplitT extends SourceSplit>
    extends Object
    A class responsible for starting the SplitFetcher and manage the life cycles of them. This class works with the SourceReaderBase.

    The split fetcher manager could be used to support different threading models by implementing the addSplits(List) method differently. For example, a single thread split fetcher manager would only start a single fetcher and assign all the splits to it. A one-thread-per-split fetcher may spawn a new thread every time a new split is assigned.

    • Constructor Detail

      • SplitFetcherManager

        public SplitFetcherManager​(Supplier<SplitReader<E,​SplitT>> splitReaderFactory,
                                   Configuration configuration)
        Create a split fetcher manager.
        Parameters:
        splitReaderFactory - a supplier that could be used to create split readers.
        configuration - the configuration of this fetcher manager.
      • SplitFetcherManager

        public SplitFetcherManager​(Supplier<SplitReader<E,​SplitT>> splitReaderFactory,
                                   Configuration configuration,
                                   Consumer<Collection<String>> splitFinishedHook)
        Create a split fetcher manager.
        Parameters:
        splitReaderFactory - a supplier that could be used to create split readers.
        configuration - the configuration of this fetcher manager.
        splitFinishedHook - Hook for handling finished splits in split fetchers.
    • Method Detail

      • addSplits

        public abstract void addSplits​(List<SplitT> splitsToAdd)
      • removeSplits

        public abstract void removeSplits​(List<SplitT> splitsToRemove)
      • createSplitFetcher

        protected SplitFetcher<E,​SplitT> createSplitFetcher()
        Synchronize method to ensure no fetcher is created after the split fetcher manager has closed.
        Returns:
        the created split fetcher.
        Throws:
        IllegalStateException - if the split fetcher manager has closed.
      • maybeShutdownFinishedFetchers

        public boolean maybeShutdownFinishedFetchers()
        Check and shutdown the fetchers that have completed their work.
        Returns:
        true if all the fetchers have completed the work, false otherwise.
      • close

        public void close​(long timeoutMs)
                   throws Exception
        Close the split fetcher manager.
        Parameters:
        timeoutMs - the max time in milliseconds to wait.
        Throws:
        Exception - when failed to close the split fetcher manager.
      • checkErrors

        public void checkErrors()