@Test public void txn_promote_thread_writer_3() { Transaction txn1 = txnMgr.begin(TxnType.READ_PROMOTE) ; boolean b = txn1.promote() ; assertTrue(b) ; AtomicReference<Transaction> ref = new AtomicReference<>(txn1) ; L.syncOtherThread(()->{ // Should fail. Transaction txn2 = txnMgr.begin(TxnType.WRITE, false) ; ref.set(txn2); }) ; assertNull(ref.get()) ; txn1.abort() ; txn1.end() ; }
@Test public void txn_promote_thread_writer_3() { Transaction txn1 = txnMgr.begin(TxnType.READ_PROMOTE) ; boolean b = txn1.promote() ; assertTrue(b) ; AtomicReference<Transaction> ref = new AtomicReference<>(txn1) ; L.syncOtherThread(()->{ // Should fail. Transaction txn2 = txnMgr.begin(TxnType.WRITE, false) ; ref.set(txn2); }) ; assertNull(ref.get()) ; txn1.abort() ; txn1.end() ; }
@Test public void txn_promote_thread_writer_4() { Transaction txn1 = txnMgr.begin(TxnType.READ_PROMOTE) ; boolean b = txn1.promote() ; assertTrue(b) ; AtomicReference<Transaction> ref = new AtomicReference<>(txn1) ; L.syncOtherThread(()->{ // Should fail. Transaction txn2 = txnMgr.begin(TxnType.WRITE, false) ; ref.set(txn2); }) ; assertNull(ref.get()) ; txn1.abort() ; txn1.end() ; L.syncOtherThread(()->{ // Should suceed Transaction txn2 = txnMgr.begin(TxnType.WRITE, false) ; ref.set(txn2); txn2.abort() ; txn2.end() ; }) ; assertNotNull(ref.get()) ; checkClear() ; }
@Test public void txn_promote_thread_writer_4() { Transaction txn1 = txnMgr.begin(TxnType.READ_PROMOTE) ; boolean b = txn1.promote() ; assertTrue(b) ; AtomicReference<Transaction> ref = new AtomicReference<>(txn1) ; L.syncOtherThread(()->{ // Should fail. Transaction txn2 = txnMgr.begin(TxnType.WRITE, false) ; ref.set(txn2); }) ; assertNull(ref.get()) ; txn1.abort() ; txn1.end() ; L.syncOtherThread(()->{ // Should suceed Transaction txn2 = txnMgr.begin(TxnType.WRITE, false) ; ref.set(txn2); txn2.abort() ; txn2.end() ; }) ; assertNotNull(ref.get()) ; checkClear() ; }
@Test public void txn_coord_exclusive_1() { txnMgr.startExclusiveMode(); L.syncOtherThread(()->{ Transaction txn1 = txnMgr.begin(TxnType.WRITE, false) ; assertNull(txn1) ; Transaction txn2 = txnMgr.begin(TxnType.READ, false) ; assertNull(txn2) ; }) ; txnMgr.finishExclusiveMode(); L.syncOtherThread(()->{ Transaction txn1 = txnMgr.begin(TxnType.WRITE, false) ; assertNotNull(txn1) ; Transaction txn2 = txnMgr.begin(TxnType.READ, false) ; assertNotNull(txn2) ; txn1.commit(); txn1.end(); txn2.commit(); txn2.end(); }) ; }
@Test public void txn_promote_thread_writer_1() { Transaction txn1 = txnMgr.begin(TxnType.READ_PROMOTE) ; L.syncOtherThread(()->{ Transaction txn2 = txnMgr.begin(TxnType.WRITE) ; txn2.commit(); txn2.end() ; }) ; boolean b = txn1.promote() ; assertFalse(b) ; txn1.end() ; checkClear() ; }
@Test public void txn_promote_thread_writer_1() { Transaction txn1 = txnMgr.begin(TxnType.READ_PROMOTE) ; L.syncOtherThread(()->{ Transaction txn2 = txnMgr.begin(TxnType.WRITE) ; txn2.commit(); txn2.end() ; }) ; boolean b = txn1.promote() ; assertFalse(b) ; txn1.end() ; checkClear() ; }
@Test public void txn_coord_exclusive_1() { txnMgr.startExclusiveMode(); L.syncOtherThread(()->{ Transaction txn1 = txnMgr.begin(TxnType.WRITE, false) ; assertNull(txn1) ; Transaction txn2 = txnMgr.begin(TxnType.READ, false) ; assertNull(txn2) ; }) ; txnMgr.finishExclusiveMode(); L.syncOtherThread(()->{ Transaction txn1 = txnMgr.begin(TxnType.WRITE, false) ; assertNotNull(txn1) ; Transaction txn2 = txnMgr.begin(TxnType.READ, false) ; assertNotNull(txn2) ; txn1.commit(); txn1.end(); txn2.commit(); txn2.end(); }) ; }
@Test public void txn_promote_thread_writer_2() { Transaction txn1 = txnMgr.begin(TxnType.READ_PROMOTE) ; L.syncOtherThread(()->{ Transaction txn2 = txnMgr.begin(TxnType.WRITE) ; txn2.abort(); txn2.end() ; }) ; boolean b = txn1.promote() ; assertTrue(b) ; // Now a writer. txn1.commit(); txn1.end() ; checkClear() ; }
@Test public void txn_promote_thread_writer_2() { Transaction txn1 = txnMgr.begin(TxnType.READ_PROMOTE) ; L.syncOtherThread(()->{ Transaction txn2 = txnMgr.begin(TxnType.WRITE) ; txn2.abort(); txn2.end() ; }) ; boolean b = txn1.promote() ; assertTrue(b) ; // Now a writer. txn1.commit(); txn1.end() ; checkClear() ; }