Search in sources :

Example 76 with TransactionalMap

use of com.hazelcast.core.TransactionalMap in project hazelcast by hazelcast.

the class TransactionalMapDeleteMessageTask method innerCall.

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

Example 77 with TransactionalMap

use of com.hazelcast.core.TransactionalMap in project hazelcast by hazelcast.

the class TransactionalMapKeySetMessageTask method innerCall.

@Override
protected Object innerCall() throws Exception {
    final TransactionContext context = getEndpoint().getTransactionContext(parameters.txnId);
    final TransactionalMap map = context.getMap(parameters.name);
    Set keySet = map.keySet();
    List<Data> list = new ArrayList<Data>(keySet.size());
    for (Object o : keySet) {
        list.add(serializationService.toData(o));
    }
    return list;
}
Also used : TransactionalMap(com.hazelcast.core.TransactionalMap) Set(java.util.Set) TransactionContext(com.hazelcast.transaction.TransactionContext) ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data)

Example 78 with TransactionalMap

use of com.hazelcast.core.TransactionalMap in project hazelcast by hazelcast.

the class TransactionalMapKeySetWithPredicateMessageTask method innerCall.

@Override
protected Object innerCall() throws Exception {
    final TransactionContext context = getEndpoint().getTransactionContext(parameters.txnId);
    final TransactionalMap map = context.getMap(parameters.name);
    Predicate predicate = serializationService.toObject(parameters.predicate);
    Set keySet = map.keySet(predicate);
    List<Data> list = new ArrayList<Data>(keySet.size());
    for (Object o : keySet) {
        list.add(serializationService.toData(o));
    }
    return list;
}
Also used : TransactionalMap(com.hazelcast.core.TransactionalMap) Set(java.util.Set) TransactionContext(com.hazelcast.transaction.TransactionContext) ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data) Predicate(com.hazelcast.query.Predicate)

Example 79 with TransactionalMap

use of com.hazelcast.core.TransactionalMap in project hazelcast by hazelcast.

the class TransactionalMapPutIfAbsentMessageTask method innerCall.

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

Example 80 with TransactionalMap

use of com.hazelcast.core.TransactionalMap in project hazelcast by hazelcast.

the class TransactionalMapRemoveIfSameMessageTask method innerCall.

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

Aggregations

TransactionalMap (com.hazelcast.core.TransactionalMap)92 Test (org.junit.Test)73 QuickTest (com.hazelcast.test.annotation.QuickTest)68 ParallelTest (com.hazelcast.test.annotation.ParallelTest)67 HazelcastInstance (com.hazelcast.core.HazelcastInstance)61 TransactionException (com.hazelcast.transaction.TransactionException)60 TransactionalTaskContext (com.hazelcast.transaction.TransactionalTaskContext)59 NightlyTest (com.hazelcast.test.annotation.NightlyTest)47 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)38 Config (com.hazelcast.config.Config)36 TransactionContext (com.hazelcast.transaction.TransactionContext)33 MapStoreConfig (com.hazelcast.config.MapStoreConfig)32 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)30 IMap (com.hazelcast.core.IMap)29 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)12 SqlPredicate (com.hazelcast.query.SqlPredicate)8 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)7 Collection (java.util.Collection)7 ExpectedRuntimeException (com.hazelcast.test.ExpectedRuntimeException)6 TransactionNotActiveException (com.hazelcast.transaction.TransactionNotActiveException)6