Class SplitFetcherManager<E,SplitT extends org.apache.flink.api.connector.source.SourceSplit>
java.lang.Object
org.apache.flink.connector.base.source.reader.fetcher.SplitFetcherManager<E,SplitT>
- Direct Known Subclasses:
SingleThreadFetcherManager
@PublicEvolving
public abstract class SplitFetcherManager<E,SplitT extends org.apache.flink.api.connector.source.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.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSplitFetcherManager(Supplier<SplitReader<E, SplitT>> splitReaderFactory, org.apache.flink.configuration.Configuration configuration) Create a split fetcher manager.SplitFetcherManager(Supplier<SplitReader<E, SplitT>> splitReaderFactory, org.apache.flink.configuration.Configuration configuration, Consumer<Collection<String>> splitFinishedHook) Create a split fetcher manager. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidvoidvoidclose(long timeoutMs) Close the split fetcher manager.protected SplitFetcher<E,SplitT> Synchronize method to ensure no fetcher is created after the split fetcher manager has closed.intgetQueue()Return the queue contains data produced by split fetchers.This method is Internal and only used inSourceReaderBase.booleanCheck and shutdown the fetchers that have completed their work.voidpauseOrResumeSplits(Collection<String> splitIdsToPause, Collection<String> splitIdsToResume) abstract voidremoveSplits(List<SplitT> splitsToRemove) protected voidstartFetcher(SplitFetcher<E, SplitT> fetcher)
-
Field Details
-
fetchers
protected final Map<Integer,SplitFetcher<E, fetchersSplitT extends org.apache.flink.api.connector.source.SourceSplit>> A map keeping track of all the split fetchers.
-
-
Constructor Details
-
SplitFetcherManager
public SplitFetcherManager(Supplier<SplitReader<E, SplitT>> splitReaderFactory, org.apache.flink.configuration.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, org.apache.flink.configuration.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 Details
-
addSplits
-
removeSplits
-
pauseOrResumeSplits
public void pauseOrResumeSplits(Collection<String> splitIdsToPause, Collection<String> splitIdsToResume) -
startFetcher
-
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.
-
getQueue
Return the queue contains data produced by split fetchers.This method is Internal and only used inSourceReaderBase. -
close
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() -
getNumAliveFetchers
@VisibleForTesting public int getNumAliveFetchers()
-