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
Fields Modifier and Type Field Description private static StringAUTHORIZATION_FAILURE_MESSAGEprivate Clockclockprivate MongoDbSchemacollectionSchemaprivate ConnectionContextconnectionContextprivate MongoDbConnectorConfigconnectorConfigprotected IncrementalSnapshotContext<CollectionId>contextprivate MongoDbCollectionSchemacurrentCollectionprivate DataChangeEventListener<MongoDbPartition>dataListenerprotected EventDispatcher<MongoDbPartition,CollectionId>dispatcherprivate static StringDOCUMENT_IDprivate static org.slf4j.LoggerLOGGERprivate ConnectionContext.MongoPrimaryprimaryprivate SnapshotProgressListener<MongoDbPartition>progressListenerprivate ReplicaSetsreplicaSetsprivate CollectionIdsignallingCollectionIdprivate MongoDbTaskContexttaskContextprivate longtotalRowsScannedprotected Map<org.apache.kafka.connect.data.Struct,Object[]>window
-
Constructor Summary
Constructors Constructor Description MongoDbIncrementalSnapshotChangeEventSource(MongoDbConnectorConfig config, MongoDbTaskContext taskContext, ReplicaSets replicaSets, EventDispatcher<MongoDbPartition,CollectionId> dispatcher, MongoDbSchema collectionSchema, Clock clock, SnapshotProgressListener<MongoDbPartition> progressListener, DataChangeEventListener<MongoDbPartition> dataChangeEventListener)
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.debezium.pipeline.source.snapshot.incremental.IncrementalSnapshotChangeEventSource
processFilteredEvent, processHeartbeat, processSchemaChange, processTransactionCommittedEvent, processTransactionStartedEvent
-
-
-
-
Field Detail
-
DOCUMENT_ID
private static final String DOCUMENT_ID
- See Also:
- Constant Field Values
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
AUTHORIZATION_FAILURE_MESSAGE
private static final String AUTHORIZATION_FAILURE_MESSAGE
- See Also:
- Constant Field Values
-
connectorConfig
private final MongoDbConnectorConfig connectorConfig
-
clock
private final Clock clock
-
collectionSchema
private final MongoDbSchema collectionSchema
-
progressListener
private final SnapshotProgressListener<MongoDbPartition> progressListener
-
dataListener
private final DataChangeEventListener<MongoDbPartition> dataListener
-
totalRowsScanned
private long totalRowsScanned
-
replicaSets
private final ReplicaSets replicaSets
-
connectionContext
private final ConnectionContext connectionContext
-
taskContext
private final MongoDbTaskContext taskContext
-
currentCollection
private MongoDbCollectionSchema currentCollection
-
dispatcher
protected EventDispatcher<MongoDbPartition,CollectionId> dispatcher
-
context
protected IncrementalSnapshotContext<CollectionId> context
-
primary
private ConnectionContext.MongoPrimary primary
-
signallingCollectionId
private CollectionId signallingCollectionId
-
-
Constructor Detail
-
MongoDbIncrementalSnapshotChangeEventSource
public MongoDbIncrementalSnapshotChangeEventSource(MongoDbConnectorConfig config, MongoDbTaskContext taskContext, ReplicaSets replicaSets, EventDispatcher<MongoDbPartition,CollectionId> dispatcher, MongoDbSchema collectionSchema, Clock clock, SnapshotProgressListener<MongoDbPartition> progressListener, DataChangeEventListener<MongoDbPartition> dataChangeEventListener)
-
-
Method Detail
-
closeWindow
public void closeWindow(MongoDbPartition partition, String id, OffsetContext offsetContext) throws InterruptedException
- Specified by:
closeWindowin interfaceIncrementalSnapshotChangeEventSource<MongoDbPartition,CollectionId>- Throws:
InterruptedException
-
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(DataCollectionId dataCollectionId, Object key)
-
emitWindowOpen
protected void emitWindowOpen() throws InterruptedExceptionUpdate low watermark for the incremental snapshot chunk- Throws:
InterruptedException
-
emitWindowClose
protected void emitWindowClose() throws InterruptedExceptionUpdate high watermark for the incremental snapshot chunk- Throws:
InterruptedException
-
init
public void init(MongoDbPartition partition, OffsetContext offsetContext)
- Specified by:
initin interfaceIncrementalSnapshotChangeEventSource<MongoDbPartition,CollectionId>
-
readChunk
protected void readChunk(MongoDbPartition partition) throws InterruptedException
- Throws:
InterruptedException
-
nextDataCollection
private void nextDataCollection(MongoDbPartition partition)
-
readMaximumKey
private Object[] readMaximumKey() throws InterruptedException
- Throws:
InterruptedException
-
addDataCollectionNamesToSnapshot
public void addDataCollectionNamesToSnapshot(MongoDbPartition partition, List<String> dataCollectionIds, OffsetContext offsetContext) throws InterruptedException
- Specified by:
addDataCollectionNamesToSnapshotin interfaceIncrementalSnapshotChangeEventSource<MongoDbPartition,CollectionId>- Throws:
InterruptedException
-
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
private void collectionScanCompleted(MongoDbPartition partition)
-
getTableScanLogTimer
private Threads.Timer getTableScanLogTimer()
-
setContext
protected void setContext(IncrementalSnapshotContext<CollectionId> context)
-
preReadChunk
protected void preReadChunk(IncrementalSnapshotContext<CollectionId> context)
-
postReadChunk
protected void postReadChunk(IncrementalSnapshotContext<CollectionId> context)
-
postIncrementalSnapshotCompleted
protected void postIncrementalSnapshotCompleted()
-
processMessage
public void processMessage(MongoDbPartition partition, DataCollectionId dataCollectionId, Object key, OffsetContext offsetContext) throws InterruptedException
- Specified by:
processMessagein interfaceIncrementalSnapshotChangeEventSource<MongoDbPartition,CollectionId>- Throws:
InterruptedException
-
establishConnectionToPrimary
private ConnectionContext.MongoPrimary establishConnectionToPrimary(MongoDbPartition partition, ReplicaSet replicaSet)
-
-