public class MySqlSnapshotChangeEventSource extends RelationalSnapshotChangeEventSource
| Modifier and Type | Class and Description |
|---|---|
private static class |
MySqlSnapshotChangeEventSource.MySqlSnapshotContext
Mutable context which is populated in the course of snapshotting.
|
RelationalSnapshotChangeEventSource.RelationalSnapshotContextAbstractSnapshotChangeEventSource.SnapshotContext, AbstractSnapshotChangeEventSource.SnapshottingTaskChangeEventSource.ChangeEventSourceContext| Modifier and Type | Field and Description |
|---|---|
private MySqlConnection |
connection |
private MySqlConnectorConfig |
connectorConfig |
private MySqlDatabaseSchema |
databaseSchema |
private Set<TableId> |
delayedSchemaSnapshotTables |
private RelationalTableFilters |
filters |
private long |
globalLockAcquiredAt |
private BlockingConsumer<Function<org.apache.kafka.connect.source.SourceRecord,org.apache.kafka.connect.source.SourceRecord>> |
lastEventProcessor |
private static org.slf4j.Logger |
LOGGER |
private MySqlSnapshotChangeEventSourceMetrics |
metrics |
private MySqlOffsetContext |
previousOffset |
private List<SchemaChangeEvent> |
schemaEvents |
private long |
tableLockAcquiredAt |
clock, dispatcher| Constructor and Description |
|---|
MySqlSnapshotChangeEventSource(MySqlConnectorConfig connectorConfig,
MySqlOffsetContext previousOffset,
MySqlConnection connection,
MySqlDatabaseSchema schema,
EventDispatcher<TableId> dispatcher,
Clock clock,
MySqlSnapshotChangeEventSourceMetrics metrics,
BlockingConsumer<Function<org.apache.kafka.connect.source.SourceRecord,org.apache.kafka.connect.source.SourceRecord>> lastEventProcessor) |
createSnapshotConnection, doExecute, enhanceOverriddenSelect, getChangeRecordEmitter, getClock, getColumnValue, tryStartingSnapshotdelaySnapshotIfNeeded, determineDataCollectionsToBeSnapshotted, executeprivate static final org.slf4j.Logger LOGGER
private final MySqlConnectorConfig connectorConfig
private final MySqlConnection connection
private long globalLockAcquiredAt
private long tableLockAcquiredAt
private final RelationalTableFilters filters
private final MySqlSnapshotChangeEventSourceMetrics metrics
private final MySqlOffsetContext previousOffset
private final MySqlDatabaseSchema databaseSchema
private final List<SchemaChangeEvent> schemaEvents
private final BlockingConsumer<Function<org.apache.kafka.connect.source.SourceRecord,org.apache.kafka.connect.source.SourceRecord>> lastEventProcessor
public MySqlSnapshotChangeEventSource(MySqlConnectorConfig connectorConfig, MySqlOffsetContext previousOffset, MySqlConnection connection, MySqlDatabaseSchema schema, EventDispatcher<TableId> dispatcher, Clock clock, MySqlSnapshotChangeEventSourceMetrics metrics, BlockingConsumer<Function<org.apache.kafka.connect.source.SourceRecord,org.apache.kafka.connect.source.SourceRecord>> lastEventProcessor)
protected AbstractSnapshotChangeEventSource.SnapshottingTask getSnapshottingTask(OffsetContext previousOffset)
getSnapshottingTask in class AbstractSnapshotChangeEventSourceprotected AbstractSnapshotChangeEventSource.SnapshotContext prepare(ChangeEventSource.ChangeEventSourceContext context) throws Exception
prepare in class AbstractSnapshotChangeEventSourceExceptionprotected void connectionCreated(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext) throws Exception
connectionCreated in class RelationalSnapshotChangeEventSourceExceptionprotected Set<TableId> getAllTableIds(RelationalSnapshotChangeEventSource.RelationalSnapshotContext ctx) throws Exception
getAllTableIds in class RelationalSnapshotChangeEventSourceExceptionprotected void lockTablesForSchemaSnapshot(ChangeEventSource.ChangeEventSourceContext sourceContext, RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext) throws SQLException, InterruptedException
lockTablesForSchemaSnapshot in class RelationalSnapshotChangeEventSourceSQLExceptionInterruptedExceptionprotected void releaseSchemaSnapshotLocks(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext) throws SQLException
releaseSchemaSnapshotLocks in class RelationalSnapshotChangeEventSourceSQLExceptionprotected void releaseDataSnapshotLocks(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext) throws Exception
releaseDataSnapshotLocks in class RelationalSnapshotChangeEventSourceExceptionprotected void determineSnapshotOffset(RelationalSnapshotChangeEventSource.RelationalSnapshotContext ctx) throws Exception
determineSnapshotOffset in class RelationalSnapshotChangeEventSourceExceptionprivate void addSchemaEvent(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext, String database, String ddl)
protected void readTableStructure(ChangeEventSource.ChangeEventSourceContext sourceContext, RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext) throws Exception
readTableStructure in class RelationalSnapshotChangeEventSourceExceptionvoid createSchemaEventsForTables(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext, Collection<TableId> tablesToRead, boolean firstPhase) throws SQLException
SQLExceptionprivate boolean twoPhaseSchemaSnapshot()
protected SchemaChangeEvent getCreateTableEvent(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext, Table table) throws SQLException
getCreateTableEvent in class RelationalSnapshotChangeEventSourceSQLExceptionprotected void complete(AbstractSnapshotChangeEventSource.SnapshotContext snapshotContext)
complete in class AbstractSnapshotChangeEventSourceprotected Optional<String> getSnapshotSelect(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext, TableId tableId)
getSnapshotSelect in class RelationalSnapshotChangeEventSourcetableId - the table to generate a query forprotected Object getColumnValue(ResultSet rs, int columnIndex, Column column, Table table) throws SQLException
getColumnValue in class RelationalSnapshotChangeEventSourceSQLExceptionprivate Object readTimeField(ResultSet rs, int fieldNo) throws SQLException
SQLExceptionhttps://issues.jboss.org/browse/DBZ-342private Object readDateField(ResultSet rs, int fieldNo, Column column, Table table) throws SQLException
SQLExceptionprivate Object readTimestampField(ResultSet rs, int fieldNo, Column column, Table table) throws SQLException
SQLExceptionprivate boolean isGloballyLocked()
private boolean isTablesLocked()
private void globalLock()
throws SQLException
SQLExceptionprivate void globalUnlock()
throws SQLException
SQLExceptionprivate void tableLock(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext) throws SQLException
SQLExceptionprivate void tableUnlock()
throws SQLException
SQLExceptionprotected OptionalLong rowCountForTable(TableId tableId)
rowCountForTable in class RelationalSnapshotChangeEventSourceprotected Statement readTableStatement(OptionalLong rowCount) throws SQLException
readTableStatement in class RelationalSnapshotChangeEventSourceSQLExceptionprivate Statement createStatementWithLargeResultSet() throws SQLException
By default, the MySQL Connector/J driver retrieves all rows for ResultSets and stores them in memory. In most cases this
is the most efficient way to operate and, due to the design of the MySQL network protocol, is easier to implement.
However, when ResultSets that have a large number of rows or large values, the driver may not be able to allocate
heap space in the JVM and may result in an OutOfMemoryError. See
DBZ-94 for details.
This method handles such cases using the
recommended
technique for MySQL by creating the JDBC Statement with forward-only cursor
and read-only concurrency flags, and with a minimum value
fetch size hint.
SQLException - if there is a problem creating the statementprotected void createSchemaChangeEventsForTables(ChangeEventSource.ChangeEventSourceContext sourceContext, RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext, AbstractSnapshotChangeEventSource.SnapshottingTask snapshottingTask) throws Exception
createSchemaChangeEventsForTables in class RelationalSnapshotChangeEventSourceExceptionprotected void lastSnapshotRecord(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext)
lastSnapshotRecord in class RelationalSnapshotChangeEventSourceprotected void postSnapshot()
throws InterruptedException
postSnapshot in class RelationalSnapshotChangeEventSourceInterruptedExceptionCopyright © 2021 JBoss by Red Hat. All rights reserved.