public class MySqlOffsetContext extends Object implements OffsetContext
| Modifier and Type | Class and Description |
|---|---|
static class |
MySqlOffsetContext.Loader |
| Modifier and Type | Field and Description |
|---|---|
private long |
currentEventLengthInBytes |
private String |
currentGtidSet |
static String |
EVENTS_TO_SKIP_OFFSET_KEY |
static String |
GTID_SET_KEY |
private boolean |
inTransaction |
static String |
NON_GTID_TRANSACTION_ID_FORMAT |
private Map<String,String> |
partition |
private String |
restartBinlogFilename |
private long |
restartBinlogPosition |
private long |
restartEventsToSkip |
private String |
restartGtidSet |
private int |
restartRowsToSkip |
private static String |
SERVER_PARTITION_KEY |
private static String |
SNAPSHOT_COMPLETED_KEY |
private boolean |
snapshotCompleted |
private SourceInfo |
sourceInfo |
private org.apache.kafka.connect.data.Schema |
sourceInfoSchema |
static String |
TIMESTAMP_KEY |
private TransactionContext |
transactionContext |
private String |
transactionId |
| Constructor and Description |
|---|
MySqlOffsetContext(MySqlConnectorConfig connectorConfig,
boolean snapshot,
boolean snapshotCompleted,
SourceInfo sourceInfo) |
MySqlOffsetContext(MySqlConnectorConfig connectorConfig,
boolean snapshot,
boolean snapshotCompleted,
TransactionContext transactionContext,
SourceInfo sourceInfo) |
| Modifier and Type | Method and Description |
|---|---|
void |
changeEventCompleted() |
void |
commitTransaction() |
void |
completeEvent()
Capture that we're starting a new event.
|
void |
databaseEvent(String database,
Instant timestamp) |
void |
event(DataCollectionId tableId,
Instant timestamp) |
long |
eventsToSkipUponRestart()
Get the number of events after the last transaction BEGIN that we've already processed.
|
Map<String,?> |
getOffset() |
Map<String,?> |
getPartition()
Get the Kafka Connect detail about the source "partition", which describes the portion of the source that we are
consuming.
|
SourceInfo |
getSource() |
org.apache.kafka.connect.data.Struct |
getSourceInfo() |
org.apache.kafka.connect.data.Schema |
getSourceInfoSchema() |
TransactionContext |
getTransactionContext() |
String |
getTransactionId() |
String |
gtidSet()
Get the string representation of the GTID range for the MySQL binary log file.
|
static MySqlOffsetContext |
initial(MySqlConnectorConfig config) |
boolean |
isSnapshotCompleted() |
boolean |
isSnapshotRunning() |
void |
markLastSnapshotRecord() |
private Map<String,Object> |
offsetUsingPosition(long rowsToSkip) |
void |
postSnapshotCompletion() |
void |
preSnapshotCompletion() |
void |
preSnapshotStart() |
private void |
resetTransactionId() |
int |
rowsToSkipUponRestart()
Get the number of rows beyond the
last completely processed event to be skipped
upon restart. |
void |
setBinlogStartPoint(String binlogFilename,
long positionOfFirstEvent)
Set the position in the MySQL binlog where we will start reading.
|
void |
setBinlogThread(long threadId) |
void |
setCompletedGtidSet(String gtidSet)
Set the GTID set that captures all of the GTID transactions that have been completely processed.
|
void |
setEventPosition(long positionOfCurrentEvent,
long eventSizeInBytes)
Set the position within the MySQL binary log file of the current event.
|
void |
setInitialSkips(long restartEventsToSkip,
int restartRowsToSkip) |
void |
setQuery(String query)
Set the original SQL query.
|
void |
setRowNumber(int eventRowNumber,
int totalNumberOfRows)
Given the row number within a binlog event and the total number of rows in that event, compute the
Kafka Connect offset that is be included in the produced change event describing the row.
|
private void |
setTransactionId() |
void |
startGtid(String gtid,
String gtidSet)
Record that a new GTID transaction has been started and has been included in the set of GTIDs known to the MySQL server.
|
void |
startNextTransaction() |
void |
tableEvent(String database,
Set<TableId> tableIds,
Instant timestamp) |
String |
toString() |
private static final String SERVER_PARTITION_KEY
private static final String SNAPSHOT_COMPLETED_KEY
public static final String EVENTS_TO_SKIP_OFFSET_KEY
public static final String TIMESTAMP_KEY
public static final String GTID_SET_KEY
public static final String NON_GTID_TRANSACTION_ID_FORMAT
private final org.apache.kafka.connect.data.Schema sourceInfoSchema
private final SourceInfo sourceInfo
private boolean snapshotCompleted
private final TransactionContext transactionContext
private String restartGtidSet
private String currentGtidSet
private String restartBinlogFilename
private long restartBinlogPosition
private int restartRowsToSkip
private long restartEventsToSkip
private long currentEventLengthInBytes
private boolean inTransaction
private String transactionId
public MySqlOffsetContext(MySqlConnectorConfig connectorConfig, boolean snapshot, boolean snapshotCompleted, TransactionContext transactionContext, SourceInfo sourceInfo)
public MySqlOffsetContext(MySqlConnectorConfig connectorConfig, boolean snapshot, boolean snapshotCompleted, SourceInfo sourceInfo)
public Map<String,?> getPartition()
database server.
The resulting map is mutable for efficiency reasons (this information rarely changes), but should not be mutated.
getPartition in interface OffsetContextpublic Map<String,?> getOffset()
getOffset in interface OffsetContextpublic org.apache.kafka.connect.data.Schema getSourceInfoSchema()
getSourceInfoSchema in interface OffsetContextpublic org.apache.kafka.connect.data.Struct getSourceInfo()
getSourceInfo in interface OffsetContextpublic boolean isSnapshotRunning()
isSnapshotRunning in interface OffsetContextpublic boolean isSnapshotCompleted()
public void preSnapshotStart()
preSnapshotStart in interface OffsetContextpublic void preSnapshotCompletion()
preSnapshotCompletion in interface OffsetContextpublic void postSnapshotCompletion()
postSnapshotCompletion in interface OffsetContextprivate void setTransactionId()
private void resetTransactionId()
public String getTransactionId()
public void setInitialSkips(long restartEventsToSkip,
int restartRowsToSkip)
public static MySqlOffsetContext initial(MySqlConnectorConfig config)
public void markLastSnapshotRecord()
markLastSnapshotRecord in interface OffsetContextpublic void event(DataCollectionId tableId, Instant timestamp)
event in interface OffsetContextpublic TransactionContext getTransactionContext()
getTransactionContext in interface OffsetContextpublic void setBinlogStartPoint(String binlogFilename, long positionOfFirstEvent)
binlogFilename - the name of the binary log file; may not be nullpositionOfFirstEvent - the position in the binary log file to begin processingpublic void setCompletedGtidSet(String gtidSet)
gtidSet - the string representation of the GTID set; may not be null, but may be an empty string if no GTIDs
have been previously processedpublic String gtidSet()
public void startGtid(String gtid, String gtidSet)
gtid - the string representation of a specific GTID that has been begun; may not be nullgtidSet - the string representation of GTID set that includes the newly begun GTID; may not be nullpublic SourceInfo getSource()
public void startNextTransaction()
public void commitTransaction()
public void completeEvent()
public void setEventPosition(long positionOfCurrentEvent,
long eventSizeInBytes)
positionOfCurrentEvent - the position within the binary log file of the current eventeventSizeInBytes - the size in bytes of this eventpublic void setQuery(String query)
query - the original SQL query that generated the event.public void changeEventCompleted()
public long eventsToSkipUponRestart()
completeEvent(),
startNextTransaction()public int rowsToSkipUponRestart()
last completely processed event to be skipped
upon restart.public void setRowNumber(int eventRowNumber,
int totalNumberOfRows)
This method should always be called before #struct().
eventRowNumber - the 0-based row number within the event for which the offset is to be producedtotalNumberOfRows - the total number of rows within the event being processed#struct()public void setBinlogThread(long threadId)
Copyright © 2021 JBoss by Red Hat. All rights reserved.