Class 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
    • 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, never null
      • 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, never null
        index - event index being processed
        event - event being processed, never null
        prevEvent - previous event in the transaction, can be null
        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, never null
        index - event index being processed
        event - event being processed, never null
        prevEvent - previous event in the transaction, can be null
        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, never null
        index - 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, never null
        index - 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, never null
        prevEvent - previous/parent event that has been processed, may be null
        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, never null
        prevEvent - previous/parent event that has been processed, never null
        Returns:
        true if the two events are for the same table row, false otherwise
      • mergeNewColumns

        protected void mergeNewColumns​(DmlEvent event,
                                       DmlEvent prevEvent)
        Merge column values from event with prevEvent.
        Parameters:
        event - current event being processed, never null
        prevEvent - previous/parent parent that has been processed, never null