public long write(final ByteBuffer data) { return write(data, null); }
public long write(final ByteBuffer data) { return write(data, null); }
private long allocBatch(Journal store, int tsts, int min, int sze, int grp) { final RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final byte[] buf = new byte[sze + 4]; // extra for checksum r.nextBytes(buf); for (int i = 0; i < grp; i++) { int alloc = min + r.nextInt(sze - min); ByteBuffer bb = ByteBuffer.wrap(buf, 0, alloc); bs.write(bb); } return 0L; }
private long allocBatch(Journal store, int tsts, int min, int sze, int grp) { final RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final byte[] buf = new byte[sze + 4]; // extra for checksum r.nextBytes(buf); for (int i = 0; i < grp; i++) { int alloc = min + r.nextInt(sze - min); ByteBuffer bb = ByteBuffer.wrap(buf, 0, alloc); bs.write(bb); } return 0L; }
@Override public void run() { for (int i = 0; i < 2000; i++) { bs.delete(addrs[r.nextInt(addrs.length)]); for (int w = 0; w < 1000; w++) bs.write(randomData(r.nextInt(500)+1)); bs.abort(); } } };
@Override public void run() { for (int i = 0; i < 2000; i++) { bs.delete(addrs[r.nextInt(addrs.length)]); for (int w = 0; w < 1000; w++) bs.write(randomData(r.nextInt(500)+1)); bs.abort(); } } };
public void testSimpleReset() { final Properties properties = new Properties(getProperties()); final Journal store = (Journal) getStore(properties); try { final RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final RWStore rw = bs.getStore(); for (int r = 0; r < 10; r++) { ArrayList<Long> addrs = new ArrayList<Long>(); for (int i = 0; i < 1000; i++) { addrs.add(bs.write(randomData(2048))); } rw.reset(); } final String fname = bs.getStore().getStoreFile().getAbsolutePath(); store.close(); } finally { store.destroy(); } }
public void testSimpleReset() { final Properties properties = new Properties(getProperties()); final Journal store = (Journal) getStore(properties); try { final RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final RWStore rw = bs.getStore(); for (int r = 0; r < 10; r++) { ArrayList<Long> addrs = new ArrayList<Long>(); for (int i = 0; i < 1000; i++) { addrs.add(bs.write(randomData(2048))); } rw.reset(); } final String fname = bs.getStore().getStoreFile().getAbsolutePath(); store.close(); } 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(); } }
ArrayList<Long> addrs = new ArrayList<Long>(); for (int i = 0; i < 1000; i++) { addrs.add(bs.write(randomData(2048)));
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(); } }
ArrayList<Long> addrs = new ArrayList<Long>(); for (int i = 0; i < 1000; i++) { addrs.add(bs.write(randomData(2048)));
/** * 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(); } }
/** * 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(); } }
/** * State2 * * Allocate - Commit - Free - Commit * * assert that allocation is no longer committed */ public void test_allocCommitFreeCommit() { 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)); store.commit(); assertFalse(bs.isCommitted(addr)); } finally { store.destroy(); } }
/** * State2 * * Allocate - Commit - Free - Commit * * assert that allocation is no longer committed */ public void test_allocCommitFreeCommit() { 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)); store.commit(); assertFalse(bs.isCommitted(addr)); } finally { store.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_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(); } }
RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final long addr = bs.write(randomData(78));