From: <tho...@us...> - 2010-11-05 15:48:57
|
Revision: 3901 http://bigdata.svn.sourceforge.net/bigdata/?rev=3901&view=rev Author: thompsonbry Date: 2010-11-05 15:48:51 +0000 (Fri, 05 Nov 2010) Log Message: ----------- Partial integration with journal shadow allocations. See comments in the code starting at line 606 for problems which still require resolution. Modified Paths: -------------- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractTask.java Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractTask.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractTask.java 2010-11-05 15:43:58 UTC (rev 3900) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractTask.java 2010-11-05 15:48:51 UTC (rev 3901) @@ -27,8 +27,6 @@ package com.bigdata.journal; -import java.io.DataInput; -import java.io.DataOutput; import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; @@ -604,14 +602,29 @@ synchronized (name2Addr) { + /* + * FIXME In order to use shadow allocations, the unisolated + * index MUST be loaded using the IsolatedActionJournal. There + * are two places immediate below where it tests the cache and + * where it loads using the AbstractJournal, both of which are + * not appropriate as they fail to impose the + * IsolatedActionJournal with the consequence that the + * allocation contexts are not isolated. + */ + // recover from unisolated index cache. btree = name2Addr.getIndexCache(name); +// btree = null; // do not use the name2Addr cache. if (btree == null) { + final IJournal tmp; + tmp = resourceManager.getLiveJournal(); +// tmp = getJournal();// wrap with the IsolatedActionJournal. + // re-load btree from the store. btree = BTree.load(// - resourceManager.getLiveJournal(),// + tmp, // backing store. entry.checkpointAddr,// false// readOnly ); @@ -951,6 +964,8 @@ l.btree.writeCheckpoint(); + ((IsolatedActionJournal) getJournal()).detachContext(); + } if(INFO) { @@ -2135,7 +2150,7 @@ * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ - class IsolatedActionJournal implements IJournal { + class IsolatedActionJournal implements IJournal, IAllocationContext { private final AbstractJournal delegate; private final IResourceLocator resourceLocator; @@ -2472,46 +2487,50 @@ return delegate.toString(addr); } -// public long unpackAddr(DataInput in) throws IOException { -// return delegate.unpackAddr(in); -// } + public IRootBlockView getRootBlock(long commitTime) { + return delegate.getRootBlock(commitTime); + } + public Iterator<IRootBlockView> getRootBlocks(long startTime) { + return delegate.getRootBlocks(startTime); + } + + /* + * IAllocationContext + * + * The journal write() and delete() methods are overridden here to use + * the IsolatedActionJournal as the IAllocationContext. This causes the + * allocations to be scoped to the AbstractTask. + */ + public long write(ByteBuffer data) { - return delegate.write(data); + return delegate.write(data, this); } public long write(ByteBuffer data, long oldAddr) { - return write(data); + return delegate.write(data, oldAddr, this); } - public void delete(long addr) { - delegate.delete(addr); - } + public void delete(long addr) { + delegate.delete(addr, this); + } - public IRootBlockView getRootBlock(long commitTime) { - return delegate.getRootBlock(commitTime); - } +// public void delete(long addr, IAllocationContext context) { +// delegate.delete(addr, context); +// } +// +// public long write(ByteBuffer data, IAllocationContext context) { +// return delegate.write(data, context); +// } +// +// public long write(ByteBuffer data, long oldAddr, IAllocationContext context) { +// return delegate.write(data, oldAddr, context); +// } - public Iterator<IRootBlockView> getRootBlocks(long startTime) { - return delegate.getRootBlocks(startTime); + public void detachContext() { + delegate.detachContext(this); } - public void delete(long addr, IAllocationContext context) { - delegate.delete(addr, context); - } - - public long write(ByteBuffer data, IAllocationContext context) { - return delegate.write(data, context); - } - - public long write(ByteBuffer data, long oldAddr, IAllocationContext context) { - return delegate.write(data, oldAddr, context); - } - - public void detachContext(IAllocationContext context) { - delegate.detachContext(context); - } - } /** @@ -2789,14 +2808,14 @@ throw new UnsupportedOperationException(); } + public void delete(long addr) { + throw new UnsupportedOperationException(); + } + /* * Methods that delegate directly to the backing journal. */ -// public IKeyBuilder getKeyBuilder() { -// return delegate.getKeyBuilder(); -// } - public int getByteCount(long addr) { return delegate.getByteCount(addr); } @@ -2857,10 +2876,6 @@ return delegate.isStable(); } -// public void packAddr(DataOutput out, long addr) throws IOException { -// delegate.packAddr(out, addr); -// } - public ByteBuffer read(long addr) { return delegate.read(addr); } @@ -2877,15 +2892,6 @@ return delegate.toString(addr); } -// public long unpackAddr(DataInput in) throws IOException { -// return delegate.unpackAddr(in); -// } - - public void delete(long addr) { - // TODO Auto-generated method stub - - } - public IRootBlockView getRootBlock(long commitTime) { return delegate.getRootBlock(commitTime); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |