void showStore(final Journal store) { final RWStrategy bufferStrategy = (RWStrategy) store.getBufferStrategy(); final RWStore rw = bufferStrategy.getStore(); if (log.isInfoEnabled()) log.info("Fixed Allocators: " + rw.getFixedAllocatorCount() + ", heap allocated: " + rw.getFileStorage() + ", utilised bytes: " + rw.getAllocatedSlots() + ", file length: " + rw.getStoreFile().length()); }
void showStore(final Journal store) { final RWStrategy bufferStrategy = (RWStrategy) store.getBufferStrategy(); final RWStore rw = bufferStrategy.getStore(); if (log.isInfoEnabled()) log.info("Fixed Allocators: " + rw.getFixedAllocatorCount() + ", heap allocated: " + rw.getFileStorage() + ", utilised bytes: " + rw.getAllocatedSlots() + ", file length: " + rw.getStoreFile().length()); }
private long pureAllocBatch(final Journal store, final int tsts, int min, int sze, int grp) { final RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final RWStore rw = bs.getStore(); final int freeAddr[] = new int[512]; int freeCurs = 0; for (int i = 0; i < grp; i++) { final int alloc = min + r.nextInt(sze - min); final int addr = rw.alloc(alloc, null); if (i % 3 != 0) { // make avail 2 out of 3 for realloc freeAddr[freeCurs++] = addr; if (freeCurs == freeAddr.length) { for (int f = 0; f < freeAddr.length; f++) { rw.free(freeAddr[f], 0); } freeCurs = 0; } } } return 0L; }
private long pureAllocBatch(final Journal store, final int tsts, int min, int sze, int grp) { final RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final RWStore rw = bs.getStore(); final int freeAddr[] = new int[512]; int freeCurs = 0; for (int i = 0; i < grp; i++) { final int alloc = min + r.nextInt(sze - min); final int addr = rw.alloc(alloc, null); if (i % 3 != 0) { // make avail 2 out of 3 for realloc freeAddr[freeCurs++] = addr; if (freeCurs == freeAddr.length) { for (int f = 0; f < freeAddr.length; f++) { rw.free(freeAddr[f], 0); } freeCurs = 0; } } } return 0L; }
public void test_metaAlloc() { Journal store = (Journal) getStore(); try { final RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final RWStore rw = bs.getStore(); long realAddr = 0; for (int i = 0; i < 100000; i++) { int allocAddr = rw.metaAlloc(); realAddr = rw.metaBit2Addr(allocAddr); } if(log.isInfoEnabled())log.info("metaAlloc lastAddr: " + realAddr); } finally { store.destroy(); } }
public void test_metaAlloc() { Journal store = (Journal) getStore(); try { final RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final RWStore rw = bs.getStore(); long realAddr = 0; for (int i = 0; i < 100000; i++) { int allocAddr = rw.metaAlloc(); realAddr = rw.metaBit2Addr(allocAddr); } if(log.isInfoEnabled())log.info("metaAlloc lastAddr: " + realAddr); } 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 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_stressAlloc() { Journal store = (Journal) getStore(); try { final RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final RWStore rw = bs.getStore(); // long realAddr = 0; // allocBatch(store, 1, 32, 650, 100000000); allocBatch(store, 1, 32, 650, 50000); store.commit(); final StringBuilder str = new StringBuilder(); rw.showAllocators(str); if(log.isInfoEnabled())log.info(str); store.close(); if(log.isInfoEnabled())log.info("Re-open Journal"); store = (Journal) getStore(); showStore(store); } finally { store.destroy(); } }
public void test_stressAlloc() { Journal store = (Journal) getStore(); try { final RWStrategy bs = (RWStrategy) store.getBufferStrategy(); final RWStore rw = bs.getStore(); // long realAddr = 0; // allocBatch(store, 1, 32, 650, 100000000); allocBatch(store, 1, 32, 650, 50000); store.commit(); final StringBuilder str = new StringBuilder(); rw.showAllocators(str); if(log.isInfoEnabled())log.info(str); store.close(); if(log.isInfoEnabled())log.info("Re-open Journal"); store = (Journal) getStore(); showStore(store); } finally { store.destroy(); } }
/** * Test low level RWStore add/removeAddress methods as used in HA * WriteCache replication to ensure Allocation consistency * * @throws IOException */ public void testStressReplication() throws IOException { // Create a couple of stores with temp files final Journal store1 = (Journal) getStore(); final Journal store2 = (Journal) getStore(); try { final RWStore rw1 = ((RWStrategy) store1.getBufferStrategy()).getStore(); final RWStore rw2 = ((RWStrategy) store2.getBufferStrategy()).getStore(); assertTrue(rw1 != rw2); final Random r = new Random(); for (int i = 0; i < 100000; i++) { final int sze = 1 + r.nextInt(2000); final int addr = rw1.alloc(sze, null); rw2.addAddress(addr, sze); } } finally { store1.destroy(); store2.destroy(); } }
final RWStore rw = bufferStrategy.getStore(); final long numAllocs = rw.getTotalAllocations(); final long startAllocations = rw.getTotalAllocationsSize();
final RWStore rw = bufferStrategy.getStore();
final RWStore rw = bufferStrategy.getStore();
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(); } }