Search in sources :

Example 1 with TDBTransactionException

use of org.apache.jena.tdb.transaction.TDBTransactionException in project jena by apache.

the class LockTx method enterCriticalSection.

@Override
public void enterCriticalSection(boolean readLockRequested) {
    if (state != TxNONE)
        throw new TDBTransactionException("Illegal state: " + state);
    if (readLockRequested) {
        state = TxREAD;
        dsg.begin(ReadWrite.READ);
    } else {
        state = TxWRITE;
        dsg.begin(ReadWrite.WRITE);
    }
}
Also used : TDBTransactionException(org.apache.jena.tdb.transaction.TDBTransactionException)

Example 2 with TDBTransactionException

use of org.apache.jena.tdb.transaction.TDBTransactionException in project jena by apache.

the class TestDatasetPrefixes method dsg_prefixes_txn_2.

// Legacy: TDBTransactionException is not under JenaTransactionException.
@Test(expected = JenaException.class)
public void dsg_prefixes_txn_2() {
    Assume.assumeTrue(txnIsolation);
    DatasetGraph dsg = create();
    Txn.executeRead(dsg, () -> {
        PrefixMap pmap = dsg.prefixes();
        try {
            // Write inside read.
            // TIM prefixes are standalone, MRSW so they are thread safe but not tied to the TIM transaction lifecycle.
            // No Isolation.
            pmap.add("ex", "http://example/2");
        } catch (JenaTransactionException | TDBTransactionException ex) {
            throw ex;
        }
    });
}
Also used : PrefixMap(org.apache.jena.riot.system.PrefixMap) JenaTransactionException(org.apache.jena.sparql.JenaTransactionException) TDBTransactionException(org.apache.jena.tdb.transaction.TDBTransactionException) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Aggregations

TDBTransactionException (org.apache.jena.tdb.transaction.TDBTransactionException)2 PrefixMap (org.apache.jena.riot.system.PrefixMap)1 JenaTransactionException (org.apache.jena.sparql.JenaTransactionException)1 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)1 Test (org.junit.Test)1