Search in sources :

Example 51 with TransactionOptions

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

the class TransactionalMultiMapSplitBrainProtectionReadTest 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, READ }, new Object[] { twoPhaseOption, READ }, new Object[] { onePhaseOption, READ_WRITE }, new Object[] { twoPhaseOption, READ_WRITE });
}
Also used : TransactionOptions(com.hazelcast.transaction.TransactionOptions) Parameters(org.junit.runners.Parameterized.Parameters)

Example 52 with TransactionOptions

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

the class TransactionContextImpl_backupLogsTest method assertBackupLogCreationNotForced.

public void assertBackupLogCreationNotForced(String serviceName) {
    TransactionOptions options = new TransactionOptions();
    TransactionContextImpl txContext = new TransactionContextImpl(localTxManager, localNodeEngine, options, ownerUuid, false);
    txContext.beginTransaction();
    TransactionalObject result = txContext.getTransactionalObject(serviceName, "foo");
    assertNotNull(result);
    assertNull(remoteTxManager.txBackupLogs.get(txContext.getTxnId()));
}
Also used : TransactionOptions(com.hazelcast.transaction.TransactionOptions) TransactionalObject(com.hazelcast.transaction.TransactionalObject)

Example 53 with TransactionOptions

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

the class TransactionImpl_OnePhaseTest method setup.

@Before
public void setup() {
    HazelcastInstance hz = createHazelcastInstance();
    operationService = getOperationService(hz);
    logger = mock(ILogger.class);
    txManagerService = mock(TransactionManagerServiceImpl.class);
    txManagerService.commitCount = MwCounter.newMwCounter();
    txManagerService.startCount = MwCounter.newMwCounter();
    txManagerService.rollbackCount = MwCounter.newMwCounter();
    nodeEngine = mock(NodeEngine.class);
    when(nodeEngine.getOperationService()).thenReturn(operationService);
    when(nodeEngine.getLocalMember()).thenReturn(new MemberImpl());
    when(nodeEngine.getLogger(TransactionImpl.class)).thenReturn(logger);
    options = new TransactionOptions().setTransactionType(ONE_PHASE);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) TransactionOptions(com.hazelcast.transaction.TransactionOptions) ILogger(com.hazelcast.logging.ILogger) Before(org.junit.Before)

Example 54 with TransactionOptions

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

the class TransactionImpl_TwoPhaseTest method commit_whenThrowsExceptionDuringCommit.

@Test
public void commit_whenThrowsExceptionDuringCommit() throws Exception {
    TransactionOptions options = new TransactionOptions().setTransactionType(TWO_PHASE).setDurability(0);
    TransactionImpl tx = new TransactionImpl(txManagerService, nodeEngine, options, UUID.randomUUID());
    tx.begin();
    tx.add(new MockTransactionLogRecord().failCommit());
    tx.prepare();
    try {
        tx.commit();
        fail();
    } catch (TransactionException expected) {
    }
    assertEquals(COMMIT_FAILED, tx.getState());
}
Also used : TransactionException(com.hazelcast.transaction.TransactionException) TransactionOptions(com.hazelcast.transaction.TransactionOptions) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 55 with TransactionOptions

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

the class TransactionImpl_TwoPhaseIntegrationTest method prepare_whenSingleItemAndDurabilityOne_thenNoBackupLog.

// =================== prepare ===========================================
@Test
public void prepare_whenSingleItemAndDurabilityOne_thenNoBackupLog() {
    TransactionOptions options = new TransactionOptions().setTransactionType(TWO_PHASE).setDurability(1);
    TransactionImpl tx = new TransactionImpl(localTxService, localNodeEngine, options, txOwner);
    tx.begin();
    MockTransactionLogRecord record = new MockTransactionLogRecord();
    tx.add(record);
    tx.prepare();
    assertPrepared(tx);
    assertNoBackupLogOnRemote(tx);
    record.assertPrepareCalled().assertCommitNotCalled().assertRollbackNotCalled();
}
Also used : TransactionOptions(com.hazelcast.transaction.TransactionOptions) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

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