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 of
LogMinerEventProcessor
that uses Infinispan to persist the transaction cache across restarts on disk.- Author:
- Chris Cranford
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classA comparator that guarantees that the sort order applied to event keys is such that they are treated as numerical values, sorted as numeric values rather than strings which would allow "100" to come before "9".Nested classes/interfaces inherited from class io.debezium.connector.oracle.logminer.processor.AbstractLogMinerEventProcessor
AbstractLogMinerEventProcessor.Counters -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EventDispatcher<OraclePartition,TableId> private InMemoryPendingTransactionsCacheprivate static AbstractInfinispanLogMinerEventProcessorprivate final OracleConnectionprivate static final org.slf4j.Loggerprivate final LogMinerStreamingChangeEventSourceMetricsprivate final OracleOffsetContextprivate final OraclePartitionFields inherited from class io.debezium.connector.oracle.logminer.processor.AbstractLogMinerEventProcessor
counters, sqlQueryFields 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
ConstructorsConstructorDescriptionAbstractInfinispanLogMinerEventProcessor(ChangeEventSource.ChangeEventSourceContext context, OracleConnectorConfig connectorConfig, OracleConnection jdbcConnection, EventDispatcher<OraclePartition, TableId> dispatcher, OraclePartition partition, OracleOffsetContext offsetContext, OracleDatabaseSchema schema, LogMinerStreamingChangeEventSourceMetrics metrics) -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 voidcleanupAfterTransactionRemovedFromCache(InfinispanTransaction transaction, boolean isAbandoned) Removes the items associated with the transaction (e.g.protected PreparedStatementCreate the JDBC query that will be used to fetch the mining result set.protected InfinispanTransactionCreates a new transaction based on the suppliedSTARTevent.voidDisplays 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.getTransactionKeysWithPrefix(String prefix) protected voidHandle processing a LogMinerEventRow for aDDLevent.protected booleanChecks 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.static voidCan be used for reporting in Debezium Embedded modeprotected voidprocessRow(OraclePartition partition, LogMinerEventRow row) Processes a single LogMinerEventRow.protected abstract voidpurgeCache(Scn minCacheScn) Purge the necessary caches with all entries that occurred prior to the specified change number.protected voidprivate voidremoveEventsWithTransaction(InfinispanTransaction transaction) protected voidRemoves a specific transaction event by database row identifier.protected <K,V> void removeIf(org.infinispan.commons.util.CloseableIterator<Map.Entry<K, V>> iterator, Predicate<Map.Entry<K, V>> filter) Helper method to remove entries that match the given predicate from a closeable iterator.protected voidresetTransactionToStart(InfinispanTransaction transaction) Methods inherited from class io.debezium.connector.oracle.logminer.processor.AbstractLogMinerEventProcessor
abandonTransactionOverEventThreshold, abandonTransactions, getAbandonedTransactionsCache, getConfig, getFirstActiveTransactionKey, getLastProcessedScn, getLastProcessedScnChangeTime, getLastScnToAbandon, getOldestTransactionInCache, getQueryString, getSchema, getTransactionCache, getTransactionCacheMinimumScn, getTransactionIdPrefix, handleCommit, handleCommitNotFoundInBuffer, handleDataEvent, handleLobWrite, handleMissingScn, handleRollback, handleRollbackNotFoundInBuffer, handleSelectLobLocator, handleStart, handleUnsupportedEvent, isTransactionIdWithNoSequence, isTransactionOverEventThreshold, isTransactionUserExcluded, isTrxIdRawValue, process, processResults, warnPotentiallyStuckScnMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.AutoCloseable
closeMethods inherited from interface io.debezium.connector.oracle.logminer.processor.infinispan.CacheProvider
getEventCache, getProcessedTransactionsCache, getSchemaChangesCache, getTransactionCache
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
jdbcConnection
-
metrics
-
partition
-
offsetContext
-
dispatcher
-
inMemoryPendingTransactionsCache
-
instance
-
-
Constructor Details
-
AbstractInfinispanLogMinerEventProcessor
public AbstractInfinispanLogMinerEventProcessor(ChangeEventSource.ChangeEventSourceContext context, OracleConnectorConfig connectorConfig, OracleConnection jdbcConnection, EventDispatcher<OraclePartition, TableId> dispatcher, OraclePartition partition, OracleOffsetContext offsetContext, OracleDatabaseSchema schema, LogMinerStreamingChangeEventSourceMetrics metrics)
-
-
Method Details
-
reCreateInMemoryCache
protected void reCreateInMemoryCache() -
logCacheStats
public static void logCacheStats()Can be used for reporting in Debezium Embedded mode -
displayCacheStatistics
public void displayCacheStatistics()Description copied from interface:CacheProviderDisplays cache statistics- Specified by:
displayCacheStatisticsin interfaceCacheProvider
-
isRecentlyProcessed
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
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
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
-
getTransactionKeysWithPrefix
-
processRow
protected void processRow(OraclePartition partition, LogMinerEventRow row) throws SQLException, InterruptedException Description copied from class:AbstractLogMinerEventProcessorProcesses a single LogMinerEventRow.- Overrides:
processRowin classAbstractLogMinerEventProcessor<InfinispanTransaction>row- the event row, must not benull- Throws:
SQLException- if a database exception occurredInterruptedException- if the dispatcher was interrupted sending an event
-
hasSchemaChangeBeenSeen
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
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
-
cleanupAfterTransactionRemovedFromCache
protected void cleanupAfterTransactionRemovedFromCache(InfinispanTransaction transaction, boolean isAbandoned) Description copied from class:AbstractLogMinerEventProcessorRemoves the items associated with the transaction (e.g. events if they are stored independently).- Overrides:
cleanupAfterTransactionRemovedFromCachein classAbstractLogMinerEventProcessor<InfinispanTransaction>- Parameters:
transaction- the transaction instance, should never benullisAbandoned- whether the removal is because transaction is being abandoned
-
getTransactionEventIterator
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
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
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
-
resetTransactionToStart
- Overrides:
resetTransactionToStartin classAbstractLogMinerEventProcessor<InfinispanTransaction>
-
handleSchemaChange
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
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
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
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
-
purgeCache
Purge the necessary caches with all entries that occurred prior to the specified change number. NOTE: This method is abstract despite the code used by both all implementations being identical. This is because the method neededentrySet()is made available on two different concrete interfaces between the embedded and remote cache implementations, and therefore we need to access this method from the concrete implementation classes (RemoteCache and Cache) rather than from the common class used by CacheProvider (BasicCache).- Parameters:
minCacheScn- the minimum system change number to keep entries until
-
removeIf
protected <K,V> void removeIf(org.infinispan.commons.util.CloseableIterator<Map.Entry<K, V>> iterator, Predicate<Map.Entry<K, V>> filter) Helper method to remove entries that match the given predicate from a closeable iterator. This method guarantees that the underlying resources are released at the end of the operation.- Type Parameters:
K- the key typeV- the value type- Parameters:
iterator- the iteratorfilter- the predicate
-
removeEventsWithTransaction
-