Search in sources :

Example 6 with Transactional

use of org.apache.jena.sparql.core.Transactional in project jena by apache.

the class TestTxn method txn_threaded_02.

// // This would lock up.
// public void txn_threaded_Not_A_Test() {
// Txn.exec(counter, TxnType.READ_PROMOTE, ()->{
// ThreadAction a = ThreadTxn.threadTxnWrite(counter, ()->{});
// // a is in a W transaction but has not committed or aborted - it's paused.
// boolean b = counter.promote();
// // Never reach here.
// a.run();
// });
// }
@Test
public void txn_threaded_02() {
    // Transactional tx = DatasetGraphFactory.createTxnMem();
    Transactional tx = counter;
    // Start and enter the W transaction.
    ThreadAction a = ThreadTxn.threadTxnWrite(tx, () -> {
    });
    // ThreadAction started ... in W transaction.
    Txn.exec(tx, TxnType.READ_PROMOTE, () -> {
        // ... have the thread action complete.
        a.run();
        // Blocks promotion.
        boolean b = tx.promote();
        assertFalse(b);
        assertEquals(ReadWrite.READ, tx.transactionMode());
    });
}
Also used : Transactional(org.apache.jena.sparql.core.Transactional) Test(org.junit.Test)

Aggregations

Transactional (org.apache.jena.sparql.core.Transactional)6 IndentedWriter (org.apache.jena.atlas.io.IndentedWriter)2 CmdException (org.apache.jena.cmd.CmdException)2 RiotException (org.apache.jena.riot.RiotException)2 RiotNotFoundException (org.apache.jena.riot.RiotNotFoundException)2 JenaException (org.apache.jena.shared.JenaException)2 ARQInternalErrorException (org.apache.jena.sparql.ARQInternalErrorException)2 TransactionalNull (org.apache.jena.sparql.core.TransactionalNull)2 ResultSetException (org.apache.jena.sparql.resultset.ResultSetException)2 Test (org.junit.Test)2 HttpResponse (java.net.http.HttpResponse)1 CmdException (jena.cmd.CmdException)1 TerminationException (jena.cmd.TerminationException)1 TerminationException (org.apache.jena.cmd.TerminationException)1 NotFoundException (org.apache.jena.shared.NotFoundException)1 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)1