@NotThreadSafe public final class TransactionalBuffer extends Object
Transactional buffer is designed to register callbacks, to execute them when transaction commits and to clear them when transaction rollbacks.
| 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 Supplier<Integer> |
commitQueueCapacity |
private io.debezium.pipeline.ErrorHandler |
errorHandler |
private ExecutorService |
executor |
private BigDecimal |
largestScn |
private BigDecimal |
lastCommittedScn |
private static org.slf4j.Logger |
LOGGER |
private TransactionalBufferMetrics |
metrics |
private Set<String> |
rolledBackTransactionIds |
private AtomicInteger |
taskCounter |
private Map<String,TransactionalBuffer.Transaction> |
transactions |
| Constructor and Description |
|---|
TransactionalBuffer(String logicalName,
io.debezium.pipeline.ErrorHandler errorHandler,
TransactionalBufferMetrics metrics,
int inCommitQueueCapacity)
Constructor to create a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
abandonLongTransactions(Long thresholdScn)
If for some reason the connector got restarted, the offset will point to the beginning of the oldest captured transaction.
|
private void |
calculateLargestScn() |
private BigDecimal |
calculateSmallestScn() |
(package private) void |
close()
Closes buffer.
|
(package private) boolean |
commit(String transactionId,
BigDecimal scn,
OracleOffsetContext offsetContext,
Timestamp timestamp,
io.debezium.pipeline.source.spi.ChangeEventSource.ChangeEventSourceContext context,
String debugMessage)
If the commit executor queue is full, back-pressure will be applied by letting execution of the callback
be performed by the calling thread.
|
(package private) BigDecimal |
getLargestScn() |
(package private) Set<String> |
getRolledBackTransactionIds() |
(package private) boolean |
isEmpty()
Returns
true if buffer is empty, otherwise false. |
(package private) void |
registerCommitCallback(String transactionId,
BigDecimal scn,
Instant changeTime,
String redoSql,
TransactionalBuffer.CommitCallback callback)
Registers callback to execute when transaction commits.
|
(package private) void |
resetLargestScn(Long value)
Reset Largest SCN
|
(package private) boolean |
rollback(String transactionId,
String debugMessage)
Clears registered callbacks for given transaction identifier.
|
String |
toString() |
private static final org.slf4j.Logger LOGGER
private final Map<String,TransactionalBuffer.Transaction> transactions
private final ExecutorService executor
private final AtomicInteger taskCounter
private final io.debezium.pipeline.ErrorHandler errorHandler
private TransactionalBufferMetrics metrics
private BigDecimal largestScn
private BigDecimal lastCommittedScn
TransactionalBuffer(String logicalName, io.debezium.pipeline.ErrorHandler errorHandler, TransactionalBufferMetrics metrics, int inCommitQueueCapacity)
logicalName - logical nameerrorHandler - logError handlermetrics - metrics MBeaninCommitQueueCapacity - commit queue capacity. On overflow, caller runs taskBigDecimal getLargestScn()
Set<String> getRolledBackTransactionIds()
void resetLargestScn(Long value)
void registerCommitCallback(String transactionId, BigDecimal scn, Instant changeTime, String redoSql, TransactionalBuffer.CommitCallback callback)
transactionId - transaction identifierscn - SCNchangeTime - time of DML parsing completionredoSql - statement from redocallback - callback to execute when transaction commitsboolean commit(String transactionId, BigDecimal scn, OracleOffsetContext offsetContext, Timestamp timestamp, io.debezium.pipeline.source.spi.ChangeEventSource.ChangeEventSourceContext context, String debugMessage)
transactionId - transaction identifierscn - SCN of the commit.offsetContext - Oracle offsettimestamp - commit timestampcontext - context to check that source is runningdebugMessage - messageboolean rollback(String transactionId, String debugMessage)
transactionId - transaction iddebugMessage - messagevoid abandonLongTransactions(Long thresholdScn)
It is limited by following condition: allOnlineRedoLogFiles.size() - currentlyMinedLogFiles.size() <= 1
If each redo lasts for 10 minutes and 7 redo group have been configured, any transaction cannot lasts longer than 1 hour.
In case of an abandonment, all DMLs/Commits/Rollbacs for this transaction will be ignored
In other words connector will not send any part of this transaction to Kafka
thresholdScn - the smallest SVN of any transaction to keep in the buffer. All others will be removed.private BigDecimal calculateSmallestScn()
private void calculateLargestScn()
boolean isEmpty()
true if buffer is empty, otherwise false.true if buffer is empty, otherwise falsevoid close()
Copyright © 2020 JBoss by Red Hat. All rights reserved.