From: <mar...@us...> - 2010-11-29 09:55:10
|
Revision: 3986 http://bigdata.svn.sourceforge.net/bigdata/?rev=3986&view=rev Author: martyncutcher Date: 2010-11-29 09:55:04 +0000 (Mon, 29 Nov 2010) Log Message: ----------- Add allocation tests and adjust for history retention. Modified Paths: -------------- branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/rwstore/TestRWJournal.java Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/rwstore/TestRWJournal.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/rwstore/TestRWJournal.java 2010-11-29 09:53:27 UTC (rev 3985) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/rwstore/TestRWJournal.java 2010-11-29 09:55:04 UTC (rev 3986) @@ -481,6 +481,33 @@ } + public void testAllocationReserves() { + final int cReserve16K = 16 * 1024; + final int cReserve128K = 32 * 1024; + + showAllocReserve(false, 64, cReserve16K, cReserve16K); + showAllocReserve(false, 128, cReserve16K, cReserve16K); + showAllocReserve(false, 1024, cReserve16K, cReserve16K); + showAllocReserve(false, 2048, cReserve16K, cReserve16K); + showAllocReserve(false, 3072, cReserve16K, cReserve16K); + showAllocReserve(false, 4096, cReserve16K, cReserve16K); + showAllocReserve(false, 8192, cReserve16K, cReserve16K); + + showAllocReserve(true, 64, cReserve128K, cReserve16K); + showAllocReserve(true, 128, cReserve128K, cReserve16K); + showAllocReserve(true, 1024, cReserve128K, cReserve16K); + showAllocReserve(true, 2048, cReserve128K, cReserve16K); + showAllocReserve(true, 3072, cReserve128K, cReserve16K); + showAllocReserve(true, 4096, cReserve16K, cReserve16K); + showAllocReserve(true, 8192, cReserve128K, cReserve16K); + } + private void showAllocReserve(final boolean optDensity, final int slotSize, final int reserve, final int mod) { + final int ints = FixedAllocator.calcBitSize(optDensity, slotSize, reserve, mod); + // there are max 126 ints available to a FixedAllocator + final int maxuse = (126/(ints+1)) * ints; + System.out.println("Allocate " + ints + ":" + (32 * ints * slotSize) + " for " + slotSize + " in " + reserve + " using " + maxuse + " of 126 possible"); + } + long allocBatch(RWStore rw, int bsize, int asze, int ainc) { long curAddress = rw.physicalAddress(rw.alloc(asze, null)); for (int i = 1; i < bsize; i++) { @@ -786,7 +813,7 @@ int[] faddrs = allocBatchBuffer(rw, 100, startBlob, endBlob); final StringBuilder str = new StringBuilder(); - rw.showAllocators(str); + rw.getStorageStats().showStats(str); System.out.println(str); } finally { @@ -844,8 +871,9 @@ /** * Test of blob allocation and read-back, firstly from cache and then from disk. + * @throws InterruptedException */ - public void test_blob_realloc() { + public void test_blob_realloc() throws InterruptedException { final Journal store = (Journal) getStore(); @@ -877,6 +905,7 @@ // allocate another address, might (or might not) be the same. faddr = bs.write(bb); // rw.alloc(buf, buf.length); + final long pa = bs.getPhysicalAddress(faddr); bb.position(0); System.out.println("Now commit to disk (1)"); @@ -892,8 +921,12 @@ // now delete the memory bs.delete(faddr); - // Must not have been immediately freed. - assertNotSame(0L, bs.getPhysicalAddress(faddr)); + // Must not have been immediately freed if history is retained. + if (rw.getHistoryRetention() != 0) + assertEquals(pa, bs.getPhysicalAddress(faddr)); + else + assertEquals(0L, bs.getPhysicalAddress(faddr)); + /* * Commit before testing for deferred frees. Since there is a @@ -906,6 +939,8 @@ store.commit(); + Thread.currentThread().sleep(10); + // Request release of deferred frees. rw.checkDeferredFrees(true/* freeNow */, store); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |