use of org.apache.jena.system.ThreadAction in project jena by apache.
the class AbstractTestTransPromote method run_07.
// Async writer after promotion.
private void run_07(boolean readCommitted) {
Assume.assumeTrue(!readCommitted || supportsReadCommitted());
setReadCommitted(readCommitted);
DatasetGraph dsg = create();
// Start long running reader.
ThreadAction tt = ThreadTxn.threadTxnRead(dsg, () -> {
long x = Iter.count(dsg.find());
if (x != 0)
throw new RuntimeException();
});
// Start R->W here
dsg.begin(ReadWrite.READ);
dsg.add(q1);
dsg.add(q2);
dsg.commit();
dsg.end();
tt.run();
}
use of org.apache.jena.system.ThreadAction in project jena by apache.
the class AbstractTestTransPromote method promote_readCommit_txnCommit.
private void promote_readCommit_txnCommit(boolean readCommitted, boolean asyncCommit) {
Assume.assumeTrue(!readCommitted || supportsReadCommitted());
setReadCommitted(readCommitted);
DatasetGraph dsg = create();
ThreadAction tt = asyncCommit ? ThreadTxn.threadTxnWrite(dsg, () -> dsg.add(q3)) : ThreadTxn.threadTxnWriteAbort(dsg, () -> dsg.add(q3));
dsg.begin(ReadWrite.READ);
// Other runs
tt.run();
// Can promote if readCommited
// Can't promote if not readCommited
dsg.add(q1);
if (!readCommitted && asyncCommit)
fail("Should not be here");
// read commited - we should see the ThreadAction change.
assertEquals(asyncCommit, dsg.contains(q3));
dsg.commit();
dsg.end();
//logger2.setLevel(level2);
}
use of org.apache.jena.system.ThreadAction in project jena by apache.
the class AbstractTestTransactionIsolation method isolation_01.
@Test
public void isolation_01() {
// Start a read transaction on another thread.
// The transaction has begin() by the time threadTxnRead
// returns but the action of the ThreadTxn is not triggered
// until other.run() is called.
DatasetGraph dsg = create();
ThreadAction other = ThreadTxn.threadTxnRead(dsg, () -> Assert.assertTrue(dsg.isEmpty()));
dsg.begin(WRITE);
dsg.add(q1);
dsg.commit();
dsg.end();
other.run();
}
Aggregations