Class MongoDbIncrementalSnapshotChangeEventSource
java.lang.Object
io.debezium.connector.mongodb.snapshot.MongoDbIncrementalSnapshotChangeEventSource
- All Implemented Interfaces:
IncrementalSnapshotChangeEventSource<MongoDbPartition,CollectionId>
@NotThreadSafe
public class MongoDbIncrementalSnapshotChangeEventSource
extends Object
implements IncrementalSnapshotChangeEventSource<MongoDbPartition,CollectionId>
An incremental snapshot change event source that emits events from a MongoDB change stream interleaved with snapshot events.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Clockprivate final MongoDbSchemaprivate final MongoDbConnectorConfigprotected IncrementalSnapshotContext<CollectionId>private MongoDbCollectionSchemaprivate final DataChangeEventListener<MongoDbPartition>protected EventDispatcher<MongoDbPartition,CollectionId> private static final Stringprivate final ExecutorServiceprivate static final org.slf4j.Loggerprivate MongoDbConnectionprotected final NotificationService<MongoDbPartition,? extends OffsetContext> private final SnapshotProgressListener<MongoDbPartition>private final CollectionIdprivate final MongoDbTaskContextprivate long -
Constructor Summary
ConstructorsConstructorDescriptionMongoDbIncrementalSnapshotChangeEventSource(MongoDbConnectorConfig config, MongoDbTaskContext taskContext, EventDispatcher<MongoDbPartition, CollectionId> dispatcher, MongoDbSchema collectionSchema, Clock clock, SnapshotProgressListener<MongoDbPartition> progressListener, DataChangeEventListener<MongoDbPartition> dataChangeEventListener, NotificationService<MongoDbPartition, ? extends OffsetContext> notificationService) -
Method Summary
Modifier and TypeMethodDescriptionprotected Object[]addChunkToExecutor(com.mongodb.client.MongoCollection<org.bson.BsonDocument> collection, Object[] lastRow, List<Future<?>> futureList, Object[] lastChunkKey) voidaddDataCollectionNamesToSnapshot(SignalPayload<MongoDbPartition> signalPayload, SnapshotConfiguration snapshotConfiguration) voidcloseWindow(MongoDbPartition partition, String id, OffsetContext offsetContext) private voidcollectionScanCompleted(MongoDbPartition partition) private org.bson.DocumentconstructQueryPredicate(Object[] startKey, Object[] endKey, String additionalConditions) private voidDispatches the data change events for the records of a single table.protected voiddeduplicateWindow(io.debezium.spi.schema.DataCollectionId dataCollectionId, Object key) protected voidemitWindowClose(Partition partition, OffsetContext offsetContext) Update high watermark for the incremental snapshot chunkprotected voidUpdate low watermark for the incremental snapshot chunkexpandAndDedupeDataCollectionIds(List<String> collectionIds) Expands the string-based list of data collection ids if supplied using regex to a list of all matching explicit data collection ids.private Stringprotected ChangeRecordEmitter<MongoDbPartition>getChangeRecordEmitter(MongoDbPartition partition, OffsetContext offsetContext, Object[] row) Returns aChangeRecordEmitterproducing the change records for the given table row.private static MongoDbOffsetContextgetMongoDbOffsetContext(OffsetContext offsetContext) private StringgetStripedAdditionalConditions(String additionalConditions) private Threads.Timerprivate WatermarkWindowClosergetWatermarkWindowCloser(CommonConnectorConfig connectorConfig, MongoDbConnection mongoDbConnection, CollectionId collectionId) private voidincrementTableRowsScanned(long rows) voidinit(MongoDbPartition partition, OffsetContext offsetContext) private Object[]keyFromRow(Object[] row) private voidnextDataCollection(MongoDbPartition partition, OffsetContext offsetContext) voidpauseSnapshot(MongoDbPartition partition, OffsetContext offsetContext) protected voidprotected voidprotected voidvoidprocessMessage(MongoDbPartition partition, io.debezium.spi.schema.DataCollectionId dataCollectionId, Object key, OffsetContext offsetContext) private voidqueryChunk(com.mongodb.client.MongoCollection<org.bson.BsonDocument> collection, Object[] startKey, Object[] endKey) protected voidreadChunk(MongoDbPartition partition, OffsetContext offsetContext) private Object[]voidresumeSnapshot(MongoDbPartition partition, OffsetContext offsetContext) protected voidsendEvent(EventDispatcher<MongoDbPartition, CollectionId> dispatcher, MongoDbPartition partition, MongoDbOffsetContext offsetContext, Object[] row) protected voidsendWindowEvents(MongoDbPartition partition, MongoDbOffsetContext offsetContext) protected voidsetContext(IncrementalSnapshotContext<CollectionId> context) voidstopSnapshot(MongoDbPartition partition, OffsetContext offsetContext, Map<String, Object> additionalData, List<String> dataCollectionPatterns) Methods 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, processSchemaChange, processTransactionCommittedEvent, processTransactionStartedEvent
-
Field Details
-
DOCUMENT_ID
- See Also:
-
LOGGER
private static final org.slf4j.Logger LOGGER -
connectorConfig
-
taskContext
-
clock
-
collectionSchema
-
progressListener
-
dataListener
-
totalRowsScanned
private long totalRowsScanned -
currentCollection
-
dispatcher
-
context
-
window
-
mongo
-
signallingCollectionId
-
notificationService
-
incrementalSnapshotThreadPool
-
-
Constructor Details
-
MongoDbIncrementalSnapshotChangeEventSource
public MongoDbIncrementalSnapshotChangeEventSource(MongoDbConnectorConfig config, MongoDbTaskContext taskContext, EventDispatcher<MongoDbPartition, CollectionId> dispatcher, MongoDbSchema collectionSchema, Clock clock, SnapshotProgressListener<MongoDbPartition> progressListener, DataChangeEventListener<MongoDbPartition> dataChangeEventListener, NotificationService<MongoDbPartition, ? extends OffsetContext> notificationService)
-
-
Method Details
-
closeWindow
public void closeWindow(MongoDbPartition partition, String id, OffsetContext offsetContext) throws InterruptedException - Specified by:
closeWindowin interfaceIncrementalSnapshotChangeEventSource<MongoDbPartition,CollectionId> - Throws:
InterruptedException
-
pauseSnapshot
public void pauseSnapshot(MongoDbPartition partition, OffsetContext offsetContext) throws InterruptedException - Specified by:
pauseSnapshotin interfaceIncrementalSnapshotChangeEventSource<MongoDbPartition,CollectionId> - Throws:
InterruptedException
-
resumeSnapshot
public void resumeSnapshot(MongoDbPartition partition, OffsetContext offsetContext) throws InterruptedException - Specified by:
resumeSnapshotin interfaceIncrementalSnapshotChangeEventSource<MongoDbPartition,CollectionId> - Throws:
InterruptedException
-
sendWindowEvents
protected void sendWindowEvents(MongoDbPartition partition, MongoDbOffsetContext offsetContext) throws InterruptedException - Throws:
InterruptedException
-
sendEvent
protected void sendEvent(EventDispatcher<MongoDbPartition, CollectionId> dispatcher, MongoDbPartition partition, MongoDbOffsetContext offsetContext, Object[] row) throws InterruptedException- Throws:
InterruptedException
-
getMongoDbOffsetContext
-
getChangeRecordEmitter
protected ChangeRecordEmitter<MongoDbPartition> getChangeRecordEmitter(MongoDbPartition partition, OffsetContext offsetContext, Object[] row) Returns aChangeRecordEmitterproducing the change records for the given table row. -
deduplicateWindow
protected void deduplicateWindow(io.debezium.spi.schema.DataCollectionId dataCollectionId, Object key) -
emitWindowOpen
Update low watermark for the incremental snapshot chunk- Throws:
InterruptedException
-
emitWindowClose
Update high watermark for the incremental snapshot chunk- Throws:
Exception
-
getWatermarkWindowCloser
private WatermarkWindowCloser getWatermarkWindowCloser(CommonConnectorConfig connectorConfig, MongoDbConnection mongoDbConnection, CollectionId collectionId) -
init
- Specified by:
initin interfaceIncrementalSnapshotChangeEventSource<MongoDbPartition,CollectionId>
-
readChunk
protected void readChunk(MongoDbPartition partition, OffsetContext offsetContext) throws InterruptedException - Throws:
InterruptedException
-
nextDataCollection
-
readMaximumKey
- Throws:
InterruptedException
-
addDataCollectionNamesToSnapshot
public void addDataCollectionNamesToSnapshot(SignalPayload<MongoDbPartition> signalPayload, SnapshotConfiguration snapshotConfiguration) throws InterruptedException - Specified by:
addDataCollectionNamesToSnapshotin interfaceIncrementalSnapshotChangeEventSource<MongoDbPartition,CollectionId> - Throws:
InterruptedException
-
stopSnapshot
public void stopSnapshot(MongoDbPartition partition, OffsetContext offsetContext, Map<String, Object> additionalData, List<String> dataCollectionPatterns) - Specified by:
stopSnapshotin interfaceIncrementalSnapshotChangeEventSource<MongoDbPartition,CollectionId>
-
expandAndDedupeDataCollectionIds
Expands the string-based list of data collection ids if supplied using regex to a list of all matching explicit data collection ids. -
createDataEventsForDataCollection
private void createDataEventsForDataCollection(MongoDbPartition partition) throws InterruptedException Dispatches the data change events for the records of a single table.- Throws:
InterruptedException
-
addChunkToExecutor
-
queryChunk
-
constructQueryPredicate
-
getAdditionalConditions
-
getStripedAdditionalConditions
-
incrementTableRowsScanned
private void incrementTableRowsScanned(long rows) -
collectionScanCompleted
-
getTableScanLogTimer
-
keyFromRow
-
setContext
-
preReadChunk
-
postReadChunk
-
postIncrementalSnapshotCompleted
protected void postIncrementalSnapshotCompleted() -
processMessage
public void processMessage(MongoDbPartition partition, io.debezium.spi.schema.DataCollectionId dataCollectionId, Object key, OffsetContext offsetContext) throws InterruptedException - Specified by:
processMessagein interfaceIncrementalSnapshotChangeEventSource<MongoDbPartition,CollectionId> - Throws:
InterruptedException
-