Package io.debezium.connector.mongodb
Class MongoDbIncrementalSnapshotChangeEventSource
java.lang.Object
io.debezium.connector.mongodb.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 ConnectionContextprivate final MongoDbConnection.ChangeEventSourceConnectionFactoryprivate final MongoDbConnectorConfigprotected IncrementalSnapshotContext<CollectionId>private MongoDbCollectionSchemaprivate final DataChangeEventListener<MongoDbPartition>protected EventDispatcher<MongoDbPartition,CollectionId> private static final Stringprivate static final org.slf4j.Loggerprivate MongoDbConnectionprivate final SnapshotProgressListener<MongoDbPartition>private final ReplicaSetsprivate CollectionIdprivate final MongoDbTaskContextprivate long -
Constructor Summary
ConstructorsConstructorDescriptionMongoDbIncrementalSnapshotChangeEventSource(MongoDbConnectorConfig config, MongoDbTaskContext taskContext, MongoDbConnection.ChangeEventSourceConnectionFactory connections, ReplicaSets replicaSets, EventDispatcher<MongoDbPartition, CollectionId> dispatcher, MongoDbSchema collectionSchema, Clock clock, SnapshotProgressListener<MongoDbPartition> progressListener, DataChangeEventListener<MongoDbPartition> dataChangeEventListener) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDataCollectionNamesToSnapshot(MongoDbPartition partition, List<String> dataCollectionIds, Optional<String> additionalCondition, Optional<String> surrogateKey, OffsetContext offsetContext) voidcloseWindow(MongoDbPartition partition, String id, OffsetContext offsetContext) private voidcollectionScanCompleted(MongoDbPartition partition) private voidDispatches the data change events for the records of a single table.protected voiddeduplicateWindow(io.debezium.spi.schema.DataCollectionId dataCollectionId, Object key) protected voidUpdate high watermark for the incremental snapshot chunkprotected voidUpdate low watermark for the incremental snapshot chunkprotected ChangeRecordEmitter<MongoDbPartition>getChangeRecordEmitter(MongoDbPartition partition, OffsetContext offsetContext, Object[] row) Returns aChangeRecordEmitterproducing the change records for the given table row.protected StringgetSignalCollectionName(String dataCollectionId) private Threads.Timerprivate voidincrementTableRowsScanned(long rows) voidinit(MongoDbPartition partition, OffsetContext offsetContext) private Object[]keyFromRow(Object[] row) private voidnextDataCollection(MongoDbPartition partition) voidpauseSnapshot(MongoDbPartition partition, OffsetContext offsetContext) protected voidprotected voidprotected voidvoidprocessMessage(MongoDbPartition partition, io.debezium.spi.schema.DataCollectionId dataCollectionId, Object key, OffsetContext offsetContext) protected voidreadChunk(MongoDbPartition partition) private Object[]voidresumeSnapshot(MongoDbPartition partition, OffsetContext offsetContext) protected voidsendEvent(MongoDbPartition partition, EventDispatcher<MongoDbPartition, CollectionId> dispatcher, OffsetContext offsetContext, Object[] row) protected voidsendWindowEvents(MongoDbPartition partition, OffsetContext offsetContext) protected voidsetContext(IncrementalSnapshotContext<CollectionId> context) voidstopSnapshot(MongoDbPartition partition, List<String> dataCollectionIds, OffsetContext offsetContext) 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
-
clock
-
collectionSchema
-
progressListener
-
dataListener
-
totalRowsScanned
private long totalRowsScanned -
replicaSets
-
connectionContext
-
taskContext
-
connections
-
currentCollection
-
dispatcher
-
context
-
window
-
mongo
-
signallingCollectionId
-
-
Constructor Details
-
MongoDbIncrementalSnapshotChangeEventSource
public MongoDbIncrementalSnapshotChangeEventSource(MongoDbConnectorConfig config, MongoDbTaskContext taskContext, MongoDbConnection.ChangeEventSourceConnectionFactory connections, ReplicaSets replicaSets, EventDispatcher<MongoDbPartition, CollectionId> dispatcher, MongoDbSchema collectionSchema, Clock clock, SnapshotProgressListener<MongoDbPartition> progressListener, DataChangeEventListener<MongoDbPartition> dataChangeEventListener)
-
-
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
-
getSignalCollectionName
-
sendWindowEvents
protected void sendWindowEvents(MongoDbPartition partition, OffsetContext offsetContext) throws InterruptedException - Throws:
InterruptedException
-
sendEvent
protected void sendEvent(MongoDbPartition partition, EventDispatcher<MongoDbPartition, CollectionId> dispatcher, OffsetContext offsetContext, Object[] row) throws InterruptedException- Throws:
InterruptedException
-
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:
InterruptedException
-
init
- Specified by:
initin interfaceIncrementalSnapshotChangeEventSource<MongoDbPartition,CollectionId>
-
readChunk
- Throws:
InterruptedException
-
nextDataCollection
-
readMaximumKey
- Throws:
InterruptedException
-
addDataCollectionNamesToSnapshot
public void addDataCollectionNamesToSnapshot(MongoDbPartition partition, List<String> dataCollectionIds, Optional<String> additionalCondition, Optional<String> surrogateKey, OffsetContext offsetContext) throws InterruptedException - Specified by:
addDataCollectionNamesToSnapshotin interfaceIncrementalSnapshotChangeEventSource<MongoDbPartition,CollectionId> - Throws:
InterruptedException
-
stopSnapshot
public void stopSnapshot(MongoDbPartition partition, List<String> dataCollectionIds, OffsetContext offsetContext) - Specified by:
stopSnapshotin interfaceIncrementalSnapshotChangeEventSource<MongoDbPartition,CollectionId>
-
createDataEventsForDataCollection
private void createDataEventsForDataCollection(MongoDbPartition partition) throws InterruptedException Dispatches the data change events for the records of a single table.- Throws:
InterruptedException
-
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
-