Class TransactionReconciliation
- java.lang.Object
-
- io.debezium.connector.oracle.logminer.processor.TransactionReconciliation
-
public class TransactionReconciliation extends Object
Helper class that performs common transaction reconciliation. Transactions read from Oracle LogMiner are subject to containing events that need to be merged together to reflect a single logical SQL operation, such as events that pertain to LOB fields. This class facilities all the steps needed to merge events and reconcile a transaction.- Author:
- Chris Cranford
-
-
Field Summary
Fields Modifier and Type Field Description private OracleConnectorConfigconnectorConfigprivate static org.slf4j.LoggerLOGGERprivate OracleDatabaseSchemaschema
-
Constructor Summary
Constructors Constructor Description TransactionReconciliation(OracleConnectorConfig connectorConfig, OracleDatabaseSchema schema)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanisForSameTableOrScn(LogMinerEvent event, LogMinerEvent prevEvent)Checks whether the two events are for the same table or participate in the same system change.protected booleanisSameTableRow(DmlEvent event, DmlEvent prevEvent)Checks whether the two events are for the same table row.protected voidmergeNewColumns(DmlEvent event, DmlEvent prevEvent)Merge column values fromeventwithprevEvent.protected List<String>readAndCombineLobWriteEvents(Transaction transaction, int index, boolean binaryData)Reads the transaction event queue and combines all LOB_WRITE events starting at the provided index.protected intreadAndConsumeLobEraseEvents(Transaction transaction, int index)Read and remove all LobErase events detected in the transaction event queue.voidreconcile(Transaction transaction)Reconcile the specified transaction by merging multiple events that should be emitted as a single logical event, such as changes made to LOB column types that involve multiple events.protected booleanshouldMergeDmlEvent(Transaction transaction, int index, DmlEvent event, DmlEvent prevEvent)Attempts to merge the provided DML event with the previous event in the transaction.protected booleanshouldMergeSelectLobLocatorEvent(Transaction transaction, int index, SelectLobLocatorEvent event, DmlEvent prevEvent)Attempts to merge the provided SEL_LOB_LOCATOR event with the previous event in the transaction.
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
connectorConfig
private final OracleConnectorConfig connectorConfig
-
schema
private final OracleDatabaseSchema schema
-
-
Constructor Detail
-
TransactionReconciliation
public TransactionReconciliation(OracleConnectorConfig connectorConfig, OracleDatabaseSchema schema)
-
-
Method Detail
-
reconcile
public void reconcile(Transaction transaction)
Reconcile the specified transaction by merging multiple events that should be emitted as a single logical event, such as changes made to LOB column types that involve multiple events.- Parameters:
transaction- transaction to be reconciled, nevernull
-
shouldMergeSelectLobLocatorEvent
protected boolean shouldMergeSelectLobLocatorEvent(Transaction transaction, int index, SelectLobLocatorEvent event, DmlEvent prevEvent)
Attempts to merge the provided SEL_LOB_LOCATOR event with the previous event in the transaction.- Parameters:
transaction- transaction being processed, nevernullindex- event index being processedevent- event being processed, nevernullprevEvent- previous event in the transaction, can benull- Returns:
- true if the event is merged, false if the event was not merged.
-
shouldMergeDmlEvent
protected boolean shouldMergeDmlEvent(Transaction transaction, int index, DmlEvent event, DmlEvent prevEvent)
Attempts to merge the provided DML event with the previous event in the transaction.- Parameters:
transaction- transaction being processed, nevernullindex- event index being processedevent- event being processed, nevernullprevEvent- previous event in the transaction, can benull- Returns:
- true if the event is merged, false if the event was not merged
-
readAndCombineLobWriteEvents
protected List<String> readAndCombineLobWriteEvents(Transaction transaction, int index, boolean binaryData)
Reads the transaction event queue and combines all LOB_WRITE events starting at the provided index. for a SEL_LOB_LOCATOR event which is for binary data (BLOB) data types.- Parameters:
transaction- transaction being processed, nevernullindex- index to the first LOB_WRITE operation- Returns:
- list of string-based values for each LOB_WRITE operation
-
readAndConsumeLobEraseEvents
protected int readAndConsumeLobEraseEvents(Transaction transaction, int index)
Read and remove all LobErase events detected in the transaction event queue.- Parameters:
transaction- transaction being processed, nevernullindex- index to the first LOB_ERASE operation- Returns:
- number of LOB_ERASE events consumed and removed from the event queue
-
isForSameTableOrScn
protected boolean isForSameTableOrScn(LogMinerEvent event, LogMinerEvent prevEvent)
Checks whether the two events are for the same table or participate in the same system change.- Parameters:
event- current event being processed, nevernullprevEvent- previous/parent event that has been processed, may benull- Returns:
- true if the two events are for the same table or system change number, false otherwise
-
isSameTableRow
protected boolean isSameTableRow(DmlEvent event, DmlEvent prevEvent)
Checks whether the two events are for the same table row.- Parameters:
event- current event being processed, nevernullprevEvent- previous/parent event that has been processed, nevernull- Returns:
- true if the two events are for the same table row, false otherwise
-
-