@NotThreadSafe final class SourceInfo extends Object
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
}
| Modifier and Type | Field and Description |
|---|---|
static String |
LAST_SNAPSHOT_RECORD_KEY |
private Boolean |
lastSnapshotRecord |
private Long |
lsn |
static String |
LSN_KEY |
static org.apache.kafka.connect.data.Schema |
SCHEMA
|
static String |
SERVER_NAME_KEY |
static String |
SERVER_PARTITION_KEY |
private String |
serverName |
private boolean |
snapshot |
static String |
SNAPSHOT_KEY |
private Map<String,String> |
sourcePartition |
static String |
TIMESTAMP_KEY |
private Integer |
txId |
static String |
TXID_KEY |
private Long |
useconds |
| Modifier | Constructor and Description |
|---|---|
protected |
SourceInfo(String serverName) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
completeSnapshot()
Denote that a snapshot has completed successfully.
|
protected boolean |
hasLastKnownPosition() |
protected boolean |
isSnapshotInEffect()
Determine whether a snapshot is currently in effect, meaning it was started and has not completed.
|
protected void |
load(Map<String,Object> lastStoredOffset) |
protected Long |
lsn() |
protected SourceInfo |
markLastSnapshotRecord() |
Map<String,?> |
offset()
Get the Kafka Connect detail about the source "offset", which describes the position within the source where we last
have last read.
|
Map<String,String> |
partition()
Get the Kafka Connect detail about the source "partition", which describes the portion of the source that we are
consuming.
|
protected org.apache.kafka.connect.data.Schema |
schema()
|
protected org.apache.kafka.connect.data.Struct |
source()
|
protected void |
startSnapshot()
Denote that a snapshot is being (or has been) started.
|
String |
toString() |
protected SourceInfo |
update(Long useconds) |
protected SourceInfo |
update(Long lsn,
Long useconds,
Integer txId)
Updates the source with information about a particular received or read event.
|
public static final String SERVER_NAME_KEY
public static final String SERVER_PARTITION_KEY
public static final String TIMESTAMP_KEY
public static final String TXID_KEY
public static final String LSN_KEY
public static final String SNAPSHOT_KEY
public static final String LAST_SNAPSHOT_RECORD_KEY
public static final org.apache.kafka.connect.data.Schema SCHEMA
private final String serverName
private Long lsn
private Integer txId
private Long useconds
private boolean snapshot
private Boolean lastSnapshotRecord
protected SourceInfo(String serverName)
public Map<String,String> partition()
serverName
as the value for the partition.public Map<String,?> offset()
protected SourceInfo update(Long lsn, Long useconds, Integer txId)
lsn - the position in the server WAL for a particular event; may be null indicating that this information is not
availableuseconds - the commit time (in microseconds since epoch) 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 nis not availableprotected SourceInfo update(Long useconds)
protected SourceInfo markLastSnapshotRecord()
protected org.apache.kafka.connect.data.Schema schema()
Schema; never nullsource()protected org.apache.kafka.connect.data.Struct source()
Struct representation of the source partition() and offset() information. The Struct
complies with the SCHEMA for the Postgres connector.
This method should always be called after update(Long, Long, Integer).
Struct; never nullschema()protected boolean isSnapshotInEffect()
true if a snapshot is in effect, or false otherwiseprotected void startSnapshot()
protected void completeSnapshot()
protected Long lsn()
protected boolean hasLastKnownPosition()
Copyright © 2017 JBoss by Red Hat. All rights reserved.