Package io.debezium.connector.postgresql
Class SourceInfo
java.lang.Object
io.debezium.connector.AbstractSourceInfo
io.debezium.connector.common.BaseSourceInfo
io.debezium.connector.postgresql.SourceInfo
Information about the source of information, which for normal events contains information about the transaction id and the
LSN position in the server WAL.
The source partition information describes the database server for which we're streaming changes.
Typically, the server is identified by the host address port number and the name of the database. Here's a JSON-like
representation of an example database:
{
"server" : "production-server"
}
The source offset information describes a structure containing the position in the server's WAL for any
particular event, transaction id and the server timestamp at which the transaction that generated that particular event has
been committed. When performing snapshots, it may also contain a snapshot field which indicates that a particular record
is created while a snapshot it taking place.
Here's a JSON-like representation of an example:
{
"ts_usec": 1465937,
"lsn" : 99490,
"txId" : 123,
"snapshot": true
}
The "ts_usec" field contains the microseconds since Unix epoch (since Jan 1, 1970) representing the time at
which the transaction that generated the event was committed while the "txId" represents the server's unique transaction
identifier. The "lsn" field represent a numerical (long) value corresponding to the server's LSN for that particular
event and can be used to uniquely identify an event within the WAL.
The source struct appears in each message envelope and contains information about the event. It is
a mixture the fields from the partition and offset.
Like with the offset, the "snapshot" field only appears for events produced when the connector is in the
middle of a snapshot. Here's a JSON-like representation of the source for an event that corresponds to the above partition and
offset:
{
"name": "production-server",
"ts_usec": 1465937,
"lsn" : 99490,
"txId" : 123,
"snapshot": true
}
- Author:
- Horia Chiorean
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringstatic final Stringprivate Lsnprivate Lsnstatic final Stringprivate static final com.fasterxml.jackson.databind.ObjectMapperprivate ReplicationMessage.Operationstatic final Stringprivate Stringprivate Stringprivate Instantstatic final Stringprivate Longstatic final Stringprivate Longstatic final StringFields 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 TypeMethodDescriptionprotected Stringdatabase()lsn()(package private) Stringsequence()(package private) Stringprotected InstanttoString()protected LongtxId()protected SourceInfoupdate(Lsn lsn, Instant commitTime, Long txId, Long xmin, TableId tableId, ReplicationMessage.Operation messageType) Updates the source with information about a particular received or read event.protected SourceInfoprotected SourceInfoupdateLastCommit(Lsn lsn) Updates the source with the LSN of the last committed transaction.xmin()Methods inherited from class io.debezium.connector.common.BaseSourceInfo
isSnapshot, setSnapshot, snapshotMethods inherited from class io.debezium.connector.AbstractSourceInfo
schema, serverName, struct, structMaker
-
Field Details
-
TIMESTAMP_USEC_KEY
- See Also:
-
TXID_KEY
- See Also:
-
XMIN_KEY
- See Also:
-
LSN_KEY
- See Also:
-
MSG_TYPE_KEY
- See Also:
-
LAST_SNAPSHOT_RECORD_KEY
- See Also:
-
MAPPER
private static final com.fasterxml.jackson.databind.ObjectMapper MAPPER -
dbName
-
lsn
-
lastCommitLsn
-
txId
-
xmin
-
messageType
-
timestamp
-
schemaName
-
tableName
-
-
Constructor Details
-
SourceInfo
-
-
Method Details
-
update
protected SourceInfo update(Lsn lsn, Instant commitTime, Long txId, Long xmin, TableId tableId, ReplicationMessage.Operation messageType) Updates the source with information about a particular received or read event.- Parameters:
lsn- the position in the server WAL for a particular event; may be null indicating that this information is not availablecommitTime- the commit time of the transaction that generated the event; may be null indicating that this information is not availabletxId- the ID of the transaction that generated the transaction; may be null if this information is not availablexmin- the xmin of the slot, may be nulltableId- the table that should be included in the source info; may be nullmessageType- the type of the message corresponding to the lsn; may be null- Returns:
- this instance
-
update
-
updateLastCommit
Updates the source with the LSN of the last committed transaction. -
lsn
-
xmin
-
messageType
-
sequence
- Overrides:
sequencein classAbstractSourceInfo
-
database
- Specified by:
databasein classAbstractSourceInfo
-
schemaName
String schemaName() -
tableName
String tableName() -
timestamp
- Specified by:
timestampin classAbstractSourceInfo
-
txId
-
toString
-