public interface IgniteTransactions
PARTITIONED
or
REPLICATED
, can also participate in the same transaction.
Transactions are AutoCloseable
, so they will automatically rollback unless
explicitly committed.
Here is an example of a transaction:
try (Transaction tx = Ignition.ignite().transactions().txStart()) { Account acct = cache.get(acctId); // Current balance. double balance = acct.getBalance(); // Deposit $100 into account. acct.setBalance(balance + 100); // Store updated account in cache. cache.put(acctId, acct); tx.commit(); }
Modifier and Type | Method and Description |
---|---|
Collection<Transaction> |
localActiveTransactions()
Returns a list of active transactions initiated by this node.
|
TransactionMetrics |
metrics() |
void |
resetMetrics()
Resets transaction metrics.
|
Transaction |
tx()
Gets transaction started by this thread or
null if this thread does
not have a transaction. |
Transaction |
txStart()
Starts transaction with default isolation, concurrency, timeout, and invalidation policy.
|
Transaction |
txStart(TransactionConcurrency concurrency,
TransactionIsolation isolation)
Starts new transaction with the specified concurrency and isolation.
|
Transaction |
txStart(TransactionConcurrency concurrency,
TransactionIsolation isolation,
long timeout,
int txSize)
Starts transaction with specified isolation, concurrency, timeout,
and number of participating entries.
|
IgniteTransactions |
withLabel(String lb)
Returns instance of Ignite Transactions to mark a transaction with a special label.
|
IgniteTransactions |
withTracing()
Returns an instance of
IgniteTransactions tran will trace every transaction. |
Transaction txStart() throws IllegalStateException
TransactionConfiguration
at startup.IllegalStateException
- If transaction is already started by this thread.Transaction txStart(TransactionConcurrency concurrency, TransactionIsolation isolation)
concurrency
- Concurrency.isolation
- Isolation.IllegalStateException
- If transaction is already started by this thread.Transaction txStart(TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout, int txSize)
concurrency
- Concurrency.isolation
- Isolation.timeout
- Timeout in milliseconds.txSize
- Number of entries participating in transaction (may be approximate).IllegalStateException
- If transaction is already started by this thread.Transaction tx()
null
if this thread does
not have a transaction.null
if this thread
does not have a transaction.TransactionMetrics metrics()
void resetMetrics()
Collection<Transaction> localActiveTransactions()
Note: returned transaction handle will only support getters, Transaction.close()
,
Transaction.rollback()
, Transaction.rollbackAsync()
methods.
Trying to invoke other methods will lead to UnsupportedOperationException.
IgniteTransactions withLabel(String lb)
Transaction.label()
method.lb
- label.This
for chaining.NullPointerException
- if label is null.Transaction.label()
IgniteTransactions withTracing()
IgniteTransactions
tran will trace every transaction.
GridGain In-Memory Computing Platform : ver. 8.9.15 Release Date : December 3 2024