From: <tho...@us...> - 2010-11-03 18:00:58
|
Revision: 3883 http://bigdata.svn.sourceforge.net/bigdata/?rev=3883&view=rev Author: thompsonbry Date: 2010-11-03 18:00:50 +0000 (Wed, 03 Nov 2010) Log Message: ----------- Sync to Martyn. Modified Paths: -------------- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/FileMetadata.java branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RWStrategy.java branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/FixedAllocator.java branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/RWStore.java branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/rwstore/TestRWJournal.java Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/FileMetadata.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/FileMetadata.java 2010-11-03 17:09:11 UTC (rev 3882) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/FileMetadata.java 2010-11-03 18:00:50 UTC (rev 3883) @@ -83,7 +83,7 @@ /** * The file that was opened. */ - final File file; + public final File file; /** * The mode used to open the file. @@ -104,6 +104,17 @@ */ RandomAccessFile raf; + /** + * The interface for IO performed on that file. + * <p> + * Note: this method is only safe for use during the initial file + * create/open. It is not safe to use once a file has been closed, whether + * directly or by an interrupt during an IO operation. + */ + public RandomAccessFile getRandomAccessFile() { + return raf; + } + /** * The 32-bit magic value at offset 0L in the file. * @@ -172,7 +183,7 @@ /** * True iff the file was opened in a read-only mode. */ - final boolean readOnly; + public final boolean readOnly; /** * The timestamp from the createTime field in the root block. @@ -233,13 +244,13 @@ * The current root block. For a new file, this is "rootBlock0". For an * existing file it is based on an examination of both root blocks. */ - final IRootBlockView rootBlock; + public final IRootBlockView rootBlock; /** * Properties used to initialize this FileMetadata object */ final Properties properties; - + /** * This constructor handles the case where the file does not exist or exists * but is empty (including files created by the temporary file creation Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RWStrategy.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RWStrategy.java 2010-11-03 17:09:11 UTC (rev 3882) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RWStrategy.java 2010-11-03 18:00:50 UTC (rev 3883) @@ -41,26 +41,25 @@ import com.bigdata.rawstore.IAddressManager; import com.bigdata.rwstore.IAllocationContext; import com.bigdata.rwstore.RWStore; -import com.bigdata.util.ChecksumUtility; /** * The hook that accesses the RWStore to provide read/write services as opposed - * to the WORM characteristics of the DiskOnlyStrategy AddressManager + * to the WORM characteristics of the DiskOnlyStrategy AddressManager. * - * The intent behind this approach is to try to manage the protocol - * differences between the IStore implementation, assumed as a backing - * service to the CTC ObjectManager, and an IBufferStrategy service for a - * BigData Journal. + * The intent behind this approach is to try to manage the protocol differences + * between the IStore implementation, assumed as a backing service to the CTC + * ObjectManager, and an IBufferStrategy service for a BigData Journal. * * The most fundamental difference is with the root data, with RootBlock - * including both low-level store data - such as metabits info - and - * higher level, journal maintained data. + * including both low-level store data - such as metabits info - and higher + * level, journal maintained data. * - * TODO: Rationalise rootBlock access - use rootblock held by RWStore + * @author Martyn Cutcher * - * TODO: Implement use of IByteArraySlice as alternative to ByteBuffer + * @todo review life cycle state changes and refusal of methods when the backing + * store is closed. * - * @author Martyn Cutcher + * @todo Implement use of IByteArraySlice as alternative to ByteBuffer */ public class RWStrategy extends AbstractRawStore implements IBufferStrategy, IHABufferStrategy { @@ -68,25 +67,26 @@ private final IAddressManager m_am = new RWAddressManager(); - final private FileMetadata m_fileMetadata; - -// final private Quorum<?,?> m_environment; - /** - * The backing store impl. - * - * @see #reopen(). + * The backing store implementation. */ - private volatile RWStore m_store = null; + private final RWStore m_store; - final private FileMetadataView m_fmv = new FileMetadataView(); - + /** + * The {@link UUID} for the store. + */ + private final UUID m_uuid; + + /** + * <code>true</code> iff the backing store is open. + */ private volatile boolean m_open = false; - - private volatile IRootBlockView m_rb; -// private volatile IRootBlockView m_rb0; -// private volatile IRootBlockView m_rb1; + /** + * The size of the backing file when it was opened by the constructor. + */ + final private long m_initialExtent; + /** * @todo The use of this lock is suspicious. It is only used by * {@link #commit(IJournal)} and that method is invoked by the @@ -103,126 +103,16 @@ */ RWStrategy(final FileMetadata fileMetadata, final Quorum<?,?> quorum) { - m_fileMetadata = fileMetadata; + m_uuid = fileMetadata.rootBlock.getUUID(); + + m_store = new RWStore(fileMetadata, quorum); -// m_environment = quorum; - - m_rb = fileMetadata.rootBlock; - - m_store = new RWStore(m_fmv, false/*readOnly*/, quorum); // not read-only for now m_open = true; - - m_rb = getRootBlock(); // ensure values correct from create/reopen - -// m_rb0 = copyRootBlock(true); -// m_rb1 = copyRootBlock(false); - - m_initialExtent = m_fileMetadata.file.length(); + + m_initialExtent = fileMetadata.file.length(); } -// /** -// * Return a copy of the current {@link IRootBlockView}. -// * -// * @param rb0 -// * When <code>true</code> the view will be flagged as root block -// * ZERO (0). Otherwise it is flagged as root block ONE (1). -// * -// * @return The {@link IRootBlockView}. -// */ -// private IRootBlockView copyRootBlock(final boolean rb0) { -// -// final IRootBlockView rbv = new RootBlockView(rb0, m_rb.getOffsetBits(), -// m_rb.getNextOffset(), m_rb.getFirstCommitTime(), m_rb -// .getLastCommitTime(), m_rb.getCommitCounter(), m_rb -// .getCommitRecordAddr(), -// m_rb.getCommitRecordIndexAddr(), m_fileMetadata.rootBlock -// .getUUID(), m_rb.getQuorumToken(), m_rb -// .getMetaStartAddr(), m_rb.getMetaBitsAddr(), -// StoreTypeEnum.RW, m_fileMetadata.rootBlock.getCreateTime(), -// m_rb.getCloseTime(), s_ckutil); -// -// return rbv; -// } - - /** - * Create a wrapper to circumvent package visibility issues since we'd like - * to keep RWStore in a separate package - * - * @author mgc - * - */ - interface IFileMetadataView { - IRootBlockView getRootBlock(); - -// IRootBlockView getRootBlock0(); -// -// IRootBlockView getRootBlock1(); - - File getFile(); - - RandomAccessFile getRandomAccessFile(); - - public IRootBlockView newRootBlockView(boolean rootBlock0, int offsetBits, long nextOffset, - long firstCommitTime, long lastCommitTime, long commitCounter, long commitRecordAddr, - long commitRecordIndexAddr, long metaStartAddr, long metaBitsAddr, long closeTime); - } - - static final private ChecksumUtility s_ckutil = new ChecksumUtility(); - - public class FileMetadataView implements IFileMetadataView { - - private FileMetadataView() { - } - - public IRootBlockView getRootBlock() { - return m_rb; - } - -// public IRootBlockView getRootBlock0() { -// return m_rb0; -// } -// -// public IRootBlockView getRootBlock1() { -// return m_rb1; -// } - - public FileMetadata getFileMetadata() { - return m_fileMetadata; - } - - public File getFile() { - return m_fileMetadata.file; - } - - public RandomAccessFile getRandomAccessFile() { - return m_fileMetadata.raf; - } - - public IRootBlockView newRootBlockView(boolean rootBlock0, - int offsetBits, long nextOffset, long firstCommitTime, - long lastCommitTime, long commitCounter, long commitRecordAddr, - long commitRecordIndexAddr, long metaStartAddr, - long metaBitsAddr, long closeTime) { - - final IRootBlockView rbv = new RootBlockView(rootBlock0, - offsetBits, nextOffset, firstCommitTime, lastCommitTime, - commitCounter, commitRecordAddr, commitRecordIndexAddr, - m_fileMetadata.rootBlock.getUUID(), - -1 /* FIXME: quorumToken */, metaStartAddr, metaBitsAddr, - StoreTypeEnum.RW, m_fileMetadata.rootBlock.getCreateTime(), - closeTime, s_ckutil); - - // writeRootBlock(rbv, ForceEnum.Force); // not sure if this is really needed now! - - return rbv; - } - - public String getProperty(String name, String defvalue) { - return m_fileMetadata.getProperty(name, defvalue); - } - } - public ByteBuffer readRootBlock(final boolean rootBlock0) { if (!isOpen()) @@ -296,21 +186,6 @@ } -// private void checkReopen() { -// if (m_needsReopen) { -// assert false; -// -// if (m_needsReopen) { -// // reopen(); // should be handled by RWStore -// m_needsReopen = false; -// } -// } -// } - -// public long allocate(int nbytes) { -// return encodeAddr(m_store.alloc(nbytes), nbytes); -// } - private long encodeAddr(long alloc, final int nbytes) { alloc <<= 32; alloc += nbytes; @@ -383,7 +258,7 @@ public long getExtent() { - return this.m_fileMetadata.file.length(); + return m_store.getStoreFile().length(); } @@ -393,10 +268,6 @@ } - final private long m_initialExtent; - -// private volatile boolean m_needsReopen = false; - public long getInitialExtent() { return m_initialExtent; @@ -450,13 +321,6 @@ final ForceEnum forceOnCommit) { m_store.writeRootBlock(rootBlock, forceOnCommit); - - // Current rootBlock is retained - m_rb = rootBlock; -// if (m_rb.isRootBlock0()) -// m_rb0 = m_rb; -// else -// m_rb1 = m_rb; } @@ -464,81 +328,43 @@ * Set close time in rootBlock, and close file */ public void close() { - if (m_fileMetadata.raf == null) { + if (!m_open) { throw new IllegalStateException(); } - try { - m_open = false; - - m_store.close(); - m_fileMetadata.raf.close(); - m_fileMetadata.raf = null; - } catch (IOException e) { - log.error(e,e);//e.printStackTrace(); - } + m_store.close(); + m_open = false; } - public void deleteResources() { - - if (m_fileMetadata.raf != null - && m_fileMetadata.raf.getChannel().isOpen()) { + public void deleteResources() { - throw new IllegalStateException("Backing store is open: " - + m_fileMetadata.file); - - } + if (m_open) + throw new IllegalArgumentException(); - if (m_fileMetadata.file.exists()) { - - try { - - if (!m_fileMetadata.file.delete()) { - - log.warn("Unable to delete file: " + m_fileMetadata.file); - - } + final File file = m_store.getStoreFile(); - } catch (SecurityException e) { - - log.warn("Problem deleting file", e); - + if (file.exists()) { + + if (!file.delete()) { + + log.warn("Unable to delete file: " + file); + } } - + } public void destroy() { - m_store.close(); - if (m_fileMetadata.raf != null && m_fileMetadata.raf.getChannel().isOpen()) { - try { - m_fileMetadata.raf.close(); - } catch (IOException e) { - log.warn("Problem with file close", e); - } - } - + m_store.close(); + m_open = false; + deleteResources(); + } - private IRootBlockView getRootBlock() { - return m_fmv.newRootBlockView(!m_rb.isRootBlock0(), // - m_rb.getOffsetBits(),// - getNextOffset(), // - m_rb.getFirstCommitTime(),// - m_rb.getLastCommitTime(), // - m_rb.getCommitCounter(),// - m_rb.getCommitRecordAddr(), // - m_rb.getCommitRecordIndexAddr(), // - getMetaStartAddr(),// - getMetaBitsAddr(), // - m_rb.getCloseTime()// - ); - } - /** - * commit must use a commit lock to synchronize the rootBlock with the commit. + * Commit must use a commit lock to synchronize the rootBlock with the commit. * * Must pass in earliestTxnTime to commitChanges to enable */ @@ -555,7 +381,9 @@ * Calls through to store and then to WriteCacheService.reset */ public void abort() { + m_store.reset(); + } public void force(final boolean metadata) { @@ -571,40 +399,12 @@ } } - -// /** -// * Must ensure that the writeCacheService is reset and direct buffers released. -// * TODO: Modify so that current WriteCacheService is reset and re-used by new -// * store. -// */ -// public void reopen() { -// try { -// log.warn("Request to reopen store after interrupt"); -// -// m_store.close(); -// m_fileMetadata.raf = new RandomAccessFile(m_fileMetadata.file, -// m_fileMetadata.fileMode); -// m_store = new RWStore(m_fmv, false, m_environment); // never read-only for now -// m_needsReopen = false; -// m_open = true; -// } catch (Throwable t) { -// log.error(t,t); -// -// throw new RuntimeException(t); -// } -// } - + public File getFile() { - return m_fileMetadata.file; + return m_store.getStoreFile(); } - - public Object getRandomAccessFile() { - - return m_fileMetadata.raf; - - } /** * Not supported - this is available on the {@link AbstractJournal}. @@ -620,7 +420,7 @@ public UUID getUUID() { - return m_fileMetadata.rootBlock.getUUID(); + return m_uuid; } Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/FixedAllocator.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/FixedAllocator.java 2010-11-03 17:09:11 UTC (rev 3882) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/FixedAllocator.java 2010-11-03 18:00:50 UTC (rev 3883) @@ -39,19 +39,26 @@ * Maintains List of AllocBlock(s) */ public class FixedAllocator implements Allocator { - protected static final Logger log = Logger.getLogger(FixedAllocator.class); + + private static final Logger log = Logger.getLogger(FixedAllocator.class); - private RWWriteCacheService m_writeCache = null; + final private RWWriteCacheService m_writeCache; volatile private int m_freeBits; volatile private int m_freeTransients; - private int m_diskAddr; - int m_index; + /** + * Address of the {@link FixedAllocator} within the meta allocation space on + * the disk. + */ + volatile private int m_diskAddr; + volatile private int m_index; - public void setIndex(int index) { - AllocBlock fb = (AllocBlock) m_allocBlocks.get(0); - if (log.isDebugEnabled()) - log.debug("Restored index " + index + " with " + getStartAddr() + "[" + fb.m_bits[0] + "] from " + m_diskAddr); + public void setIndex(final int index) { + final AllocBlock fb = (AllocBlock) m_allocBlocks.get(0); + + if (log.isDebugEnabled()) + log.debug("Restored index " + index + " with " + getStartAddr() + + "[" + fb.m_bits[0] + "] from " + m_diskAddr); m_index = index; } @@ -60,12 +67,16 @@ return RWStore.convertAddr(m_startAddr); } - public int compareTo(Object o) { - Allocator other = (Allocator) o; + /* + * Note: Object#equals() is fine with this compareTo() implementation. It is + * only used to sort the allocators. + */ + public int compareTo(final Object o) { + final Allocator other = (Allocator) o; if (other.getStartAddr() == 0) { return -1; } else { - long val = getStartAddr() - other.getStartAddr(); + final long val = getStartAddr() - other.getStartAddr(); if (val == 0) { throw new Error("Two allocators at same address"); @@ -79,30 +90,32 @@ return m_diskAddr; } - public void setDiskAddr(int addr) { + public void setDiskAddr(final int addr) { m_diskAddr = addr; } - /** - * The tweek of 3 to the offset is to ensure 1, that no address is zero and 2 to enable - * the values 1 & 2 to be special cased (this aspect is now historical). - */ + /** + * The tweak of 3 to the offset is to ensure 1, that no address is zero and + * 2 to enable the values 1 & 2 to be special cased (this aspect is now + * historical). + */ public long getPhysicalAddress(int offset) { offset -= 3; - int allocBlockRange = 32 * m_bitSize; + final int allocBlockRange = 32 * m_bitSize; - AllocBlock block = (AllocBlock) m_allocBlocks.get(offset / allocBlockRange); - int bit = offset % allocBlockRange; + final AllocBlock block = (AllocBlock) m_allocBlocks.get(offset / allocBlockRange); + final int bit = offset % allocBlockRange; + if (RWStore.tstBit(block.m_bits, bit)) { - return RWStore.convertAddr(block.m_addr) + m_size * bit; + return RWStore.convertAddr(block.m_addr) + ((long)m_size * bit); } else { return 0L; } } - public int getPhysicalSize(int offset) { + public int getPhysicalSize(final int offset) { return m_size; } @@ -122,7 +135,7 @@ } volatile private IAllocationContext m_context; - public void setAllocationContext(IAllocationContext context) { + public void setAllocationContext(final IAllocationContext context) { if (context == null && m_context != null) { // restore commit bits in AllocBlocks for (AllocBlock allocBlock : m_allocBlocks) { @@ -150,39 +163,43 @@ log.debug("writing allocator " + m_index + " for " + getStartAddr() + " with " + fb.m_bits[0]); final byte[] buf = new byte[1024]; final DataOutputStream str = new DataOutputStream(new FixedOutputStream(buf)); + try { + str.writeInt(m_size); - str.writeInt(m_size); + final Iterator<AllocBlock> iter = m_allocBlocks.iterator(); + while (iter.hasNext()) { + final AllocBlock block = iter.next(); - final Iterator<AllocBlock> iter = m_allocBlocks.iterator(); - while (iter.hasNext()) { - final AllocBlock block = iter.next(); + str.writeInt(block.m_addr); + for (int i = 0; i < m_bitSize; i++) { + str.writeInt(block.m_bits[i]); + } - str.writeInt(block.m_addr); - for (int i = 0; i < m_bitSize; i++) { - str.writeInt(block.m_bits[i]); - } + if (!m_store.isSessionPreserved()) { + block.m_transients = block.m_bits.clone(); + } - if (!m_store.isSessionPreserved()) { - block.m_transients = block.m_bits.clone(); - } + /** + * If this allocator is shadowed then copy the new committed + * state to m_saveCommit + */ + if (m_context != null) { + assert block.m_saveCommit != null; - /** - * If this allocator is shadowed then copy the new - * committed state to m_saveCommit - */ - if (m_context != null) { - assert block.m_saveCommit != null; - - block.m_saveCommit = block.m_bits.clone(); - } else if (m_store.isSessionPreserved()) { - block.m_commit = block.m_transients.clone(); - } else { - block.m_commit = block.m_bits.clone(); - } + block.m_saveCommit = block.m_bits.clone(); + } else if (m_store.isSessionPreserved()) { + block.m_commit = block.m_transients.clone(); + } else { + block.m_commit = block.m_bits.clone(); + } + } + // add checksum + final int chk = ChecksumUtility.getCHK().checksum(buf, + str.size()); + str.writeInt(chk); + } finally { + str.close(); } - // add checksum - final int chk = ChecksumUtility.getCHK().checksum(buf, str.size()); - str.writeInt(chk); if (!m_store.isSessionPreserved()) { m_freeBits += m_freeTransients; @@ -205,14 +222,14 @@ // read does not read in m_size since this is read to determine the class of // allocator - public void read(DataInputStream str) { + public void read(final DataInputStream str) { try { m_freeBits = 0; - Iterator iter = m_allocBlocks.iterator(); - int blockSize = m_bitSize * 32 * m_size; + final Iterator<AllocBlock> iter = m_allocBlocks.iterator(); + final int blockSize = m_bitSize * 32 * m_size; while (iter.hasNext()) { - AllocBlock block = (AllocBlock) iter.next(); + final AllocBlock block = iter.next(); block.m_addr = str.readInt(); for (int i = 0; i < m_bitSize; i++) { @@ -220,7 +237,7 @@ /** * Need to calc how many free blocks are available, minor - * optimisation by checking against either empty or full to + * optimization by checking against either empty or full to * avoid scanning every bit unnecessarily **/ if (block.m_bits[i] == 0) { // empty @@ -252,11 +269,11 @@ } - /**The size of the allocation slots in bytes.*/ - private final int m_size; + /** The size of the allocation slots in bytes. */ + private final int m_size; - int m_startAddr = 0; - int m_endAddr = 0; + private int m_startAddr = 0; + private int m_endAddr = 0; /** * The #of ints in the {@link AllocBlock}'s internal arrays. @@ -265,12 +282,12 @@ private final ArrayList<AllocBlock> m_allocBlocks; - private RWStore m_store; + final private RWStore m_store; /** * Calculating the number of ints (m_bitSize) cannot rely on a power of 2. Previously this * assumption was sufficient to guarantee a rounding on to an 64k boundary. However, now - * nints * 32 * 64 = 64K, so need multiple of 32 ints + * nints * 32 * 64 = 64K, so need multiple of 32 ints. * <p> * So, whatever multiple of 64, if we allocate a multiple of 32 ints we are guaranteed to be * on an 64K boundary. @@ -337,7 +354,7 @@ } sb.append(block.getStats(null) + "\r\n"); if (counter != null) - counter.addAndGet(block.getAllocBits() * m_size); + counter.addAndGet(block.getAllocBits() * (long) m_size); } return sb.toString(); @@ -561,8 +578,9 @@ * all reserved allocation blocks. */ public long getFileStorage() { - final long blockSize = 32 * m_bitSize * m_size; + final long blockSize = 32L * m_bitSize * m_size; + long allocated = getAllocatedBlocks(); allocated *= blockSize; Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/RWStore.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2010-11-03 17:09:11 UTC (rev 3882) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2010-11-03 18:00:50 UTC (rev 3883) @@ -65,7 +65,6 @@ import com.bigdata.journal.JournalTransactionService; import com.bigdata.journal.Options; import com.bigdata.journal.RootBlockView; -import com.bigdata.journal.RWStrategy.FileMetadataView; import com.bigdata.quorum.Quorum; import com.bigdata.util.ChecksumUtility; @@ -391,7 +390,7 @@ // private String m_filename; - private final FileMetadataView m_fmv; +// private final FileMetadataView m_fmv; private IRootBlockView m_rb; @@ -407,11 +406,14 @@ * @param readOnly * @param quorum * @throws InterruptedException + * + * @todo support read-only open. */ + public RWStore(final FileMetadata fileMetadata, final Quorum<?, ?> quorum) { - public RWStore(final FileMetadataView fileMetadataView, - final boolean readOnly, final Quorum<?, ?> quorum) { - + if (fileMetadata == null) + throw new IllegalArgumentException(); + m_metaBitsSize = cDefaultMetaBitsSize; m_metaBits = new int[m_metaBitsSize]; @@ -420,14 +422,12 @@ m_maxFileSize = 2 * 1024 * 1024; // 1gb max (mult by 128)!! m_quorum = quorum; - - m_fmv = fileMetadataView; - m_fd = m_fmv.getFile(); + m_fd = fileMetadata.file; - m_raf = m_fmv.getRandomAccessFile(); + m_raf = fileMetadata.getRandomAccessFile(); - m_rb = m_fmv.getRootBlock(); + m_rb = fileMetadata.rootBlock; m_commitList = new ArrayList<Allocator>(); @@ -447,7 +447,7 @@ m_bufferedWrite = null; } - final int buffers = m_fmv.getFileMetadata().writeCacheBufferCount; + final int buffers = fileMetadata.writeCacheBufferCount; if(log.isInfoEnabled()) log.info("RWStore using writeCacheService with buffers: " + buffers); @@ -474,16 +474,17 @@ try { - if (m_rb.getNextOffset() == 0) { // if zero then new file - String buckets = m_fmv.getProperty(Options.RW_ALLOCATIONS, null); + if (m_rb.getNextOffset() == 0) { // if zero then new file + final String buckets = fileMetadata.getProperty( + Options.RW_ALLOCATIONS, null/* default */); if (buckets == null) { m_allocSizes = DEFAULT_ALLOC_SIZES; } else { - String[] specs = buckets.split(","); + final String[] specs = buckets.split(","); m_allocSizes = new int[specs.length]; int prevSize = 0; for (int i = 0; i < specs.length; i++) { - int nxtSize = Integer.parseInt(specs[i]); + final int nxtSize = Integer.parseInt(specs[i]); if (nxtSize <= prevSize) throw new IllegalArgumentException("Invalid AllocSizes property"); m_allocSizes[i] = nxtSize; @@ -595,7 +596,7 @@ * * Rather than reading from file, instead reads from the current root block. * - * We use the rootBlock fields, nextOffset, metaStartAddr, metaBitsAddr + * We use the rootBlock fields, nextOffset, metaStartAddr, metaBitsAddr. * * metaBitsAddr indicates where the meta allocation bits are. * 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-03 17:09:11 UTC (rev 3882) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/rwstore/TestRWJournal.java 2010-11-03 18:00:50 UTC (rev 3883) @@ -157,7 +157,7 @@ assertEquals(Options.MAXIMUM_EXTENT, 0L/* soft limit for disk mode */, bufferStrategy .getMaximumExtent()); - assertNotNull("raf", bufferStrategy.getRandomAccessFile()); +// assertNotNull("raf", bufferStrategy.getRandomAccessFile()); assertEquals(Options.BUFFER_MODE, BufferMode.DiskRW, bufferStrategy .getBufferMode()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |