Class MySqlTaskContext
java.lang.Object
io.debezium.connector.common.CdcSourceTaskContext
io.debezium.connector.mysql.legacy.MySqlTaskContext
A Kafka Connect source task reads the MySQL binary log and generate the corresponding data change events.
- Author:
- Randall Hauch
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Configurationprivate final MySqlJdbcContextprivate final MySqlConnectorConfigprivate final MySqlSchemaprivate static final org.slf4j.Loggerprivate final RecordMakersprivate final SourceInfoprivate final booleanWhether table ids are compared ignoring letter casing.private final TopicSelector<TableId> -
Constructor Summary
ConstructorsConstructorDescriptionMySqlTaskContext(Configuration config, Filters filters) MySqlTaskContext(Configuration config, Filters filters, Boolean tableIdCaseInsensitive, Map<String, ?> restartOffset) MySqlTaskContext(Configuration config, Filters filters, Map<String, ?> restartOffset) -
Method Summary
Modifier and TypeMethodDescriptionintconfig()dbSchema()Get the predicate function that will returntrueif a DDL has to be skipped over and left out of the schema history orfalsewhen it should be processed.filterGtidSet(GtidSet availableServerGtidSet, GtidSet purgedServerGtid) Apply the include/exclude GTID source filters to the currentGTID setand merge them onto the currently available GTID set from a MySQL server.Get the predicate function that will returntrueif a GTID source is to be included, orfalseif a GTID source is to be excluded.booleanReturn true if the database history entity existsbooleanbooleanvoidInitialize the database history with any server-specific information.voidInitialize permanent storage for database historybooleanbooleanbooleanbooleanbooleanbooleanvoidloadHistory(SourceInfo startingPoint) Load the database schema information using the previously-recorded history, and stop reading the history when the the history reaches the supplied starting point.longlongserverId()voidshutdown()protected MySqlConnectorConfig.SnapshotModesource()voidstart()voidtemporaryLoggingContext(String contextName, Runnable operation) Run the supplied function in the temporary connector MDC context, and when complete always return the MDC context to its state before this method was called.Methods inherited from class io.debezium.connector.common.CdcSourceTaskContext
capturedDataCollections, configureLoggingContext, configureLoggingContext, getClock, getConnectorName, getConnectorType, getTaskId, temporaryLoggingContext
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
connectionContext
-
config
-
connectorConfig
-
source
-
dbSchema
-
topicSelector
-
recordProcessor
-
gtidSourceFilter
-
ddlFilter
-
tableIdCaseInsensitive
private final boolean tableIdCaseInsensitiveWhether table ids are compared ignoring letter casing.
-
-
Constructor Details
-
MySqlTaskContext
-
MySqlTaskContext
-
MySqlTaskContext
public MySqlTaskContext(Configuration config, Filters filters, Boolean tableIdCaseInsensitive, Map<String, ?> restartOffset)
-
-
Method Details
-
config
-
getConnectorConfig
-
getConnectionContext
-
connectorName
-
topicSelector
-
source
-
dbSchema
-
makeRecord
-
gtidSourceFilter
Get the predicate function that will returntrueif a GTID source is to be included, orfalseif a GTID source is to be excluded.- Returns:
- the GTID source predicate function; never null
-
initializeHistory
public void initializeHistory()Initialize the database history with any server-specific information. This should be done only upon connector startup when the connector has no prior history. -
loadHistory
Load the database schema information using the previously-recorded history, and stop reading the history when the the history reaches the supplied starting point.- Parameters:
startingPoint- the source information with the currentSourceInfo.partition()andoffsetat which the database schemas are to reflect; may not be null
-
historyExists
public boolean historyExists()Return true if the database history entity exists -
initializeHistoryStorage
public void initializeHistoryStorage()Initialize permanent storage for database history -
serverId
public long serverId() -
rowCountForLargeTable
public long rowCountForLargeTable() -
bufferSizeForBinlogReader
public int bufferSizeForBinlogReader() -
includeSchemaChangeRecords
public boolean includeSchemaChangeRecords() -
includeSqlQuery
public boolean includeSqlQuery() -
isSnapshotAllowedWhenNeeded
public boolean isSnapshotAllowedWhenNeeded() -
isSnapshotNeverAllowed
public boolean isSnapshotNeverAllowed() -
isInitialSnapshotOnly
public boolean isInitialSnapshotOnly() -
isSchemaOnlySnapshot
public boolean isSchemaOnlySnapshot() -
isSchemaOnlyRecoverySnapshot
public boolean isSchemaOnlyRecoverySnapshot() -
snapshotMode
-
start
public void start() -
shutdown
public void shutdown() -
temporaryLoggingContext
Run the supplied function in the temporary connector MDC context, and when complete always return the MDC context to its state before this method was called.- Parameters:
contextName- the name of the context; may not be nulloperation- the function to run in the new MDC context; may not be null- Throws:
IllegalArgumentException- if any of the parameters are null
-
filterGtidSet
Apply the include/exclude GTID source filters to the currentGTID setand merge them onto the currently available GTID set from a MySQL server. The merging behavior of this method might seem a bit strange at first. It's required in order for Debezium to consume a MySQL binlog that has multi-source replication enabled, if a failover has to occur. In such a case, the server that Debezium is failed over to might have a different set of sources, but still include the sources required for Debezium to continue to function. MySQL does not allow downstream replicas to connect if the GTID set does not contain GTIDs for all channels that the server is replicating from, even if the server does have the data needed by the client. To get around this, we can have Debezium merge its GTID set with whatever is on the server, so that MySQL will allow it to connect. See DBZ-143 for details. This method does not mutate any state in the context.- Parameters:
availableServerGtidSet- the GTID set currently available in the MySQL serverpurgedServerGtid- the GTID set already purged by the MySQL server- Returns:
- A GTID set meant for consuming from a MySQL binlog; may return null if the SourceInfo has no GTIDs and therefore none were filtered
-
ddlFilter
Get the predicate function that will returntrueif a DDL has to be skipped over and left out of the schema history orfalsewhen it should be processed.- Returns:
- the DDL predicate function; never null
-
isTableIdCaseInsensitive
public boolean isTableIdCaseInsensitive()
-