Search in sources :

Example 1 with TransactionOptions

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

the class TransactionalMapReadWriteQuorumTest method parameters.

@Parameterized.Parameters(name = "Executing: {0}")
public static Collection<Object[]> parameters() {
    TransactionOptions onePhaseOption = TransactionOptions.getDefault();
    onePhaseOption.setTransactionType(ONE_PHASE);
    TransactionOptions twoPhaseOption = TransactionOptions.getDefault();
    twoPhaseOption.setTransactionType(TWO_PHASE);
    return Arrays.asList(new Object[] { twoPhaseOption }, new Object[] { onePhaseOption });
}
Also used : TransactionOptions(com.hazelcast.transaction.TransactionOptions)

Example 2 with TransactionOptions

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

the class ClientTransactionalMapQuorumTest method parameters.

@Parameterized.Parameters(name = "Options: {0}")
public static Collection<Object[]> parameters() {
    TransactionOptions localOption = TransactionOptions.getDefault();
    localOption.setTransactionType(ONE_PHASE);
    TransactionOptions twoPhaseOption = TransactionOptions.getDefault();
    twoPhaseOption.setTransactionType(TWO_PHASE);
    return Arrays.asList(new Object[] { twoPhaseOption }, new Object[] { localOption });
}
Also used : TransactionOptions(com.hazelcast.transaction.TransactionOptions)

Example 3 with TransactionOptions

use of com.hazelcast.transaction.TransactionOptions in project hazelcast-simulator by hazelcast.

the class MapTransactionTest method setup.

@Setup
public void setup() {
    map = targetInstance.getMap(name);
    resultList = targetInstance.getList(name + "results");
    transactionOptions = new TransactionOptions();
    transactionOptions.setTransactionType(transactionType).setDurability(durability);
}
Also used : TransactionOptions(com.hazelcast.transaction.TransactionOptions) Setup(com.hazelcast.simulator.test.annotations.Setup)

Example 4 with TransactionOptions

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

the class TransactionQueueTest method testQueueWithMap.

@Test
public void testQueueWithMap() {
    int insCount = 4;
    String queueName = "defQueue";
    String mapName = "defMap";
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(insCount);
    HazelcastInstance[] instances = factory.newInstances(getConfig());
    instances[0].getMap(mapName).lock("lock1");
    TransactionContext context = instances[1].newTransactionContext(new TransactionOptions().setTimeout(5, SECONDS));
    context.beginTransaction();
    try {
        boolean offered = context.getQueue(queueName).offer(new VersionedObject<>("item1"));
        assertTrue(offered);
        context.getMap(mapName).put("lock1", "value1");
        fail();
    } catch (TransactionException ex) {
        // expected
        context.rollbackTransaction();
    }
    assertEquals(0, instances[0].getQueue(queueName).size());
    assertNull(instances[0].getMap(mapName).get("lock1"));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) TransactionException(com.hazelcast.transaction.TransactionException) TransactionContext(com.hazelcast.transaction.TransactionContext) TransactionOptions(com.hazelcast.transaction.TransactionOptions) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with TransactionOptions

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

the class TransactionalListSplitBrainProtectionWriteTest method parameters.

@Parameters(name = "Executing: {0} {1}")
public static Collection<Object[]> parameters() {
    TransactionOptions onePhaseOption = TransactionOptions.getDefault();
    onePhaseOption.setTransactionType(ONE_PHASE);
    TransactionOptions twoPhaseOption = TransactionOptions.getDefault();
    twoPhaseOption.setTransactionType(TWO_PHASE);
    return Arrays.asList(new Object[] { onePhaseOption, WRITE }, new Object[] { twoPhaseOption, WRITE }, new Object[] { onePhaseOption, READ_WRITE }, new Object[] { twoPhaseOption, READ_WRITE });
}
Also used : TransactionOptions(com.hazelcast.transaction.TransactionOptions) Parameters(org.junit.runners.Parameterized.Parameters)

Aggregations

TransactionOptions (com.hazelcast.transaction.TransactionOptions)64 Test (org.junit.Test)41 QuickTest (com.hazelcast.test.annotation.QuickTest)33 HazelcastInstance (com.hazelcast.core.HazelcastInstance)20 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)19 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)13 TransactionException (com.hazelcast.transaction.TransactionException)13 TransactionContext (com.hazelcast.transaction.TransactionContext)10 Parameters (org.junit.runners.Parameterized.Parameters)10 TransactionManagerServiceImpl (com.hazelcast.transaction.impl.TransactionManagerServiceImpl)9 SlowTest (com.hazelcast.test.annotation.SlowTest)8 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)5 Config (com.hazelcast.config.Config)4 AssertTask (com.hazelcast.test.AssertTask)4 NightlyTest (com.hazelcast.test.annotation.NightlyTest)3 TransactionalMap (com.hazelcast.transaction.TransactionalMap)3 Address (com.hazelcast.cluster.Address)2 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)2 MapStoreConfig (com.hazelcast.config.MapStoreConfig)2 ILogger (com.hazelcast.logging.ILogger)2