Class SnapshotSplitAssigner<C extends SourceConfig>
- java.lang.Object
-
- org.apache.flink.cdc.connectors.base.source.assigner.SnapshotSplitAssigner<C>
-
- All Implemented Interfaces:
Closeable,AutoCloseable,SplitAssigner
public class SnapshotSplitAssigner<C extends SourceConfig> extends Object implements SplitAssigner
Assigner for snapshot split.
-
-
Constructor Summary
Constructors Constructor Description SnapshotSplitAssigner(C sourceConfig, int currentParallelism, List<io.debezium.relational.TableId> remainingTables, boolean isTableIdCaseSensitive, DataSourceDialect<C> dialect, OffsetFactory offsetFactory)SnapshotSplitAssigner(C sourceConfig, int currentParallelism, SnapshotPendingSplitsState checkpoint, DataSourceDialect<C> dialect, OffsetFactory offsetFactory)
-
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.Map<String,SchemalessSnapshotSplit>getAssignedSplits()AssignerStatusgetAssignerStatus()Gets the split assigner status, seeAssignerStatus.List<FinishedSnapshotSplitInfo>getFinishedSplitInfos()Gets the finished splits' information.Optional<SourceSplitBase>getNext()Gets the next split.Map<String,Offset>getSplitFinishedOffsets()Map<io.debezium.relational.TableId,io.debezium.relational.history.TableChanges.TableChange>getTableSchemas()voidinitEnumeratorMetrics(SourceEnumeratorMetrics enumeratorMetrics)This must be invoked before this class'sopen()method, becauseopen()starts an asynchronous splitting thread that concurrently mutatesremainingSplits.booleanisSnapshotMetaReleased()Returns whetherSplitAssigner.releaseSnapshotMetadata()has dropped the snapshot metadata.booleanneedToDiscoveryTables()Indicates current assigner need to discovery tables or not.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.voidreleaseSnapshotMetadata()Releases the bulk snapshot-split metadata once the reader has assembled it and a checkpoint has covered that assignment.SnapshotPendingSplitsStatesnapshotState(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.
-
-
-
Constructor Detail
-
SnapshotSplitAssigner
public SnapshotSplitAssigner(C sourceConfig, int currentParallelism, List<io.debezium.relational.TableId> remainingTables, boolean isTableIdCaseSensitive, DataSourceDialect<C> dialect, OffsetFactory offsetFactory)
-
SnapshotSplitAssigner
public SnapshotSplitAssigner(C sourceConfig, int currentParallelism, SnapshotPendingSplitsState checkpoint, DataSourceDialect<C> dialect, OffsetFactory offsetFactory)
-
-
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
-
initEnumeratorMetrics
public void initEnumeratorMetrics(SourceEnumeratorMetrics enumeratorMetrics)
This must be invoked before this class'sopen()method, becauseopen()starts an asynchronous splitting thread that concurrently mutatesremainingSplits.
-
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 SnapshotPendingSplitsState 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)
-
releaseSnapshotMetadata
public void releaseSnapshotMetadata()
Releases the bulk snapshot-split metadata once the reader has assembled it and a checkpoint has covered that assignment. Clears the metadata maps but keepsalreadyProcessedTables, the assigner status and the chunk-splitter state so a restore does not re-discover tables or rebuild the stream split. Generalizes the MySQL mechanism (FLINK-39775).- Specified by:
releaseSnapshotMetadatain interfaceSplitAssigner
-
isSnapshotMetaReleased
public boolean isSnapshotMetaReleased()
Description copied from interface:SplitAssignerReturns whetherSplitAssigner.releaseSnapshotMetadata()has dropped the snapshot metadata.- Specified by:
isSnapshotMetaReleasedin 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
-
noMoreSplits
public boolean noMoreSplits()
Description copied from interface:SplitAssignerIndicates there is no more splits available in this assigner.- Specified by:
noMoreSplitsin interfaceSplitAssigner
-
needToDiscoveryTables
public boolean needToDiscoveryTables()
Indicates current assigner need to discovery tables or not.
-
getAssignedSplits
public Map<String,SchemalessSnapshotSplit> getAssignedSplits()
-
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
-
getTableSchemas
public Map<io.debezium.relational.TableId,io.debezium.relational.history.TableChanges.TableChange> getTableSchemas()
-
-