Search in sources :

Example 6 with TransactionManagerServiceImpl

use of com.hazelcast.transaction.impl.TransactionManagerServiceImpl in project hazelcast by hazelcast.

the class AdvancedClusterStateTest method changeClusterState_shouldFail_withoutBackup_whenInitiatorDies_afterPrepare.

@Test
public void changeClusterState_shouldFail_withoutBackup_whenInitiatorDies_afterPrepare() throws Exception {
    final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
    final HazelcastInstance[] instances = factory.newInstances();
    final HazelcastInstance hz = instances[instances.length - 1];
    TransactionManagerServiceImpl transactionManagerService = spyTransactionManagerService(hz);
    TransactionOptions options = new TransactionOptions().setDurability(0).setTimeout(30, TimeUnit.SECONDS);
    when(transactionManagerService.newAllowedDuringPassiveStateTransaction(options)).thenAnswer(new TransactionAnswer() {

        @Override
        protected void afterPrepare() {
            terminateInstance(hz);
        }
    });
    try {
        hz.getCluster().changeClusterState(ClusterState.FROZEN, options);
        fail("This instance is terminated. Cannot commit the transaction!");
    } catch (HazelcastInstanceNotActiveException ignored) {
    }
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertClusterState(ClusterState.ACTIVE, instances[0], instances[1]);
        }
    });
}
Also used : HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) HazelcastInstance(com.hazelcast.core.HazelcastInstance) 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 7 with TransactionManagerServiceImpl

use of com.hazelcast.transaction.impl.TransactionManagerServiceImpl 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 8 with TransactionManagerServiceImpl

use of com.hazelcast.transaction.impl.TransactionManagerServiceImpl in project hazelcast by hazelcast.

the class CreateAllowedDuringPassiveStateTxBackupLogOperation method run.

@Override
public void run() throws Exception {
    TransactionManagerServiceImpl txManagerService = getService();
    txManagerService.createAllowedDuringPassiveStateBackupLog(getCallerUuid(), getTxnId());
}
Also used : TransactionManagerServiceImpl(com.hazelcast.transaction.impl.TransactionManagerServiceImpl)

Example 9 with TransactionManagerServiceImpl

use of com.hazelcast.transaction.impl.TransactionManagerServiceImpl in project hazelcast by hazelcast.

the class PurgeTxBackupLogOperation method run.

@Override
public void run() throws Exception {
    TransactionManagerServiceImpl txManagerService = getService();
    txManagerService.purgeBackupLog(txnId);
}
Also used : TransactionManagerServiceImpl(com.hazelcast.transaction.impl.TransactionManagerServiceImpl)

Example 10 with TransactionManagerServiceImpl

use of com.hazelcast.transaction.impl.TransactionManagerServiceImpl in project hazelcast by hazelcast.

the class RollbackTxBackupLogOperation method run.

@Override
public void run() throws Exception {
    TransactionManagerServiceImpl txManagerService = getService();
    txManagerService.rollbackBackupLog(txnId);
}
Also used : TransactionManagerServiceImpl(com.hazelcast.transaction.impl.TransactionManagerServiceImpl)

Aggregations

TransactionManagerServiceImpl (com.hazelcast.transaction.impl.TransactionManagerServiceImpl)14 TargetNotMemberException (com.hazelcast.spi.exception.TargetNotMemberException)7 TransactionOptions (com.hazelcast.transaction.TransactionOptions)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)6 AssertTask (com.hazelcast.test.AssertTask)6 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)6 ParallelTest (com.hazelcast.test.annotation.ParallelTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 TransactionException (com.hazelcast.transaction.TransactionException)6 ExecutionException (java.util.concurrent.ExecutionException)6 Test (org.junit.Test)6 Address (com.hazelcast.nio.Address)2 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)2 MemberLeftException (com.hazelcast.core.MemberLeftException)1 TransactionContext (com.hazelcast.transaction.TransactionContext)1 Transaction (com.hazelcast.transaction.impl.Transaction)1 Field (java.lang.reflect.Field)1