Class StreamSplitAssigner
- java.lang.Object
-
- org.apache.flink.cdc.connectors.base.source.assigner.StreamSplitAssigner
-
- All Implemented Interfaces:
Closeable,AutoCloseable,SplitAssigner
public class StreamSplitAssigner extends Object implements SplitAssigner
Assigner for stream split.
-
-
Constructor Summary
Constructors Constructor Description StreamSplitAssigner(SourceConfig sourceConfig, DataSourceDialect dialect, OffsetFactory offsetFactory, org.apache.flink.api.connector.source.SplitEnumeratorContext<? extends org.apache.flink.api.connector.source.SourceSplit> enumeratorContext)StreamSplitAssigner(SourceConfig sourceConfig, StreamPendingSplitsState checkpoint, DataSourceDialect dialect, OffsetFactory offsetFactory, org.apache.flink.api.connector.source.SplitEnumeratorContext<? extends org.apache.flink.api.connector.source.SourceSplit> enumeratorContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSplits(Collection<SourceSplitBase> splits)Adds a set of splits to this assigner.voidclose()Called to close the assigner, in case it holds on to any resources, like threads or network connections.StreamSplitcreateStreamSplit()AssignerStatusgetAssignerStatus()Gets the split assigner status, seeAssignerStatus.List<FinishedSnapshotSplitInfo>getFinishedSplitInfos()Gets the finished splits' information.Optional<SourceSplitBase>getNext()Gets the next split.booleannoMoreSplits()Indicates there is no more splits available in this assigner.voidnotifyCheckpointComplete(long checkpointId)Notifies the listener that the checkpoint with the givencheckpointIdcompleted and was committed.voidonFinishedSplits(Map<String,Offset> splitFinishedOffsets)Callback to handle the finished splits with finished change log offset.voidonStreamSplitUpdated()Callback to handle the stream split has been updated in the newly added tables process.voidopen()Called to open the assigner to acquire any resources, like threads or network connections.PendingSplitsStatesnapshotState(long checkpointId)Creates a snapshot of the state of this split assigner, to be stored in a checkpoint.voidstartAssignNewlyAddedTables()Starts assign newly added tables.booleanwaitingForFinishedSplits()Whether the split assigner is still waiting for callback of finished splits, i.e.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.cdc.connectors.base.source.assigner.SplitAssigner
isSnapshotMetaReleased, releaseSnapshotMetadata
-
-
-
-
Constructor Detail
-
StreamSplitAssigner
public StreamSplitAssigner(SourceConfig sourceConfig, DataSourceDialect dialect, OffsetFactory offsetFactory, org.apache.flink.api.connector.source.SplitEnumeratorContext<? extends org.apache.flink.api.connector.source.SourceSplit> enumeratorContext)
-
StreamSplitAssigner
public StreamSplitAssigner(SourceConfig sourceConfig, StreamPendingSplitsState checkpoint, DataSourceDialect dialect, OffsetFactory offsetFactory, org.apache.flink.api.connector.source.SplitEnumeratorContext<? extends org.apache.flink.api.connector.source.SourceSplit> enumeratorContext)
-
-
Method Detail
-
open
public void open()
Description copied from interface:SplitAssignerCalled to open the assigner to acquire any resources, like threads or network connections.- Specified by:
openin interfaceSplitAssigner
-
getNext
public Optional<SourceSplitBase> getNext()
Description copied from interface:SplitAssignerGets the next split.When this method returns an empty
Optional, then the set of splits is assumed to be done and the source will finish once the readers finished their current splits.- Specified by:
getNextin interfaceSplitAssigner
-
waitingForFinishedSplits
public boolean waitingForFinishedSplits()
Description copied from interface:SplitAssignerWhether the split assigner is still waiting for callback of finished splits, i.e.SplitAssigner.onFinishedSplits(Map).- Specified by:
waitingForFinishedSplitsin interfaceSplitAssigner
-
getFinishedSplitInfos
public List<FinishedSnapshotSplitInfo> getFinishedSplitInfos()
Description copied from interface:SplitAssignerGets the finished splits' information. This is useful metadata to generate a stream split that considering finished snapshot splits.- Specified by:
getFinishedSplitInfosin interfaceSplitAssigner
-
onFinishedSplits
public void onFinishedSplits(Map<String,Offset> splitFinishedOffsets)
Description copied from interface:SplitAssignerCallback to handle the finished splits with finished change log offset. This is useful for determine when to generate stream split and what stream split to generate.- Specified by:
onFinishedSplitsin interfaceSplitAssigner
-
addSplits
public void addSplits(Collection<SourceSplitBase> splits)
Description copied from interface:SplitAssignerAdds a set of splits to this assigner. This happens for example when some split processing failed and the splits need to be re-added.- Specified by:
addSplitsin interfaceSplitAssigner
-
snapshotState
public PendingSplitsState snapshotState(long checkpointId)
Description copied from interface:SplitAssignerCreates a snapshot of the state of this split assigner, to be stored in a checkpoint.The snapshot should contain the latest state of the assigner: It should assume that all operations that happened before the snapshot have successfully completed. For example all splits assigned to readers via
SplitAssigner.getNext()don't need to be included in the snapshot anymore.This method takes the ID of the checkpoint for which the state is snapshotted. Most implementations should be able to ignore this parameter, because for the contents of the snapshot, it doesn't matter for which checkpoint it gets created. This parameter can be interesting for source connectors with external systems where those systems are themselves aware of checkpoints; for example in cases where the enumerator notifies that system about a specific checkpoint being triggered.
- Specified by:
snapshotStatein interfaceSplitAssigner- Parameters:
checkpointId- The ID of the checkpoint for which the snapshot is created.- Returns:
- an object containing the state of the split enumerator.
-
notifyCheckpointComplete
public void notifyCheckpointComplete(long checkpointId)
Description copied from interface:SplitAssignerNotifies the listener that the checkpoint with the givencheckpointIdcompleted and was committed.- Specified by:
notifyCheckpointCompletein interfaceSplitAssigner- See Also:
CheckpointListener.notifyCheckpointComplete(long)
-
getAssignerStatus
public AssignerStatus getAssignerStatus()
Description copied from interface:SplitAssignerGets the split assigner status, seeAssignerStatus.- Specified by:
getAssignerStatusin interfaceSplitAssigner
-
startAssignNewlyAddedTables
public void startAssignNewlyAddedTables()
Description copied from interface:SplitAssignerStarts assign newly added tables.- Specified by:
startAssignNewlyAddedTablesin interfaceSplitAssigner
-
onStreamSplitUpdated
public void onStreamSplitUpdated()
Description copied from interface:SplitAssignerCallback to handle the stream split has been updated in the newly added tables process. This is useful to check the newly added tables has been finished or not.- Specified by:
onStreamSplitUpdatedin interfaceSplitAssigner
-
noMoreSplits
public boolean noMoreSplits()
Description copied from interface:SplitAssignerIndicates there is no more splits available in this assigner.- Specified by:
noMoreSplitsin interfaceSplitAssigner
-
close
public void close() throws IOExceptionDescription copied from interface:SplitAssignerCalled to close the assigner, in case it holds on to any resources, like threads or network connections.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceSplitAssigner- Throws:
IOException
-
createStreamSplit
public StreamSplit createStreamSplit()
-
-