THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||||
---|---|---|---|---|
| ||||
public interface IgniteTransactions { Transaction begin(); CompletableFuture<Transaction> beginAsync(); void commit(); CompletableFuture<Void> commitAsync(); void rollback(); CompletableFuture<Void> rollbackAsync(); /** * Executes a closure within a transaction. * * <p>If the closure is executed normally (no exceptions) the transaction is automatically committed. * <p> In case of serialization conflict (or other retriable issue), the transaction will be automatically retried, so the closure must be a "pure function". * @param clo The closure. * * @throws TransactionException If a transaction can't be finished successfully. */ void runInTransaction(Consumer<Transaction> clo); <T> T runInTransaction(Function<Transaction, T> clo); <T> CompletableFuture<T> runInTransactionAsync(Function<Transaction, CompletableFuture<T>> clo) } public interface Transaction { /** * Synchronously commits a transaction. * * @throws TransactionException If a transaction can't be committed. */ void commit() throws TransactionException; /** * Asynchronously commits a transaction. * * @return The future. */ CompletableFuture<Void> commitAsync(); /** * Synchronously rolls back a transaction. * * @throws TransactionException If a transaction can't be rolled back. */ void rollback() throws TransactionException; /** * Asynchronously rolls back a transaction. * * @return The future. */ CompletableFuture<Void> rollbackAsync(); } |
To enlist the operation into a transaction, the Transaction instance must be passed to the corresponding transaction’s store methods. Each method accepts a transaction argument. Consider, for example, a method for updating a tuple:
...