Class SignalBasedIncrementalSnapshotChangeEventSource<T extends DataCollectionId>
- java.lang.Object
-
- io.debezium.pipeline.source.snapshot.incremental.SignalBasedIncrementalSnapshotChangeEventSource<T>
-
- All Implemented Interfaces:
IncrementalSnapshotChangeEventSource<T>
@NotThreadSafe public class SignalBasedIncrementalSnapshotChangeEventSource<T extends DataCollectionId> extends Object implements IncrementalSnapshotChangeEventSource<T>
-
-
Field Summary
Fields Modifier and Type Field Description private Clockclockprivate CommonConnectorConfigconnectorConfigprivate IncrementalSnapshotContext<T>contextprivate TablecurrentTableprivate RelationalDatabaseSchemadatabaseSchemaprivate DataChangeEventListenerdataListenerprivate JdbcConnectionjdbcConnectionprivate static org.slf4j.LoggerLOGGERprivate SnapshotProgressListenerprogressListenerprivate StringsignalWindowStatementprivate longtotalRowsScannedprivate Map<org.apache.kafka.connect.data.Struct,Object[]>window
-
Constructor Summary
Constructors Constructor Description SignalBasedIncrementalSnapshotChangeEventSource(CommonConnectorConfig config, JdbcConnection jdbcConnection, DatabaseSchema<?> databaseSchema, Clock clock, SnapshotProgressListener progressListener, DataChangeEventListener dataChangeEventListener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDataCollectionNamesToSnapshot(List<String> dataCollectionIds, OffsetContext offsetContext)protected voidaddKeyColumnsToCondition(Table table, StringBuilder sql, String predicate)protected StringbuildChunkQuery(Table table)protected StringbuildMaxPrimaryKeyQuery(Table table)voidcloseWindow(String id, EventDispatcher<T> dispatcher, OffsetContext offsetContext)private voidcreateDataEventsForTable()Dispatches the data change events for the records of a single table.private voidemitWindowClose()private voidemitWindowOpen()protected ChangeRecordEmittergetChangeRecordEmitter(T dataCollectionId, OffsetContext offsetContext, Object[] row)Returns aChangeRecordEmitterproducing the change records for the given table row.private Threads.TimergetTableScanLogTimer()private voidincrementTableRowsScanned(long rows)voidinit(OffsetContext offsetContext)private Object[]keyFromRow(Object[] row)voidprocessMessage(DataCollectionId dataCollectionId, Object key, OffsetContext offsetContext)private voidreadChunk()protected PreparedStatementreadTableChunkStatement(String sql)protected voidsendEvent(EventDispatcher<T> dispatcher, OffsetContext offsetContext, Object[] row)protected voidsetContext(IncrementalSnapshotContext<T> context)private voidtableScanCompleted()
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
connectorConfig
private CommonConnectorConfig connectorConfig
-
jdbcConnection
private JdbcConnection jdbcConnection
-
clock
private final Clock clock
-
signalWindowStatement
private final String signalWindowStatement
-
databaseSchema
private final RelationalDatabaseSchema databaseSchema
-
progressListener
private final SnapshotProgressListener progressListener
-
dataListener
private final DataChangeEventListener dataListener
-
totalRowsScanned
private long totalRowsScanned
-
currentTable
private Table currentTable
-
context
private IncrementalSnapshotContext<T extends DataCollectionId> context
-
-
Constructor Detail
-
SignalBasedIncrementalSnapshotChangeEventSource
public SignalBasedIncrementalSnapshotChangeEventSource(CommonConnectorConfig config, JdbcConnection jdbcConnection, DatabaseSchema<?> databaseSchema, Clock clock, SnapshotProgressListener progressListener, DataChangeEventListener dataChangeEventListener)
-
-
Method Detail
-
closeWindow
public void closeWindow(String id, EventDispatcher<T> dispatcher, OffsetContext offsetContext) throws InterruptedException
- Specified by:
closeWindowin interfaceIncrementalSnapshotChangeEventSource<T extends DataCollectionId>- Throws:
InterruptedException
-
sendEvent
protected void sendEvent(EventDispatcher<T> dispatcher, OffsetContext offsetContext, Object[] row) throws InterruptedException
- Throws:
InterruptedException
-
getChangeRecordEmitter
protected ChangeRecordEmitter getChangeRecordEmitter(T dataCollectionId, OffsetContext offsetContext, Object[] row)
Returns aChangeRecordEmitterproducing the change records for the given table row.
-
processMessage
public void processMessage(DataCollectionId dataCollectionId, Object key, OffsetContext offsetContext)
- Specified by:
processMessagein interfaceIncrementalSnapshotChangeEventSource<T extends DataCollectionId>
-
emitWindowOpen
private void emitWindowOpen() throws SQLException- Throws:
SQLException
-
emitWindowClose
private void emitWindowClose() throws SQLException- Throws:
SQLException
-
init
public void init(OffsetContext offsetContext)
- Specified by:
initin interfaceIncrementalSnapshotChangeEventSource<T extends DataCollectionId>
-
readChunk
private void readChunk() throws InterruptedException- Throws:
InterruptedException
-
addDataCollectionNamesToSnapshot
public void addDataCollectionNamesToSnapshot(List<String> dataCollectionIds, OffsetContext offsetContext) throws InterruptedException
- Specified by:
addDataCollectionNamesToSnapshotin interfaceIncrementalSnapshotChangeEventSource<T extends DataCollectionId>- Throws:
InterruptedException
-
addKeyColumnsToCondition
protected void addKeyColumnsToCondition(Table table, StringBuilder sql, String predicate)
-
createDataEventsForTable
private void createDataEventsForTable() throws InterruptedExceptionDispatches the data change events for the records of a single table.- Throws:
InterruptedException
-
incrementTableRowsScanned
private void incrementTableRowsScanned(long rows)
-
tableScanCompleted
private void tableScanCompleted()
-
readTableChunkStatement
protected PreparedStatement readTableChunkStatement(String sql) throws SQLException
- Throws:
SQLException
-
getTableScanLogTimer
private Threads.Timer getTableScanLogTimer()
-
setContext
protected void setContext(IncrementalSnapshotContext<T> context)
-
-