Class MySqlBinlogSplitAssigner
- java.lang.Object
-
- org.apache.flink.cdc.connectors.mysql.source.assigners.MySqlBinlogSplitAssigner
-
- All Implemented Interfaces:
Closeable,AutoCloseable,MySqlSplitAssigner
public class MySqlBinlogSplitAssigner extends Object implements MySqlSplitAssigner
AMySqlSplitAssignerwhich only read binlog from current binlog position.
-
-
Field Summary
Fields Modifier and Type Field Description static StringBINLOG_SPLIT_ID
-
Constructor Summary
Constructors Constructor Description MySqlBinlogSplitAssigner(MySqlSourceConfig sourceConfig)MySqlBinlogSplitAssigner(MySqlSourceConfig sourceConfig, BinlogPendingSplitsState checkpoint)
-
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.List<FinishedSnapshotSplitInfo>getFinishedSplitInfos()Gets the finished splits' information.Optional<MySqlSplit>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.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.
-
-
-
Field Detail
-
BINLOG_SPLIT_ID
public static final String BINLOG_SPLIT_ID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MySqlBinlogSplitAssigner
public MySqlBinlogSplitAssigner(MySqlSourceConfig sourceConfig)
-
MySqlBinlogSplitAssigner
public MySqlBinlogSplitAssigner(MySqlSourceConfig sourceConfig, BinlogPendingSplitsState checkpoint)
-
-
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 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)
-
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() throws IOExceptionDescription 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- Throws:
IOException
-
-