@NotThreadSafe public final class TransactionalBuffer extends Object implements AutoCloseable
| Modifier and Type | Class and Description |
|---|---|
static interface |
TransactionalBuffer.CommitCallback
Callback is designed to execute when transaction commits.
|
private static class |
TransactionalBuffer.Transaction |
| Modifier and Type | Field and Description |
|---|---|
private Set<String> |
abandonedTransactionIds |
private ErrorHandler |
errorHandler |
private Scn |
lastCommittedScn |
private static org.slf4j.Logger |
LOGGER |
private TransactionalBufferMetrics |
metrics |
private Set<String> |
rolledBackTransactionIds |
private Map<String,TransactionalBuffer.Transaction> |
transactions |
| Constructor and Description |
|---|
TransactionalBuffer(OracleTaskContext taskContext,
ErrorHandler errorHandler)
Constructor to create a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
abandonLongTransactions(Long 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,
List<TransactionalBuffer.CommitCallback> commitCallbacks,
Timestamp timestamp,
Scn smallestScn,
Scn scn,
EventDispatcher<?> dispatcher) |
(package private) boolean |
commit(String transactionId,
Scn scn,
OracleOffsetContext offsetContext,
Timestamp timestamp,
ChangeEventSource.ChangeEventSourceContext context,
String debugMessage,
EventDispatcher 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) TransactionalBufferMetrics |
getMetrics() |
(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 |
registerCommitCallback(String transactionId,
Scn scn,
Instant changeTime,
TransactionalBuffer.CommitCallback callback)
Registers callback to execute when transaction commits.
|
(package private) boolean |
rollback(String transactionId,
String debugMessage)
Clears registered callbacks for given transaction identifier.
|
(package private) void |
setDatabaseTimeDifference(long difference)
Set the database time difference.
|
String |
toString() |
private static final org.slf4j.Logger LOGGER
private final Map<String,TransactionalBuffer.Transaction> transactions
private final ErrorHandler errorHandler
private final TransactionalBufferMetrics metrics
private Scn lastCommittedScn
TransactionalBuffer(OracleTaskContext taskContext, ErrorHandler errorHandler)
taskContext - the task contexterrorHandler - the connector error handlerTransactionalBufferMetrics getMetrics()
Set<String> getRolledBackTransactionIds()
void registerCommitCallback(String transactionId, Scn scn, Instant changeTime, TransactionalBuffer.CommitCallback callback)
transactionId - transaction identifierscn - SCNchangeTime - time of DML parsing completioncallback - callback to execute when transaction commitsboolean commit(String transactionId, Scn scn, OracleOffsetContext offsetContext, Timestamp timestamp, ChangeEventSource.ChangeEventSourceContext context, String debugMessage, EventDispatcher 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, List<TransactionalBuffer.CommitCallback> commitCallbacks, Timestamp timestamp, Scn smallestScn, Scn scn, EventDispatcher<?> dispatcher)
boolean rollback(String transactionId, String debugMessage)
transactionId - transaction iddebugMessage - messagevoid abandonLongTransactions(Long 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 falsevoid setDatabaseTimeDifference(long difference)
difference - the time difference in millisecondspublic void close()
close in interface AutoCloseableCopyright © 2021 JBoss by Red Hat. All rights reserved.