public abstract class HistorizedRelationalSnapshotChangeEventSource extends Object implements SnapshotChangeEventSource
SnapshotChangeEventSource for relational databases with 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 |
HistorizedRelationalSnapshotChangeEventSource.SnapshotContext
Mutable context which is populated in the course of snapshotting.
|
static class |
HistorizedRelationalSnapshotChangeEventSource.SnapshottingTask
A configuration describing the task to be performed during snapshotting.
|
ChangeEventSource.ChangeEventSourceContext| Modifier and Type | Field and Description |
|---|---|
private 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 |
|---|
HistorizedRelationalSnapshotChangeEventSource(RelationalDatabaseConnectorConfig connectorConfig,
OffsetContext previousOffset,
JdbcConnection jdbcConnection,
HistorizedRelationalDatabaseSchema schema,
EventDispatcher<TableId> dispatcher,
Clock clock,
SnapshotProgressListener snapshotProgressListener) |
private 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
private final Clock clock
private final SnapshotProgressListener snapshotProgressListener
public HistorizedRelationalSnapshotChangeEventSource(RelationalDatabaseConnectorConfig connectorConfig, OffsetContext previousOffset, JdbcConnection jdbcConnection, HistorizedRelationalDatabaseSchema schema, EventDispatcher<TableId> dispatcher, Clock clock, SnapshotProgressListener snapshotProgressListener)
public SnapshotResult execute(ChangeEventSource.ChangeEventSourceContext context) throws InterruptedException
SnapshotChangeEventSourceexecute in interface SnapshotChangeEventSourcecontext - contextual information for this source's executionInterruptedException - in case the snapshot was aborted before completionprotected abstract HistorizedRelationalSnapshotChangeEventSource.SnapshottingTask getSnapshottingTask(OffsetContext previousOffset)
private void delaySnapshotIfNeeded(ChangeEventSource.ChangeEventSourceContext context) throws InterruptedException
CommonConnectorConfig.SNAPSHOT_DELAY_MS parameter.InterruptedExceptionprotected abstract HistorizedRelationalSnapshotChangeEventSource.SnapshotContext prepare(ChangeEventSource.ChangeEventSourceContext changeEventSourceContext) throws Exception
HistorizedRelationalSnapshotChangeEventSource.SnapshotContext.Exceptionprotected void connectionCreated(HistorizedRelationalSnapshotChangeEventSource.SnapshotContext snapshotContext) throws Exception
Exceptionprivate void determineCapturedTables(HistorizedRelationalSnapshotChangeEventSource.SnapshotContext ctx) throws Exception
Exceptionprotected abstract Set<TableId> getAllTableIds(HistorizedRelationalSnapshotChangeEventSource.SnapshotContext snapshotContext) throws Exception
Exceptionprotected abstract void lockTablesForSchemaSnapshot(ChangeEventSource.ChangeEventSourceContext sourceContext, HistorizedRelationalSnapshotChangeEventSource.SnapshotContext snapshotContext) throws Exception
Exceptionprotected abstract void determineSnapshotOffset(HistorizedRelationalSnapshotChangeEventSource.SnapshotContext 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, HistorizedRelationalSnapshotChangeEventSource.SnapshotContext snapshotContext) throws Exception
HistorizedRelationalSnapshotChangeEventSource.SnapshotContext.tables.Exceptionprotected abstract void releaseSchemaSnapshotLocks(HistorizedRelationalSnapshotChangeEventSource.SnapshotContext snapshotContext) throws Exception
Exceptionprivate void createSchemaChangeEventsForTables(ChangeEventSource.ChangeEventSourceContext sourceContext, HistorizedRelationalSnapshotChangeEventSource.SnapshotContext snapshotContext) throws Exception
Exceptionprotected abstract SchemaChangeEvent getCreateTableEvent(HistorizedRelationalSnapshotChangeEventSource.SnapshotContext snapshotContext, Table table) throws Exception
SchemaChangeEvent representing the creation of the given table.Exceptionprivate void createDataEvents(ChangeEventSource.ChangeEventSourceContext sourceContext, HistorizedRelationalSnapshotChangeEventSource.SnapshotContext snapshotContext) throws InterruptedException
InterruptedExceptionprivate void createDataEventsForTable(ChangeEventSource.ChangeEventSourceContext sourceContext, HistorizedRelationalSnapshotChangeEventSource.SnapshotContext snapshotContext, EventDispatcher.SnapshotReceiver snapshotReceiver, Table table) throws InterruptedException
InterruptedExceptionprivate Threads.Timer getTableScanLogTimer()
protected abstract ChangeRecordEmitter getChangeRecordEmitter(HistorizedRelationalSnapshotChangeEventSource.SnapshotContext snapshotContext, Object[] row)
ChangeRecordEmitter producing the change records for the given table row.protected abstract String getSnapshotSelect(HistorizedRelationalSnapshotChangeEventSource.SnapshotContext snapshotContext, TableId tableId)
private Column[] getColumnsForResultSet(Table table, ResultSet rs) throws SQLException
SQLExceptionprivate Object getColumnValue(ResultSet rs, int columnIndex, Column column) throws SQLException
SQLExceptionprivate Statement readTableStatement() throws SQLException
SQLExceptionprotected abstract void complete(HistorizedRelationalSnapshotChangeEventSource.SnapshotContext snapshotContext)
snapshotContext - snapshot contextprivate void rollbackTransaction(Connection connection)
protected Clock getClock()
Copyright © 2019 JBoss by Red Hat. All rights reserved.