Class AbstractLogMinerEventProcessor<T extends io.debezium.connector.oracle.logminer.processor.AbstractTransaction>
- java.lang.Object
-
- io.debezium.connector.oracle.logminer.processor.AbstractLogMinerEventProcessor<T>
-
- All Implemented Interfaces:
io.debezium.connector.oracle.logminer.processor.LogMinerEventProcessor,AutoCloseable
- Direct Known Subclasses:
io.debezium.connector.oracle.logminer.processor.infinispan.AbstractInfinispanLogMinerEventProcessor,io.debezium.connector.oracle.logminer.processor.memory.MemoryLogMinerEventProcessor
public abstract class AbstractLogMinerEventProcessor<T extends io.debezium.connector.oracle.logminer.processor.AbstractTransaction> extends Object implements io.debezium.connector.oracle.logminer.processor.LogMinerEventProcessor
Copied from Debezium 1.9.8.Final.An abstract implementation of
LogMinerEventProcessorthat all processors should extend.Lines 411, 423: pass ROWID to LogMinerChangeRecordEmitter.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractLogMinerEventProcessor.CountersWrapper for all counter variables.
-
Field Summary
Fields Modifier and Type Field Description protected AbstractLogMinerEventProcessor.Counterscounters
-
Constructor Summary
Constructors Constructor Description AbstractLogMinerEventProcessor(io.debezium.pipeline.source.spi.ChangeEventSource.ChangeEventSourceContext context, io.debezium.connector.oracle.OracleConnectorConfig connectorConfig, io.debezium.connector.oracle.OracleDatabaseSchema schema, io.debezium.connector.oracle.OraclePartition partition, io.debezium.connector.oracle.OracleOffsetContext offsetContext, io.debezium.pipeline.EventDispatcher<io.debezium.connector.oracle.OraclePartition,io.debezium.relational.TableId> dispatcher, io.debezium.connector.oracle.OracleStreamingChangeEventSourceMetrics metrics)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidaddToTransaction(String transactionId, io.debezium.connector.oracle.logminer.events.LogMinerEventRow row, java.util.function.Supplier<io.debezium.connector.oracle.logminer.events.LogMinerEvent> eventSupplier)Add a transaction to the transaction map if allowed.protected abstract io.debezium.connector.oracle.ScncalculateNewStartScn(io.debezium.connector.oracle.Scn endScn, io.debezium.connector.oracle.Scn maxCommittedScn)Calculates the new starting system change number based on the current processing range.protected abstract PreparedStatementcreateQueryStatement()Create the JDBC query that will be used to fetch the mining result set.protected abstract TcreateTransaction(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)Creates a new transaction based on the suppliedSTARTevent.protected abstract voidfinalizeTransactionCommit(String transactionId, io.debezium.connector.oracle.Scn commitScn)Finalizes the commit of a transaction.protected abstract voidfinalizeTransactionRollback(String transactionId, io.debezium.connector.oracle.Scn rollbackScn)Finalizes the rollback the specified transaction.protected abstract TgetAndRemoveTransactionFromCache(String transactionId)Gets a transaction instance from the transaction cache while also removing its cache entry.protected io.debezium.connector.oracle.OracleConnectorConfiggetConfig()protected io.debezium.connector.oracle.ScngetLastProcessedScn()Return the last processed system change number handled by the processor.protected io.debezium.connector.oracle.OracleDatabaseSchemagetSchema()protected abstract Map<String,T>getTransactionCache()Returns theTransactionCacheimplementation.protected abstract io.debezium.connector.oracle.ScngetTransactionCacheMinimumScn()Gets the minimum system change number stored in the transaction cache.protected abstract intgetTransactionEventCount(T transaction)Returns the number of events associated with the specified transaction.protected abstract Iterator<io.debezium.connector.oracle.logminer.events.LogMinerEvent>getTransactionEventIterator(T transaction)Get an iterator over the events that are part of the specified transaction.protected StringgetTransactionIdPrefix(String transactionId)protected voidhandleCommit(io.debezium.connector.oracle.OraclePartition partition, io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)Handle processing a LogMinerEventRow for aCOMMITevent.protected voidhandleDataEvent(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)Handle processing a LogMinerEventRow for aINSERT,UPDATE, orDELETEevent.protected voidhandleLobWrite(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)Handle processing a LogMinerEventRow for aLOB_WRITEevent.protected voidhandleMissingScn(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)Handle processing a LogMinerEventRow for aMISSING_SCNevent.protected voidhandleRollback(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)Handle processing a LogMinerEventRow for aROLLBACKevent.protected voidhandleSchemaChange(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)Handle processing a LogMinerEventRow for aDDLevent.protected voidhandleSelectLobLocator(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)Handle processing a LogMinerEventRow for aSEL_LOB_LOCATORevent.protected voidhandleStart(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)Handle processing a LogMinerEventRow for aSTARTevent.protected voidhandleUnsupportedEvent(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)protected booleanhasSchemaChangeBeenSeen(io.debezium.connector.oracle.logminer.events.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 booleanisTransactionIdWithNoSequence(String transactionId)Returns whether the transaction id has no sequence number component.protected booleanisTransactionUserExcluded(T transaction)Check whether the supplied username associated with the specified transaction is excluded.protected booleanisTrxIdRawValue()io.debezium.connector.oracle.Scnprocess(io.debezium.connector.oracle.OraclePartition partition, io.debezium.connector.oracle.Scn startScn, io.debezium.connector.oracle.Scn endScn)protected voidprocessResults(io.debezium.connector.oracle.OraclePartition partition, ResultSet resultSet)Processes the LogMiner results.protected voidprocessRow(io.debezium.connector.oracle.OraclePartition partition, io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)Processes a single LogMinerEventRow.protected abstract voidremoveEventWithRowId(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)Removes a specific transaction event by database row identifier.protected abstract voidremoveTransactionAndEventsFromCache(T transaction)Removes the transaction and all its associated event entries from the connector's caches.protected voidwarnPotentiallyStuckScn(io.debezium.connector.oracle.Scn previousOffsetScn, Map<Integer,io.debezium.connector.oracle.Scn> previousOffsetCommitScns)Checks to see whether the offset'sscnis remaining the same across multiple mining sessions while the offset'scommit_scnis changing between sessions.-
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
-
-
-
-
Field Detail
-
counters
protected final AbstractLogMinerEventProcessor.Counters counters
-
-
Constructor Detail
-
AbstractLogMinerEventProcessor
public AbstractLogMinerEventProcessor(io.debezium.pipeline.source.spi.ChangeEventSource.ChangeEventSourceContext context, io.debezium.connector.oracle.OracleConnectorConfig connectorConfig, io.debezium.connector.oracle.OracleDatabaseSchema schema, io.debezium.connector.oracle.OraclePartition partition, io.debezium.connector.oracle.OracleOffsetContext offsetContext, io.debezium.pipeline.EventDispatcher<io.debezium.connector.oracle.OraclePartition,io.debezium.relational.TableId> dispatcher, io.debezium.connector.oracle.OracleStreamingChangeEventSourceMetrics metrics)
-
-
Method Detail
-
getConfig
protected io.debezium.connector.oracle.OracleConnectorConfig getConfig()
-
getSchema
protected io.debezium.connector.oracle.OracleDatabaseSchema getSchema()
-
isRecentlyProcessed
protected boolean isRecentlyProcessed(String transactionId)
Check whether a transaction has been recently processed through either a commit or rollback.- Parameters:
transactionId- the unique transaction id- Returns:
- true if the transaction has been recently processed, false otherwise
-
hasSchemaChangeBeenSeen
protected boolean hasSchemaChangeBeenSeen(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)
Checks whether the LogMinerEvent row for a schema change can be emitted.- Parameters:
row- the result set row- Returns:
- true if the schema change has been seen, false otherwise.
-
getLastProcessedScn
protected io.debezium.connector.oracle.Scn getLastProcessedScn()
Return the last processed system change number handled by the processor.- Returns:
- the last processed system change number, never
null.
-
getTransactionCache
protected abstract Map<String,T> getTransactionCache()
Returns theTransactionCacheimplementation.- Returns:
- the transaction cache, never
null
-
createTransaction
protected abstract T createTransaction(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)
Creates a new transaction based on the suppliedSTARTevent.- Parameters:
row- the event row, must not benull- Returns:
- the implementation-specific
Transactioninstance
-
removeEventWithRowId
protected abstract void removeEventWithRowId(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)
Removes a specific transaction event by database row identifier.- Parameters:
row- the event row that contains the row identifier, must not benull
-
getTransactionEventCount
protected abstract int getTransactionEventCount(T transaction)
Returns the number of events associated with the specified transaction.- Parameters:
transaction- the transaction, must not benull- Returns:
- the number of events in the transaction
-
isTrxIdRawValue
protected boolean isTrxIdRawValue()
-
process
public io.debezium.connector.oracle.Scn process(io.debezium.connector.oracle.OraclePartition partition, io.debezium.connector.oracle.Scn startScn, io.debezium.connector.oracle.Scn endScn) throws SQLException, InterruptedException- Specified by:
processin interfaceio.debezium.connector.oracle.logminer.processor.LogMinerEventProcessor- Throws:
SQLExceptionInterruptedException
-
createQueryStatement
protected abstract PreparedStatement createQueryStatement() throws SQLException
Create the JDBC query that will be used to fetch the mining result set.- Returns:
- a prepared query statement, never
null - Throws:
SQLException- if a database exception occurred creating the statement
-
calculateNewStartScn
protected abstract io.debezium.connector.oracle.Scn calculateNewStartScn(io.debezium.connector.oracle.Scn endScn, io.debezium.connector.oracle.Scn maxCommittedScn) throws InterruptedExceptionCalculates the new starting system change number based on the current processing range.- 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
-
processResults
protected void processResults(io.debezium.connector.oracle.OraclePartition partition, ResultSet resultSet) throws SQLException, InterruptedExceptionProcesses the LogMiner results.- Parameters:
resultSet- the result set from a LogMiner query- Throws:
SQLException- if a database exception occurredInterruptedException- if the dispatcher was interrupted sending an event
-
processRow
protected void processRow(io.debezium.connector.oracle.OraclePartition partition, io.debezium.connector.oracle.logminer.events.LogMinerEventRow row) throws SQLException, InterruptedExceptionProcesses a single LogMinerEventRow.- Parameters:
row- the event row, must not benull- Throws:
SQLException- if a database exception occurredInterruptedException- if the dispatcher was interrupted sending an event
-
handleMissingScn
protected void handleMissingScn(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)
Handle processing a LogMinerEventRow for aMISSING_SCNevent.- Parameters:
row- the result set row
-
handleStart
protected void handleStart(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)
Handle processing a LogMinerEventRow for aSTARTevent.- Parameters:
row- the result set row
-
handleCommit
protected void handleCommit(io.debezium.connector.oracle.OraclePartition partition, io.debezium.connector.oracle.logminer.events.LogMinerEventRow row) throws InterruptedExceptionHandle processing a LogMinerEventRow for aCOMMITevent.- Parameters:
row- the result set row- Throws:
InterruptedException- if the event dispatcher was interrupted sending events
-
getAndRemoveTransactionFromCache
protected abstract T getAndRemoveTransactionFromCache(String transactionId)
Gets a transaction instance from the transaction cache while also removing its cache entry.- Parameters:
transactionId- the transaction's unique identifier, should not benull- Returns:
- the transaction instance if found,
nullif the transaction wasn't found
-
removeTransactionAndEventsFromCache
protected abstract void removeTransactionAndEventsFromCache(T transaction)
Removes the transaction and all its associated event entries from the connector's caches.- Parameters:
transaction- the transaction instance, should never benull
-
getTransactionEventIterator
protected abstract Iterator<io.debezium.connector.oracle.logminer.events.LogMinerEvent> getTransactionEventIterator(T transaction)
Get an iterator over the events that are part of the specified transaction.- Parameters:
transaction- the transaction instance, should never benull- Returns:
- an iterator over the transaction's events, never
null
-
finalizeTransactionCommit
protected abstract void finalizeTransactionCommit(String transactionId, io.debezium.connector.oracle.Scn commitScn)
Finalizes the commit of a transaction.- Parameters:
transactionId- the transaction's unique identifier, should not benullcommitScn- the transaction's system change number, should not benull
-
isTransactionUserExcluded
protected boolean isTransactionUserExcluded(T transaction)
Check whether the supplied username associated with the specified transaction is excluded.- Parameters:
transaction- the transaction, nevernull- Returns:
- true if the transaction should be skipped; false if transaction should be emitted
-
handleRollback
protected void handleRollback(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)
Handle processing a LogMinerEventRow for aROLLBACKevent.- Parameters:
row- the result set row
-
finalizeTransactionRollback
protected abstract void finalizeTransactionRollback(String transactionId, io.debezium.connector.oracle.Scn rollbackScn)
Finalizes the rollback the specified transaction.- Parameters:
transactionId- the unique transaction identifier, nevernullrollbackScn- the rollback transaction's system change number, nevernull
-
handleSchemaChange
protected void handleSchemaChange(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row) throws InterruptedExceptionHandle processing a LogMinerEventRow for aDDLevent.- Parameters:
row- the result set row- Throws:
InterruptedException- if the event dispatcher is interrupted sending the event
-
handleSelectLobLocator
protected void handleSelectLobLocator(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)
Handle processing a LogMinerEventRow for aSEL_LOB_LOCATORevent.- Parameters:
row- the result set row
-
handleLobWrite
protected void handleLobWrite(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)
Handle processing a LogMinerEventRow for aLOB_WRITEevent.- Parameters:
row- the result set row
-
handleDataEvent
protected void handleDataEvent(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row) throws SQLException, InterruptedExceptionHandle processing a LogMinerEventRow for aINSERT,UPDATE, orDELETEevent.- Parameters:
row- the result set row- Throws:
SQLException- if a database exception occursInterruptedException- if the dispatch of an event is interrupted
-
handleUnsupportedEvent
protected void handleUnsupportedEvent(io.debezium.connector.oracle.logminer.events.LogMinerEventRow row)
-
warnPotentiallyStuckScn
protected void warnPotentiallyStuckScn(io.debezium.connector.oracle.Scn previousOffsetScn, Map<Integer,io.debezium.connector.oracle.Scn> previousOffsetCommitScns)Checks to see whether the offset'sscnis remaining the same across multiple mining sessions while the offset'scommit_scnis changing between sessions.- Parameters:
previousOffsetScn- the previous offset system change numberpreviousOffsetCommitScns- the previous offset commit system change number
-
addToTransaction
protected abstract void addToTransaction(String transactionId, io.debezium.connector.oracle.logminer.events.LogMinerEventRow row, java.util.function.Supplier<io.debezium.connector.oracle.logminer.events.LogMinerEvent> eventSupplier)
Add a transaction to the transaction map if allowed.- 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
-
getTransactionCacheMinimumScn
protected abstract io.debezium.connector.oracle.Scn getTransactionCacheMinimumScn()
Gets the minimum system change number stored in the transaction cache.- Returns:
- the minimum system change number, never
nullbut could beScn.NULL.
-
isTransactionIdWithNoSequence
protected boolean isTransactionIdWithNoSequence(String transactionId)
Returns whether the transaction id has no sequence number component.Oracle transaction identifiers are a composite of:
- Undo segment number
- Slot numbber of the transaction that generated the change
- Sequence number of the transaction that generated the change
When Oracle LogMiner mines records, it is possible that when an undo operation is detected, often the product of a constraint violation, the LogMiner row will have the same explicit XID (transaction id) as the source operation that we should undo; however, if the record to be undone was mined in a prior iteration, Oracle LogMiner won't be able to make a link back to the full transaction's sequence number, therefore the XID value for the undo row will contain only the undo segment number and slot number, setting the sequence number to 4294967295 (aka -1 or 0xFFFFFFFF).
This method explicitly checks if the provided transaction id has the no sequence sentinel value and if so, returns
true; otherwise returnsfalse.- Parameters:
transactionId- the transaction identifier to check, should not benull- Returns:
- true if the transaction has no sequence reference, false if it does
-
-