From: <sgo...@us...> - 2010-09-24 17:46:12
|
Revision: 3627 http://bigdata.svn.sourceforge.net/bigdata/?rev=3627&view=rev Author: sgossard Date: 2010-09-24 17:46:05 +0000 (Fri, 24 Sep 2010) Log Message: ----------- [maven_scaleout] : Fix for broken IndexSegment caused by r3612, which did not account for IndexSegment btrees being constructed by reflection. IndexSegment now properly returns SegmentMetadata, and this is verified in unit tests. This change also introduces a common super-type for IJournal and IndexSegmentStore, the new IStoreFile interface. Modified Paths: -------------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BTree.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegment.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentStore.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IJournal.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IResourceManager.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/Journal.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/IndexManager.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/StoreManager.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/jini/util/DumpFederation.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestAll_IndexSegment.java Added Paths: ----------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IStoreFile.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestIndexSegment.java Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -1335,7 +1335,7 @@ */ abstract public IRawStore getStore(); - final public IResourceMetadata[] getResourceMetadata() { + public IResourceMetadata[] getResourceMetadata() { if (store == null) { @@ -1351,14 +1351,12 @@ }; + } else { + //This is a default metadata, appropriate for rawstores. + return new IResourceMetadata[] { + new SimpleResourceMetadata(store.getUUID()) + }; } - - return new IResourceMetadata[] { - - new SimpleResourceMetadata(store.getUUID()) - - }; - } /** Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BTree.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BTree.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BTree.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -190,6 +190,11 @@ } + public final IResourceMetadata[] getResourceMetadata() { + //override to make final so sub-classes cannot modify behavior. + return super.getResourceMetadata(); + } + /** * Returns an {@link ICounter}. The {@link ICounter} is mutable iff the * {@link BTree} is mutable. All {@link ICounter}s returned by this method Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegment.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegment.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegment.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -34,6 +34,7 @@ import com.bigdata.btree.raba.ReadOnlyValuesRaba; import com.bigdata.io.AbstractFixedByteArrayBuffer; import com.bigdata.io.FixedByteArrayBuffer; +import com.bigdata.mdi.IResourceMetadata; import com.bigdata.service.Event; import com.bigdata.service.EventResource; import com.bigdata.service.EventType; @@ -676,6 +677,13 @@ } + public final IResourceMetadata[] getResourceMetadata() { + //Overrides the default returned metadata, providing IndexSegmentStore specific metadata. + return new IResourceMetadata[] { + fileStore.getResourceMetadata() + }; + } + /* * INodeFactory */ Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentStore.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentStore.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentStore.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -37,10 +37,10 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; +import com.bigdata.journal.IStoreFile; import org.apache.log4j.Logger; import com.bigdata.cache.IGlobalLRU; -import com.bigdata.cache.IGlobalLRU.ILRUCache; import com.bigdata.counters.CounterSet; import com.bigdata.counters.Instrument; import com.bigdata.counters.OneShotInstrument; @@ -67,7 +67,7 @@ * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ -public class IndexSegmentStore extends AbstractRawStore { +public class IndexSegmentStore extends AbstractRawStore implements IStoreFile { /** * Logger. Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IJournal.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IJournal.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IJournal.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -25,8 +25,6 @@ import java.util.Properties; -import com.bigdata.btree.keys.IKeyBuilderFactory; -import com.bigdata.mdi.IResourceMetadata; import com.bigdata.rawstore.IMRMW; /** @@ -39,7 +37,7 @@ * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ -public interface IJournal extends IMRMW, IAtomicStore, IBTreeManager { +public interface IJournal extends IMRMW, IAtomicStore, IBTreeManager, IStoreFile { /** * A copy of the properties used to initialize this journal. @@ -56,9 +54,5 @@ * Immediate shutdown. */ public void shutdownNow(); - - /** - * A description of this store in support of the scale-out architecture. - */ - public IResourceMetadata getResourceMetadata(); + } Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IResourceManager.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IResourceManager.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IResourceManager.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -40,7 +40,6 @@ import com.bigdata.btree.IndexSegmentStore; import com.bigdata.btree.view.FusedView; import com.bigdata.counters.CounterSet; -import com.bigdata.rawstore.IRawStore; import com.bigdata.resources.ResourceManager; import com.bigdata.resources.StaleLocatorException; import com.bigdata.resources.StaleLocatorReason; @@ -99,17 +98,17 @@ public AbstractJournal getJournal(long timestamp); /** - * Opens an {@link IRawStore}. + * Opens an {@link IStoreFile}. * * @param uuid * The UUID identifying that store file. * - * @return The open {@link IRawStore}. + * @return The open {@link IStoreFile}. * * @throws RuntimeException * if something goes wrong. */ - public IRawStore openStore(UUID uuid); + public IStoreFile openStore(UUID uuid); /** * Return the ordered {@link AbstractBTree} sources for an index or a view Added: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IStoreFile.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IStoreFile.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IStoreFile.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -0,0 +1,53 @@ +/* + +Copyright (C) SYSTAP, LLC 2006-2010. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +package com.bigdata.journal; + +import com.bigdata.mdi.IResourceMetadata; +import com.bigdata.rawstore.IRawStore; + +import com.bigdata.btree.IndexSegmentStore; +import com.bigdata.journal.IJournal; + +/** + * An {@link IRawStore} that exposes additional serializable metadata allowing it to be managed by an + * {@link IResourceManager}. Currently this is common interface between the two main store + * file types that are used to store btree indices. + * <b /> + * The methods on this interface have been moved from <code>IRawStore</code> in order to reduce the burden on + * rawstore implementations which we often needed to stub methods out even though they were never used. + * It also improves encapsulation by removing direct knowledge of resource management related classes in the rawstore + * package. + * + * {@see IndexSegmentStore} + * {@see IJournal} + */ +public interface IStoreFile extends IRawStore { + + /** + * A description of this store in support of the scale-out architecture. + */ + public IResourceMetadata getResourceMetadata(); +} Property changes on: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IStoreFile.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/Journal.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/Journal.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/Journal.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -49,7 +49,6 @@ import com.bigdata.config.IntegerValidator; import com.bigdata.config.LongValidator; import com.bigdata.counters.CounterSet; -import com.bigdata.rawstore.IRawStore; import com.bigdata.relation.locator.DefaultResourceLocator; import com.bigdata.relation.locator.ILocatableResource; import com.bigdata.relation.locator.IResourceLocator; @@ -292,7 +291,7 @@ * Note: This will only succeed if the <i>uuid</i> identifies <i>this</i> * journal. */ - public IRawStore openStore(final UUID uuid) { + public IStoreFile openStore(final UUID uuid) { if(uuid == getRootBlockView().getUUID()) { Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/IndexManager.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/IndexManager.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/IndexManager.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -42,6 +42,7 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.Lock; +import com.bigdata.journal.*; import org.apache.log4j.Logger; import com.bigdata.btree.AbstractBTree; @@ -66,24 +67,12 @@ import com.bigdata.counters.CounterSet; import com.bigdata.counters.ICounterSet; import com.bigdata.io.DataInputBuffer; -import com.bigdata.journal.AbstractJournal; -import com.bigdata.journal.AbstractTask; -import com.bigdata.journal.ConcurrencyManager; -import com.bigdata.journal.ICommitRecord; -import com.bigdata.journal.IJournal; -import com.bigdata.journal.ITx; -import com.bigdata.journal.Journal; -import com.bigdata.journal.Name2Addr; -import com.bigdata.journal.NoSuchIndexException; -import com.bigdata.journal.TimestampUtility; -import com.bigdata.journal.Tx; import com.bigdata.journal.Name2Addr.Entry; import com.bigdata.journal.Name2Addr.EntrySerializer; import com.bigdata.mdi.IResourceMetadata; import com.bigdata.mdi.LocalPartitionMetadata; import com.bigdata.mdi.SegmentMetadata; import com.bigdata.rawstore.Bytes; -import com.bigdata.rawstore.IRawStore; import com.bigdata.service.Event; import com.bigdata.service.EventType; import com.bigdata.service.IBigdataClient; @@ -134,11 +123,11 @@ * Note: The {@link IIndex}s managed by this class are a * {@link FusedView} of {@link AbstractBTree}s. Each * {@link AbstractBTree} has a hard reference to the backing - * {@link IRawStore} and will keep the {@link IRawStore} from being + * {@link com.bigdata.journal.IStoreFile} and will keep the {@link IStoreFile} from being * finalized as long as a hard reference exists to the - * {@link AbstractBTree} (the reverse is not true - an {@link IRawStore} + * {@link AbstractBTree} (the reverse is not true - an {@link IStoreFile} * reference does NOT hold a hard reference to {@link AbstractBTree}s - * on that {@link IRawStore}). + * on that {@link IStoreFile}). * <p> * Note: The retention of the {@link BTree}s on the live * {@link ManagedJournal}s is governed by @@ -923,7 +912,7 @@ * {@link StoreManager#openStores}. */ public AbstractBTree getIndexOnStore(final String name, - final long timestamp, final IRawStore store) { + final long timestamp, final IStoreFile store) { if (name == null) throw new IllegalArgumentException(); @@ -1232,7 +1221,7 @@ final IResourceMetadata resource = a[i]; - final IRawStore store; + final IStoreFile store; try { store = openStore(resource.getUUID()); @@ -2021,7 +2010,7 @@ /** * Canonical per-index partition {@link BTreeCounters}. These counters are * set on each {@link AbstractBTree} that is materialized by - * {@link #getIndexOnStore(String, long, IRawStore)}. The same + * {@link #getIndexOnStore(String, long, IStoreFile)}. The same * {@link BTreeCounters} object is used for the unisolated, read-committed, * read-historical and isolated views of the index partition and for each * source in the view regardless of whether the source is a mutable Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/StoreManager.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/StoreManager.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/StoreManager.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -44,13 +44,13 @@ import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantReadWriteLock; +import com.bigdata.journal.*; import org.apache.log4j.Logger; import com.bigdata.bfs.BigdataFileSystem; @@ -67,25 +67,7 @@ import com.bigdata.cache.IGlobalLRU.ILRUCache; import com.bigdata.concurrent.NamedLock; import com.bigdata.io.SerializerUtil; -import com.bigdata.journal.AbstractJournal; -import com.bigdata.journal.AbstractLocalTransactionManager; -import com.bigdata.journal.BufferMode; -import com.bigdata.journal.CommitRecordIndex; -import com.bigdata.journal.ConcurrencyManager; -import com.bigdata.journal.DiskOnlyStrategy; -import com.bigdata.journal.IBufferStrategy; -import com.bigdata.journal.ICommitRecord; -import com.bigdata.journal.IConcurrencyManager; -import com.bigdata.journal.ILocalTransactionManager; -import com.bigdata.journal.IResourceLockService; -import com.bigdata.journal.IResourceManager; -import com.bigdata.journal.IRootBlockView; //BTM import com.bigdata.journal.ITransactionService; -import com.bigdata.journal.ITx; -import com.bigdata.journal.Name2Addr; -import com.bigdata.journal.TemporaryStore; -import com.bigdata.journal.WORMStrategy; -import com.bigdata.journal.WriteExecutorService; import com.bigdata.journal.WORMStrategy.StoreCounters; import com.bigdata.mdi.IPartitionMetadata; import com.bigdata.mdi.IResourceMetadata; @@ -94,7 +76,6 @@ import com.bigdata.mdi.LocalPartitionMetadata; import com.bigdata.mdi.SegmentMetadata; import com.bigdata.rawstore.Bytes; -import com.bigdata.rawstore.IRawStore; import com.bigdata.relation.locator.DefaultResourceLocator; import com.bigdata.service.DataService; import com.bigdata.service.Event; @@ -108,8 +89,8 @@ import static java.util.concurrent.TimeUnit.*; //BTM -import com.bigdata.journal.TransactionService; + /** * Class encapsulates logic for managing the store files (journals and index * segments), including the logic to compute the effective release time for the @@ -178,7 +159,7 @@ String DATA_DIR = StoreManager.class.getName()+".dataDir"; /** - * The capacity of the LRU cache of open {@link IRawStore}s. The + * The capacity of the LRU cache of open {@link IStoreFile}s. The * capacity of this cache indirectly controls how many stores will be * held open. The main reason for keeping an store open is to reuse its * buffers if another request arrives "soon" which would read on that @@ -213,7 +194,7 @@ * The time in milliseconds before an entry in the store cache will be * cleared from the backing {@link HardReferenceQueue} (default * {@value #DEFAULT_STORE_CACHE_TIMEOUT}). This property controls how - * long the store cache will retain an {@link IRawStore} which has not + * long the store cache will retain an {@link IStoreFile} which has not * been recently used. This is in contrast to the cache capacity. */ String STORE_CACHE_TIMEOUT = StoreManager.class.getName() @@ -574,8 +555,8 @@ * @see Options#STORE_CACHE_CAPACITY * @see Options#STORE_CACHE_TIMEOUT */ -// final protected WeakValueCache<UUID, IRawStore> storeCache; - final protected ConcurrentWeakValueCacheWithTimeout<UUID, IRawStore> storeCache; +// final protected WeakValueCache<UUID, IStoreFile> storeCache; + final protected ConcurrentWeakValueCacheWithTimeout<UUID, IStoreFile> storeCache; /** * Provides locks on a per-{resourceUUID} basis for higher concurrency. @@ -583,11 +564,11 @@ private final transient NamedLock<UUID> namedLock = new NamedLock<UUID>(); /** - * The #of entries in the hard reference cache for {@link IRawStore}s, + * The #of entries in the hard reference cache for {@link IStoreFile}s, * including both {@link ManagedJournal}s and IndexSegment}s. There MAY be - * more {@link IRawStore}s open than are reported by this method if there - * are hard references held by the application to those {@link IRawStore}s. - * {@link IRawStore}s that are not fixed by a hard reference will be + * more {@link IStoreFile}s open than are reported by this method if there + * are hard references held by the application to those {@link IStoreFile}s. + * {@link IStoreFile}s that are not fixed by a hard reference will be * quickly finalized by the JVM. */ public int getStoreCacheSize() { @@ -1123,12 +1104,12 @@ throw new RuntimeException(Options.STORE_CACHE_TIMEOUT + " must be non-negative"); - storeCache = new ConcurrentWeakValueCacheWithTimeout<UUID, IRawStore>( + storeCache = new ConcurrentWeakValueCacheWithTimeout<UUID, IStoreFile>( storeCacheCapacity, MILLISECONDS .toNanos(storeCacheTimeout)); -// storeCache = new WeakValueCache<UUID, IRawStore>( -// new LRUCache<UUID, IRawStore>(storeCacheCapacity)); +// storeCache = new WeakValueCache<UUID, IStoreFile>( +// new LRUCache<UUID, IStoreFile>(storeCacheCapacity)); } @@ -2036,7 +2017,7 @@ * that we can find the relevant journal quickly for a given timestamp. * <p> * Note: This requires that we open each resource in order to extract its - * {@link IResourceMetadata} description. We only open the {@link IRawStore} + * {@link IResourceMetadata} description. We only open the {@link IStoreFile} * for the resource, not its indices. The stores are closed again * immediately. * @@ -2249,15 +2230,15 @@ */ private void closeStores() { -// final Iterator<IRawStore> itr = storeCache.iterator(); +// final Iterator<IStoreFile> itr = storeCache.iterator(); - final Iterator<WeakReference<IRawStore>> itr = storeCache.iterator(); + final Iterator<WeakReference<IStoreFile>> itr = storeCache.iterator(); while (itr.hasNext()) { -// final IRawStore store = itr.next(); +// final IStoreFile store = itr.next(); - final IRawStore store = itr.next().get(); + final IStoreFile store = itr.next().get(); if (store == null) { // weak reference has been cleared. @@ -2804,12 +2785,12 @@ } /** - * Opens an {@link IRawStore}. + * Opens an {@link IStoreFile}. * * @param uuid * The UUID identifying that store file. * - * @return The open {@link IRawStore}. + * @return The open {@link IStoreFile}. * * @throws IllegalStateException * if the {@link StoreManager} is not open. @@ -2830,7 +2811,7 @@ * something goes wrong (except that I was planning to drop the file * name from that interface). */ - public IRawStore openStore(final UUID uuid) { + public IStoreFile openStore(final UUID uuid) { assertRunning(); @@ -2854,7 +2835,7 @@ * Check to see if the given resource is already open. */ - IRawStore store; + IStoreFile store; // synchronized(storeCache) { store = storeCache.get(uuid); @@ -3311,9 +3292,9 @@ // if(false) {// @todo remove code. // int nstores = 0, nindices = 0; // { -// Iterator<WeakReference<IRawStore>> itr = storeCache.iterator(); +// Iterator<WeakReference<IStoreFile>> itr = storeCache.iterator(); // while (itr.hasNext()) { -// IRawStore store = itr.next().get(); +// IStoreFile store = itr.next().get(); // if (store != null) { // log.warn("Store: " + store); // nstores++; @@ -3837,7 +3818,7 @@ */ { - final IRawStore store = storeCache.remove(uuid); + final IStoreFile store = storeCache.remove(uuid); if (store != null) { @@ -4094,7 +4075,7 @@ */ { - final IRawStore store = storeCache.remove(uuid); + final IStoreFile store = storeCache.remove(uuid); if (store != null) { Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/jini/util/DumpFederation.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/jini/util/DumpFederation.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/jini/util/DumpFederation.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -49,6 +49,7 @@ import java.util.concurrent.TimeoutException; import com.bigdata.io.BytesUtil; +import com.bigdata.journal.IStoreFile; import net.jini.config.ConfigurationException; import net.jini.core.entry.Entry; import net.jini.core.lookup.ServiceItem; @@ -72,7 +73,6 @@ import com.bigdata.mdi.IResourceMetadata; import com.bigdata.mdi.LocalPartitionMetadata; import com.bigdata.mdi.PartitionLocator; -import com.bigdata.rawstore.IRawStore; import com.bigdata.resources.ResourceManager; import com.bigdata.resources.StoreManager; import com.bigdata.resources.StoreManager.ManagedJournal; @@ -1379,7 +1379,7 @@ * expensive IO. */ - final IRawStore store = resourceManager.getJournal(timestamp); + final IStoreFile store = resourceManager.getJournal(timestamp); if (store == null) { @@ -1441,7 +1441,7 @@ * IndexSegmentStore, but not of the IndexSegment on that * store! */ - final IRawStore store = resourceManager.openStore(x + final IStoreFile store = resourceManager.openStore(x .getUUID()); if (store == null) { Modified: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestAll_IndexSegment.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestAll_IndexSegment.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestAll_IndexSegment.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -65,7 +65,9 @@ * * See DumpIndexSegment. */ - + + //basic unit tests for IndexSegment. + suite.addTestSuite(TestIndexSegment.class); // test static methods for the index builder. suite.addTestSuite(TestIndexSegmentPlan.class); // test encoding and decoding of child node/leaf addresses. Added: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestIndexSegment.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestIndexSegment.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestIndexSegment.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -0,0 +1,81 @@ +/* + * Created by IntelliJ IDEA. + * User: gossard + * Date: Sep 23, 2010 + * Time: 2:40:27 PM + */ +package com.bigdata.btree; + +import com.bigdata.mdi.IResourceMetadata; +import com.bigdata.mdi.SegmentMetadata; +import com.bigdata.rawstore.SimpleMemoryRawStore; +import junit.framework.TestCase; + +import java.io.File; +import java.util.UUID; + +/** + * Basic unit tests for IndexSegment class. + */ +public class TestIndexSegment extends TestCase { + File outputDirectory; + File outputFile; + + BTree sampleTree; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + outputFile = new File(getClass().getName() + ".seg").getAbsoluteFile(); + outputDirectory = outputFile.getParentFile(); + + if ( outputFile.exists() && !outputFile.delete() ) + throw new RuntimeException("Could not delete test file -" + outputFile.getAbsolutePath()); + + //just to be sure. + outputFile.deleteOnExit(); + + + + sampleTree = BTree.create(new SimpleMemoryRawStore(), + new IndexMetadata(UUID.randomUUID()) + ); + + for (int i = 0;i < 10;i++) + sampleTree.insert("key-"+i, "value-"+i); + + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + outputFile.delete(); + } + + public void test_verify_getResourceMetadata() throws Exception { + //write segment file from sample tree to disk. + IndexSegmentCheckpoint checkpoint = IndexSegmentBuilder + .newInstance(outputFile, outputDirectory, sampleTree.getEntryCount(), + sampleTree.rangeIterator(), 3, sampleTree.getIndexMetadata(), + System.currentTimeMillis() , true/* compactingMerge */, true /*bufferNodes*/) + .call(); + + //load the segment file from disk. + IndexSegmentStore segStore = new IndexSegmentStore(outputFile); + IndexSegment seg = segStore.loadIndexSegment(); + + IResourceMetadata[] metaList = seg.getResourceMetadata(); + assertNotNull("cannot return null",metaList); + assertEquals("must return only one item", 1, metaList.length); + assertNotNull("item cannot be null",metaList[0]); + assertTrue("resource metadata for IndexSegment must be instanceof SegmentMetadata", (metaList[0] instanceof SegmentMetadata) ); + + SegmentMetadata meta = (SegmentMetadata)metaList[0]; + assertTrue("index segment metadata must return true for isIndexSegment()", meta.isIndexSegment() ); + assertFalse("index segment metadata must return false for isJournal()", meta.isJournal() ); + + //expect short filename like 'foo.seg' , not absolute path. + assertEquals("index metadata backing filename wasn't same as original?", outputFile.getName() , meta.getFile() ); + } +} \ No newline at end of file Property changes on: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestIndexSegment.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |