Search in sources :

Example 51 with TransactionalMap

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

the class TransactionalMapSetMessageTask method innerCall.

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

Example 52 with TransactionalMap

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

the class TransactionalMapValuesMessageTask method innerCall.

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

Example 53 with TransactionalMap

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

the class TransactionalMapKeySetWithPredicateMessageTask method innerCall.

@Override
protected Object innerCall() throws Exception {
    final TransactionContext context = endpoint.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.transaction.TransactionalMap) Set(java.util.Set) TransactionContext(com.hazelcast.transaction.TransactionContext) ArrayList(java.util.ArrayList) Data(com.hazelcast.internal.serialization.Data) Predicate(com.hazelcast.query.Predicate)

Example 54 with TransactionalMap

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

the class TransactionalMapSizeMessageTask method innerCall.

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

Example 55 with TransactionalMap

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

the class TransactionalMapValuesWithPredicateMessageTask method innerCall.

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

Aggregations

TransactionalMap (com.hazelcast.transaction.TransactionalMap)95 Test (org.junit.Test)77 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)76 QuickTest (com.hazelcast.test.annotation.QuickTest)76 HazelcastInstance (com.hazelcast.core.HazelcastInstance)63 TransactionException (com.hazelcast.transaction.TransactionException)60 TransactionalTaskContext (com.hazelcast.transaction.TransactionalTaskContext)55 NightlyTest (com.hazelcast.test.annotation.NightlyTest)42 Config (com.hazelcast.config.Config)39 TransactionContext (com.hazelcast.transaction.TransactionContext)38 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)37 MapStoreConfig (com.hazelcast.config.MapStoreConfig)32 IMap (com.hazelcast.map.IMap)28 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)27 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)14 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)7 ExpectedRuntimeException (com.hazelcast.test.ExpectedRuntimeException)6 TransactionNotActiveException (com.hazelcast.transaction.TransactionNotActiveException)6 Collection (java.util.Collection)6 ExecutionException (java.util.concurrent.ExecutionException)6