Search in sources :

Example 1 with COMMITTING

use of com.hazelcast.transaction.impl.Transaction.State.COMMITTING in project hazelcast by hazelcast.

the class XATransaction method commitAsync.

public void commitAsync(BiConsumer callback) {
    if (state != PREPARED) {
        throw new IllegalStateException("Transaction is not prepared");
    }
    checkTimeout();
    state = COMMITTING;
    BiConsumer wrappedCallback = (input, throwable) -> {
        try {
            callback.accept(input, throwable);
        } finally {
            if (throwable != null) {
                transactionLog.onCommitFailure();
            } else {
                transactionLog.onCommitSuccess();
            }
        }
    };
    transactionLog.commitAsync(nodeEngine, wrappedCallback);
    // We should rethrow exception if transaction is not TWO_PHASE
    state = COMMITTED;
}
Also used : TransactionLogRecord(com.hazelcast.transaction.impl.TransactionLogRecord) FutureUtil.logAllExceptions(com.hazelcast.internal.util.FutureUtil.logAllExceptions) Clock(com.hazelcast.internal.util.Clock) PutRemoteTransactionOperation(com.hazelcast.transaction.impl.xa.operations.PutRemoteTransactionOperation) FutureUtil(com.hazelcast.internal.util.FutureUtil) ROLLING_BACK(com.hazelcast.transaction.impl.Transaction.State.ROLLING_BACK) MINUTES(java.util.concurrent.TimeUnit.MINUTES) TransactionException(com.hazelcast.transaction.TransactionException) Level(java.util.logging.Level) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) Future(java.util.concurrent.Future) RETHROW_TRANSACTION_EXCEPTION(com.hazelcast.internal.util.FutureUtil.RETHROW_TRANSACTION_EXCEPTION) ILogger(com.hazelcast.logging.ILogger) ROLLED_BACK(com.hazelcast.transaction.impl.Transaction.State.ROLLED_BACK) BiConsumer(java.util.function.BiConsumer) PREPARING(com.hazelcast.transaction.impl.Transaction.State.PREPARING) UuidUtil(com.hazelcast.internal.util.UuidUtil) TransactionLog(com.hazelcast.transaction.impl.TransactionLog) Xid(javax.transaction.xa.Xid) NodeEngine(com.hazelcast.spi.impl.NodeEngine) Collection(java.util.Collection) FutureUtil.waitWithDeadline(com.hazelcast.internal.util.FutureUtil.waitWithDeadline) PREPARED(com.hazelcast.transaction.impl.Transaction.State.PREPARED) IPartitionService(com.hazelcast.internal.partition.IPartitionService) ExceptionUtil(com.hazelcast.internal.util.ExceptionUtil) SERVICE_NAME(com.hazelcast.transaction.impl.xa.XAService.SERVICE_NAME) ACTIVE(com.hazelcast.transaction.impl.Transaction.State.ACTIVE) Transaction(com.hazelcast.transaction.impl.Transaction) UUID(java.util.UUID) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) COMMIT_FAILED(com.hazelcast.transaction.impl.Transaction.State.COMMIT_FAILED) COMMITTING(com.hazelcast.transaction.impl.Transaction.State.COMMITTING) ExecutionException(java.util.concurrent.ExecutionException) List(java.util.List) TransactionNotActiveException(com.hazelcast.transaction.TransactionNotActiveException) NO_TXN(com.hazelcast.transaction.impl.Transaction.State.NO_TXN) COMMITTED(com.hazelcast.transaction.impl.Transaction.State.COMMITTED) XAException(javax.transaction.xa.XAException) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) TransactionType(com.hazelcast.transaction.TransactionOptions.TransactionType) SECONDS(java.util.concurrent.TimeUnit.SECONDS) BiConsumer(java.util.function.BiConsumer)

Aggregations

IPartitionService (com.hazelcast.internal.partition.IPartitionService)1 Clock (com.hazelcast.internal.util.Clock)1 ExceptionUtil (com.hazelcast.internal.util.ExceptionUtil)1 FutureUtil (com.hazelcast.internal.util.FutureUtil)1 RETHROW_TRANSACTION_EXCEPTION (com.hazelcast.internal.util.FutureUtil.RETHROW_TRANSACTION_EXCEPTION)1 FutureUtil.logAllExceptions (com.hazelcast.internal.util.FutureUtil.logAllExceptions)1 FutureUtil.waitWithDeadline (com.hazelcast.internal.util.FutureUtil.waitWithDeadline)1 UuidUtil (com.hazelcast.internal.util.UuidUtil)1 ILogger (com.hazelcast.logging.ILogger)1 InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)1 NodeEngine (com.hazelcast.spi.impl.NodeEngine)1 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)1 TransactionException (com.hazelcast.transaction.TransactionException)1 TransactionNotActiveException (com.hazelcast.transaction.TransactionNotActiveException)1 TransactionType (com.hazelcast.transaction.TransactionOptions.TransactionType)1 Transaction (com.hazelcast.transaction.impl.Transaction)1 ACTIVE (com.hazelcast.transaction.impl.Transaction.State.ACTIVE)1 COMMITTED (com.hazelcast.transaction.impl.Transaction.State.COMMITTED)1 COMMITTING (com.hazelcast.transaction.impl.Transaction.State.COMMITTING)1 COMMIT_FAILED (com.hazelcast.transaction.impl.Transaction.State.COMMIT_FAILED)1