Class TransactionCommitConsumer
java.lang.Object
io.debezium.connector.oracle.logminer.processor.TransactionCommitConsumer
- All Implemented Interfaces:
BlockingConsumer<LogMinerEvent>,AutoCloseable
public class TransactionCommitConsumer
extends Object
implements AutoCloseable, BlockingConsumer<LogMinerEvent>
A consumer of transaction events at commit time that is capable of inspecting the event stream,
merging events that should be merged when LOB support is enabled, and then delegating the final
stream of events to a delegate consumer.
When a table has a LOB or XML field, Oracle LogMiner often supplies us with synthetic events that deal
with sub-tasks that occur in the database as a result of writing LOB data to the database. We
would prefer to emit these synthetic events as a part of the overall logical event, whether that
is an insert or update.
An example of a scenario would be the following logical user action:
INSERT INTO my_table (id,lob_field) values (1, 'some clob data');
Oracle LogMiner provides the connector with the following events:
INSERT INTO my_table (id,lob_field) values (1, EMPTY_CLOB());
UPDATE my_table SET lob_field = 'some clob data' where id = 1;
When LOB support is enabled, this consumer implementation will detect that the update is an
event that should be merged with the previous insert event so that the emitted change events
consists a single logical change, an insert that have an after section like:
"after": {
"id": 1,
"lob_field": "some clob data"
}
When LOB support isn't enabled, events are simply passed through to the delegate and no event
inspection, merging, or buffering occurs.- Author:
- Chris Cranford
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) static class(package private) static class(package private) static interface(package private) static class(package private) static classprivate static class(package private) static class(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringprivate final OracleConnectorConfigprivate final TransactionCommitConsumer.ConstructionDetailsprivate final TransactionCommitConsumer.ConstructionDetailsprivate final TransactionCommitConsumer.Handler<LogMinerEvent>private static final org.slf4j.Loggerprivate static final Stringprivate final Map<String,TransactionCommitConsumer.RowState> private final OracleDatabaseSchemaprivate intprivate int -
Constructor Summary
ConstructorsConstructorDescriptionTransactionCommitConsumer(TransactionCommitConsumer.Handler<LogMinerEvent> delegate, OracleConnectorConfig connectorConfig, OracleDatabaseSchema schema) -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(LogMinerEvent event) private voidacceptDmlEvent(DmlEvent event) private voidprivate voidprivate voidvoidclose()private voidprivate voiddispatchChangeEvent(LogMinerEvent event) private Objectintprivate booleanprivate voidinitConstructable(TransactionCommitConsumer.ConstructionDetails details, String rowId, String columnName, Table table, DmlEvent accumulatorEvent, Function<Object, Object> constructor) private booleanisLobColumn(Column column) private booleanisSelectLobLocatorForSameRow(DmlEvent into, DmlEvent event) private booleanisUpdateForSameTableWithLobColumnChanges(DmlEvent into, DmlEvent event) private voidmergeEvents(DmlEvent into, DmlEvent from) private Object[]private Object[]private voidprepareAndDispatch(DmlEvent event) private StringrowIdFromEvent(Table table, DmlEvent event) private boolean
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
NULL_COLUMN
- See Also:
-
BLOB_TYPE
- See Also:
-
CLOB_TYPE
- See Also:
-
delegate
-
connectorConfig
-
schema
-
rows
-
currentLobDetails
-
currentXmlDetails
-
transactionIndex
private int transactionIndex -
totalEvents
private int totalEvents
-
-
Constructor Details
-
TransactionCommitConsumer
public TransactionCommitConsumer(TransactionCommitConsumer.Handler<LogMinerEvent> delegate, OracleConnectorConfig connectorConfig, OracleDatabaseSchema schema)
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
InterruptedException
-
accept
- Specified by:
acceptin interfaceBlockingConsumer<LogMinerEvent>- Throws:
InterruptedException
-
getTotalEvents
public int getTotalEvents() -
acceptDmlEvent
- Throws:
InterruptedException
-
acceptManipulationEvent
-
acceptLobManipulationEvent
-
acceptXmlManipulationEvent
-
getConstructable
-
initConstructable
-
prepareAndDispatch
- Throws:
InterruptedException
-
tryMerge
-
mergeEvents
-
isUpdateForSameTableWithLobColumnChanges
-
isSelectLobLocatorForSameRow
-
isLobColumn
-
dispatchChangeEvent
- Throws:
InterruptedException
-
rowIdFromEvent
-
newValues
-
oldValues
-
discardCurrentMergeState
-
hasRowId
-