Class 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 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 Details

  • Constructor Details

  • 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 available
      commitTime - the commit time of the transaction that generated the event; may be null indicating that this information is not available
      txId - the ID of the transaction that generated the transaction; may be null if this information is not available
      xmin - the xmin of the slot, may be null
      tableId - the table that should be included in the source info; may be null
      messageType - the type of the message corresponding to the lsn; may be null
      Returns:
      this instance
    • update

      protected SourceInfo update(Instant timestamp, TableId tableId)
    • updateLastCommit

      protected SourceInfo updateLastCommit(Lsn lsn)
      Updates the source with the LSN of the last committed transaction.
    • lsn

      public Lsn lsn()
    • xmin

      public Long xmin()
    • messageType

      public ReplicationMessage.Operation messageType()
    • sequence

      public String sequence()
      Overrides:
      sequence in class AbstractSourceInfo
    • database

      protected String database()
      Specified by:
      database in class AbstractSourceInfo
    • schemaName

      String schemaName()
    • tableName

      String tableName()
    • timestamp

      protected Instant timestamp()
      Specified by:
      timestamp in class AbstractSourceInfo
    • txId

      protected Long txId()
    • toString

      public String toString()
      Overrides:
      toString in class Object