Class MySqlSnapshotSplitAssigner
- java.lang.Object
-
- org.apache.flink.cdc.connectors.mysql.source.assigners.MySqlSnapshotSplitAssigner
-
- All Implemented Interfaces:
Closeable,AutoCloseable,MySqlSplitAssigner
public class MySqlSnapshotSplitAssigner extends Object implements MySqlSplitAssigner
AMySqlSplitAssignerthat splits tables into small chunk splits based on primary key range and chunk size.
-
-
Constructor Summary
Constructors Constructor Description MySqlSnapshotSplitAssigner(MySqlSourceConfig sourceConfig, int currentParallelism, List<io.debezium.relational.TableId> remainingTables, boolean isTableIdCaseSensitive, org.apache.flink.api.connector.source.SplitEnumeratorContext<MySqlSplit> enumeratorContext)MySqlSnapshotSplitAssigner(MySqlSourceConfig sourceConfig, int currentParallelism, SnapshotPendingSplitsState checkpoint, org.apache.flink.api.connector.source.SplitEnumeratorContext<MySqlSplit> enumeratorContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSplits(Collection<MySqlSplit> 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,MySqlSchemalessSnapshotSplit>getAssignedSplits()AssignerStatusgetAssignerStatus()Gets the split assigner status, seeAssignerStatus.List<FinishedSnapshotSplitInfo>getFinishedSplitInfos()Gets the finished splits' information.Optional<MySqlSplit>getNext()Gets the next split.Map<String,BinlogOffset>getSplitFinishedOffsets()Map<io.debezium.relational.TableId,io.debezium.relational.history.TableChanges.TableChange>getTableSchemas()booleanisSnapshotMetaReleased()Returns whetherreleaseSnapshotMetadata()has already been performed.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.voidonBinlogSplitUpdated()Callback to handle the binlog split has been updated in the newly added tables process.voidonFinishedSplits(Map<String,BinlogOffset> splitFinishedOffsets)Callback to handle the finished splits with finished binlog offset.voidopen()Called to open the assigner to acquire any resources, like threads or network connections.voidreleaseSnapshotMetadata()Releases the heavyweight snapshot split metadata (assigned splits, finished offsets, table schemas) after the binlog phase begins, so it is no longer held in the coordinator nor checkpointed.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
-
MySqlSnapshotSplitAssigner
public MySqlSnapshotSplitAssigner(MySqlSourceConfig sourceConfig, int currentParallelism, List<io.debezium.relational.TableId> remainingTables, boolean isTableIdCaseSensitive, org.apache.flink.api.connector.source.SplitEnumeratorContext<MySqlSplit> enumeratorContext)
-
MySqlSnapshotSplitAssigner
public MySqlSnapshotSplitAssigner(MySqlSourceConfig sourceConfig, int currentParallelism, SnapshotPendingSplitsState checkpoint, org.apache.flink.api.connector.source.SplitEnumeratorContext<MySqlSplit> enumeratorContext)
-
-
Method Detail
-
open
public void open()
Description copied from interface:MySqlSplitAssignerCalled to open the assigner to acquire any resources, like threads or network connections.- Specified by:
openin interfaceMySqlSplitAssigner
-
getNext
public Optional<MySqlSplit> getNext()
Description copied from interface:MySqlSplitAssignerGets 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 interfaceMySqlSplitAssigner
-
waitingForFinishedSplits
public boolean waitingForFinishedSplits()
Description copied from interface:MySqlSplitAssignerWhether the split assigner is still waiting for callback of finished splits, i.e.MySqlSplitAssigner.onFinishedSplits(Map).- Specified by:
waitingForFinishedSplitsin interfaceMySqlSplitAssigner
-
getFinishedSplitInfos
public List<FinishedSnapshotSplitInfo> getFinishedSplitInfos()
Description copied from interface:MySqlSplitAssignerGets the finished splits' information. This is useful metadata to generate a binlog split that considering finished snapshot splits.- Specified by:
getFinishedSplitInfosin interfaceMySqlSplitAssigner
-
onFinishedSplits
public void onFinishedSplits(Map<String,BinlogOffset> splitFinishedOffsets)
Description copied from interface:MySqlSplitAssignerCallback to handle the finished splits with finished binlog offset. This is useful for determine when to generate binlog split and what binlog split to generate.- Specified by:
onFinishedSplitsin interfaceMySqlSplitAssigner
-
addSplits
public void addSplits(Collection<MySqlSplit> splits)
Description copied from interface:MySqlSplitAssignerAdds 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 interfaceMySqlSplitAssigner
-
snapshotState
public SnapshotPendingSplitsState snapshotState(long checkpointId)
Description copied from interface:MySqlSplitAssignerCreates 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
MySqlSplitAssigner.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 interfaceMySqlSplitAssigner- 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:MySqlSplitAssignerNotifies the listener that the checkpoint with the givencheckpointIdcompleted and was committed.- Specified by:
notifyCheckpointCompletein interfaceMySqlSplitAssigner- See Also:
CheckpointListener.notifyCheckpointComplete(long)
-
getAssignerStatus
public AssignerStatus getAssignerStatus()
Description copied from interface:MySqlSplitAssignerGets the split assigner status, seeAssignerStatus.- Specified by:
getAssignerStatusin interfaceMySqlSplitAssigner
-
startAssignNewlyAddedTables
public void startAssignNewlyAddedTables()
Description copied from interface:MySqlSplitAssignerStarts assign newly added tables.- Specified by:
startAssignNewlyAddedTablesin interfaceMySqlSplitAssigner
-
onBinlogSplitUpdated
public void onBinlogSplitUpdated()
Description copied from interface:MySqlSplitAssignerCallback to handle the binlog 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:
onBinlogSplitUpdatedin interfaceMySqlSplitAssigner
-
close
public void close()
Description copied from interface:MySqlSplitAssignerCalled 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 interfaceMySqlSplitAssigner
-
noMoreSplits
public boolean noMoreSplits()
Indicates there is no more splits available in this assigner.- Specified by:
noMoreSplitsin interfaceMySqlSplitAssigner
-
needToDiscoveryTables
public boolean needToDiscoveryTables()
Indicates current assigner need to discovery tables or not.
-
getAssignedSplits
public Map<String,MySqlSchemalessSnapshotSplit> getAssignedSplits()
-
getTableSchemas
public Map<io.debezium.relational.TableId,io.debezium.relational.history.TableChanges.TableChange> getTableSchemas()
-
getSplitFinishedOffsets
public Map<String,BinlogOffset> getSplitFinishedOffsets()
-
releaseSnapshotMetadata
public void releaseSnapshotMetadata()
Releases the heavyweight snapshot split metadata (assigned splits, finished offsets, table schemas) after the binlog phase begins, so it is no longer held in the coordinator nor checkpointed. KeepsalreadyProcessedTablesand the assigner status so a restore does not re-discover tables. Only called once the binlog split is assigned and checkpoint-covered.
-
isSnapshotMetaReleased
public boolean isSnapshotMetaReleased()
Returns whetherreleaseSnapshotMetadata()has already been performed.
-
-