use of org.apache.jena.dboe.transaction.txn.Transaction in project jena by apache.
the class TestTransactionLifecycle2 method txn_overlap_RW.
@Test
public void txn_overlap_RW() {
Transaction txn1 = txnMgr.begin(TxnType.READ, false);
assertNotNull(txn1);
Transaction txn2 = txnMgr.begin(TxnType.WRITE, false);
assertNotNull(txn2);
txn1.commit();
txn1.end();
txn2.abort();
txn2.end();
checkClear();
}
use of org.apache.jena.dboe.transaction.txn.Transaction in project jena by apache.
the class TestTransactionLifecycle2 method txn_promote_deadlock.
// Not a @Test
public void txn_promote_deadlock() {
Transaction txn1 = txnMgr.begin(TxnType.READ);
Transaction txn2 = txnMgr.begin(TxnType.WRITE);
// Deadlock.
// Promotion waits for the writer to decide whether it is commiting or not.
// This can't be done on one thread.
boolean b = txn1.promote();
assertFalse(b);
txn1.end();
txn2.commit();
txn2.end();
checkClear();
}
use of org.apache.jena.dboe.transaction.txn.Transaction in project jena by apache.
the class TestTransactionLifecycle2 method txn_promote_thread_writer_4.
@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);
ThreadLib.syncOtherThread(() -> {
// Should fail.
Transaction txn2 = txnMgr.begin(TxnType.WRITE, false);
ref.set(txn2);
});
assertNull(ref.get());
txn1.abort();
txn1.end();
ThreadLib.syncOtherThread(() -> {
// Should suceed
Transaction txn2 = txnMgr.begin(TxnType.WRITE, false);
ref.set(txn2);
txn2.abort();
txn2.end();
});
assertNotNull(ref.get());
checkClear();
}
use of org.apache.jena.dboe.transaction.txn.Transaction in project jena by apache.
the class TestTransactionLifecycle2 method txn_direct_04.
@Test
public void txn_direct_04() {
Transaction txn1 = txnMgr.begin(TxnType.WRITE);
// This tests the TransactionCoordinator
// but the TransactiolComponentLifecycle doesn't support multiple
// transactions per thread (use of ThreadLocals).
// To do that, the transaction object would be needed in all
// component API calls. Doable but intrusive.
Transaction txn2 = txnMgr.begin(TxnType.READ);
txn1.commit();
txn2.end();
txn1.end();
checkClear();
}
use of org.apache.jena.dboe.transaction.txn.Transaction in project jena by apache.
the class StoragePrefixesTDB method ensureWriteTxn.
// private void requireTxn() {
// if ( ! txnSystem.isInTransaction() )
// throw new TransactionException("Not on a transaction");
// }
private void ensureWriteTxn() {
Transaction txn = txnSystem.getThreadTransaction();
if (txn == null)
throw new TransactionException("Not in a transaction");
txn.ensureWriteTxn();
}
Aggregations