Package io.debezium.connector.postgresql
Class SourceInfo
- java.lang.Object
-
- io.debezium.connector.AbstractSourceInfo
-
- io.debezium.connector.common.BaseSourceInfo
-
- io.debezium.connector.postgresql.SourceInfo
-
@NotThreadSafe public final class SourceInfo extends BaseSourceInfo
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 partitioninformation 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 offsetinformation 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. Thesourcestruct appears in each message envelope and contains information about the event. It is a mixture the fields from thepartitionandoffset. 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
Fields Modifier and Type Field Description private StringdbNamestatic StringLAST_SNAPSHOT_RECORD_KEYprivate LsnlastCommitLsnprivate Lsnlsnstatic StringLSN_KEYprivate static com.fasterxml.jackson.databind.ObjectMapperMAPPERprivate StringschemaNameprivate StringtableNameprivate Instanttimestampstatic StringTIMESTAMP_USEC_KEYprivate LongtxIdstatic StringTXID_KEYprivate Longxminstatic StringXMIN_KEY-
Fields inherited from class io.debezium.connector.common.BaseSourceInfo
snapshotRecord
-
Fields 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
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSourceInfo(PostgresConnectorConfig connectorConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Stringdatabase()Lsnlsn()(package private) StringschemaName()Stringsequence()SnapshotRecordsnapshot()(package private) StringtableName()protected Instanttimestamp()StringtoString()protected LongtxId()protected SourceInfoupdate(Lsn lsn, Instant commitTime, Long txId, TableId tableId, Long xmin)Updates the source with information about a particular received or read event.protected SourceInfoupdate(Instant timestamp, TableId tableId)protected SourceInfoupdateLastCommit(Lsn lsn)Updates the source with the LSN of the last committed transaction.Longxmin()-
Methods inherited from class io.debezium.connector.common.BaseSourceInfo
isSnapshot, setSnapshot
-
Methods inherited from class io.debezium.connector.AbstractSourceInfo
schema, serverName, struct, structMaker
-
-
-
-
Field Detail
-
TIMESTAMP_USEC_KEY
public static final String TIMESTAMP_USEC_KEY
- See Also:
- Constant Field Values
-
TXID_KEY
public static final String TXID_KEY
- See Also:
- Constant Field Values
-
XMIN_KEY
public static final String XMIN_KEY
- See Also:
- Constant Field Values
-
LSN_KEY
public static final String LSN_KEY
- See Also:
- Constant Field Values
-
LAST_SNAPSHOT_RECORD_KEY
public static final String LAST_SNAPSHOT_RECORD_KEY
- See Also:
- Constant Field Values
-
MAPPER
private static final com.fasterxml.jackson.databind.ObjectMapper MAPPER
-
dbName
private final String dbName
-
lsn
private Lsn lsn
-
lastCommitLsn
private Lsn lastCommitLsn
-
txId
private Long txId
-
xmin
private Long xmin
-
timestamp
private Instant timestamp
-
schemaName
private String schemaName
-
tableName
private String tableName
-
-
Constructor Detail
-
SourceInfo
protected SourceInfo(PostgresConnectorConfig connectorConfig)
-
-
Method Detail
-
update
protected SourceInfo update(Lsn lsn, Instant commitTime, Long txId, TableId tableId, Long xmin)
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 availabletableId- the table that should be included in the source info; may be nullxmin- the xmin of the slot, may be null- Returns:
- this instance
-
updateLastCommit
protected SourceInfo updateLastCommit(Lsn lsn)
Updates the source with the LSN of the last committed transaction.
-
update
protected SourceInfo update(Instant timestamp, TableId tableId)
-
lsn
public Lsn lsn()
-
xmin
public Long xmin()
-
sequence
public String sequence()
- Overrides:
sequencein classAbstractSourceInfo
-
database
protected String database()
- Specified by:
databasein classAbstractSourceInfo
-
schemaName
String schemaName()
-
tableName
String tableName()
-
timestamp
protected Instant timestamp()
- Specified by:
timestampin classAbstractSourceInfo
-
txId
protected Long txId()
-
snapshot
public SnapshotRecord snapshot()
- Overrides:
snapshotin classBaseSourceInfo
-
-