Search in sources :

Example 21 with Transaction

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

the class TestTransactionLifecycle2 method txn_direct_03.

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

Example 22 with Transaction

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

the class TestTransactionLifecycle2 method txn_promote_1.

@Test
public void txn_promote_1() {
    Transaction txn1 = txnMgr.begin(TxnType.READ_PROMOTE);
    assertNotNull(txn1);
    boolean b = txn1.promote();
    assertTrue(b);
    assertEquals(ReadWrite.WRITE, txn1.getMode());
    txn1.commit();
    txn1.end();
    checkClear();
}
Also used : Transaction(org.apache.jena.dboe.transaction.txn.Transaction) Test(org.junit.Test)

Example 23 with Transaction

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

the class StorageTDB method ensureWriteTxn.

// private void requireTxn() {
// if ( ! txnSystem.isInTransaction() )
// throw new TransactionException("Not on a transaction");
// }
private void ensureWriteTxn() {
    Transaction txn = txnSystem.getThreadTransaction();
    if (txn == null)
        throw new TransactionException("Not on a write transaction");
    txn.ensureWriteTxn();
}
Also used : TransactionException(org.apache.jena.dboe.transaction.txn.TransactionException) Transaction(org.apache.jena.dboe.transaction.txn.Transaction)

Example 24 with Transaction

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

the class LoaderMain method indexPhase.

private static void indexPhase(List<BulkStartFinish> processes, TupleIndex srcIdx, TupleIndex[] indexes, MonitorOutput output) {
    String indexSetLabel = PhasedOps.indexMappings(indexes);
    output.print("Index set:  %s => %s", srcIdx.getName(), indexSetLabel);
    Indexer indexer = new Indexer(output, indexes);
    Destination<Tuple<NodeId>> dest = indexer.index();
    indexer.startBulk();
    TransactionCoordinator coordinator = CoLib.newCoordinator();
    CoLib.add(coordinator, srcIdx);
    CoLib.start(coordinator);
    // READ transaction.
    Transaction transaction = coordinator.begin(TxnType.READ);
    // Add to processes - we can wait later if we do not touched indexes being built.
    processes.add(indexer);
    PhasedOps.ReplayResult result = PhasedOps.replay(srcIdx, dest, output);
    // End read transaction on srcIdx
    transaction.end();
    String timeStr = "---";
    if (result.elapsed != 0) {
        double time = result.elapsed / 1000.0;
        // long AvgRate = (result.items * 1000L) / result.elapsed;
        timeStr = String.format("%,.1f", time);
    }
    output.print("Index set:  %s => %s [%,d items, %s seconds]", srcIdx.getName(), indexSetLabel, result.items, timeStr);
}
Also used : Transaction(org.apache.jena.dboe.transaction.txn.Transaction) TransactionCoordinator(org.apache.jena.dboe.transaction.txn.TransactionCoordinator) Tuple(org.apache.jena.atlas.lib.tuple.Tuple)

Example 25 with Transaction

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

the class TestTransactionLifecycle2 method txn_promote_4.

@Test(expected = TransactionException.class)
public void txn_promote_4() {
    Transaction txn1 = txnMgr.begin(TxnType.READ);
    txn1.end();
    txn1.promote();
}
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