Search in sources :

Example 71 with TransactionContext

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

the class TransactionalSetAddMessageTask method innerCall.

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

Example 72 with TransactionContext

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

the class TransactionalMapReplaceMessageTask method innerCall.

@Override
protected Object innerCall() throws Exception {
    final TransactionContext context = getEndpoint().getTransactionContext(parameters.txnId);
    final TransactionalMap map = context.getMap(parameters.name);
    Object oldValue = map.replace(parameters.key, parameters.value);
    return serializationService.toData(oldValue);
}
Also used : TransactionalMap(com.hazelcast.core.TransactionalMap) TransactionContext(com.hazelcast.transaction.TransactionContext)

Example 73 with TransactionContext

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

the class TransactionalMultiMapRemoveMessageTask method innerCall.

@Override
protected Object innerCall() throws Exception {
    final TransactionContext context = endpoint.getTransactionContext(parameters.txnId);
    TransactionalMultiMap<Object, Object> multiMap = context.getMultiMap(parameters.name);
    Collection<Object> collection = multiMap.remove(parameters.key);
    List<Data> list = new ArrayList<Data>(collection.size());
    for (Object o : collection) {
        list.add(serializationService.toData(o));
    }
    return list;
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data)

Example 74 with TransactionContext

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

the class XAResourceProxy method rollback.

@Override
public void rollback(Xid xid) throws XAException {
    List<TransactionContext> contexts = xidContextMap.remove(xid);
    if (contexts == null) {
        finalizeTransactionRemotely(xid, false);
        return;
    }
    for (TransactionContext context : contexts) {
        getTransaction(context).rollback();
    }
    clearRemoteTransactions(xid);
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext)

Example 75 with TransactionContext

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

the class XAResourceProxy method createTransactionContext.

private TransactionContext createTransactionContext(Xid xid) {
    ClientContext clientContext = getContext();
    ClientTransactionManagerService transactionManager = clientContext.getTransactionManager();
    TransactionContext context = transactionManager.newXATransactionContext(xid, timeoutInSeconds.get());
    getTransaction(context).begin();
    return context;
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) ClientContext(com.hazelcast.client.spi.ClientContext) ClientTransactionManagerService(com.hazelcast.client.spi.ClientTransactionManagerService)

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