/** * Extends the basic behavior to force a commit of the {@link Journal}. * This makes the {@link Journal} appear to have "auto-commit" semantics * from the perspective of the unit tests that are written to the assumption * that the {@link IIndexManager} is an {@link IBigdataFederation}. * Otherwise those unit tests tend not to force a commit and hence * restart-safe tests tend to fail for one reason or another. */ protected Journal reopenStore(final Journal store) { store.commit(); return super.reopenStore(store); }
/** * Extends the basic behavior to force a commit of the {@link Journal}. * This makes the {@link Journal} appear to have "auto-commit" semantics * from the perspective of the unit tests that are written to the assumption * that the {@link IIndexManager} is an {@link IBigdataFederation}. * Otherwise those unit tests tend not to force a commit and hence * restart-safe tests tend to fail for one reason or another. */ protected Journal reopenStore(final Journal store) { store.commit(); return super.reopenStore(store); }
private void commitSomeData(final Journal store) { final IRWStrategy bs = (IRWStrategy) store.getBufferStrategy(); // final IStore rw = bs.getStore(); // byte[] buf = new byte[r.nextInt(1024)]; // extra for checksum final byte[] buf = new byte[863]; // extra for checksum r.nextBytes(buf); bs.write(ByteBuffer.wrap(buf)); store.commit(); }
private void commitSomeData(final Journal store) { final IRWStrategy bs = (IRWStrategy) store.getBufferStrategy(); // final IStore rw = bs.getStore(); // byte[] buf = new byte[r.nextInt(1024)]; // extra for checksum final byte[] buf = new byte[863]; // extra for checksum r.nextBytes(buf); bs.write(ByteBuffer.wrap(buf)); store.commit(); }
/** * Creates a mocked local triple (memory) store with the given namespace, * with unisolated transactions. * * @param namespace * @return */ public static AbstractTripleStore mockTripleStore(final String namespace) { final Properties properties = new Properties(); properties.setProperty( com.bigdata.journal.Options.BUFFER_MODE,BufferMode.MemStore.name()); final Journal store = new Journal(properties); final AbstractTripleStore kb = new LocalTripleStore( store, namespace, ITx.UNISOLATED, properties); kb.create(); store.commit(); return kb; }
/** * Creates a mocked local triple (memory) store with the given namespace, * with unisolated transactions. * * @param namespace * @return */ public static AbstractTripleStore mockTripleStore(final String namespace) { final Properties properties = new Properties(); properties.setProperty( com.bigdata.journal.Options.BUFFER_MODE,BufferMode.MemStore.name()); final Journal store = new Journal(properties); final AbstractTripleStore kb = new LocalTripleStore( store, namespace, ITx.UNISOLATED, properties); kb.create(); store.commit(); return kb; }
/** * Add the value to the index, commit, assert value retrieval and * return the commit time */ static long insertName(final Journal jrnl, final String name) { IIndex index = jrnl.getIndex("TestIndex"); index.remove("Name"); index.insert("Name", name); final long ret = jrnl.commit(); if(!name.equals(index.lookup("Name"))) { throw new AssertionError(name + " != " + index.lookup("Name")); } return ret; }
/** * Add the value to the index, commit, assert value retrieval and * return the commit time */ static long insertName(final Journal jrnl, final String name) { IIndex index = jrnl.getIndex("TestIndex"); index.remove("Name"); index.insert("Name", name); final long ret = jrnl.commit(); if(!name.equals(index.lookup("Name"))) { throw new AssertionError(name + " != " + index.lookup("Name")); } return ret; }
public void test_allocCommitFreeWithHistory() { final Properties properties = new Properties(getProperties()); properties.setProperty( AbstractTransactionService.Options.MIN_RELEASE_AGE, "100"); final Journal store = getJournal(properties); try { MemStrategy bs = (MemStrategy) store.getBufferStrategy(); final long addr = bs.write(randomData(78)); store.commit(); bs.delete(addr); assertTrue(bs.isCommitted(addr)); } finally { store.destroy(); } }
public void test_allocCommitFreeWithHistory() { final Properties properties = new Properties(getProperties()); properties.setProperty( AbstractTransactionService.Options.MIN_RELEASE_AGE, "100"); final Journal store = getJournal(properties); try { MemStrategy bs = (MemStrategy) store.getBufferStrategy(); final long addr = bs.write(randomData(78)); store.commit(); bs.delete(addr); assertTrue(bs.isCommitted(addr)); } finally { store.destroy(); } }
/** * Dump a journal with a single named index. */ public void test_journal_oneIndexNoData() throws IOException, InterruptedException, ExecutionException { final Journal src = getStore(getProperties()); try { // register an index and commit the journal. final String NAME = "testIndex"; src.registerIndex(new IndexMetadata(NAME, UUID.randomUUID())); src.commit(); new DumpJournal(src) .dumpJournal(true/* dumpHistory */, true/* dumpPages */, true/* dumpIndices */, true/* showTuples */); } finally { src.destroy(); } }
/** * Dump a journal with a single named index. */ public void test_journal_oneIndexNoData() throws IOException, InterruptedException, ExecutionException { final Journal src = getStore(getProperties()); try { // register an index and commit the journal. final String NAME = "testIndex"; src.registerIndex(new IndexMetadata(NAME, UUID.randomUUID())); src.commit(); new DumpJournal(src) .dumpJournal(true/* dumpHistory */, true/* dumpPages */, true/* dumpIndices */, true/* showTuples */); } finally { src.destroy(); } }
public void test_allocCommitFreeCommitWriteCacheWithHistory() { final Journal store = (Journal) getStore(5); try { final RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final long addr = bs.write(randomData(78)); // Has just been written so must be in cache assertTrue(bs.inWriteCache(addr)); store.commit(); bs.delete(addr); // since data is committed, should be accessible from any new // readCommitted transaction assertTrue(bs.inWriteCache(addr)); store.commit(); // Since state is retained, the delete is deferred assertTrue(bs.inWriteCache(addr)); } finally { store.destroy(); } }
public void test_allocCommitFreeWithHistory() { final Journal store = (Journal) getStore(4); try { final RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final long addr = bs.write(randomData(78)); store.commit(); bs.delete(addr); assertTrue(bs.isCommitted(addr)); } finally { store.destroy(); } }
public void test_allocCommitFreeWithHistory() { final Journal store = (Journal) getStore(4); try { final RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final long addr = bs.write(randomData(78)); store.commit(); bs.delete(addr); assertTrue(bs.isCommitted(addr)); } finally { store.destroy(); } }
public void test_allocCommitFree() { final Journal store = getJournal(getProperties()); try { MemStrategy bs = (MemStrategy) store.getBufferStrategy(); final long addr = bs.write(randomData(78)); store.commit(); bs.delete(addr); assertTrue(bs.isCommitted(addr)); } finally { store.destroy(); } }
public void test_allocCommitFree() { final Journal store = getJournal(getProperties()); try { MemStrategy bs = (MemStrategy) store.getBufferStrategy(); final long addr = bs.write(randomData(78)); store.commit(); bs.delete(addr); assertTrue(bs.isCommitted(addr)); } finally { store.destroy(); } }
/** * State1 * * Allocate - Commit - Free * * assert that allocation remains committed */ public void test_allocCommitFree() { Journal store = (Journal) getStore(); try { RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final long addr = bs.write(randomData(78)); store.commit(); bs.delete(addr); assertTrue(bs.isCommitted(addr)); } finally { store.destroy(); } }
public void test_multiVoidCommit() { final Journal store = (Journal) getStore(); try { final RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final RWStore rw = bs.getStore(); final boolean initRequire = bs.requiresCommit(store.getRootBlockView()); assertTrue(initRequire); for (int n = 0; n < 20; n++) { store.commit(); final IRootBlockView rbv = store.getRootBlockView(); assertTrue(1 == rbv.getCommitCounter()); assertFalse(bs.requiresCommit(store.getRootBlockView())); assertFalse(rw.requiresCommit()); } } finally { store.destroy(); } }
public void test_multiVoidCommit() { final Journal store = (Journal) getStore(); try { final RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final RWStore rw = bs.getStore(); final boolean initRequire = bs.requiresCommit(store.getRootBlockView()); assertTrue(initRequire); for (int n = 0; n < 20; n++) { store.commit(); final IRootBlockView rbv = store.getRootBlockView(); assertTrue(1 == rbv.getCommitCounter()); assertFalse(bs.requiresCommit(store.getRootBlockView())); assertFalse(rw.requiresCommit()); } } finally { store.destroy(); } }