Search in sources :

Example 56 with TransactionContext

use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.

the class TransactionCommitMessageTask method innerCall.

@Override
protected Object innerCall() throws Exception {
    TransactionContext transactionContext = endpoint.getTransactionContext(parameters.transactionId);
    transactionContext.commitTransaction();
    endpoint.removeTransactionContext(parameters.transactionId);
    return null;
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext)

Example 57 with TransactionContext

use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.

the class TransactionRollbackMessageTask method innerCall.

@Override
protected Object innerCall() throws Exception {
    TransactionContext transactionContext = endpoint.getTransactionContext(parameters.transactionId);
    transactionContext.rollbackTransaction();
    endpoint.removeTransactionContext(parameters.transactionId);
    return null;
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext)

Example 58 with TransactionContext

use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.

the class XATransactionPrepareMessageTask method call.

@Override
protected Object call() throws Exception {
    String transactionId = parameters.transactionId;
    TransactionContext transactionContext = endpoint.getTransactionContext(transactionId);
    if (transactionContext == null) {
        throw new TransactionException("No transaction context with given transactionId: " + transactionId);
    }
    Transaction transaction = TransactionAccessor.getTransaction(transactionContext);
    transaction.prepare();
    return null;
}
Also used : TransactionException(com.hazelcast.transaction.TransactionException) Transaction(com.hazelcast.transaction.impl.Transaction) TransactionContext(com.hazelcast.transaction.TransactionContext)

Example 59 with TransactionContext

use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.

the class XATransactionRollbackMessageTask method call.

@Override
protected Object call() throws Exception {
    String transactionId = parameters.transactionId;
    TransactionContext transactionContext = endpoint.getTransactionContext(transactionId);
    if (transactionContext == null) {
        throw new TransactionException("No transaction context with given transactionId: " + transactionId);
    }
    Transaction transaction = TransactionAccessor.getTransaction(transactionContext);
    transaction.rollback();
    endpoint.removeTransactionContext(transactionId);
    return null;
}
Also used : TransactionException(com.hazelcast.transaction.TransactionException) Transaction(com.hazelcast.transaction.impl.Transaction) TransactionContext(com.hazelcast.transaction.TransactionContext)

Example 60 with TransactionContext

use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.

the class TransactionalListAddMessageTask method innerCall.

@Override
protected Object innerCall() throws Exception {
    final TransactionContext context = endpoint.getTransactionContext(parameters.txnId);
    TransactionalList<Object> list = context.getList(parameters.name);
    return list.add(parameters.item);
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext)

Aggregations

TransactionContext (com.hazelcast.transaction.TransactionContext)280 Test (org.junit.Test)209 QuickTest (com.hazelcast.test.annotation.QuickTest)189 ParallelTest (com.hazelcast.test.annotation.ParallelTest)184 HazelcastInstance (com.hazelcast.core.HazelcastInstance)58 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)48 TransactionalMap (com.hazelcast.core.TransactionalMap)33 TransactionException (com.hazelcast.transaction.TransactionException)22 IMap (com.hazelcast.core.IMap)21 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)19 Config (com.hazelcast.config.Config)17 NightlyTest (com.hazelcast.test.annotation.NightlyTest)16 CountDownLatch (java.util.concurrent.CountDownLatch)14 XAException (javax.transaction.xa.XAException)14 TransactionalQueue (com.hazelcast.core.TransactionalQueue)13 TransactionalMultiMap (com.hazelcast.core.TransactionalMultiMap)9 HazelcastXAResource (com.hazelcast.transaction.HazelcastXAResource)9 ExecutionException (java.util.concurrent.ExecutionException)9 ISet (com.hazelcast.core.ISet)8 MultiMap (com.hazelcast.core.MultiMap)8