Search in sources :

Example 6 with Journal

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

the class TestJournal method journal_07.

@Test
public void journal_07() {
    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(JournalEntry.COMMIT);
    long locn = jrnl.position();
    jrnl.writeJournal(e);
    assertNotEquals(0, locn);
    jrnl.sync();
    JournalEntry e2 = jrnl.readJournal(locn);
    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 7 with Journal

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

the class TestJournal method journal_02.

@Test
public void journal_02() {
    Journal jrnl = Journal.create(Location.mem());
    assertNotNull(jrnl);
    JournalEntry e = JournalEntry.COMMIT;
    jrnl.writeJournal(e);
    assertFalse(jrnl.isEmpty());
    assertNotEquals(0, jrnl.position());
}
Also used : Journal(org.apache.jena.dboe.transaction.txn.journal.Journal) JournalEntry(org.apache.jena.dboe.transaction.txn.journal.JournalEntry) Test(org.junit.Test)

Example 8 with Journal

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

the class TestJournal method journal_04.

@Test
public void journal_04() {
    Journal jrnl = Journal.create(Location.mem());
    jrnl.writeJournal(JournalEntry.COMMIT);
    jrnl.writeJournal(JournalEntry.ABORT);
    jrnl.writeJournal(JournalEntry.ABORT);
    jrnl.writeJournal(JournalEntry.COMMIT);
    assertFalse(jrnl.isEmpty());
    Iterator<JournalEntry> iter = jrnl.entries(0);
    List<JournalEntry> expected = Arrays.asList(JournalEntry.COMMIT, JournalEntry.ABORT, JournalEntry.ABORT, JournalEntry.COMMIT);
}
Also used : Journal(org.apache.jena.dboe.transaction.txn.journal.Journal) JournalEntry(org.apache.jena.dboe.transaction.txn.journal.JournalEntry) Test(org.junit.Test)

Example 9 with Journal

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

the class TDB2StorageBuilder method buildTransactionCoordinator.

private static TransactionCoordinator buildTransactionCoordinator(Location location) {
    Journal journal = Journal.create(location);
    TransactionCoordinator txnCoord = new TransactionCoordinator(journal);
    return txnCoord;
}
Also used : Journal(org.apache.jena.dboe.transaction.txn.journal.Journal)

Example 10 with Journal

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

the class TestJournal method journal_03.

@Test
public void journal_03() {
    Journal jrnl = Journal.create(Location.mem());
    assertNotNull(jrnl);
    jrnl.writeJournal(JournalEntry.COMMIT);
    assertNotEquals(0, jrnl.position());
    JournalEntry e = jrnl.readJournal(0);
    check(JournalEntry.COMMIT, e);
    assertEquals(ComponentIds.idSystem, e.getComponentId());
    assertEquals(JournalEntryType.COMMIT, e.getType());
    check(JournalEntry.COMMIT, e);
}
Also used : Journal(org.apache.jena.dboe.transaction.txn.journal.Journal) JournalEntry(org.apache.jena.dboe.transaction.txn.journal.JournalEntry) Test(org.junit.Test)

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