Class LogMinerStreamingChangeEventSource
- java.lang.Object
-
- io.debezium.connector.oracle.logminer.LogMinerStreamingChangeEventSource
-
- All Implemented Interfaces:
ChangeEventSource,StreamingChangeEventSource<OracleOffsetContext>
public class LogMinerStreamingChangeEventSource extends Object implements StreamingChangeEventSource<OracleOffsetContext>
AStreamingChangeEventSourcebased on Oracle's LogMiner utility. The event handler loop is executed in a separate executor.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.debezium.pipeline.source.spi.ChangeEventSource
ChangeEventSource.ChangeEventSourceContext
-
-
Field Summary
Fields Modifier and Type Field Description private StringarchiveDestinationNameprivate booleanarchiveLogOnlyModeprivate DurationarchiveLogRetentionprivate Clockclockprivate OracleConnectorConfigconnectorConfigprivate List<BigInteger>currentRedoLogSequencesprivate EventDispatcher<TableId>dispatcherprivate ScnendScnprivate ErrorHandlererrorHandlerprivate booleanisContinuousMiningprivate booleanisRacprivate JdbcConfigurationjdbcConfigurationprivate OracleConnectionjdbcConnectionprivate static org.slf4j.LoggerLOGGERprivate Set<String>racHostsprivate OracleDatabaseSchemaschemaprivate ScnstartScnprivate OracleConnectorConfig.LogMiningStrategystrategyprivate OracleStreamingChangeEventSourceMetricsstreamingMetrics
-
Constructor Summary
Constructors Constructor Description LogMinerStreamingChangeEventSource(OracleConnectorConfig connectorConfig, OracleConnection jdbcConnection, EventDispatcher<TableId> dispatcher, ErrorHandler errorHandler, Clock clock, OracleDatabaseSchema schema, Configuration jdbcConfig, OracleStreamingChangeEventSourceMetrics streamingMetrics)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidabandonOldTransactionsIfExist(OracleConnection connection, OracleOffsetContext offsetContext, TransactionalBuffer transactionalBuffer)voidcommitOffset(Map<String,?> offset)voidexecute(ChangeEventSource.ChangeEventSourceContext context, OracleOffsetContext offsetContext)This is the loop to get changes from LogMinerprivate List<BigInteger>getCurrentRedoLogSequences()Get the current redo log sequence(s).private booleanhasLogSwitchOccurred()Checks whether a database log switch has occurred and updates metrics if so.private voidinitializeRedoLogsForMining(OracleConnection connection, boolean postEndMiningSession, Scn startScn)private booleanisStartScnInArchiveLogs(Scn startScn)Returns whether the starting system change number is in the archive logs.private voidpauseBetweenMiningSessions()private booleanwaitForStartScnInArchiveLogs(ChangeEventSource.ChangeEventSourceContext context, Scn startScn)Waits for the starting system change number to exist in the archive logs before returning.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.debezium.pipeline.source.spi.StreamingChangeEventSource
init
-
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
jdbcConnection
private final OracleConnection jdbcConnection
-
dispatcher
private final EventDispatcher<TableId> dispatcher
-
clock
private final Clock clock
-
schema
private final OracleDatabaseSchema schema
-
isRac
private final boolean isRac
-
jdbcConfiguration
private final JdbcConfiguration jdbcConfiguration
-
strategy
private final OracleConnectorConfig.LogMiningStrategy strategy
-
errorHandler
private final ErrorHandler errorHandler
-
isContinuousMining
private final boolean isContinuousMining
-
streamingMetrics
private final OracleStreamingChangeEventSourceMetrics streamingMetrics
-
connectorConfig
private final OracleConnectorConfig connectorConfig
-
archiveLogRetention
private final Duration archiveLogRetention
-
archiveLogOnlyMode
private final boolean archiveLogOnlyMode
-
archiveDestinationName
private final String archiveDestinationName
-
startScn
private Scn startScn
-
endScn
private Scn endScn
-
currentRedoLogSequences
private List<BigInteger> currentRedoLogSequences
-
-
Constructor Detail
-
LogMinerStreamingChangeEventSource
public LogMinerStreamingChangeEventSource(OracleConnectorConfig connectorConfig, OracleConnection jdbcConnection, EventDispatcher<TableId> dispatcher, ErrorHandler errorHandler, Clock clock, OracleDatabaseSchema schema, Configuration jdbcConfig, OracleStreamingChangeEventSourceMetrics streamingMetrics)
-
-
Method Detail
-
execute
public void execute(ChangeEventSource.ChangeEventSourceContext context, OracleOffsetContext offsetContext)
This is the loop to get changes from LogMiner- Specified by:
executein interfaceStreamingChangeEventSource<OracleOffsetContext>- Parameters:
context- change event source context
-
abandonOldTransactionsIfExist
private void abandonOldTransactionsIfExist(OracleConnection connection, OracleOffsetContext offsetContext, TransactionalBuffer transactionalBuffer)
-
initializeRedoLogsForMining
private void initializeRedoLogsForMining(OracleConnection connection, boolean postEndMiningSession, Scn startScn) throws SQLException
- Throws:
SQLException
-
hasLogSwitchOccurred
private boolean hasLogSwitchOccurred() throws SQLExceptionChecks whether a database log switch has occurred and updates metrics if so.- Returns:
trueif a log switch was detected, otherwisefalse- Throws:
SQLException- if a database exception occurred
-
getCurrentRedoLogSequences
private List<BigInteger> getCurrentRedoLogSequences() throws SQLException
Get the current redo log sequence(s). In an Oracle RAC environment, there are multiple current redo logs and therefore this method returns multiple values, each relating to a single RAC node in the Oracle cluster.- Returns:
- list of sequence numbers
- Throws:
SQLException- if a database exception occurred
-
pauseBetweenMiningSessions
private void pauseBetweenMiningSessions() throws InterruptedException- Throws:
InterruptedException
-
waitForStartScnInArchiveLogs
private boolean waitForStartScnInArchiveLogs(ChangeEventSource.ChangeEventSourceContext context, Scn startScn) throws SQLException, InterruptedException
Waits for the starting system change number to exist in the archive logs before returning.- Parameters:
context- the change event source contextstartScn- the starting system change number- Returns:
- true if the code should continue, false if the code should end.
- Throws:
SQLException- if a database exception occurredInterruptedException- if the pause between checks is interrupted
-
isStartScnInArchiveLogs
private boolean isStartScnInArchiveLogs(Scn startScn) throws SQLException
Returns whether the starting system change number is in the archive logs.- Parameters:
startScn- the starting system change number- Returns:
- true if the starting system change number is in the archive logs; false otherwise.
- Throws:
SQLException- if a database exception occurred
-
commitOffset
public void commitOffset(Map<String,?> offset)
- Specified by:
commitOffsetin interfaceStreamingChangeEventSource<OracleOffsetContext>
-
-