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
    • 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 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
        tableId - the table that should be included in the source info; may be null
        xmin - 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.
      • lsn

        public Lsn lsn()
      • xmin

        public Long xmin()
      • schemaName

        String schemaName()
      • tableName

        String tableName()
      • txId

        protected Long txId()