Search in sources :

Example 6 with TransactionalOperation

use of org.redisson.transaction.operation.TransactionalOperation in project redisson by redisson.

the class RedissonTransaction method rollbackAsync.

@Override
public RFuture<Void> rollbackAsync() {
    checkState();
    CommandBatchService executorService = new CommandBatchService(commandExecutor);
    for (TransactionalOperation transactionalOperation : operations) {
        transactionalOperation.rollback(executorService);
    }
    RPromise<Void> result = new RedissonPromise<>();
    RFuture<BatchResult<?>> future = executorService.executeAsync();
    future.onComplete((res, e) -> {
        if (e != null) {
            result.tryFailure(new TransactionException("Unable to rollback transaction", e));
            return;
        }
        operations.clear();
        executed.set(true);
        result.trySuccess(null);
    });
    return result;
}
Also used : TransactionalOperation(org.redisson.transaction.operation.TransactionalOperation) RedissonPromise(org.redisson.misc.RedissonPromise) CommandBatchService(org.redisson.command.CommandBatchService)

Example 7 with TransactionalOperation

use of org.redisson.transaction.operation.TransactionalOperation in project redisson by redisson.

the class BaseTransactionalSet method addAsync.

public RFuture<Boolean> addAsync(V value) {
    long threadId = Thread.currentThread().getId();
    TransactionalOperation operation = createAddOperation(value, threadId);
    return addAsync(value, operation);
}
Also used : TransactionalOperation(org.redisson.transaction.operation.TransactionalOperation)

Aggregations

TransactionalOperation (org.redisson.transaction.operation.TransactionalOperation)7 CommandBatchService (org.redisson.command.CommandBatchService)4 RedissonLocalCachedMap (org.redisson.RedissonLocalCachedMap)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 RedissonBatch (org.redisson.RedissonBatch)2 LocalCachedMapDisable (org.redisson.cache.LocalCachedMapDisable)2 LocalCachedMapDisabledKey (org.redisson.cache.LocalCachedMapDisabledKey)2 AsyncCountDownLatch (org.redisson.misc.AsyncCountDownLatch)2 RedissonPromise (org.redisson.misc.RedissonPromise)2 MapOperation (org.redisson.transaction.operation.map.MapOperation)2 Timeout (io.netty.util.Timeout)1 TimerTask (io.netty.util.TimerTask)1 RedissonObject (org.redisson.RedissonObject)1