public abstract class RelationalSnapshotChangeEventSource extends AbstractSnapshotChangeEventSource
SnapshotChangeEventSource for relational databases with or without a schema history.
A transaction is managed by this base class, sub-classes shouldn't rollback or commit this transaction. They are free to use nested transactions or savepoints, though.
| Modifier and Type | Class and Description |
|---|---|
static class |
RelationalSnapshotChangeEventSource.RelationalSnapshotContext
Mutable context which is populated in the course of snapshotting.
|
AbstractSnapshotChangeEventSource.SnapshotContext, AbstractSnapshotChangeEventSource.SnapshottingTaskChangeEventSource.ChangeEventSourceContext| Modifier and Type | Field and Description |
|---|---|
protected Clock |
clock |
private RelationalDatabaseConnectorConfig |
connectorConfig |
private EventDispatcher<TableId> |
dispatcher |
private JdbcConnection |
jdbcConnection |
private static Duration |
LOG_INTERVAL
Interval for showing a log statement with the progress while scanning a single table.
|
private static org.slf4j.Logger |
LOGGER |
private OffsetContext |
previousOffset |
private HistorizedRelationalDatabaseSchema |
schema |
private SnapshotProgressListener |
snapshotProgressListener |
| Constructor and Description |
|---|
RelationalSnapshotChangeEventSource(RelationalDatabaseConnectorConfig connectorConfig,
OffsetContext previousOffset,
JdbcConnection jdbcConnection,
EventDispatcher<TableId> dispatcher,
Clock clock,
SnapshotProgressListener snapshotProgressListener) |
RelationalSnapshotChangeEventSource(RelationalDatabaseConnectorConfig connectorConfig,
OffsetContext previousOffset,
JdbcConnection jdbcConnection,
HistorizedRelationalDatabaseSchema schema,
EventDispatcher<TableId> dispatcher,
Clock clock,
SnapshotProgressListener snapshotProgressListener) |
complete, delaySnapshotIfNeeded, determineDataCollectionsToBeSnapshotted, execute, getSnapshottingTask, prepareprivate static final org.slf4j.Logger LOGGER
private static final Duration LOG_INTERVAL
private final RelationalDatabaseConnectorConfig connectorConfig
private final OffsetContext previousOffset
private final JdbcConnection jdbcConnection
private final HistorizedRelationalDatabaseSchema schema
private final EventDispatcher<TableId> dispatcher
protected final Clock clock
private final SnapshotProgressListener snapshotProgressListener
public RelationalSnapshotChangeEventSource(RelationalDatabaseConnectorConfig connectorConfig, OffsetContext previousOffset, JdbcConnection jdbcConnection, HistorizedRelationalDatabaseSchema schema, EventDispatcher<TableId> dispatcher, Clock clock, SnapshotProgressListener snapshotProgressListener)
public RelationalSnapshotChangeEventSource(RelationalDatabaseConnectorConfig connectorConfig, OffsetContext previousOffset, JdbcConnection jdbcConnection, EventDispatcher<TableId> dispatcher, Clock clock, SnapshotProgressListener snapshotProgressListener)
public SnapshotResult doExecute(ChangeEventSource.ChangeEventSourceContext context, AbstractSnapshotChangeEventSource.SnapshotContext snapshotContext, AbstractSnapshotChangeEventSource.SnapshottingTask snapshottingTask) throws Exception
AbstractSnapshotChangeEventSourcedoExecute in class AbstractSnapshotChangeEventSourcecontext - contextual information for this source's executionsnapshotContext - mutable context information populated throughout the snapshot processsnapshottingTask - immutable information about what tasks should be performed during snapshotExceptionpublic Connection createSnapshotConnection() throws SQLException
SQLExceptionprotected void connectionCreated(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext) throws Exception
Exceptionprivate void determineCapturedTables(RelationalSnapshotChangeEventSource.RelationalSnapshotContext ctx) throws Exception
Exceptionprotected abstract Set<TableId> getAllTableIds(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext) throws Exception
Exceptionprotected abstract void lockTablesForSchemaSnapshot(ChangeEventSource.ChangeEventSourceContext sourceContext, RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext) throws Exception
Exceptionprotected abstract void determineSnapshotOffset(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext) throws Exception
StreamingChangeEventSource will be set up with this initial position to continue with stream
reading from there.Exceptionprotected abstract void readTableStructure(ChangeEventSource.ChangeEventSourceContext sourceContext, RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext) throws Exception
RelationalSnapshotChangeEventSource.RelationalSnapshotContext.tables.Exceptionprotected abstract void releaseSchemaSnapshotLocks(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext) throws Exception
Exceptionprivate void createSchemaChangeEventsForTables(ChangeEventSource.ChangeEventSourceContext sourceContext, RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext, AbstractSnapshotChangeEventSource.SnapshottingTask snapshottingTask) throws Exception
Exceptionprotected abstract SchemaChangeEvent getCreateTableEvent(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext, Table table) throws Exception
SchemaChangeEvent representing the creation of the given table.Exceptionprivate void createDataEvents(ChangeEventSource.ChangeEventSourceContext sourceContext, RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext) throws InterruptedException
InterruptedExceptionprivate void tryStartingSnapshot(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext)
private void createDataEventsForTable(ChangeEventSource.ChangeEventSourceContext sourceContext, RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext, EventDispatcher.SnapshotReceiver snapshotReceiver, Table table) throws InterruptedException
InterruptedExceptionprivate Threads.Timer getTableScanLogTimer()
protected ChangeRecordEmitter getChangeRecordEmitter(AbstractSnapshotChangeEventSource.SnapshotContext snapshotContext, TableId tableId, Object[] row)
ChangeRecordEmitter producing the change records for the given table row.private Optional<String> determineSnapshotSelect(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext, TableId tableId)
tableId - the table to generate a query forprotected String enhanceOverriddenSelect(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext, String overriddenSelect, TableId tableId)
snapshotContext - snapshot context, used for getting offset SCNoverriddenSelect - conditional snapshot selectprotected abstract Optional<String> getSnapshotSelect(RelationalSnapshotChangeEventSource.RelationalSnapshotContext snapshotContext, TableId tableId)
protected Object getColumnValue(ResultSet rs, int columnIndex, Column column) throws SQLException
SQLExceptionprivate Statement readTableStatement() throws SQLException
SQLExceptionprivate void rollbackTransaction(Connection connection)
protected Clock getClock()
Copyright © 2021 JBoss by Red Hat. All rights reserved.