Class MemoryLogMinerEventProcessor
- java.lang.Object
-
- io.debezium.connector.oracle.logminer.processor.AbstractLogMinerEventProcessor<MemoryTransaction>
-
- io.debezium.connector.oracle.logminer.processor.memory.MemoryLogMinerEventProcessor
-
- All Implemented Interfaces:
LogMinerEventProcessor,AutoCloseable
public class MemoryLogMinerEventProcessor extends AbstractLogMinerEventProcessor<MemoryTransaction>
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 EventDispatcher<OraclePartition,TableId>dispatcherprivate OracleConnectionjdbcConnectionprivate static org.slf4j.LoggerLOGGERprivate OracleStreamingChangeEventSourceMetricsmetricsprivate OracleOffsetContextoffsetContextprivate OraclePartitionpartitionprivate Map<String,Scn>recentlyProcessedTransactionsCacheCache of processed transactions (committed or rolled back), keyed based on the transaction's unique identifier.private Set<Scn>schemaChangesCacheprivate Map<String,MemoryTransaction>transactionCacheCache of transactions, keyed based on the transaction's unique identifier-
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<OraclePartition,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.protected voidaddToTransaction(String transactionId, LogMinerEventRow row, Supplier<LogMinerEvent> eventSupplier)Add a transaction to the transaction map if allowed.protected ScncalculateNewStartScn(Scn endScn, Scn maxCommittedScn)Calculates the new starting system change number based on the current processing range.voidclose()protected PreparedStatementcreateQueryStatement()Create the JDBC query that will be used to fetch the mining result set.protected MemoryTransactioncreateTransaction(LogMinerEventRow row)Creates a new transaction based on the suppliedSTARTevent.protected voidfinalizeTransactionCommit(String transactionId, Scn commitScn)Finalizes the commit of a transaction.protected voidfinalizeTransactionRollback(String transactionId, Scn rollbackScn)Finalizes the rollback the specified transactionprotected MemoryTransactiongetAndRemoveTransactionFromCache(String transactionId)Gets a transaction instance from the transaction cache while also removing its cache entry.protected Optional<Scn>getLastScnToAbandon(OracleConnection connection, Scn offsetScn, Duration retention)Calculates the SCN as a watermark to abandon for long running transactions.protected Map<String,MemoryTransaction>getTransactionCache()Returns theTransactionCacheimplementation.protected ScngetTransactionCacheMinimumScn()Gets the minimum system change number stored in the transaction cache.protected intgetTransactionEventCount(MemoryTransaction transaction)Returns the number of events associated with the specified transaction.protected Iterator<LogMinerEvent>getTransactionEventIterator(MemoryTransaction transaction)Get an iterator over the events that are part of the specified transaction.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 booleanisRecentlyProcessed(String transactionId)Check whether a transaction has been recently processed through either a commit or rollback.protected voidremoveEventWithRowId(LogMinerEventRow row)Removes a specific transaction event by database row identifier.protected voidremoveTransactionAndEventsFromCache(MemoryTransaction transaction)Removes the transaction and all its associated event entries from the connector's caches.-
Methods inherited from class io.debezium.connector.oracle.logminer.processor.AbstractLogMinerEventProcessor
getConfig, getLastProcessedScn, getSchema, handleCommit, handleDataEvent, handleLobWrite, handleMissingScn, handleRollback, handleSelectLobLocator, handleStart, isTransactionAlreadyProcessed, isTransactionUserExcluded, isTrxIdRawValue, process, processResults, processRow, warnPotentiallyStuckScn
-
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
jdbcConnection
private final OracleConnection jdbcConnection
-
dispatcher
private final EventDispatcher<OraclePartition,TableId> dispatcher
-
partition
private final OraclePartition partition
-
offsetContext
private final OracleOffsetContext offsetContext
-
metrics
private final OracleStreamingChangeEventSourceMetrics metrics
-
transactionCache
private final Map<String,MemoryTransaction> transactionCache
Cache of transactions, keyed based on the transaction's unique identifier
-
recentlyProcessedTransactionsCache
private final Map<String,Scn> recentlyProcessedTransactionsCache
Cache of processed transactions (committed or rolled back), keyed based on the transaction's unique identifier.
-
-
Constructor Detail
-
MemoryLogMinerEventProcessor
public MemoryLogMinerEventProcessor(ChangeEventSource.ChangeEventSourceContext context, OracleConnectorConfig connectorConfig, OracleConnection jdbcConnection, EventDispatcher<OraclePartition,TableId> dispatcher, OraclePartition partition, OracleOffsetContext offsetContext, OracleDatabaseSchema schema, OracleStreamingChangeEventSourceMetrics metrics)
-
-
Method Detail
-
getTransactionCache
protected Map<String,MemoryTransaction> getTransactionCache()
Description copied from class:AbstractLogMinerEventProcessorReturns theTransactionCacheimplementation.- Specified by:
getTransactionCachein classAbstractLogMinerEventProcessor<MemoryTransaction>- Returns:
- the transaction cache, never
null
-
createTransaction
protected MemoryTransaction createTransaction(LogMinerEventRow row)
Description copied from class:AbstractLogMinerEventProcessorCreates a new transaction based on the suppliedSTARTevent.- Specified by:
createTransactionin classAbstractLogMinerEventProcessor<MemoryTransaction>- Parameters:
row- the event row, must not benull- Returns:
- the implementation-specific
Transactioninstance
-
removeEventWithRowId
protected void removeEventWithRowId(LogMinerEventRow row)
Description copied from class:AbstractLogMinerEventProcessorRemoves a specific transaction event by database row identifier.- Specified by:
removeEventWithRowIdin classAbstractLogMinerEventProcessor<MemoryTransaction>- Parameters:
row- the event row that contains the row identifier, must not benull
-
abandonTransactions
public void abandonTransactions(Duration retention) throws InterruptedException
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.- Throws:
InterruptedException
-
isRecentlyProcessed
protected boolean isRecentlyProcessed(String transactionId)
Description copied from class:AbstractLogMinerEventProcessorCheck whether a transaction has been recently processed through either a commit or rollback.- Overrides:
isRecentlyProcessedin classAbstractLogMinerEventProcessor<MemoryTransaction>- Parameters:
transactionId- the unique transaction id- Returns:
- true if the transaction has been recently processed, false otherwise
-
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<MemoryTransaction>- Parameters:
row- the result set row- Returns:
- true if the schema change has been seen, false otherwise.
-
getAndRemoveTransactionFromCache
protected MemoryTransaction getAndRemoveTransactionFromCache(String transactionId)
Description copied from class:AbstractLogMinerEventProcessorGets a transaction instance from the transaction cache while also removing its cache entry.- Specified by:
getAndRemoveTransactionFromCachein classAbstractLogMinerEventProcessor<MemoryTransaction>- Parameters:
transactionId- the transaction's unique identifier, should not benull- Returns:
- the transaction instance if found,
nullif the transaction wasn't found
-
removeTransactionAndEventsFromCache
protected void removeTransactionAndEventsFromCache(MemoryTransaction transaction)
Description copied from class:AbstractLogMinerEventProcessorRemoves the transaction and all its associated event entries from the connector's caches.- Specified by:
removeTransactionAndEventsFromCachein classAbstractLogMinerEventProcessor<MemoryTransaction>- Parameters:
transaction- the transaction instance, should never benull
-
getTransactionEventIterator
protected Iterator<LogMinerEvent> getTransactionEventIterator(MemoryTransaction transaction)
Description copied from class:AbstractLogMinerEventProcessorGet an iterator over the events that are part of the specified transaction.- Specified by:
getTransactionEventIteratorin classAbstractLogMinerEventProcessor<MemoryTransaction>- Parameters:
transaction- the transaction instance, should never benull- Returns:
- an iterator over the transaction's events, never
null
-
finalizeTransactionCommit
protected void finalizeTransactionCommit(String transactionId, Scn commitScn)
Description copied from class:AbstractLogMinerEventProcessorFinalizes the commit of a transaction.- Specified by:
finalizeTransactionCommitin classAbstractLogMinerEventProcessor<MemoryTransaction>- Parameters:
transactionId- the transaction's unique identifier, should not benullcommitScn- the transaction's system change number, should not benull
-
finalizeTransactionRollback
protected void finalizeTransactionRollback(String transactionId, Scn rollbackScn)
Description copied from class:AbstractLogMinerEventProcessorFinalizes the rollback the specified transaction- Specified by:
finalizeTransactionRollbackin classAbstractLogMinerEventProcessor<MemoryTransaction>- Parameters:
transactionId- the unique transaction identifier, nevernullrollbackScn- the rollback transaction's system change number, nevernull
-
handleSchemaChange
protected void handleSchemaChange(LogMinerEventRow row) throws InterruptedException
Description copied from class:AbstractLogMinerEventProcessorHandle processing a LogMinerEventRow for aDDLevent.- Overrides:
handleSchemaChangein classAbstractLogMinerEventProcessor<MemoryTransaction>- Parameters:
row- the result set row- Throws:
InterruptedException- if the event dispatcher is interrupted sending the event
-
addToTransaction
protected void addToTransaction(String transactionId, LogMinerEventRow row, Supplier<LogMinerEvent> eventSupplier)
Description copied from class:AbstractLogMinerEventProcessorAdd a transaction to the transaction map if allowed.- Specified by:
addToTransactionin classAbstractLogMinerEventProcessor<MemoryTransaction>- Parameters:
transactionId- the unqiue transaction idrow- the LogMiner event roweventSupplier- the supplier of the event to create if the event is allowed to be added
-
getTransactionEventCount
protected int getTransactionEventCount(MemoryTransaction transaction)
Description copied from class:AbstractLogMinerEventProcessorReturns the number of events associated with the specified transaction.- Specified by:
getTransactionEventCountin classAbstractLogMinerEventProcessor<MemoryTransaction>- Parameters:
transaction- the transaction, must not benull- Returns:
- the number of events in the transaction
-
createQueryStatement
protected PreparedStatement createQueryStatement() throws SQLException
Description copied from class:AbstractLogMinerEventProcessorCreate the JDBC query that will be used to fetch the mining result set.- Specified by:
createQueryStatementin classAbstractLogMinerEventProcessor<MemoryTransaction>- Returns:
- a prepared query statement, never
null - Throws:
SQLException- if a database exception occurred creating the statement
-
calculateNewStartScn
protected Scn calculateNewStartScn(Scn endScn, Scn maxCommittedScn) throws InterruptedException
Description copied from class:AbstractLogMinerEventProcessorCalculates the new starting system change number based on the current processing range.- Specified by:
calculateNewStartScnin classAbstractLogMinerEventProcessor<MemoryTransaction>- Parameters:
endScn- the end system change number for the previously mined range, nevernullmaxCommittedScn- the maximum committed system change number, nevernull- Returns:
- the system change number to start then next mining iteration from, never
null - Throws:
InterruptedException- if the current thread is interrupted
-
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
-
getTransactionCacheMinimumScn
protected Scn getTransactionCacheMinimumScn()
Description copied from class:AbstractLogMinerEventProcessorGets the minimum system change number stored in the transaction cache.- Specified by:
getTransactionCacheMinimumScnin classAbstractLogMinerEventProcessor<MemoryTransaction>- Returns:
- the minimum system change number, never
nullbut could beScn.NULL.
-
-