Search in sources :

Example 6 with TransactionOptions

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

the class HazelcastOSGiInstanceTest method executeTransactionWithOptionsCalledSuccessfullyOverOSGiInstance.

@Test
public void executeTransactionWithOptionsCalledSuccessfullyOverOSGiInstance() {
    Object result = new Object();
    TransactionOptions transactionOptions = new TransactionOptions();
    TransactionalTask mockTransactionalTask = mock(TransactionalTask.class);
    HazelcastInstance mockHazelcastInstance = mock(HazelcastInstance.class);
    HazelcastOSGiInstance hazelcastOSGiInstance = HazelcastOSGiTestUtil.createHazelcastOSGiInstance(mockHazelcastInstance);
    when(mockHazelcastInstance.executeTransaction(transactionOptions, mockTransactionalTask)).thenReturn(result);
    assertEquals(result, hazelcastOSGiInstance.executeTransaction(transactionOptions, mockTransactionalTask));
    verify(mockHazelcastInstance).executeTransaction(transactionOptions, mockTransactionalTask);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) TransactionOptions(com.hazelcast.transaction.TransactionOptions) TransactionalTask(com.hazelcast.transaction.TransactionalTask) DistributedObject(com.hazelcast.core.DistributedObject) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 7 with TransactionOptions

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

the class HazelcastOSGiInstanceTest method newTransactionContextWithOptionsCalledSuccessfullyOverOSGiInstance.

@Test
public void newTransactionContextWithOptionsCalledSuccessfullyOverOSGiInstance() {
    TransactionOptions transactionOptions = new TransactionOptions();
    TransactionContext mockTransactionContext = mock(TransactionContext.class);
    HazelcastInstance mockHazelcastInstance = mock(HazelcastInstance.class);
    HazelcastOSGiInstance hazelcastOSGiInstance = HazelcastOSGiTestUtil.createHazelcastOSGiInstance(mockHazelcastInstance);
    when(mockHazelcastInstance.newTransactionContext(transactionOptions)).thenReturn(mockTransactionContext);
    assertEquals(mockTransactionContext, hazelcastOSGiInstance.newTransactionContext(transactionOptions));
    verify(mockHazelcastInstance).newTransactionContext(transactionOptions);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) TransactionOptions(com.hazelcast.transaction.TransactionOptions) TransactionContext(com.hazelcast.transaction.TransactionContext) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 8 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 9 with TransactionOptions

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

the class AdvancedClusterStateTest method changeClusterState_shouldNotFail_whenNonInitiatorMemberDies_duringCommit.

@Test
public void changeClusterState_shouldNotFail_whenNonInitiatorMemberDies_duringCommit() throws Exception {
    final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
    final HazelcastInstance[] instances = factory.newInstances();
    final HazelcastInstance hz = instances[2];
    TransactionManagerServiceImpl transactionManagerService = spyTransactionManagerService(hz);
    final Address address = getAddress(instances[0]);
    TransactionOptions options = TransactionOptions.getDefault().setDurability(0);
    when(transactionManagerService.newAllowedDuringPassiveStateTransaction(options)).thenAnswer(new TransactionAnswer() {

        @Override
        protected void afterPrepare() {
            terminateInstance(instances[0]);
        }
    });
    hz.getCluster().changeClusterState(ClusterState.FROZEN, options);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertClusterState(ClusterState.FROZEN, instances[2], instances[1]);
        }
    });
    instances[0] = factory.newHazelcastInstance(address);
    assertClusterSizeEventually(3, instances[0]);
    assertClusterSizeEventually(3, instances[1]);
    assertClusterSizeEventually(3, instances[2]);
    assertClusterState(ClusterState.FROZEN, instances);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.nio.Address) TransactionManagerServiceImpl(com.hazelcast.transaction.impl.TransactionManagerServiceImpl) TransactionOptions(com.hazelcast.transaction.TransactionOptions) AssertTask(com.hazelcast.test.AssertTask) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) TransactionException(com.hazelcast.transaction.TransactionException) ExecutionException(java.util.concurrent.ExecutionException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 10 with TransactionOptions

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

the class BasicClusterStateTest method changeClusterState_transaction_mustBe_TWO_PHASE.

@Test(expected = IllegalArgumentException.class)
public void changeClusterState_transaction_mustBe_TWO_PHASE() {
    HazelcastInstance hz = createHazelcastInstance();
    hz.getCluster().changeClusterState(ClusterState.FROZEN, new TransactionOptions().setTransactionType(TransactionType.LOCAL));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) TransactionOptions(com.hazelcast.transaction.TransactionOptions) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

TransactionOptions (com.hazelcast.transaction.TransactionOptions)47 QuickTest (com.hazelcast.test.annotation.QuickTest)36 Test (org.junit.Test)36 TransactionException (com.hazelcast.transaction.TransactionException)18 HazelcastInstance (com.hazelcast.core.HazelcastInstance)15 ParallelTest (com.hazelcast.test.annotation.ParallelTest)14 AssertTask (com.hazelcast.test.AssertTask)9 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)9 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)7 TransactionManagerServiceImpl (com.hazelcast.transaction.impl.TransactionManagerServiceImpl)7 ExecutionException (java.util.concurrent.ExecutionException)7 TargetNotMemberException (com.hazelcast.spi.exception.TargetNotMemberException)6 TransactionContext (com.hazelcast.transaction.TransactionContext)6 Config (com.hazelcast.config.Config)3 NightlyTest (com.hazelcast.test.annotation.NightlyTest)3 MapStoreConfig (com.hazelcast.config.MapStoreConfig)2 TransactionalMap (com.hazelcast.core.TransactionalMap)2 MemberImpl (com.hazelcast.instance.MemberImpl)2 ILogger (com.hazelcast.logging.ILogger)2 Address (com.hazelcast.nio.Address)2