Search in sources :

Example 16 with Transaction

use of org.apache.jena.dboe.transaction.txn.Transaction in project jena by apache.

the class TestTransactionCoordinatorControl method txn_coord_disable_writers_2.

@Test
public void txn_coord_disable_writers_2() {
    txnMgr.blockWriters();
    Transaction txn = ThreadLib.syncCallThread(() -> txnMgr.begin(TxnType.WRITE, false));
    assertNull(txn);
    txnMgr.enableWriters();
    Transaction txn2 = ThreadLib.syncCallThread(() -> {
        Transaction txn1 = txnMgr.begin(TxnType.WRITE, false);
        assertNotNull(txn1);
        txn1.abort();
        txn1.end();
        return txn1;
    });
    assertNotNull(txn2);
}
Also used : Transaction(org.apache.jena.dboe.transaction.txn.Transaction) Test(org.junit.Test)

Example 17 with Transaction

use of org.apache.jena.dboe.transaction.txn.Transaction in project jena by apache.

the class TestTransactionCoordinatorControl method txn_coord_exclusive_1.

@Test
public void txn_coord_exclusive_1() {
    txnMgr.startExclusiveMode();
    ThreadLib.syncOtherThread(() -> {
        Transaction txn1 = txnMgr.begin(TxnType.WRITE, false);
        assertNull(txn1);
        Transaction txn2 = txnMgr.begin(TxnType.READ, false);
        assertNull(txn2);
    });
    txnMgr.finishExclusiveMode();
    ThreadLib.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();
    });
}
Also used : Transaction(org.apache.jena.dboe.transaction.txn.Transaction) Test(org.junit.Test)

Example 18 with Transaction

use of org.apache.jena.dboe.transaction.txn.Transaction in project jena by apache.

the class TestTransactionLifecycle2 method txn_direct_01.

@Test
public void txn_direct_01() {
    Transaction txn1 = txnMgr.begin(TxnType.READ);
    txn1.end();
    checkClear();
}
Also used : Transaction(org.apache.jena.dboe.transaction.txn.Transaction) Test(org.junit.Test)

Example 19 with Transaction

use of org.apache.jena.dboe.transaction.txn.Transaction in project jena by apache.

the class TestTransactionLifecycle2 method txn_direct_05.

@Test
public void txn_direct_05() {
    Transaction txn1 = txnMgr.begin(TxnType.WRITE);
    txn1.prepare();
    txn1.commit();
    txn1.end();
    checkClear();
}
Also used : Transaction(org.apache.jena.dboe.transaction.txn.Transaction) Test(org.junit.Test)

Example 20 with Transaction

use of org.apache.jena.dboe.transaction.txn.Transaction in project jena by apache.

the class TestTransactionLifecycle2 method txn_overlap_WW.

@Test
public void txn_overlap_WW() {
    Transaction txn1 = txnMgr.begin(TxnType.WRITE, false);
    assertNotNull(txn1);
    Transaction txn2 = txnMgr.begin(TxnType.WRITE, false);
    // Otherwise blocking.
    assertNull(txn2);
    txn1.commit();
    txn1.end();
    checkClear();
}
Also used : Transaction(org.apache.jena.dboe.transaction.txn.Transaction) Test(org.junit.Test)

Aggregations

Transaction (org.apache.jena.dboe.transaction.txn.Transaction)26 Test (org.junit.Test)21 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)2 TransactionCoordinator (org.apache.jena.dboe.transaction.txn.TransactionCoordinator)2 TransactionException (org.apache.jena.dboe.transaction.txn.TransactionException)2