use of org.apache.jena.dboe.transaction.txn.TransactionCoordinator 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.TransactionCoordinator in project jena by apache.
the class IndexerInline method startBulk.
@Override
public void startBulk() {
TransactionCoordinator coordinator = CoLib.newCoordinator();
Arrays.stream(indexes).forEach(idx -> CoLib.add(coordinator, idx));
CoLib.start(coordinator);
transaction = coordinator.begin(TxnType.WRITE);
}
use of org.apache.jena.dboe.transaction.txn.TransactionCoordinator in project jena by apache.
the class TestRecovery method recoverBlobFile_2.
@Test
public void recoverBlobFile_2() throws Exception {
String str1 = "Recovery One";
String str2 = "Recovery Two";
ComponentId cid1 = ComponentId.allocLocal();
ComponentId cid2 = ComponentId.allocLocal();
// Write out a journal for two components.
{
Journal journal = Journal.create(Location.create(dir.getRoot().getAbsolutePath()));
journal.write(JournalEntryType.REDO, cid1, IO.stringToByteBuffer(str1));
journal.write(JournalEntryType.REDO, cid2, IO.stringToByteBuffer(str2));
journal.writeJournal(JournalEntry.COMMIT);
journal.close();
}
Journal journal = Journal.create(Location.create(dir.getRoot().getAbsolutePath()));
BufferChannel chan = BufferChannelFile.create(data);
TransBlob tBlob1 = new TransBlob(cid1, chan);
TransBlob tBlob2 = new TransBlob(cid2, chan);
TransactionCoordinator coord = new TransactionCoordinator(journal, Arrays.asList(tBlob1, tBlob2));
coord.start();
ByteBuffer blob1 = tBlob1.getBlob();
assertNotNull(blob1);
String s1 = IO.byteBufferToString(blob1);
assertEquals(str1, s1);
ByteBuffer blob2 = tBlob2.getBlob();
assertNotNull(blob2);
String s2 = IO.byteBufferToString(blob2);
assertEquals(str2, s2);
assertNotEquals(str1, str2);
coord.shutdown();
}
use of org.apache.jena.dboe.transaction.txn.TransactionCoordinator in project jena by apache.
the class TestTxnLib2 method setup.
@Before
public void setup() {
TransactionCoordinator coord = new TransactionCoordinator(Location.mem());
integer = new TransactionalInteger(coord, InitValue);
coord.start();
}
use of org.apache.jena.dboe.transaction.txn.TransactionCoordinator in project jena by apache.
the class TestTransactionCoordinatorControl method init.
@Before
public void init() {
txnMgr = new TransactionCoordinator(Location.mem());
unit = new TransactionalBase(txnMgr);
txnMgr.start();
}
Aggregations