From: <tho...@us...> - 2010-11-04 13:13:34
|
Revision: 3889 http://bigdata.svn.sourceforge.net/bigdata/?rev=3889&view=rev Author: thompsonbry Date: 2010-11-04 13:13:27 +0000 (Thu, 04 Nov 2010) Log Message: ----------- Clean up on JournalShadow prior to integration into AbstractTask. Modified Paths: -------------- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/JournalShadow.java Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/JournalShadow.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/JournalShadow.java 2010-11-04 12:46:45 UTC (rev 3888) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/JournalShadow.java 2010-11-04 13:13:27 UTC (rev 3889) @@ -25,83 +25,102 @@ package com.bigdata.rwstore; import java.nio.ByteBuffer; -import java.util.concurrent.atomic.AtomicLong; import com.bigdata.journal.AbstractJournal; +import com.bigdata.journal.IBufferStrategy; import com.bigdata.journal.IJournal; import com.bigdata.journal.JournalDelegate; import com.bigdata.journal.RWStrategy; /** - * A JournalShadow wraps a Journal as a JournalDelegate but provides itself - * as the allocation context to be passed through to any interested - * BufferStrategy. + * A {@link JournalShadow} wraps an Journal but provides itself as the + * allocation context to be passed through to any interested + * {@link IBufferStrategy}. This is the path by which {@link RWStore} allocators + * are provided with the context for the allocations and deletes made. * - * This is the path by which RWStore allocators are provided the context for - * the allocations and deletes made - * * @author Martyn Cutcher - * */ public class JournalShadow extends JournalDelegate implements IAllocationContext { - static AtomicLong s_idCounter = new AtomicLong(23); - int m_id = (int) s_idCounter.incrementAndGet(); - private JournalShadow(AbstractJournal source) { - super(source); +// private final static AtomicLong s_idCounter = new AtomicLong(23); +// +// final private int m_id = (int) s_idCounter.incrementAndGet(); + + private JournalShadow(final AbstractJournal source) { + + super(source); + } - public long write(ByteBuffer data) { - return delegate.write(data, this); + public long write(final ByteBuffer data) { + + return delegate.write(data, this); + } - public long write(ByteBuffer data, long oldAddr) { - return delegate.write(data, oldAddr, this); + public long write(final ByteBuffer data, final long oldAddr) { + + return delegate.write(data, oldAddr, this); + } public void delete(long oldAddr) { - delegate.delete(oldAddr, this); - } - public int compareTo(Object o) { - if (o instanceof JournalShadow) { - JournalShadow js = (JournalShadow) o; - return m_id - js.m_id; - } else { - return -1; - } + delegate.delete(oldAddr, this); + } - /** - * TODO: should retrieve from localTransactionService or Journal - * properties - */ - public long minimumReleaseTime() { - return 0; - } +// public int compareTo(Object o) { +// if (o instanceof JournalShadow) { +// JournalShadow js = (JournalShadow) o; +// return m_id - js.m_id; +// } else { +// return -1; +// } +// } + +// /** +// * TODO: should retrieve from localTransactionService or Journal +// * properties +// */ +// public long minimumReleaseTime() { +// return 0; +// } /** * Release itself from the wrapped Journal, this unlocks the allocator for * the RWStore */ public void detach() { - delegate.detachContext(this); + + delegate.detachContext(this); + } - /** - * This factory pattern creates a shadow for a RWStrategy-backed Journal - * to support protected allocations while allowing for deletion and - * re-allocation where possible. If the Journal is not backed by a - * RWStrategy, then the original Journal is returned. - * - * @param journal - the journal to be shadowed - * @return the shadowed journal if necessary - */ - public static IJournal newShadow(AbstractJournal journal) { - if (journal.getBufferStrategy() instanceof RWStrategy) { - return new JournalShadow(journal); - } else { - return journal; - } - } + /** + * This factory pattern creates a shadow for a RWStrategy-backed Journal to + * support protected allocations while allowing for deletion and + * re-allocation where possible. If the Journal is not backed by a + * RWStrategy, then the original Journal is returned. + * + * @param journal + * The journal to be shadowed + * + * @return The shadowed journal if necessary and otherwise the + * <i>journal</i>. + */ + public static IJournal newShadow(AbstractJournal journal) { + + if (journal.getBufferStrategy() instanceof RWStrategy) { + + return new JournalShadow(journal); + + } else { + + return journal; + + } + + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |