Class SourceInfo
The source partition information identifies the particular MongoDB replica set and the connector's
logical name of the MongoDB server. A JSON-like representation of the source partition for a database named "customers" hosted
in a MongoDB replica set named "myMongoServer" is as follows:
{
"server_id" : "myMongoServer",
"replicaSetName" : "rs0"
}
The source offset information describes the position within a particular partition of each record.
Since each event in MongoDB's oplog is identified by a BSONTimestamp that tracks the time and the order of the
event for that particular time (e.g., multiple events that occur at the same time will have unique orders), the offset
includes the BSONTimetamp representation. (The event's h field is the unique ID for the operation, so this is also
included in the offset.) And, if an initial sync is in progress, the offset will include the initsync field.
Here's a JSON-like representation of an example timestamp:
{
"sec" = 1422998530,
"ord" = 0,
"h" = 398278732173914406,
"initsync" = true
}
- Author:
- Randall Hauch
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final class(package private) static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprivate CollectionIdId of collection the current event applies to.private final MongoDbConnectorConfigprivate static final SourceInfo.Positionstatic final Stringprivate static final org.bson.BsonTimestampbooleanstatic final Stringstatic final Stringprivate SourceInfo.Positionstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate longFields inherited from class io.debezium.connector.common.BaseSourceInfo
snapshotRecordFields inherited from class io.debezium.connector.AbstractSourceInfo
COLLECTION_NAME_KEY, DATABASE_NAME_KEY, DEBEZIUM_CONNECTOR_KEY, DEBEZIUM_VERSION_KEY, SCHEMA_NAME_KEY, SEQUENCE_KEY, SERVER_NAME_KEY, SNAPSHOT_KEY, TABLE_NAME_KEY, TIMESTAMP_KEY, TIMESTAMP_NS_KEY, TIMESTAMP_US_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidchangeStreamEvent(com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument> changeStreamEvent) voidcollectionEvent(CollectionId collectionId, long wallTime) Get aStructrepresentation of the source partition and offset information where we have last read.(package private) CollectionIdprotected Stringdatabase()booleanDetermine whether we have previously recorded a MongoDB timestamp for the replica set.voidinitEvent(com.mongodb.client.MongoChangeStreamCursor<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument>> cursor) booleanReturns whether any replica sets are still running a snapshot.org.bson.BsonTimestampvoidnoEvent(com.mongodb.client.MongoChangeStreamCursor<?> cursor) voidnoEvent(BufferingChangeStreamCursor.ResumableChangeStreamEvent<org.bson.BsonDocument> event) private voidnoEvent(SourceInfo.Position position) private voidvoidnoEvent(org.bson.BsonTimestamp timestamp) private voidonEvent(CollectionId collectionId, SourceInfo.Position position, long wallTime) (package private) SourceInfo.Positionposition()voidsetPosition(SourceInfo.Position position) snapshot()voidRecord that an initial sync has started for the given replica set.voidRecord that an initial sync has stopped for the given replica set.protected InstanttoString()(package private) longwallTime()Methods inherited from class io.debezium.connector.common.BaseSourceInfo
isSnapshot, setSnapshotMethods inherited from class io.debezium.connector.AbstractSourceInfo
schema, sequence, serverName, struct, structMaker
-
Field Details
-
RESUME_TOKEN
- See Also:
-
TIMESTAMP
- See Also:
-
ORDER
- See Also:
-
INITIAL_SYNC
- See Also:
-
COLLECTION
- See Also:
-
LSID
- See Also:
-
TXN_NUMBER
- See Also:
-
WALL_TIME
- See Also:
-
INITIAL_TIMESTAMP
private static final org.bson.BsonTimestamp INITIAL_TIMESTAMP -
INITIAL_POSITION
-
initialSnapshot
public boolean initialSnapshot -
connectorConfig
-
collectionId
Id of collection the current event applies to. May benullafter noop events, after which the recorded offset may be retrieved but not the source struct. -
position
-
wallTime
private long wallTime
-
-
Constructor Details
-
SourceInfo
-
-
Method Details
-
collectionId
CollectionId collectionId() -
position
SourceInfo.Position position() -
lastResumeToken
-
lastTimestamp
public org.bson.BsonTimestamp lastTimestamp() -
collectionEvent
Get aStructrepresentation of the source partition and offset information where we have last read. The Struct complies with theAbstractSourceInfo.schema()for the MongoDB connector.- Parameters:
collectionId- the event's collection identifier; may not be null- See Also:
-
initEvent
public void initEvent(com.mongodb.client.MongoChangeStreamCursor<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument>> cursor) -
noEvent
public void noEvent(BufferingChangeStreamCursor.ResumableChangeStreamEvent<org.bson.BsonDocument> event) -
noEvent
public void noEvent(com.mongodb.client.MongoChangeStreamCursor<?> cursor) -
noEvent
public void noEvent(org.bson.BsonTimestamp timestamp) -
noEvent
-
noEvent
-
changeStreamEvent
public void changeStreamEvent(com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument> changeStreamEvent) -
onEvent
-
hasPosition
public boolean hasPosition()Determine whether we have previously recorded a MongoDB timestamp for the replica set.- Returns:
trueif an offset has been recorded for the replica set, orfalseif the replica set has not yet been seen
-
setPosition
-
startInitialSnapshot
public void startInitialSnapshot()Record that an initial sync has started for the given replica set. -
stopInitialSnapshot
public void stopInitialSnapshot()Record that an initial sync has stopped for the given replica set. -
isSnapshotRunning
public boolean isSnapshotRunning()Returns whether any replica sets are still running a snapshot. -
timestamp
- Specified by:
timestampin classAbstractSourceInfo
-
snapshot
- Overrides:
snapshotin classBaseSourceInfo
-
database
- Specified by:
databasein classAbstractSourceInfo
-
wallTime
long wallTime() -
toString
-