Class MemoryLogMinerEventProcessor
- java.lang.Object
-
- io.debezium.connector.oracle.logminer.processor.AbstractLogMinerEventProcessor
-
- io.debezium.connector.oracle.logminer.processor.memory.MemoryLogMinerEventProcessor
-
- All Implemented Interfaces:
LogMinerEventProcessor,AutoCloseable
public class MemoryLogMinerEventProcessor extends AbstractLogMinerEventProcessor
ALogMinerEventProcessorthat uses the JVM heap to store events as they're being processed and emitted from Oracle LogMiner.- Author:
- Chris Cranford
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.debezium.connector.oracle.logminer.processor.AbstractLogMinerEventProcessor
AbstractLogMinerEventProcessor.Counters
-
-
Field Summary
Fields Modifier and Type Field Description private Set<String>abandonedTransactionsCacheprivate ChangeEventSource.ChangeEventSourceContextcontextprivate ScncurrentOffsetCommitScnprivate ScncurrentOffsetScnprivate EventDispatcher<TableId>dispatcherprivate OracleConnectionjdbcConnectionprivate ScnlastCommittedScnprivate static org.slf4j.LoggerLOGGERprivate ScnmaxCommittedScnprivate OracleStreamingChangeEventSourceMetricsmetricsprivate OracleOffsetContextoffsetContextprivate OraclePartitionpartitionprivate Map<String,Scn>recentlyCommittedTransactionsCacheprivate Set<String>rollbackTransactionsCacheprivate Set<Scn>schemaChangesCacheprivate MemoryTransactionCachetransactionCache-
Fields inherited from class io.debezium.connector.oracle.logminer.processor.AbstractLogMinerEventProcessor
counters
-
-
Constructor Summary
Constructors Constructor Description MemoryLogMinerEventProcessor(ChangeEventSource.ChangeEventSourceContext context, OracleConnectorConfig connectorConfig, OracleConnection jdbcConnection, EventDispatcher<TableId> dispatcher, OraclePartition partition, OracleOffsetContext offsetContext, OracleDatabaseSchema schema, OracleStreamingChangeEventSourceMetrics metrics)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabandonTransactions(Duration retention)A callback for the event processor to abandon long running transactions.private ScncalculateNewStartScn(Scn endScn)voidclose()private PreparedStatementcreateQueryStatement()protected Optional<Scn>getLastScnToAbandon(OracleConnection connection, Scn offsetScn, Duration retention)Calculates the SCN as a watermark to abandon for long running transactions.protected TransactionCache<?>getTransactionCache()Returns theTransactionCacheimplementation.protected voidhandleCommit(LogMinerEventRow row)Handle processing a LogMinerEventRow for aCOMMITevent.protected voidhandleRollback(LogMinerEventRow row)Handle processing a LogMinerEventRow for aROLLBACKevent.protected voidhandleSchemaChange(LogMinerEventRow row)Handle processing a LogMinerEventRow for aDDLevent.protected booleanhasSchemaChangeBeenSeen(LogMinerEventRow row)Checks whether the LogMinerEvent row for a schema change can be emitted.protected booleanisRecentlyCommitted(String transactionId)Check whether a transaction has been recently committed.protected booleanisTransactionIdAllowed(String transactionId)Return whether a give transaction can be added to the processor's buffer.Scnprocess(Scn startScn, Scn endScn)Process Oracle LogMiner events for a given system change number range.-
Methods inherited from class io.debezium.connector.oracle.logminer.processor.AbstractLogMinerEventProcessor
addToTransaction, getConfig, getLastProcessedScn, getReconciliation, getSchema, handleDataEvent, handleLobWrite, handleMissingScn, handleSelectLobLocator, handleStart, isTrxIdRawValue, processResults, processRow, warnPotentiallyStuckScn
-
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
context
private final ChangeEventSource.ChangeEventSourceContext context
-
jdbcConnection
private final OracleConnection jdbcConnection
-
dispatcher
private final EventDispatcher<TableId> dispatcher
-
partition
private final OraclePartition partition
-
offsetContext
private final OracleOffsetContext offsetContext
-
metrics
private final OracleStreamingChangeEventSourceMetrics metrics
-
transactionCache
private final MemoryTransactionCache transactionCache
-
recentlyCommittedTransactionsCache
private final Map<String,Scn> recentlyCommittedTransactionsCache
-
currentOffsetScn
private Scn currentOffsetScn
-
currentOffsetCommitScn
private Scn currentOffsetCommitScn
-
lastCommittedScn
private Scn lastCommittedScn
-
maxCommittedScn
private Scn maxCommittedScn
-
-
Constructor Detail
-
MemoryLogMinerEventProcessor
public MemoryLogMinerEventProcessor(ChangeEventSource.ChangeEventSourceContext context, OracleConnectorConfig connectorConfig, OracleConnection jdbcConnection, EventDispatcher<TableId> dispatcher, OraclePartition partition, OracleOffsetContext offsetContext, OracleDatabaseSchema schema, OracleStreamingChangeEventSourceMetrics metrics)
-
-
Method Detail
-
getTransactionCache
protected TransactionCache<?> getTransactionCache()
Description copied from class:AbstractLogMinerEventProcessorReturns theTransactionCacheimplementation.- Specified by:
getTransactionCachein classAbstractLogMinerEventProcessor- Returns:
- the transaction cache, never
null
-
process
public Scn process(Scn startScn, Scn endScn) throws SQLException, InterruptedException
Description copied from interface:LogMinerEventProcessorProcess Oracle LogMiner events for a given system change number range.- Parameters:
startScn- the starting system change number, must not benullendScn- the ending system change number, must not benull- Returns:
- the next iteration's starting system change number, never
null - Throws:
SQLExceptionInterruptedException
-
abandonTransactions
public void abandonTransactions(Duration retention)
Description copied from interface:LogMinerEventProcessorA callback for the event processor to abandon long running transactions.- Parameters:
retention- the maximum duration in which long running transactions are allowed.
-
isRecentlyCommitted
protected boolean isRecentlyCommitted(String transactionId)
Description copied from class:AbstractLogMinerEventProcessorCheck whether a transaction has been recently committed. Any implementation that does not support recently-committed tracking should return false.- Overrides:
isRecentlyCommittedin classAbstractLogMinerEventProcessor- Parameters:
transactionId- the unique transaction id- Returns:
- true if the transaction has been recently committed, false otherwise
-
isTransactionIdAllowed
protected boolean isTransactionIdAllowed(String transactionId)
Description copied from class:AbstractLogMinerEventProcessorReturn whether a give transaction can be added to the processor's buffer. The default implementation is to allow all transaction ids.- Overrides:
isTransactionIdAllowedin classAbstractLogMinerEventProcessor- Parameters:
transactionId- the unique transaction id- Returns:
- whether a transaction id can be added to the processor's buffer
-
hasSchemaChangeBeenSeen
protected boolean hasSchemaChangeBeenSeen(LogMinerEventRow row)
Description copied from class:AbstractLogMinerEventProcessorChecks whether the LogMinerEvent row for a schema change can be emitted.- Overrides:
hasSchemaChangeBeenSeenin classAbstractLogMinerEventProcessor- Parameters:
row- the result set row- Returns:
- true if the schema change has been seen, false otherwise.
-
handleCommit
protected void handleCommit(LogMinerEventRow row) throws InterruptedException
Description copied from class:AbstractLogMinerEventProcessorHandle processing a LogMinerEventRow for aCOMMITevent.- Specified by:
handleCommitin classAbstractLogMinerEventProcessor- Parameters:
row- the result set row- Throws:
InterruptedException- if the event dispatcher was interrupted sending events
-
handleRollback
protected void handleRollback(LogMinerEventRow row)
Description copied from class:AbstractLogMinerEventProcessorHandle processing a LogMinerEventRow for aROLLBACKevent. The default implementation is a no-op.- Overrides:
handleRollbackin classAbstractLogMinerEventProcessor- Parameters:
row- the result set row
-
handleSchemaChange
protected void handleSchemaChange(LogMinerEventRow row) throws InterruptedException
Description copied from class:AbstractLogMinerEventProcessorHandle processing a LogMinerEventRow for aDDLevent.- Overrides:
handleSchemaChangein classAbstractLogMinerEventProcessor- Parameters:
row- the result set row- Throws:
InterruptedException- if the event dispatcher is interrupted sending the event
-
createQueryStatement
private PreparedStatement createQueryStatement() throws SQLException
- Throws:
SQLException
-
calculateNewStartScn
private Scn calculateNewStartScn(Scn endScn) throws InterruptedException
- Throws:
InterruptedException
-
getLastScnToAbandon
protected Optional<Scn> getLastScnToAbandon(OracleConnection connection, Scn offsetScn, Duration retention)
Calculates the SCN as a watermark to abandon for long running transactions. The criteria is do not let the offset SCN expire from archives older the specified retention hours.- Parameters:
connection- database connection, should not benulloffsetScn- offset system change number, should not benullretention- duration to tolerate long running transactions before being abandoned, must not benull- Returns:
- an optional system change number as the watermark for transaction buffer abandonment
-
-