Class AbstractIncrementalSnapshotChangeEventSource<P extends Partition,T extends DataCollectionId>
java.lang.Object
io.debezium.pipeline.source.snapshot.incremental.AbstractIncrementalSnapshotChangeEventSource<P,T>
- All Implemented Interfaces:
IncrementalSnapshotChangeEventSource<P,T>
- Direct Known Subclasses:
SignalBasedIncrementalSnapshotChangeEventSource
@NotThreadSafe
public abstract class AbstractIncrementalSnapshotChangeEventSource<P extends Partition,T extends DataCollectionId>
extends Object
implements IncrementalSnapshotChangeEventSource<P,T>
An incremental snapshot change event source that emits events from a DB log interleaved with snapshot events.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Clockprivate final RelationalDatabaseConnectorConfigprotected IncrementalSnapshotContext<T>private Tableprivate final RelationalDatabaseSchemaprivate final DataChangeEventListener<P>protected EventDispatcher<P,T> protected JdbcConnectionprivate static final org.slf4j.Loggerprivate final SnapshotProgressListener<P>private long -
Constructor Summary
ConstructorsConstructorDescriptionAbstractIncrementalSnapshotChangeEventSource(RelationalDatabaseConnectorConfig config, JdbcConnection jdbcConnection, EventDispatcher<P, T> dispatcher, DatabaseSchema<?> databaseSchema, Clock clock, SnapshotProgressListener<P> progressListener, DataChangeEventListener<P> dataChangeEventListener) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDataCollectionNamesToSnapshot(P partition, List<String> dataCollectionIds, OffsetContext offsetContext) protected voidaddKeyColumnsToCondition(Table table, StringBuilder sql, String predicate) private voidaddLowerBound(Table table, StringBuilder sql) protected StringbuildChunkQuery(Table table) protected StringbuildChunkQuery(Table table, int limit) protected StringbuildMaxPrimaryKeyQuery(Table table) private booleanvoidcloseWindow(P partition, String id, OffsetContext offsetContext) private booleancreateDataEventsForTable(P partition) Dispatches the data change events for the records of a single table.protected voiddeduplicateWindow(DataCollectionId dataCollectionId, Object key) protected abstract voidemitWindowClose(P partition) Update high watermark for the incremental snapshot chunkprotected abstract voidUpdate low watermark for the incremental snapshot chunkprotected ChangeRecordEmitter<P>getChangeRecordEmitter(P partition, T dataCollectionId, OffsetContext offsetContext, Object[] row) Returns aChangeRecordEmitterproducing the change records for the given table row.private Key.KeyMapperprotected StringgetSignalTableName(String dataCollectionId) private Tableprivate Threads.Timerprivate voidincrementTableRowsScanned(P partition, long rows) voidinit(P partition, OffsetContext offsetContext) private booleanisTableInvalid(P partition) private Object[]keyFromRow(Object[] row) private voidnextDataCollection(P partition) protected voidprotected voidpostReadChunk(IncrementalSnapshotContext<T> context) protected voidpreReadChunk(IncrementalSnapshotContext<T> context) voidprocessSchemaChange(P partition, DataCollectionId dataCollectionId) protected voidprivate Tableprotected PreparedStatementprotected TablerefreshTableSchema(Table table) voidrereadChunk(P partition) private booleanVerifies that in-memory representation of the table’s schema is up to date with the table's schema in the database.protected voidsendEvent(P partition, EventDispatcher<P, T> dispatcher, OffsetContext offsetContext, Object[] row) protected voidsendWindowEvents(P partition, OffsetContext offsetContext) protected voidsetContext(IncrementalSnapshotContext<T> context) private voidtableScanCompleted(P partition) private voidVerifies that table's schema in the database has not changed since it was captured in the previous windowMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.debezium.pipeline.source.snapshot.incremental.IncrementalSnapshotChangeEventSource
processFilteredEvent, processHeartbeat, processMessage, processTransactionCommittedEvent, processTransactionStartedEvent
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
connectorConfig
-
clock
-
databaseSchema
-
progressListener
-
dataListener
-
totalRowsScanned
private long totalRowsScanned -
currentTable
-
dispatcher
-
context
-
jdbcConnection
-
window
-
-
Constructor Details
-
AbstractIncrementalSnapshotChangeEventSource
public AbstractIncrementalSnapshotChangeEventSource(RelationalDatabaseConnectorConfig config, JdbcConnection jdbcConnection, EventDispatcher<P, T> dispatcher, DatabaseSchema<?> databaseSchema, Clock clock, SnapshotProgressListener<P> progressListener, DataChangeEventListener<P> dataChangeEventListener)
-
-
Method Details
-
closeWindow
public void closeWindow(P partition, String id, OffsetContext offsetContext) throws InterruptedException - Specified by:
closeWindowin interfaceIncrementalSnapshotChangeEventSource<P extends Partition,T extends DataCollectionId> - Throws:
InterruptedException
-
processSchemaChange
public void processSchemaChange(P partition, DataCollectionId dataCollectionId) throws InterruptedException - Specified by:
processSchemaChangein interfaceIncrementalSnapshotChangeEventSource<P extends Partition,T extends DataCollectionId> - Throws:
InterruptedException
-
rereadChunk
- Throws:
InterruptedException
-
getSignalTableName
-
sendWindowEvents
protected void sendWindowEvents(P partition, OffsetContext offsetContext) throws InterruptedException - Throws:
InterruptedException
-
sendEvent
protected void sendEvent(P partition, EventDispatcher<P, T> dispatcher, OffsetContext offsetContext, Object[] row) throws InterruptedException- Throws:
InterruptedException
-
getChangeRecordEmitter
protected ChangeRecordEmitter<P> getChangeRecordEmitter(P partition, T dataCollectionId, OffsetContext offsetContext, Object[] row) Returns aChangeRecordEmitterproducing the change records for the given table row. -
deduplicateWindow
-
emitWindowOpen
Update low watermark for the incremental snapshot chunk- Throws:
SQLException
-
emitWindowClose
Update high watermark for the incremental snapshot chunk- Throws:
SQLExceptionInterruptedException
-
buildChunkQuery
-
buildChunkQuery
-
addLowerBound
-
buildMaxPrimaryKeyQuery
-
init
- Specified by:
initin interfaceIncrementalSnapshotChangeEventSource<P extends Partition,T extends DataCollectionId>
-
readChunk
- Throws:
InterruptedException
-
isTableInvalid
-
schemaHistoryIsUpToDate
private boolean schemaHistoryIsUpToDate()Verifies that in-memory representation of the table’s schema is up to date with the table's schema in the database.Verification is a two step process:
- Save table's schema from the database to the context
- Verify schema hasn't changed in the following window. If schema has changed repeat the process
Verification is done at the beginning of the incremental snapshot and on every schema change during the snapshotting.
-
verifySchemaUnchanged
private void verifySchemaUnchanged()Verifies that table's schema in the database has not changed since it was captured in the previous window -
readSchema
-
nextDataCollection
-
addDataCollectionNamesToSnapshot
public void addDataCollectionNamesToSnapshot(P partition, List<String> dataCollectionIds, OffsetContext offsetContext) throws InterruptedException - Specified by:
addDataCollectionNamesToSnapshotin interfaceIncrementalSnapshotChangeEventSource<P extends Partition,T extends DataCollectionId> - Throws:
InterruptedException
-
addKeyColumnsToCondition
-
createDataEventsForTable
Dispatches the data change events for the records of a single table. -
checkSchemaChanges
- Throws:
SQLException
-
getTable
- Throws:
SQLException
-
incrementTableRowsScanned
-
tableScanCompleted
-
readTableChunkStatement
- Throws:
SQLException
-
getTableScanLogTimer
-
keyFromRow
-
setContext
-
preReadChunk
-
postReadChunk
-
postIncrementalSnapshotCompleted
protected void postIncrementalSnapshotCompleted() -
refreshTableSchema
- Throws:
SQLException
-
getKeyMapper
-