@NotThreadSafe public class MySqlDatabaseSchema extends HistorizedRelationalDatabaseSchema
table definitions and the Kafka Connect Schemas for each table, where the
Schema excludes any columns that have been specified in the
configuration.
The history is changed by applying DDL
statements, and every change is persisted as defined in the supplied MySQL
connector configuration. This component can be reconstructed (e.g., on connector restart) and the history
loaded from persisted storage.
Note that when applying DDL statements, the
caller is able to supply a consumer function that will be called with the DDL
statements and the database to which they apply, grouped by database names. However, these will only be called based when the
databases are included by the database filters defined in the MySQL connector configuration.
HistorizedDatabaseSchema.SchemaChangeEventConsumer| Modifier and Type | Field and Description |
|---|---|
private DdlChanges |
ddlChanges |
private DdlParser |
ddlParser |
private RelationalTableFilters |
filters |
private Set<String> |
ignoredQueryStatements |
private static org.slf4j.Logger |
LOGGER |
private boolean |
storageInitialiationExecuted |
private Map<Long,TableId> |
tableIdsByTableNumber |
databaseHistoryNO_CAPTURED_DATA_COLLECTIONS_WARNING| Constructor and Description |
|---|
MySqlDatabaseSchema(MySqlConnectorConfig connectorConfig,
MySqlValueConverters valueConverter,
TopicSelector<TableId> topicSelector,
SchemaNameAdjuster schemaNameAdjuster,
boolean tableIdCaseInsensitive)
Create a schema component given the supplied
MySQL connector configuration. |
| Modifier and Type | Method and Description |
|---|---|
private boolean |
acceptableDatabase(String databaseName) |
protected void |
appendCreateTableStatement(StringBuilder sb,
Table table) |
protected void |
appendDropTableStatement(StringBuilder sb,
TableId tableId) |
void |
applySchemaChange(SchemaChangeEvent schemaChange) |
boolean |
assignTableNumber(long tableNumber,
TableId id)
Assign the given table number to the table with the specified
table ID. |
void |
clearTableMappings()
Clear all of the table mappings.
|
private void |
emitChangeEvent(MySqlOffsetContext offset,
List<SchemaChangeEvent> schemaChangeEvents,
String sanitizedDbName,
DdlParserListener.Event event,
TableId tableId,
SchemaChangeEvent.SchemaChangeEventType type,
boolean snapshot) |
protected DdlParser |
getDdlParser() |
private TableId |
getTableId(DdlParserListener.Event event) |
TableId |
getTableId(long tableNumber)
Return the table id associated with MySQL-specific table number.
|
boolean |
historyExists()
Return true if the database history entity exists
|
void |
initializeStorage() |
boolean |
isGlobalSetVariableStatement(String ddl,
String databaseName) |
boolean |
isStorageInitializationExecuted() |
String[] |
monitoredTablesAsStringArray()
Get all table names for all databases that are monitored whose events are captured by Debezium
|
private List<SchemaChangeEvent> |
parseDdl(String ddlStatements,
String databaseName,
MySqlOffsetContext offset,
Instant sourceTime,
boolean snapshot) |
List<SchemaChangeEvent> |
parseSnapshotDdl(String ddlStatements,
String databaseName,
MySqlOffsetContext offset,
Instant sourceTime) |
List<SchemaChangeEvent> |
parseStreamingDdl(String ddlStatements,
String databaseName,
MySqlOffsetContext offset,
Instant sourceTime) |
protected void |
refreshSchemas()
Discard any currently-cached schemas and rebuild them using the filters.
|
void |
setSystemVariables(Map<String,String> variables)
Set the system variables on the DDL parser.
|
boolean |
storeOnlyMonitoredTables() |
SystemVariables |
systemVariables()
Get the system variables as known by the DDL parser.
|
close, record, recover, tableInformationCompleteassureNonEmptySchema, buildAndRegisterSchema, clearSchemas, getTableFilter, refresh, refreshSchema, removeSchema, schemaFor, tableFor, tableIds, tablesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitassureNonEmptySchema, schemaForprivate static final org.slf4j.Logger LOGGER
private final DdlParser ddlParser
private final RelationalTableFilters filters
private final DdlChanges ddlChanges
private boolean storageInitialiationExecuted
public MySqlDatabaseSchema(MySqlConnectorConfig connectorConfig, MySqlValueConverters valueConverter, TopicSelector<TableId> topicSelector, SchemaNameAdjuster schemaNameAdjuster, boolean tableIdCaseInsensitive)
MySQL connector configuration.
The DDL statements passed to the schema are parsed and a logical model of the database schema is created.public String[] monitoredTablesAsStringArray()
public void setSystemVariables(Map<String,String> variables)
variables - the system variables; may not be null but may be emptypublic SystemVariables systemVariables()
protected void appendDropTableStatement(StringBuilder sb, TableId tableId)
protected void appendCreateTableStatement(StringBuilder sb, Table table)
protected void refreshSchemas()
public boolean isGlobalSetVariableStatement(String ddl, String databaseName)
public void applySchemaChange(SchemaChangeEvent schemaChange)
public List<SchemaChangeEvent> parseSnapshotDdl(String ddlStatements, String databaseName, MySqlOffsetContext offset, Instant sourceTime)
public List<SchemaChangeEvent> parseStreamingDdl(String ddlStatements, String databaseName, MySqlOffsetContext offset, Instant sourceTime)
private List<SchemaChangeEvent> parseDdl(String ddlStatements, String databaseName, MySqlOffsetContext offset, Instant sourceTime, boolean snapshot)
private void emitChangeEvent(MySqlOffsetContext offset, List<SchemaChangeEvent> schemaChangeEvents, String sanitizedDbName, DdlParserListener.Event event, TableId tableId, SchemaChangeEvent.SchemaChangeEventType type, boolean snapshot)
private boolean acceptableDatabase(String databaseName)
private TableId getTableId(DdlParserListener.Event event)
protected DdlParser getDdlParser()
getDdlParser in class HistorizedRelationalDatabaseSchemapublic boolean historyExists()
public boolean storeOnlyMonitoredTables()
storeOnlyMonitoredTables in interface HistorizedDatabaseSchema<TableId>storeOnlyMonitoredTables in class HistorizedRelationalDatabaseSchemapublic boolean assignTableNumber(long tableNumber,
TableId id)
table ID.tableNumber - the table number found in binlog eventsid - the identifier for the corresponding tabletrue if the assignment was successful, or false if the table is currently excluded in the
connector's configurationpublic TableId getTableId(long tableNumber)
tableNumber - public void clearTableMappings()
public void initializeStorage()
initializeStorage in interface HistorizedDatabaseSchema<TableId>initializeStorage in class HistorizedRelationalDatabaseSchemapublic boolean isStorageInitializationExecuted()
Copyright © 2021 JBoss by Red Hat. All rights reserved.