use of org.apache.jena.dboe.transaction.txn.Transaction in project jena by apache.
the class Indexer method stageIndex.
private void stageIndex(BlockingQueue<List<Tuple<NodeId>>> pipe, TupleIndex idx) {
TransactionCoordinator coordinator = CoLib.newCoordinator();
CoLib.add(coordinator, idx);
CoLib.start(coordinator);
Transaction transaction = coordinator.begin(TxnType.WRITE);
boolean workHasBeenDone;
try {
Destination<Tuple<NodeId>> loader = loadTuples(idx);
for (; ; ) {
List<Tuple<NodeId>> tuples = pipe.take();
if (tuples.isEmpty())
break;
loader.deliver(tuples);
}
workHasBeenDone = !idx.isEmpty();
transaction.commit();
} catch (Exception ex) {
Log.error(this, "Interrupted", ex);
transaction.abort();
workHasBeenDone = false;
}
CoLib.finish(coordinator);
if (workHasBeenDone)
output.print("Finish - index %s", idx.getName());
termination.release();
}
use of org.apache.jena.dboe.transaction.txn.Transaction in project jena by apache.
the class TestTransactionLifecycle2 method txn_promote_thread_writer_3.
@Test
public void txn_promote_thread_writer_3() {
Transaction txn1 = txnMgr.begin(TxnType.READ_PROMOTE);
boolean b = txn1.promote();
assertTrue(b);
AtomicReference<Transaction> ref = new AtomicReference<>(txn1);
ThreadLib.syncOtherThread(() -> {
// Should fail.
Transaction txn2 = txnMgr.begin(TxnType.WRITE, false);
ref.set(txn2);
});
assertNull(ref.get());
txn1.abort();
txn1.end();
}
use of org.apache.jena.dboe.transaction.txn.Transaction in project jena by apache.
the class TestTransactionLifecycle2 method txn_promote_thread_writer_2.
@Test
public void txn_promote_thread_writer_2() {
Transaction txn1 = txnMgr.begin(TxnType.READ_PROMOTE);
ThreadLib.syncOtherThread(() -> {
Transaction txn2 = txnMgr.begin(TxnType.WRITE);
txn2.abort();
txn2.end();
});
boolean b = txn1.promote();
assertTrue(b);
// Now a writer.
txn1.commit();
txn1.end();
checkClear();
}
use of org.apache.jena.dboe.transaction.txn.Transaction in project jena by apache.
the class TestTransactionLifecycle2 method txn_promote_thread_writer_1.
@Test
public void txn_promote_thread_writer_1() {
Transaction txn1 = txnMgr.begin(TxnType.READ_PROMOTE);
ThreadLib.syncOtherThread(() -> {
Transaction txn2 = txnMgr.begin(TxnType.WRITE);
txn2.commit();
txn2.end();
});
boolean b = txn1.promote();
assertFalse(b);
txn1.end();
checkClear();
}
use of org.apache.jena.dboe.transaction.txn.Transaction in project jena by apache.
the class TestTransactionLifecycle2 method txn_overlap_RR.
@Test
public void txn_overlap_RR() {
Transaction txn1 = txnMgr.begin(TxnType.READ, false);
assertNotNull(txn1);
Transaction txn2 = txnMgr.begin(TxnType.READ, false);
assertNotNull(txn2);
txn1.commit();
txn1.end();
txn2.end();
checkClear();
}
Aggregations