public class TransactionContext extends Object
| Constructor and Description |
|---|
TransactionContext(TransactionSystemClient txClient,
Iterable<TransactionAware> txAwares) |
TransactionContext(TransactionSystemClient txClient,
TransactionAware... txAwares) |
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Aborts the given transaction, and rolls back all data set changes.
|
void |
abort(TransactionFailureException cause)
Aborts the given transaction, and rolls back all data set changes.
|
void |
addTransactionAware(TransactionAware txAware)
Adds a new transaction-aware to participate in the transaction.
|
void |
checkpoint()
Checkpoints the current transaction by flushing any pending writes for the registered
TransactionAware
instances, and obtaining a new current write pointer for the transaction. |
void |
finish()
Commits the current transaction.
|
Transaction |
getCurrentTransaction()
Returns the current transaction or null if no transaction is currently in progress.
|
void |
start()
Starts a new transaction.
|
public TransactionContext(TransactionSystemClient txClient, TransactionAware... txAwares)
public TransactionContext(TransactionSystemClient txClient, Iterable<TransactionAware> txAwares)
public void addTransactionAware(TransactionAware txAware)
txAware - the new transaction-awarepublic void start()
throws TransactionFailureException
TransactionSystemClient,
and pass the returned transaction to TransactionAware.startTx(Transaction) for each registered
TransactionAware. If an exception is encountered, the transaction will be aborted and a
TransactionFailureException wrapping the root cause will be thrown.TransactionFailureException - if an exception occurs starting the transaction with any registered
TransactionAwarepublic void finish()
throws TransactionFailureException
TransactionAware instances; flush any pending writes from the TransactionAwares;
commit the current transaction with the TransactionSystemClient; and clear the current transaction state.TransactionConflictException - if a conflict is detected with a recently committed transactionTransactionFailureException - if an error occurs while committingpublic void abort()
throws TransactionFailureException
TransactionFailureException - for any exception that is encountered.public void checkpoint()
throws TransactionFailureException
TransactionAware
instances, and obtaining a new current write pointer for the transaction. By performing a checkpoint,
the client can ensure that all previous writes were flushed and are visible. By default, the current write
pointer for the transaction is also visible. The current write pointer can be excluded from read
operations by setting an attribute with the key TxConstants#TX_EXCLUDE_CURRENT_WRITE on the
Get or Scan operation. After the checkpoint operation is performed, the updated
Transaction instance will be passed to TransactionAware.startTx(Transaction) for each
registered TransactionAware instance.TransactionFailureException - if an error occurs while performing the checkpoint@Nullable public Transaction getCurrentTransaction()
public void abort(TransactionFailureException cause) throws TransactionFailureException
cause - the original exception that caused the abortTransactionFailureException - for any exception that is encountered.Copyright © 2015. All Rights Reserved.