Class InfinispanLogMinerEventProcessor
- java.lang.Object
-
- io.debezium.connector.oracle.logminer.processor.AbstractLogMinerEventProcessor
-
- io.debezium.connector.oracle.logminer.processor.infinispan.InfinispanLogMinerEventProcessor
-
- All Implemented Interfaces:
LogMinerEventProcessor,AutoCloseable
public class InfinispanLogMinerEventProcessor extends AbstractLogMinerEventProcessor
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 ChangeEventSource.ChangeEventSourceContextcontextprivate ScncurrentOffsetCommitScnprivate ScncurrentOffsetScnprivate EventDispatcher<TableId>dispatcherprivate OracleConnectionjdbcConnectionprivate ScnlastCommittedScnprivate static org.slf4j.LoggerLOGGERprivate ScnmaxCommittedScnprivate OracleStreamingChangeEventSourceMetricsmetricsprivate OracleOffsetContextoffsetContextprivate OraclePartitionpartitionprivate org.infinispan.Cache<String,String>recentlyCommittedTransactionsCacheA cache storing recently committed transactions key by the unique transaction id and the event's system change number.private org.infinispan.Cache<String,String>rollbackTransactionsCacheA cache storing recently rolled back transactions keyed by the unique transaction id and the event's system change number.private org.infinispan.Cache<String,String>schemaChangesCacheA cache storing recently emitted schema changes keyed by the system change number of the schema change and the associated fully qualified TableId identifier value for the change.private InfinispanTransactionCachetransactionCacheA cache that stores the completeTransactionobject keyed by the unique transaction id.-
Fields inherited from class io.debezium.connector.oracle.logminer.processor.AbstractLogMinerEventProcessor
counters
-
-
Constructor Summary
Constructors Constructor Description InfinispanLogMinerEventProcessor(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.private ScncalculateNewStartScn(Scn endScn)voidclose()private <K,V>
org.infinispan.Cache<K,V>createCache(org.infinispan.manager.EmbeddedCacheManager manager, OracleConnectorConfig connectorConfig, String name)private PreparedStatementcreateQueryStatement()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 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.protected voidprocessRow(LogMinerEventRow row)Processes a single LogMinerEventRow.-
Methods inherited from class io.debezium.connector.oracle.logminer.processor.AbstractLogMinerEventProcessor
getConfig, getReconciliation, getSchema, handleDataEvent, handleLobWrite, handleMissingScn, handleSelectLobLocator, handleStart, isRecentlyCommitted, isTrxIdRawValue, processResults, warnPotentiallyStuckScn
-
-
-
-
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
-
context
private final ChangeEventSource.ChangeEventSourceContext context
-
transactionCache
private final InfinispanTransactionCache transactionCache
A cache that stores the completeTransactionobject keyed by the unique transaction id.
-
recentlyCommittedTransactionsCache
private final org.infinispan.Cache<String,String> recentlyCommittedTransactionsCache
A cache storing recently committed transactions key by the unique transaction id and the event's system change number. This cache is used to filter events during re-mining when LOB support is enabled to skip the processing of already emitted transactions. Entries in this cache are removed when the offset low watermark (scn) advances beyond the system change number associated with the transaction.
-
rollbackTransactionsCache
private final org.infinispan.Cache<String,String> rollbackTransactionsCache
A cache storing recently rolled back transactions keyed by the unique transaction id and the event's system change number. This cache is used to filter events during re-mining when LOB support is enabled to skip the processing of already discarded transactions. Entries in this cache are removed when the offset low watermark (scn) advances beyond the system change number associated with the transaction.
-
schemaChangesCache
private final org.infinispan.Cache<String,String> schemaChangesCache
A cache storing recently emitted schema changes keyed by the system change number of the schema change and the associated fully qualified TableId identifier value for the change. This cache is used to filter events during re-mining when LOB support is enabled to skip the processing of already emitted schema changes. Entries in this cache are removed when the offset low watermark (scn) advances beyond the system change number associated with the schema change event.
-
currentOffsetScn
private Scn currentOffsetScn
-
currentOffsetCommitScn
private Scn currentOffsetCommitScn
-
lastCommittedScn
private Scn lastCommittedScn
-
maxCommittedScn
private Scn maxCommittedScn
-
-
Constructor Detail
-
InfinispanLogMinerEventProcessor
public InfinispanLogMinerEventProcessor(ChangeEventSource.ChangeEventSourceContext context, OracleConnectorConfig connectorConfig, OracleConnection jdbcConnection, EventDispatcher<TableId> dispatcher, OraclePartition partition, OracleOffsetContext offsetContext, OracleDatabaseSchema schema, OracleStreamingChangeEventSourceMetrics metrics)
-
-
Method Detail
-
createCache
private <K,V> org.infinispan.Cache<K,V> createCache(org.infinispan.manager.EmbeddedCacheManager manager, OracleConnectorConfig connectorConfig, String name)
-
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
-
processRow
protected void processRow(LogMinerEventRow row) throws SQLException, InterruptedException
Description copied from class:AbstractLogMinerEventProcessorProcesses a single LogMinerEventRow.- Overrides:
processRowin classAbstractLogMinerEventProcessor- 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.- Parameters:
retention- the maximum duration in which long running transactions are allowed.
-
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
-
addToTransaction
protected void addToTransaction(String transactionId, LogMinerEventRow row, Supplier<LogMinerEvent> eventSupplier)
Description copied from class:AbstractLogMinerEventProcessorAdd a transaction to the transaction map if allowed.- Overrides:
addToTransactionin classAbstractLogMinerEventProcessor- 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
-
createQueryStatement
private PreparedStatement createQueryStatement() throws SQLException
- Throws:
SQLException
-
calculateNewStartScn
private Scn calculateNewStartScn(Scn endScn) throws InterruptedException
- Throws:
InterruptedException
-
-