Search in sources :

Example 6 with Transaction

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

the class TestTransactionCoordinatorControl method txn_coord_disable_writers_3.

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

Example 7 with Transaction

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

the class TestTransactionLifecycle2 method txn_overlap_WR.

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

Example 8 with Transaction

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

the class TestTransactionLifecycle2 method txn_promote_3.

@Test
public void txn_promote_3() {
    Transaction txn1 = txnMgr.begin(TxnType.READ);
    boolean b = txn1.promote();
    assertFalse(b);
    b = txn1.promote();
    assertFalse(b);
    // Not a writer
    txn1.end();
    checkClear();
}
Also used : Transaction(org.apache.jena.dboe.transaction.txn.Transaction) Test(org.junit.Test)

Example 9 with Transaction

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

the class TestTransactionLifecycle2 method txn_promote_2.

@Test
public void txn_promote_2() {
    Transaction txn1 = txnMgr.begin(TxnType.WRITE);
    boolean b = txn1.promote();
    assertTrue(b);
    b = txn1.promote();
    assertTrue(b);
    txn1.abort();
    txn1.end();
    checkClear();
}
Also used : Transaction(org.apache.jena.dboe.transaction.txn.Transaction) Test(org.junit.Test)

Example 10 with Transaction

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

the class TestTransactionLifecycle2 method txn_direct_06.

@Test
public void txn_direct_06() {
    Transaction txn1 = txnMgr.begin(TxnType.WRITE);
    // txn1.prepare(); Optional.
    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