@NotThreadSafe public final class TransactionalBuffer extends Object implements AutoCloseable
| Modifier and Type | Class and Description |
|---|---|
private static class |
TransactionalBuffer.DmlEvent
Represents a DML event for a given table row.
|
private static class |
TransactionalBuffer.Transaction
Represents a logical database transaction
|
| Modifier and Type | Field and Description |
|---|---|
private Set<String> |
abandonedTransactionIds |
private Clock |
clock |
private ErrorHandler |
errorHandler |
private Scn |
lastCommittedScn |
private static org.slf4j.Logger |
LOGGER |
private Set<String> |
rolledBackTransactionIds |
private OracleDatabaseSchema |
schema |
private OracleStreamingChangeEventSourceMetrics |
streamingMetrics |
private Map<String,TransactionalBuffer.Transaction> |
transactions |
| Constructor and Description |
|---|
TransactionalBuffer(OracleDatabaseSchema schema,
Clock clock,
ErrorHandler errorHandler,
OracleStreamingChangeEventSourceMetrics streamingMetrics)
Constructor to create a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
abandonLongTransactions(Scn thresholdScn,
OracleOffsetContext offsetContext)
If for some reason the connector got restarted, the offset will point to the beginning of the oldest captured transaction.
|
private Scn |
calculateSmallestScn() |
void |
close() |
private void |
commit(ChangeEventSource.ChangeEventSourceContext context,
OracleOffsetContext offsetContext,
Instant start,
TransactionalBuffer.Transaction transaction,
Timestamp timestamp,
Scn smallestScn,
Scn scn,
EventDispatcher<TableId> dispatcher) |
(package private) boolean |
commit(String transactionId,
Scn scn,
OracleOffsetContext offsetContext,
Timestamp timestamp,
ChangeEventSource.ChangeEventSourceContext context,
String debugMessage,
EventDispatcher<TableId> dispatcher)
Commits a transaction by looking up the transaction in the buffer and if exists, all registered callbacks
will be executed in chronological order, emitting events for each followed by a transaction commit event.
|
(package private) Set<String> |
getRolledBackTransactionIds() |
(package private) boolean |
isEmpty()
Returns
true if buffer is empty, otherwise false. |
(package private) boolean |
isTransactionRegistered(String txId) |
(package private) void |
registerDmlOperation(int operation,
String transactionId,
Scn scn,
TableId tableId,
LogMinerDmlEntry parseEntry,
Instant changeTime,
String rowId)
Register a DML operation with the transaction buffer.
|
(package private) boolean |
rollback(String transactionId,
String debugMessage)
Clears registered callbacks for given transaction identifier.
|
String |
toString() |
(package private) void |
undoDmlOperation(String transactionId,
String undoRowId,
TableId tableId)
Undo a staged DML operation in the transaction buffer.
|
private static final org.slf4j.Logger LOGGER
private final Map<String,TransactionalBuffer.Transaction> transactions
private final OracleDatabaseSchema schema
private final Clock clock
private final ErrorHandler errorHandler
private final OracleStreamingChangeEventSourceMetrics streamingMetrics
private Scn lastCommittedScn
TransactionalBuffer(OracleDatabaseSchema schema, Clock clock, ErrorHandler errorHandler, OracleStreamingChangeEventSourceMetrics streamingMetrics)
errorHandler - the connector error handlerstreamingMetrics - the streaming metricsSet<String> getRolledBackTransactionIds()
void registerDmlOperation(int operation,
String transactionId,
Scn scn,
TableId tableId,
LogMinerDmlEntry parseEntry,
Instant changeTime,
String rowId)
operation - operation typetransactionId - unique transaction identifierscn - system change numbertableId - table identifierparseEntry - parser entrychangeTime - time the DML operation occurredrowId - unique row identifiervoid undoDmlOperation(String transactionId, String undoRowId, TableId tableId)
transactionId - unique transaction identifierundoRowId - unique row identifier to be undonetableId - table identifierboolean commit(String transactionId, Scn scn, OracleOffsetContext offsetContext, Timestamp timestamp, ChangeEventSource.ChangeEventSourceContext context, String debugMessage, EventDispatcher<TableId> dispatcher)
transactionId - transaction identifierscn - SCN of the commit.offsetContext - Oracle offsettimestamp - commit timestampcontext - context to check that source is runningdebugMessage - messagedispatcher - event dispatcherprivate void commit(ChangeEventSource.ChangeEventSourceContext context, OracleOffsetContext offsetContext, Instant start, TransactionalBuffer.Transaction transaction, Timestamp timestamp, Scn smallestScn, Scn scn, EventDispatcher<TableId> dispatcher)
boolean rollback(String transactionId, String debugMessage)
transactionId - transaction iddebugMessage - messagevoid abandonLongTransactions(Scn thresholdScn, OracleOffsetContext offsetContext)
In case of an abandonment, all DMLs/Commits/Rollbacks for this transaction will be ignored
thresholdScn - the smallest SVN of any transaction to keep in the buffer. All others will be removed.offsetContext - the offset contextboolean isTransactionRegistered(String txId)
private Scn calculateSmallestScn()
boolean isEmpty()
true if buffer is empty, otherwise false.true if buffer is empty, otherwise falsepublic void close()
close in interface AutoCloseableCopyright © 2021 JBoss by Red Hat. All rights reserved.