Search in sources :

Example 11 with TransactionCoordinator

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

the class TestRecovery method recoverBlobFile_1.

// Fake journal recovery.
@Test
public void recoverBlobFile_1() throws Exception {
    String str = "Hello Journal";
    ComponentId cid = ComponentId.allocLocal();
    // ComponentIdRegistry registry = new ComponentIdRegistry();
    // registry.register(cid, "Blob", 1);
    // Write out a journal.
    {
        Journal journal = Journal.create(Location.create(dir.getRoot().getAbsolutePath()));
        journal.write(JournalEntryType.REDO, cid, IO.stringToByteBuffer(str));
        journal.writeJournal(JournalEntry.COMMIT);
        journal.close();
    }
    TransactionCoordinator coord = new TransactionCoordinator(Location.create(dir.getRoot().getAbsolutePath()));
    BufferChannel chan = BufferChannelFile.create(data);
    TransBlob tBlob = new TransBlob(cid, chan);
    coord.add(tBlob);
    coord.start();
    ByteBuffer blob = tBlob.getBlob();
    assertNotNull(blob);
    String s = IO.byteBufferToString(blob);
    assertEquals(str, s);
    coord.shutdown();
}
Also used : TransBlob(org.apache.jena.dboe.trans.data.TransBlob) BufferChannel(org.apache.jena.dboe.base.file.BufferChannel) TransactionCoordinator(org.apache.jena.dboe.transaction.txn.TransactionCoordinator) Journal(org.apache.jena.dboe.transaction.txn.journal.Journal) ComponentId(org.apache.jena.dboe.transaction.txn.ComponentId) ByteBuffer(java.nio.ByteBuffer)

Aggregations

TransactionCoordinator (org.apache.jena.dboe.transaction.txn.TransactionCoordinator)11 Before (org.junit.Before)4 Journal (org.apache.jena.dboe.transaction.txn.journal.Journal)3 ByteBuffer (java.nio.ByteBuffer)2 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)2 BufferChannel (org.apache.jena.dboe.base.file.BufferChannel)2 TransBlob (org.apache.jena.dboe.trans.data.TransBlob)2 ComponentId (org.apache.jena.dboe.transaction.txn.ComponentId)2 Transaction (org.apache.jena.dboe.transaction.txn.Transaction)2 TransactionException (org.apache.jena.dboe.transaction.txn.TransactionException)1 TransactionalBase (org.apache.jena.dboe.transaction.txn.TransactionalBase)1 TransactionalSystem (org.apache.jena.dboe.transaction.txn.TransactionalSystem)1 TDBException (org.apache.jena.tdb2.TDBException)1 DatasetGraphTDB (org.apache.jena.tdb2.store.DatasetGraphTDB)1