use of org.apache.jena.dboe.trans.data.TransBlob 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.trans.data.TransBlob 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();
}
Aggregations