Class AbstractInfinispanLogMinerEventProcessor
- java.lang.Object
-
- io.debezium.connector.oracle.logminer.processor.AbstractLogMinerEventProcessor<InfinispanTransaction>
-
- io.debezium.connector.oracle.logminer.processor.infinispan.AbstractInfinispanLogMinerEventProcessor
-
- All Implemented Interfaces:
CacheProvider,LogMinerEventProcessor,AutoCloseable
- Direct Known Subclasses:
EmbeddedInfinispanLogMinerEventProcessor,RemoteInfinispanLogMinerEventProcessor
public abstract class AbstractInfinispanLogMinerEventProcessor extends AbstractLogMinerEventProcessor<InfinispanTransaction> implements CacheProvider
An implementation ofLogMinerEventProcessorthat uses Infinispan to persist the transaction cache across restarts on disk.- 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 EventDispatcher<TableId>dispatcherprivate OracleConnectionjdbcConnectionprivate static org.slf4j.LoggerLOGGERprivate OracleStreamingChangeEventSourceMetricsmetricsprivate OracleOffsetContextoffsetContextprivate OraclePartitionpartition-
Fields inherited from class io.debezium.connector.oracle.logminer.processor.AbstractLogMinerEventProcessor
counters
-
Fields inherited from interface io.debezium.connector.oracle.logminer.processor.infinispan.CacheProvider
EVENTS_CACHE_NAME, PROCESSED_TRANSACTIONS_CACHE_NAME, SCHEMA_CHANGES_CACHE_NAME, TRANSACTIONS_CACHE_NAME
-
-
Constructor Summary
Constructors Constructor Description AbstractInfinispanLogMinerEventProcessor(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.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.protected PreparedStatementcreateQueryStatement()Create the JDBC query that will be used to fetch the mining result set.protected InfinispanTransactioncreateTransaction(LogMinerEventRow row)Creates a new transaction based on the suppliedSTARTevent.voiddisplayCacheStatistics()Displays cache statisticsprotected voidfinalizeTransactionCommit(String transactionId, Scn commitScn)Finalizes the commit of a transaction.protected voidfinalizeTransactionRollback(String transactionId, Scn rollbackScn)Finalizes the rollback the specified transactionprotected InfinispanTransactiongetAndRemoveTransactionFromCache(String transactionId)Gets a transaction instance from the transaction cache while also removing its cache entry.protected intgetTransactionEventCount(InfinispanTransaction transaction)Returns the number of events associated with the specified transaction.protected Iterator<LogMinerEvent>getTransactionEventIterator(InfinispanTransaction 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 voidprocessRow(LogMinerEventRow row)Processes a single LogMinerEventRow.private voidremoveEventsWithTransaction(InfinispanTransaction transaction)protected voidremoveEventWithRowId(LogMinerEventRow row)Removes a specific transaction event by database row identifier.protected voidremoveTransactionAndEventsFromCache(InfinispanTransaction 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, getTransactionCache, getTransactionCacheMinimumScn, handleCommit, handleDataEvent, handleLobWrite, handleMissingScn, handleRollback, handleSelectLobLocator, handleStart, isTransactionAlreadyProcessed, isTransactionUserExcluded, isTrxIdRawValue, process, processResults, warnPotentiallyStuckScn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.AutoCloseable
close
-
Methods inherited from interface io.debezium.connector.oracle.logminer.processor.infinispan.CacheProvider
getEventCache, getProcessedTransactionsCache, getSchemaChangesCache, getTransactionCache
-
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
jdbcConnection
private final OracleConnection jdbcConnection
-
metrics
private final OracleStreamingChangeEventSourceMetrics metrics
-
partition
private final OraclePartition partition
-
offsetContext
private final OracleOffsetContext offsetContext
-
dispatcher
private final EventDispatcher<TableId> dispatcher
-
-
Constructor Detail
-
AbstractInfinispanLogMinerEventProcessor
public AbstractInfinispanLogMinerEventProcessor(ChangeEventSource.ChangeEventSourceContext context, OracleConnectorConfig connectorConfig, OracleConnection jdbcConnection, EventDispatcher<TableId> dispatcher, OraclePartition partition, OracleOffsetContext offsetContext, OracleDatabaseSchema schema, OracleStreamingChangeEventSourceMetrics metrics)
-
-
Method Detail
-
displayCacheStatistics
public void displayCacheStatistics()
Description copied from interface:CacheProviderDisplays cache statistics- Specified by:
displayCacheStatisticsin interfaceCacheProvider
-
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<InfinispanTransaction>- Parameters:
transactionId- the unique transaction id- Returns:
- true if the transaction has been recently processed, false otherwise
-
createTransaction
protected InfinispanTransaction createTransaction(LogMinerEventRow row)
Description copied from class:AbstractLogMinerEventProcessorCreates a new transaction based on the suppliedSTARTevent.- Specified by:
createTransactionin classAbstractLogMinerEventProcessor<InfinispanTransaction>- 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<InfinispanTransaction>- Parameters:
row- the event row that contains the row identifier, must not benull
-
processRow
protected void processRow(LogMinerEventRow row) throws SQLException, InterruptedException
Description copied from class:AbstractLogMinerEventProcessorProcesses a single LogMinerEventRow.- Overrides:
processRowin classAbstractLogMinerEventProcessor<InfinispanTransaction>- Parameters:
row- the event row, must not benull- Throws:
SQLException- if a database exception occurredInterruptedException- if the dispatcher was interrupted sending an event
-
abandonTransactions
public void abandonTransactions(Duration retention)
Description copied from interface:LogMinerEventProcessorA callback for the event processor to abandon long running transactions.- Specified by:
abandonTransactionsin interfaceLogMinerEventProcessor- Parameters:
retention- the maximum duration in which long running transactions are allowed.
-
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<InfinispanTransaction>- Parameters:
row- the result set row- Returns:
- true if the schema change has been seen, false otherwise.
-
getAndRemoveTransactionFromCache
protected InfinispanTransaction 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<InfinispanTransaction>- 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(InfinispanTransaction transaction)
Description copied from class:AbstractLogMinerEventProcessorRemoves the transaction and all its associated event entries from the connector's caches.- Specified by:
removeTransactionAndEventsFromCachein classAbstractLogMinerEventProcessor<InfinispanTransaction>- Parameters:
transaction- the transaction instance, should never benull
-
getTransactionEventIterator
protected Iterator<LogMinerEvent> getTransactionEventIterator(InfinispanTransaction transaction)
Description copied from class:AbstractLogMinerEventProcessorGet an iterator over the events that are part of the specified transaction.- Specified by:
getTransactionEventIteratorin classAbstractLogMinerEventProcessor<InfinispanTransaction>- 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<InfinispanTransaction>- 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<InfinispanTransaction>- 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<InfinispanTransaction>- 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<InfinispanTransaction>- 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(InfinispanTransaction transaction)
Description copied from class:AbstractLogMinerEventProcessorReturns the number of events associated with the specified transaction.- Specified by:
getTransactionEventCountin classAbstractLogMinerEventProcessor<InfinispanTransaction>- 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<InfinispanTransaction>- 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<InfinispanTransaction>- 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
-
removeEventsWithTransaction
private void removeEventsWithTransaction(InfinispanTransaction transaction)
-
-