Class SnapshotSplitReader
- java.lang.Object
-
- org.apache.flink.cdc.connectors.mysql.debezium.reader.SnapshotSplitReader
-
- All Implemented Interfaces:
DebeziumReader<SourceRecords,MySqlSplit>
public class SnapshotSplitReader extends Object implements DebeziumReader<SourceRecords,MySqlSplit>
A snapshot reader that reads data from Table in split level, the split is assigned by primary key range.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSnapshotSplitReader.SnapshotSplitChangeEventSourceContextImplChangeEventSource.ChangeEventSourceContextimplementation that keeps low/high watermark for eachMySqlSnapshotSplit.
-
Field Summary
Fields Modifier and Type Field Description AtomicBooleanhasNextElementAtomicBooleanreachEnd
-
Constructor Summary
Constructors Constructor Description SnapshotSplitReader(StatefulTaskContext statefulTaskContext, int subtaskId)SnapshotSplitReader(StatefulTaskContext statefulTaskContext, int subtaskId, SnapshotPhaseHooks hooks)SnapshotSplitReader(MySqlSourceConfig sourceConfig, int subtaskId, SnapshotPhaseHooks hooks)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the reader and releases all resources.ExecutorServicegetExecutorService()booleanisFinished()Return the current split of the reader is finished or not.Iterator<SourceRecords>pollSplitRecords()Reads records from MySQL.Iterator<SourceRecords>pollWithBuffer()Iterator<SourceRecords>pollWithoutBuffer()voidsubmitSplit(MySqlSplit mySqlSplit)Add to split to read, this should call only the when reader is idle.
-
-
-
Field Detail
-
hasNextElement
public AtomicBoolean hasNextElement
-
reachEnd
public AtomicBoolean reachEnd
-
-
Constructor Detail
-
SnapshotSplitReader
public SnapshotSplitReader(MySqlSourceConfig sourceConfig, int subtaskId, SnapshotPhaseHooks hooks)
-
SnapshotSplitReader
public SnapshotSplitReader(StatefulTaskContext statefulTaskContext, int subtaskId, SnapshotPhaseHooks hooks)
-
SnapshotSplitReader
public SnapshotSplitReader(StatefulTaskContext statefulTaskContext, int subtaskId)
-
-
Method Detail
-
submitSplit
public void submitSplit(MySqlSplit mySqlSplit)
Description copied from interface:DebeziumReaderAdd to split to read, this should call only the when reader is idle.- Specified by:
submitSplitin interfaceDebeziumReader<SourceRecords,MySqlSplit>
-
isFinished
public boolean isFinished()
Description copied from interface:DebeziumReaderReturn the current split of the reader is finished or not.- Specified by:
isFinishedin interfaceDebeziumReader<SourceRecords,MySqlSplit>
-
pollSplitRecords
@Nullable public Iterator<SourceRecords> pollSplitRecords() throws InterruptedException
Description copied from interface:DebeziumReaderReads records from MySQL. The method should return null when reaching the end of the split, the emptyIteratorwill be returned if the data of split is on pulling.- Specified by:
pollSplitRecordsin interfaceDebeziumReader<SourceRecords,MySqlSplit>- Throws:
InterruptedException
-
pollWithoutBuffer
public Iterator<SourceRecords> pollWithoutBuffer() throws InterruptedException
- Throws:
InterruptedException
-
pollWithBuffer
public Iterator<SourceRecords> pollWithBuffer() throws InterruptedException
- Throws:
InterruptedException
-
close
public void close()
Description copied from interface:DebeziumReaderClose the reader and releases all resources.- Specified by:
closein interfaceDebeziumReader<SourceRecords,MySqlSplit>
-
getExecutorService
@VisibleForTesting public ExecutorService getExecutorService()
-
-