Search in sources :

Example 1 with TxBackupLog

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

the class TransactionImpl_TwoPhaseIntegrationTest method prepare_whenMultipleItemsAndDurabilityOne_thenBackupLog.

@Test
public void prepare_whenMultipleItemsAndDurabilityOne_thenBackupLog() {
    TransactionOptions options = new TransactionOptions().setTransactionType(TWO_PHASE).setDurability(1);
    TransactionImpl tx = new TransactionImpl(localTxService, localNodeEngine, options, txOwner);
    tx.begin();
    MockTransactionLogRecord record1 = new MockTransactionLogRecord();
    tx.add(record1);
    MockTransactionLogRecord record2 = new MockTransactionLogRecord();
    tx.add(record2);
    tx.prepare();
    assertPrepared(tx);
    TxBackupLog log = remoteTxService.txBackupLogs.get(tx.getTxnId());
    assertNotNull(log);
    assertEquals(COMMITTING, log.state);
    record1.assertPrepareCalled().assertCommitNotCalled().assertRollbackNotCalled();
    record2.assertPrepareCalled().assertCommitNotCalled().assertRollbackNotCalled();
}
Also used : TransactionOptions(com.hazelcast.transaction.TransactionOptions) TxBackupLog(com.hazelcast.transaction.impl.TransactionManagerServiceImpl.TxBackupLog) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with TxBackupLog

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

the class TransactionImpl_TwoPhaseIntegrationTest method prepare_whenMultipleItemsAndDurabilityOne_thenRemoveBackupLog.

@Test
public void prepare_whenMultipleItemsAndDurabilityOne_thenRemoveBackupLog() {
    final String txOwner = localNodeEngine.getLocalMember().getUuid();
    TransactionOptions options = new TransactionOptions().setTransactionType(TWO_PHASE).setDurability(1);
    final TransactionImpl tx = new TransactionImpl(localTxService, localNodeEngine, options, txOwner);
    tx.begin();
    tx.add(new MockTransactionLogRecord());
    tx.add(new MockTransactionLogRecord());
    tx.prepare();
    assertPrepared(tx);
    TxBackupLog log = remoteTxService.txBackupLogs.get(tx.getTxnId());
    assertNotNull(log);
    cluster[0].shutdown();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertFalse(remoteTxService.txBackupLogs.containsKey(tx.getTxnId()));
        }
    });
}
Also used : TransactionOptions(com.hazelcast.transaction.TransactionOptions) AssertTask(com.hazelcast.test.AssertTask) TxBackupLog(com.hazelcast.transaction.impl.TransactionManagerServiceImpl.TxBackupLog) TransactionException(com.hazelcast.transaction.TransactionException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with TxBackupLog

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

the class TransactionImpl_TwoPhaseIntegrationTest method assertNoBackupLogOnRemote.

private void assertNoBackupLogOnRemote(TransactionImpl tx) {
    TxBackupLog log = remoteTxService.txBackupLogs.get(tx.getTxnId());
    assertNull(log);
}
Also used : TxBackupLog(com.hazelcast.transaction.impl.TransactionManagerServiceImpl.TxBackupLog)

Example 4 with TxBackupLog

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

the class TransactionManagerServiceImplTest method assertTxLogState.

private void assertTxLogState(String txId, Transaction.State state) {
    TxBackupLog backupLog = txService.txBackupLogs.get(txId);
    assertNotNull(backupLog);
    assertEquals(state, backupLog.state);
}
Also used : TxBackupLog(com.hazelcast.transaction.impl.TransactionManagerServiceImpl.TxBackupLog)

Aggregations

TxBackupLog (com.hazelcast.transaction.impl.TransactionManagerServiceImpl.TxBackupLog)4 QuickTest (com.hazelcast.test.annotation.QuickTest)2 TransactionOptions (com.hazelcast.transaction.TransactionOptions)2 Test (org.junit.Test)2 AssertTask (com.hazelcast.test.AssertTask)1 TransactionException (com.hazelcast.transaction.TransactionException)1