Class MySqlHybridSplitAssigner
- java.lang.Object
-
- org.apache.flink.cdc.connectors.mysql.source.assigners.MySqlHybridSplitAssigner
-
- All Implemented Interfaces:
Closeable,AutoCloseable,MySqlSplitAssigner
public class MySqlHybridSplitAssigner extends Object implements MySqlSplitAssigner
AMySqlSplitAssignerthat splits tables into small chunk splits based on primary key range and chunk size and also continue with a binlog split.
-
-
Constructor Summary
Constructors Constructor Description MySqlHybridSplitAssigner(MySqlSourceConfig sourceConfig, int currentParallelism, List<io.debezium.relational.TableId> remainingTables, boolean isTableIdCaseSensitive, org.apache.flink.api.connector.source.SplitEnumeratorContext<MySqlSplit> enumeratorContext)MySqlHybridSplitAssigner(MySqlSourceConfig sourceConfig, int currentParallelism, HybridPendingSplitsState 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.AssignerStatusgetAssignerStatus()Gets the split assigner status, seeAssignerStatus.longgetBinlogAssignmentGeneration()Returns the current binlog split assignment generation.List<FinishedSnapshotSplitInfo>getFinishedSplitInfos()Gets the finished splits' information.Optional<MySqlSplit>getNext()Gets the next split.booleanisSnapshotMetaReleased()Returns whether the snapshot split metadata has been released.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.voidonBinlogReaderReset()Invalidates any in-flight binlog split assembly when the binlog reader resets, so a stale assembled event from the failed attempt cannot arm a release.voidonBinlogSplitMetaAssembled(long reportedGeneration)Marks that the reader holds the complete binlog split, arming the metadata release.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.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.
-
-
-
Constructor Detail
-
MySqlHybridSplitAssigner
public MySqlHybridSplitAssigner(MySqlSourceConfig sourceConfig, int currentParallelism, List<io.debezium.relational.TableId> remainingTables, boolean isTableIdCaseSensitive, org.apache.flink.api.connector.source.SplitEnumeratorContext<MySqlSplit> enumeratorContext)
-
MySqlHybridSplitAssigner
public MySqlHybridSplitAssigner(MySqlSourceConfig sourceConfig, int currentParallelism, HybridPendingSplitsState 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
-
onBinlogReaderReset
public void onBinlogReaderReset()
Invalidates any in-flight binlog split assembly when the binlog reader resets, so a stale assembled event from the failed attempt cannot arm a release. Also runs when the split is not handed back, since a checkpoint-covered reset produces an empty add-back.
-
snapshotState
public PendingSplitsState 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)
-
onBinlogSplitMetaAssembled
public void onBinlogSplitMetaAssembled(long reportedGeneration)
Marks that the reader holds the complete binlog split, arming the metadata release. A reported generation that is neither the current one nor the inline sentinel is ignored, which drops a stale event from a reader attempt that an add-back has already superseded.
-
getBinlogAssignmentGeneration
public long getBinlogAssignmentGeneration()
Returns the current binlog split assignment generation.
-
isSnapshotMetaReleased
public boolean isSnapshotMetaReleased()
Returns whether the snapshot split metadata has been released.
-
getAssignerStatus
public AssignerStatus getAssignerStatus()
Description copied from interface:MySqlSplitAssignerGets the split assigner status, seeAssignerStatus.- Specified by:
getAssignerStatusin interfaceMySqlSplitAssigner
-
noMoreSplits
public boolean noMoreSplits()
Description copied from interface:MySqlSplitAssignerIndicates there is no more splits available in this assigner.- Specified by:
noMoreSplitsin 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
-
-