Search in sources :

Example 11 with Journal

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

the class TestTransactionLifecycle2 method setup.

@Before
public void setup() {
    Journal jrnl = Journal.create(Location.mem());
    txnMgr = new TransactionCoordinator(jrnl);
    txnMgr.start();
}
Also used : TransactionCoordinator(org.apache.jena.dboe.transaction.txn.TransactionCoordinator) Journal(org.apache.jena.dboe.transaction.txn.journal.Journal) Before(org.junit.Before)

Example 12 with Journal

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

the class TestJournal method journal_06.

@Test
public void journal_06() {
    ByteBuffer bb = ByteBuffer.allocateDirect(100);
    ByteBufferLib.fill(bb, (byte) 0XA5);
    Journal jrnl = Journal.create(Location.mem());
    JournalEntry e = new JournalEntry(JournalEntryType.REDO, ComponentId.allocLocal(), bb);
    jrnl.writeJournal(e);
    jrnl.sync();
    JournalEntry e2 = jrnl.readJournal(0);
    check(e, e2);
}
Also used : Journal(org.apache.jena.dboe.transaction.txn.journal.Journal) ByteBuffer(java.nio.ByteBuffer) JournalEntry(org.apache.jena.dboe.transaction.txn.journal.JournalEntry) Test(org.junit.Test)

Example 13 with Journal

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

the class TestJournal method journal_01.

// For testing recovery, we need something to recover!
// See tests in TestRecovery in dboe-trans-data
@Test
public void journal_01() {
    Journal jrnl = Journal.create(Location.mem());
    assertNotNull(jrnl);
    assertTrue(jrnl.isEmpty());
}
Also used : Journal(org.apache.jena.dboe.transaction.txn.journal.Journal) Test(org.junit.Test)

Example 14 with Journal

use of org.apache.jena.dboe.transaction.txn.journal.Journal 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

Journal (org.apache.jena.dboe.transaction.txn.journal.Journal)14 Test (org.junit.Test)7 JournalEntry (org.apache.jena.dboe.transaction.txn.journal.JournalEntry)6 ByteBuffer (java.nio.ByteBuffer)4 BufferChannel (org.apache.jena.dboe.base.file.BufferChannel)4 ComponentId (org.apache.jena.dboe.transaction.txn.ComponentId)4 TransactionCoordinator (org.apache.jena.dboe.transaction.txn.TransactionCoordinator)3 TransBlob (org.apache.jena.dboe.trans.data.TransBlob)2 Transactional (org.apache.jena.dboe.transaction.Transactional)2 Before (org.junit.Before)2