use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class TransactionImpl_TwoPhaseIntegrationTest method commit_whenMultipleItemsAndDurabilityZero_thenNoBackupLog.
@Test
public void commit_whenMultipleItemsAndDurabilityZero_thenNoBackupLog() {
TransactionOptions options = new TransactionOptions().setTransactionType(TWO_PHASE).setDurability(0);
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();
tx.commit();
assertCommitted(tx);
assertNoBackupLogOnRemote(tx);
record1.assertPrepareCalled().assertCommitCalled().assertRollbackNotCalled();
record2.assertPrepareCalled().assertCommitCalled().assertRollbackNotCalled();
}
use of com.hazelcast.transaction.TransactionOptions 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();
}
use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class TransactionImpl_TwoPhaseIntegrationTest method rollback_whenMultipleItemsAndDurabilityOne_thenBackupLog.
@Test
public void rollback_whenMultipleItemsAndDurabilityOne_thenBackupLog() {
TransactionOptions options = new TransactionOptions().setTransactionType(TWO_PHASE).setDurability(1);
final 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();
tx.rollback();
assertRolledBack(tx);
// it can take some time because the transaction doesn't sync on purging the backups.
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertNoBackupLogOnRemote(tx);
}
});
record1.assertPrepareCalled().assertCommitNotCalled().assertRollbackCalled();
record2.assertPrepareCalled().assertCommitNotCalled().assertRollbackCalled();
}
use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class TransactionImpl_TwoPhaseIntegrationTest method commit_whenMultipleItemsAndDurabilityOne_thenBackupLog.
@Test
public void commit_whenMultipleItemsAndDurabilityOne_thenBackupLog() {
TransactionOptions options = new TransactionOptions().setTransactionType(TWO_PHASE).setDurability(1);
final 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();
tx.commit();
assertCommitted(tx);
// it can take some time because the transaction doesn't sync on purging the backups.
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertNoBackupLogOnRemote(tx);
}
});
record1.assertPrepareCalled().assertCommitCalled().assertRollbackNotCalled();
record2.assertPrepareCalled().assertCommitCalled().assertRollbackNotCalled();
}
use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class TransactionImpl_TwoPhaseIntegrationTest method rollback_whenSingleItemAndDurabilityOne_thenNoBackupLog.
// =================== rollback ===========================================
@Test
public void rollback_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();
tx.rollback();
assertRolledBack(tx);
assertNoBackupLogOnRemote(tx);
record.assertPrepareCalled().assertCommitNotCalled().assertRollbackCalled();
}
Aggregations