From: <sgo...@us...> - 2010-10-01 15:01:26
|
Revision: 3711 http://bigdata.svn.sourceforge.net/bigdata/?rev=3711&view=rev Author: sgossard Date: 2010-10-01 15:01:16 +0000 (Fri, 01 Oct 2010) Log Message: ----------- [maven_scaleout] : Broke all direct dependency cycles with package 'com.bigdata.mdi'. Wound up moving IMetadataIndex, LocalPartitionMetadata and JournalMetadata related classes to 'com.bigdata.btree'. This is likely a temporary move until the cycles between the btree and journal packages can be sorted out. These classes were Externalizable, so this change is not backwards compatible with existing installs. Also moved/renamed 'com.bigdata.service.Params' to 'com.bigdata.event.IEventParams'. Modified Paths: -------------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/bfs/BigdataFileSystem.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTreeTupleCursor.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/IndexMetadata.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentBuilder.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentStore.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/KeyAfterPartitionException.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/KeyBeforePartitionException.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/ViewStatistics.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/proc/RangeCountProcedure.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/view/FusedView.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/AbstractJournal.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/Name2Addr.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/RegisterIndexTask.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/mdi/AbstractResourceMetadata.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/mdi/IPartitionMetadata.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/mdi/IndexPartitionCause.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/mdi/PartitionLocator.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/mdi/SegmentMetadata.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/metadata/EmbeddedIndexStore.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/metadata/EmbeddedShardLocator.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/relation/accesspath/AbstractAccessPath.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/relation/rule/eval/IJoinNexus.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/AsynchronousOverflowTask.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/BTreeMetadata.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/BuildResult.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/CompactingMergeTask.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/IncrementalBuildTask.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/JoinIndexPartitionTask.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/JournalIndex.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/MoveTask.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/OverflowManager.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/PurgeResult.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/ResourceManager.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/ScatterSplitTask.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/SplitIndexPartitionTask.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/SplitResult.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/SplitUtility.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/StoreManager.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/ViewMetadata.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/AbstractScaleOutClient.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/AbstractScaleOutFederation.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/CacheOnceMetadataIndex.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/CachingMetadataIndex.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/EventResource.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/IBigdataFederation.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/IDataService.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/IMetadataService.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/IndexCache.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/MetadataIndexCache.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/MetadataService.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/NoCacheMetadataIndexView.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/ShardLocator.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/ShardManagement.java 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/ndx/AbstractScaleOutClientIndexView.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/ndx/AbstractScaleOutClientIndexView2.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/ndx/AbstractSplitter.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/ndx/ClientIndexView.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/ndx/ClientIndexViewRefactor.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/ndx/IScaleOutClientIndex.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/ndx/ISplitter.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestIndexPartitionFencePosts.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/rdf/store/AbstractServerTestCase.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/resources/AbstractResourceManagerTestCase.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/resources/TestBuildTask.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/resources/TestBuildTask2.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/resources/TestMergeTask.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/resources/TestOverflow.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/resources/TestResourceManagerBootstrap.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/resources/TestSegSplitter.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/AbstractEmbeddedFederationTestCase.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/TestEmbeddedClient.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/TestEventReceiver.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/TestMetadataIndex.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/TestMove.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/TestOverflow.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/TestScatterSplit.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/TestSplitJoin.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/ndx/TestSplitter.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/ndx/pipeline/AbstractKeyRangeMasterTestCase.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/ndx/pipeline/TestMasterTaskWithSplits.java branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/service/jini/AbstractServerTestCase.java Added Paths: ----------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IMetadataIndex.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/JournalMetadata.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/LocalPartitionMetadata.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/MetadataIndex.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/MetadataIndexView.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/event/ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/event/IEventParams.java Removed Paths: ------------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/mdi/IMetadataIndex.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/mdi/JournalMetadata.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/mdi/LocalPartitionMetadata.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/mdi/MetadataIndex.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/mdi/MetadataIndexView.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/Params.java Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/bfs/BigdataFileSystem.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/bfs/BigdataFileSystem.java 2010-10-01 13:20:12 UTC (rev 3710) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/bfs/BigdataFileSystem.java 2010-10-01 15:01:16 UTC (rev 3711) @@ -34,7 +34,7 @@ import com.bigdata.journal.IResourceLock; import com.bigdata.journal.ITx; import com.bigdata.journal.Journal; -import com.bigdata.mdi.MetadataIndex; +import com.bigdata.btree.MetadataIndex; import com.bigdata.rawstore.Bytes; import com.bigdata.rawstore.IBlock; import com.bigdata.rawstore.WormAddressManager; 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-10-01 13:20:12 UTC (rev 3710) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java 2010-10-01 15:01:16 UTC (rev 3711) @@ -81,7 +81,6 @@ import com.bigdata.journal.IIndexManager; import com.bigdata.journal.Journal; import com.bigdata.mdi.IResourceMetadata; -import com.bigdata.mdi.LocalPartitionMetadata; import com.bigdata.rawstore.IRawStore; import com.bigdata.resources.IndexManager; import com.bigdata.resources.OverflowManager; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTreeTupleCursor.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTreeTupleCursor.java 2010-10-01 13:20:12 UTC (rev 3710) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTreeTupleCursor.java 2010-10-01 15:01:16 UTC (rev 3711) @@ -37,7 +37,6 @@ import com.bigdata.btree.isolation.IsolatedFusedView; import com.bigdata.btree.view.FusedView; import com.bigdata.io.DataOutputBuffer; -import com.bigdata.mdi.LocalPartitionMetadata; /** * Class supporting random access to tuples and sequential tuple-based cursor 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-10-01 13:20:12 UTC (rev 3710) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BTree.java 2010-10-01 15:01:16 UTC (rev 3711) @@ -41,8 +41,6 @@ import com.bigdata.journal.Name2Addr; import com.bigdata.journal.Name2Addr.Entry; import com.bigdata.mdi.IResourceMetadata; -import com.bigdata.mdi.JournalMetadata; -import com.bigdata.mdi.LocalPartitionMetadata; import com.bigdata.rawstore.IRawStore; /** Copied: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IMetadataIndex.java (from rev 3704, branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/mdi/IMetadataIndex.java) =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IMetadataIndex.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IMetadataIndex.java 2010-10-01 15:01:16 UTC (rev 3711) @@ -0,0 +1,95 @@ +/* + +Copyright (C) SYSTAP, LLC 2006-2008. 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 + +*/ +/* + * Created on Feb 11, 2008 + */ + +package com.bigdata.btree; + +import com.bigdata.btree.MetadataIndex.MetadataIndexMetadata; +import com.bigdata.mdi.PartitionLocator; +import com.bigdata.service.IDataService; + +/** + * Interface for a metadata index. The metadata index stores the + * {@link com.bigdata.mdi.PartitionLocator}s that specify which {@link IDataService} has data + * for each index partition in a scale-out index. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + */ +public interface IMetadataIndex extends IRangeQuery { //extends IIndex { + + /** + * The metadata for the metadata index itself. Note that the + * {@link MetadataIndexMetadata#getManagedIndexMetadata()} returns the + * template {@link IndexMetadata} for the scale-out index partitions. + * + * @see #getScaleOutIndexMetadata() + */ + public MetadataIndexMetadata getIndexMetadata(); + + /** + * The metadata template for the scale-out index managed by this metadata + * index. + */ + public IndexMetadata getScaleOutIndexMetadata(); + + /** + * The partition with that separator key or <code>null</code> (exact match + * on the separator key). + * + * @param key + * The separator key (the first key that would go into that + * partition). + * + * @return The partition with that separator key or <code>null</code>. + */ + public PartitionLocator get(byte[] key); + + /** + * Find and return the partition spanning the given key. + * + * @param key + * A key (optional). When <code>null</code> the locator for the + * last index partition will be returned. + * + * @return The partition spanning the given key or <code>null</code> if + * there are no partitions defined. + */ + public PartitionLocator find(byte[] key); + + /** + * Notification that a locator is stale. Caching implementations of this + * interface will use this notice to update their state from the + * authoritative metadata index. Non-caching and authoritative + * implementations just ignore this message. + * + * @param locator + * The locator. + */ + public void staleLocator(PartitionLocator locator); + +} Property changes on: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IMetadataIndex.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL Added: svn:eol-style + native Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexMetadata.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexMetadata.java 2010-10-01 13:20:12 UTC (rev 3710) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexMetadata.java 2010-10-01 15:01:16 UTC (rev 3711) @@ -57,8 +57,6 @@ import com.bigdata.io.SerializerUtil; import com.bigdata.io.compression.IRecordCompressorFactory; import com.bigdata.journal.IIndexManager; -import com.bigdata.mdi.LocalPartitionMetadata; -import com.bigdata.mdi.MetadataIndex; import com.bigdata.rawstore.IRawStore; import com.bigdata.relation.accesspath.IAsynchronousIterator; import com.bigdata.resources.OverflowManager; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentBuilder.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentBuilder.java 2010-10-01 13:20:12 UTC (rev 3710) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentBuilder.java 2010-10-01 15:01:16 UTC (rev 3711) @@ -52,12 +52,10 @@ import com.bigdata.btree.raba.MutableKeyBuffer; import com.bigdata.btree.raba.MutableValueBuffer; import com.bigdata.btree.view.FusedView; -import com.bigdata.cache.IGlobalLRU.ILRUCache; import com.bigdata.journal.Journal; import com.bigdata.journal.Name2Addr; import com.bigdata.journal.TemporaryRawStore; import com.bigdata.mdi.IResourceMetadata; -import com.bigdata.mdi.LocalPartitionMetadata; import com.bigdata.mdi.SegmentMetadata; import com.bigdata.rawstore.Bytes; import com.bigdata.rawstore.IAddressManager; 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-10-01 13:20:12 UTC (rev 3710) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentStore.java 2010-10-01 15:01:16 UTC (rev 3711) @@ -51,7 +51,6 @@ import com.bigdata.journal.AbstractJournal; import com.bigdata.journal.RootBlockException; import com.bigdata.mdi.IResourceMetadata; -import com.bigdata.mdi.LocalPartitionMetadata; import com.bigdata.mdi.SegmentMetadata; import com.bigdata.rawstore.AbstractRawStore; import com.bigdata.resources.StoreManager; Copied: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/JournalMetadata.java (from rev 3704, branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/mdi/JournalMetadata.java) =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/JournalMetadata.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/JournalMetadata.java 2010-10-01 15:01:16 UTC (rev 3711) @@ -0,0 +1,152 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2007. 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.btree; + +import java.io.File; +import java.util.UUID; + +import com.bigdata.journal.AbstractJournal; +import com.bigdata.journal.IJournal; +import com.bigdata.journal.Journal; +import com.bigdata.mdi.AbstractResourceMetadata; + +/** + * Metadata required to locate a {@link Journal} resource. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + */ +public class JournalMetadata extends AbstractResourceMetadata { + + /** + * + */ + private static final long serialVersionUID = 3783897093328558238L; + + public final boolean isIndexSegment() { + + return false; + + } + + public final boolean isJournal() { + + return true; + + } + + /** + * Return the file whose contents are the persistent state for the + * journal. + * + * @param journal + * The journal. + * + * @return The file. + */ + private static String getFileString(final IJournal journal) { + + final File file = journal.getFile(); + + if (file == null) + return ""; + + return file.getName();//toString(); + + } + + /** + * De-serialization constructor. + */ + public JournalMetadata() { + + } + + /** + * The description of a journal. The {@link JournalMetadata} state will not + * change as writes are made on the journal since it does not reflect + * anything exception the {@link UUID}, the filename, and the create time. + * + * @param journal + * The journal. + */ + public JournalMetadata(final AbstractJournal journal) { + + this(getFileString(journal), //journal.getBufferStrategy().getExtent(), + journal.getRootBlockView().getUUID(), // + journal.getRootBlockView().getCreateTime(), // createTime. + 0L // commitTime + ); + + } + + /** + * Constructor variant used to indicate a read from a specific commitTime on + * a journal. + * + * @param journal + * The journal. + * @param commitTime + * The commitTime. + */ + public JournalMetadata(final AbstractJournal journal, final long commitTime) { + + this(getFileString(journal), //journal.getBufferStrategy().getExtent(), + journal.getRootBlockView().getUUID(),// + journal.getRootBlockView().getCreateTime(),// + commitTime + ); + + } + + /** + * Data only constructor used by some unit tests. + * + * @param file + * @param uuid + * @param createTime + */ + public JournalMetadata(final File file, /* long nbytes, */final UUID uuid, + final long createTime, final long commitTime) { + + this(file.getName()/* ,nbytes */, uuid, createTime, commitTime); + + } + + /** + * Package private constructor used by the other constructors and when + * deserializing records. + * + * @param file + * @param uuid + * @param createTime + */ + JournalMetadata(final String file, /* long nbytes, */final UUID uuid, + final long createTime, final long commitTime) { + + super(file, /*nbytes, */ uuid, createTime, commitTime); + + } + +} Property changes on: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/JournalMetadata.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL Added: svn:eol-style + native Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/KeyAfterPartitionException.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/KeyAfterPartitionException.java 2010-10-01 13:20:12 UTC (rev 3710) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/KeyAfterPartitionException.java 2010-10-01 15:01:16 UTC (rev 3711) @@ -31,7 +31,6 @@ import java.io.File; import com.bigdata.io.BytesUtil; -import com.bigdata.mdi.LocalPartitionMetadata; /** * An exception thrown when a key lies after the half-open range of an index Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/KeyBeforePartitionException.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/KeyBeforePartitionException.java 2010-10-01 13:20:12 UTC (rev 3710) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/KeyBeforePartitionException.java 2010-10-01 15:01:16 UTC (rev 3711) @@ -31,7 +31,6 @@ import java.io.File; import com.bigdata.io.BytesUtil; -import com.bigdata.mdi.LocalPartitionMetadata; /** * Exception thrown when a key is before the start of the half-open range of an Copied: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/LocalPartitionMetadata.java (from rev 3704, branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/mdi/LocalPartitionMetadata.java) =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/LocalPartitionMetadata.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/LocalPartitionMetadata.java 2010-10-01 15:01:16 UTC (rev 3711) @@ -0,0 +1,706 @@ +/* + +Copyright (C) SYSTAP, LLC 2006-2007. 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.btree; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.Arrays; +import java.util.UUID; + +import com.bigdata.io.BytesUtil; +import com.bigdata.mdi.*; +import org.CognitiveWeb.extser.LongPacker; +import org.CognitiveWeb.extser.ShortPacker; + +import com.bigdata.journal.Journal; +import com.bigdata.service.DataService; + +/** + * An immutable object providing metadata about a local index partition, + * including the partition identifier, the left and right separator keys + * defining the half-open key range of the index partition, and optionally + * defining the {@link com.bigdata.mdi.IResourceMetadata}[] required to materialize a view of + * that index partition. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + */ +public class LocalPartitionMetadata implements IPartitionMetadata, + Externalizable { + + /** + * + */ + private static final long serialVersionUID = -1511361004851335936L; + + /** + * The maximum length of the history string (4kb). + * <p> + * Note: The history is written each time the {@link IndexMetadata} is + * written and is read each time it is read so this can be the main driver + * of the size of the {@link IndexMetadata} record. + * + * @deprecated + */ + protected final static transient int MAX_HISTORY_LENGTH = 0;//4 * Bytes.kilobyte32; + + /** + * The unique partition identifier. + */ + private int partitionId; + + /** + * + * @see #getSourcePartitionId() + * + * @deprecated MoveTask manages without this field (it was required by the + * previous MOVE implementation). + */ + private int sourcePartitionId; + + /** + * + */ + private byte[] leftSeparatorKey; + private byte[] rightSeparatorKey; + + /** + * Description of the resources required to materialize a view of the index + * partition (optional - not stored when the partition metadata is stored on + * an {@link IndexSegmentStore}). + * <p> + * The entries in the array reflect the creation time of the resources. The + * earliest resource is listed first. The most recently created resource is + * listed last. + * <p> + * When present, the #of sources in the index partition view includes: the + * mutable {@link BTree}, any {@link BTree}s on historical journal(s) + * still incorporated into the view, and any {@link IndexSegment}s + * incorporated into the view. + */ + private IResourceMetadata[] resources; + + /** + * The reason why an index partition was created together with some metadata + * about when it was created. + */ + private IndexPartitionCause cause; + +// /** +// * A history of operations giving rise to the current partition metadata. +// * E.g., register(timestamp), copyOnOverflow(timestamp), split(timestamp), +// * join(partitionId,partitionId,timestamp), etc. This is truncated when +// * serialized to keep it from growing without bound. +// * +// * @deprecated See {@link #getHistory()} +// */ +// private String history; +// +// /** +// * If the history string exceeds {@link #MAX_HISTORY_LENGTH} characters then +// * truncates it to the last {@link #MAX_HISTORY_LENGTH}-3 characters, +// * prepends "...", and returns the result. Otherwise returns the entire +// * history string. +// * +// * @deprecated See {@link #history} +// */ +// protected String getTruncatedHistory() { +// +// if (MAX_HISTORY_LENGTH == 0) +// return ""; +// +// String history = this.history; +// +// if(history.length() > MAX_HISTORY_LENGTH) { +// +// /* +// * Truncate the history. +// */ +// +// final int len = history.length(); +// +// final int fromIndex = len - (MAX_HISTORY_LENGTH - 3); +// +// assert fromIndex > 0 : "len=" + len + ", fromIndex=" + fromIndex +// + ", maxHistoryLength=" + MAX_HISTORY_LENGTH; +// +// history = "..." + history.substring(fromIndex, len); +// +// } +// +// return history; +// +// } + + /** + * De-serialization constructor. + */ + public LocalPartitionMetadata() { + + } + + /** + * + * @param partitionId + * The unique partition identifier assigned by the + * {@link MetadataIndex}. + * @param sourcePartitionId + * <code>-1</code> unless this index partition is the target + * for a move, in which case this is the partition identifier of + * the source index partition. + * @param leftSeparatorKey + * The first key that can enter this index partition. The left + * separator key for the first index partition is always + * <code>new byte[]{}</code>. The left separator key MAY NOT + * be <code>null</code>. + * @param rightSeparatorKey + * The first key that is excluded from this index partition or + * <code>null</code> iff there is no upper bound. + * @param resources + * A description of each {@link Journal} or {@link IndexSegment} + * resource(s) required to compose a view of the index partition + * (optional). + * <p> + * The entries in the array reflect the creation time of the + * resources. The earliest resource is listed first. The most + * recently created resource is listed last. + * <p> + * Note: This is required if the {@link LocalPartitionMetadata} + * record will be saved on the {@link IndexMetadata} of a + * {@link BTree}. It is NOT recommended when it will be saved on + * the {@link IndexMetadata} of an {@link IndexSegment}. When + * the {@link IndexMetadata} is sent to a remote + * {@link DataService} this field MUST be <code>null</code> and + * the remote {@link DataService} will fill it in on arrival. + * @param cause + * The underlying cause for the creation of the index partition. + */ +// * @param history +// * A human interpretable history of the index partition. The +// * history is a series of whitespace delimited records each of +// * more or less the form <code>foo(x,y,z)</code>. The history +// * gets truncated when the {@link LocalPartitionMetadata} is +// * serialized in order to prevent it from growing without bound. + public LocalPartitionMetadata(// + final int partitionId,// + final int sourcePartitionId,// + final byte[] leftSeparatorKey,// + final byte[] rightSeparatorKey,// + final IResourceMetadata[] resources,// + final IndexPartitionCause cause +// final String history + ) { + + /* + * Set fields first so that toString() can be used in thrown exceptions. + */ + + this.partitionId = partitionId; + + this.sourcePartitionId = sourcePartitionId; + + this.leftSeparatorKey = leftSeparatorKey; + + this.rightSeparatorKey = rightSeparatorKey; + + this.resources = resources; + + this.cause = cause; + +// this.history = history; + + /* + * Test arguments. + */ + + if (leftSeparatorKey == null) + throw new IllegalArgumentException("leftSeparatorKey"); + + // Note: rightSeparatorKey MAY be null. + + if (rightSeparatorKey != null) { + + final int cmp = BytesUtil.compareBytes(leftSeparatorKey, + rightSeparatorKey); + + if (cmp >= 0) { + + throw new IllegalArgumentException("Separator keys are " + + (cmp == 0 ? "equal" : "out of order") + " : " + this); + + } + + } + + if (resources != null) { + + if (resources.length == 0) { + + throw new IllegalArgumentException("Empty resources array."); + + } + + for (IResourceMetadata t : resources) { + + if (t == null) + throw new IllegalArgumentException( + "null value in resources[]"); + + } + + /* + * This is the "live" journal. + * + * Note: The "live" journal is still available for writes. Index + * segments created off of this journal will therefore have a + * createTime that is greater than the firstCommitTime of this + * journal while being LTE to the lastCommitTime of the journal and + * strictly LT the commitTime of any other resource for this index + * partition. + */ + + if (!resources[0].isJournal()) { + + throw new RuntimeException( + "Expecting a journal as the first resource: " + this); + + } + + /* + * Scan from 1 to n-1 - these are historical resources + * (non-writable). resources[0] is always the live journal. The + * other resources may be either historical journals or index + * segments. + * + * The order of the array is the order of the view. Reads on a + * FusedView will process the resources in the order in which they + * are specified by this array. + * + * The live journal gets listed first since it can continue to + * receive writes and therefore logically comes before any other + * resource in the ordering since any writes on the live index on + * the journal will be more recent than the data on the index + * segment. + * + * Normally, each successive entry in the resources[] will have an + * earlier createTime (smaller number) than the one that follows it. + * However, there is one exception. The createTime of the live + * journal MAY be less than the createTime of index segments created + * from that journal - this will be true if those indices are + * created from a historical view found on that journal and put into + * play while the journal is still the live journal. To work around + * this we start at the 2nd entry in the array. + */ + + /* + * Note: The practice of sending and index segment generated on one + * data service to another data service introduces another way in + * which the resource timestamp order can be broken. During the next + * synchronous overflow event you can see things like this: + * + * resourceMetadata=[ + * JournalMetadata{filename=journal28417.jnl,uuid=add43d12-29b5-44e5-b26a-ae1b0694f67d,createTime=1236974533730}, + * JournalMetadata{filename=journal28409.jnl,uuid=b954caf8-431b-42ae-9453-4c009398bec2,createTime=1236974293720}, + * SegmentMetadata{filename=U8000_spo_OSP_part00050_28412.seg,uuid=cd954860-76fa-41ff-b788-e73a21b2c306,createTime=1236974525108}, + * SegmentMetadata{filename=U8000_spo_OSP_part00050_28411.seg,uuid=35840589-6fb5-4691-b271-cf660186cd4b,createTime=1236974523976} ] + * + * This is in fact well-formed. However, because the index segments + * were generated on a different host, the create times get out of + * wack. For that reason, I have disabled checking here. + */ + final boolean checkCreateTimes = false; + + if (checkCreateTimes && resources.length > 2) { + + long lastTimestamp = resources[1/*2ndEntry*/].getCreateTime(); + + for (int i = 2/* 3rd entry */; i < resources.length; i++) { + + // createTime of the resource. + final long thisTimestamp = resources[i].getCreateTime(); + + if (lastTimestamp <= thisTimestamp) { + + throw new RuntimeException( + "Resources out of timestamp order @ index=" + + i + " : "+ this); + + } + + lastTimestamp = resources[i].getCreateTime(); + + } + + } + + } + + } + + final public int getPartitionId() { + + return partitionId; + + } + + /** + * <code>-1</code> unless this index partition is the target for a move, + * in which case this is the partition identifier of the source index + * partition and the move operation has not been completed. This property is + * used to prevent the target data service from de-defining the index + * partition using a split, join or move operation while the MOVE operation + * is proceeding. The property is cleared to <code>-1</code> (which is an + * invalid index partition identifier) once the move has been completed + * successfully. + * + * @deprecated MoveTask manages without this field (it was required by the + * previous MOVE implementation). + */ + final public int getSourcePartitionId() { + + return sourcePartitionId; + + } + + final public byte[] getLeftSeparatorKey() { + + return leftSeparatorKey; + + } + + final public byte[] getRightSeparatorKey() { + + return rightSeparatorKey; + + } + + /** + * Description of the resources required to materialize a view of the index + * partition (optional, but required for a {@link BTree}). + * <p> + * The entries in the array reflect the creation time of the resources. The + * earliest resource is listed first. The most recently created resource is + * listed last. The order of the resources corresponds to the order in which + * a fused view of the index partition will be read. Reads begin with the + * most "recent" data for the index partition and stop as soon as there is a + * "hit" on one of the resources (including a hit on a deleted index entry). + * <p> + * When present, the #of sources in the index partition view includes: the + * mutable {@link BTree}, any {@link BTree}s on historical journal(s) + * still incorporated into the view, and any {@link IndexSegment}s + * incorporated into the view. + * <p> + * Note: the {@link IResourceMetadata}[] is only available when the + * {@link LocalPartitionMetadata} is attached to the {@link IndexMetadata} + * of a {@link BTree} and is NOT defined when the + * {@link LocalPartitionMetadata} is attached to an {@link IndexSegment}. + * The reason is that the index partition view is always described by the + * {@link BTree} and that view evolves as journals overflow. On the other + * hand, {@link IndexSegment}s are used as resources in index partition + * views but exist in a one to many relationship to those views. + */ + final public IResourceMetadata[] getResources() { + + return resources; + + } + + /** + * The reason why an index partition was created together with some metadata + * about when it was created. + */ + final public IndexPartitionCause getIndexPartitionCause() { + + return cause; + + } + +// /** +// * A history of the changes to the index partition. +// * +// * @deprecated I've essentially disabled the history (it is always empty +// * when it is persisted). I found it nearly impossible to read. +// * There are much saner ways to track what is going on in the +// * federation. An analysis of the {@link Event} log is much more +// * useful. If nothing else, you could examine the index +// * partition in the metadata index by scanning the commit points +// * and reading its state in each commit and reporting all state +// * changes. +// */ +// final public String getHistory() { +// +// return history; +// +// } + + final public int hashCode() { + + // per the interface contract. + return partitionId; + + } + + // Note: used by assertEquals in the test cases. + public boolean equals(final Object o) { + + if (this == o) + return true; + + final LocalPartitionMetadata o2 = (LocalPartitionMetadata) o; + + if (partitionId != o2.partitionId) + return false; + + if (!BytesUtil.bytesEqual(leftSeparatorKey, o2.leftSeparatorKey)) { + + return false; + + } + + if (rightSeparatorKey == null) { + + if (o2.rightSeparatorKey != null) + return false; + + } else { + + if (!BytesUtil.bytesEqual(rightSeparatorKey, o2.rightSeparatorKey)) { + + return false; + + } + + } + + if (resources.length != o2.resources.length) + return false; + + for (int i = 0; i < resources.length; i++) { + + if (!resources[i].equals(o2.resources[i])) + return false; + + } + + return true; + + } + + public String toString() { + + return + "{ partitionId="+partitionId+ + (sourcePartitionId!=-1?", sourcePartitionId="+sourcePartitionId:"")+ + ", leftSeparator="+BytesUtil.toString(leftSeparatorKey)+ + ", rightSeparator="+BytesUtil.toString(rightSeparatorKey)+ + ", resourceMetadata="+Arrays.toString(resources)+ + ", cause="+cause+ +// ", history="+history+ + "}" + ; + + } + + /* + * Externalizable + */ + + private static final transient short VERSION0 = 0x0; + + /** + * This version adds support for {@link IResourceMetadata#getCommitTime()}, + * but that field is only serialized for a journal. + */ + private static final transient short VERSION1 = 0x1; + + /** + * This version serializes the {@link #partitionId} as 32-bits clean and + * gets rid of the <code>history</code> field. + */ + private static final transient short VERSION2 = 0x2; + + /** + * The current version. + */ + private static final transient short VERSION = VERSION2; + + public void readExternal(final ObjectInput in) throws IOException, + ClassNotFoundException { + + final short version = ShortPacker.unpackShort(in); + + switch (version) { + case VERSION0: + case VERSION1: + case VERSION2: + break; + default: + throw new IOException("Unknown version: " + version); + } + + if (version < VERSION2) { + partitionId = (int) LongPacker.unpackLong(in); + } else { + partitionId = in.readInt(); + } + + sourcePartitionId = in.readInt(); // MAY be -1. + + final int nresources = ShortPacker.unpackShort(in); + + final int leftLen = (int) LongPacker.unpackLong(in); + + final int rightLen = (int) LongPacker.unpackLong(in); + + leftSeparatorKey = new byte[leftLen]; + + in.readFully(leftSeparatorKey); + + if (rightLen != 0) { + + rightSeparatorKey = new byte[rightLen]; + + in.readFully(rightSeparatorKey); + + } else { + + rightSeparatorKey = null; + + } + + cause = (IndexPartitionCause)in.readObject(); + + if (version < VERSION2) { + /* history = */in.readUTF(); + } + + resources = nresources>0 ? new IResourceMetadata[nresources] : null; + + for (int j = 0; j < nresources; j++) { + + final boolean isIndexSegment = in.readBoolean(); + + final String filename = in.readUTF(); + +// long nbytes = LongPacker.unpackLong(in); + + final UUID uuid = new UUID(in.readLong()/*MSB*/,in.readLong()/*LSB*/); + + final long createTime = in.readLong(); + + long commitTime = 0L; + if (version >= VERSION1 && !isIndexSegment) { + + commitTime = in.readLong(); + + } + + resources[j] = (isIndexSegment // + ? new SegmentMetadata(filename, /*nbytes,*/ uuid, createTime) // + : new JournalMetadata(filename, /*nbytes,*/ uuid, createTime, commitTime) // + ); + + } + + } + + public void writeExternal(final ObjectOutput out) throws IOException { + + ShortPacker.packShort(out, VERSION); + + if (VERSION < VERSION2) { + LongPacker.packLong(out, partitionId); + } else { + out.writeInt(partitionId); + } + + out.writeInt(sourcePartitionId); // MAY be -1. + + final int nresources = (resources == null ? 0 : resources.length); + + assert nresources < Short.MAX_VALUE; + + ShortPacker.packShort(out, (short) nresources); + + LongPacker.packLong(out, leftSeparatorKey.length); + + LongPacker.packLong(out, rightSeparatorKey == null ? 0 + : rightSeparatorKey.length); + + out.write(leftSeparatorKey); + + if (rightSeparatorKey != null) { + + out.write(rightSeparatorKey); + + } + + out.writeObject(cause); + + if (VERSION < VERSION2) { + out.writeUTF("");// getTruncatedHistory() + } + + /* + * Note: we serialize using the IResourceMetadata interface so that we + * can handle different subclasses and then special case the + * deserialization based on the boolean flag. This is significantly more + * compact than using an Externalizable for each ResourceMetadata object + * since we do not have to write the class names for those objects. + */ + + for (int j = 0; j < nresources; j++) { + + final IResourceMetadata rmd = resources[j]; + + final boolean isSegment = rmd.isIndexSegment(); + + out.writeBoolean(isSegment); + + out.writeUTF(rmd.getFile()); + +// LongPacker.packLong(out,rmd.size()); + + final UUID resourceUUID = rmd.getUUID(); + + out.writeLong(resourceUUID.getMostSignificantBits()); + + out.writeLong(resourceUUID.getLeastSignificantBits()); + + out.writeLong(rmd.getCreateTime()); + + if (!isSegment) { + + out.writeLong(rmd.getCommitTime()); + + } + + } + + } + +} Property changes on: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/LocalPartitionMetadata.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL Added: svn:eol-style + native Copied: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/MetadataIndex.java (from rev 3704, branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/mdi/MetadataIndex.java) =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/MetadataIndex.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/MetadataIndex.java 2010-10-01 15:01:16 UTC (rev 3711) @@ -0,0 +1,513 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2007. 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.btree; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.UUID; + +import com.bigdata.mdi.PartitionLocator; +import org.CognitiveWeb.extser.LongPacker; + +import com.bigdata.btree.keys.IKeyBuilderFactory; +import com.bigdata.btree.view.FusedView; +import com.bigdata.journal.ICommitter; +import com.bigdata.journal.IResourceManager; +import com.bigdata.rawstore.IRawStore; +import com.bigdata.service.MetadataService; + +/** + * A metadata index for the partitions of a distributed index. There is one + * metadata index for each distributed index. The keys of the metadata index are + * the first key that would be directed into the corresponding index segment, + * e.g., a <em>separator key</em> (this is just the standard btree semantics). + * The values are serialized {@link com.bigdata.mdi.PartitionLocator} objects. + * <p> + * Note: At this time the recommended scale-out approach for the metadata index + * is to place the metadata indices on a {@link MetadataService} (the same + * {@link MetadataService} may be used for an arbitrary #of scale-out indices) + * and to <em>replicate</em> the state for the {@link MetadataService} onto + * failover {@link MetadataService}s. Since the {@link MetadataIndex} may grow + * without bound, you simply need to have enough disk on hand for it (the size + * requirements are quite modest). Further, the {@link MetadataService} MUST NOT + * be used to hold the data for the scale-out indices themselves since the + * {@link MetadataIndex} can not undergo {@link IResourceManager#overflow()}. + * <p> + * One advantage of this approach is that the {@link MetadataIndex} is + * guaranteed to hold all historical states of the partition definitions for + * each index - effectively it is an immortal store for the partition metadata. + * On the other hand it is not possible to compact the metadata index without + * taking the database offline. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + * + * @todo The {@link MetadataIndex} does NOT support either overflow (it may NOT + * be a {@link FusedView}) NOR key-range splits. There are several issues + * involved: + * <p> + * (a) How to track the next partition identifier to be assigned to an + * index partition for the managed index. Currently this value is written + * in the {@link MetadataIndexCheckpoint} record and is propagated to the + * new backing store on overflow. However, if the metadata index is split + * into partitions then additional care MUST be taken to use only the + * value of that field on the 'meta-meta' index. + * <p> + * (b) how to locate the partitions of the metadata index itself. + * + * @todo one way to locate the metadata-index partitions is to hash partition + * the metadata index and range queries can be flooded to all partitions. + * the #of metadata service nodes can be changed by a suitable broadcast + * event in which clients have to change to the new hash basis. this + * feature can be generalized to provide hash partitioned indices as well + * as key-range partitioned indices. + * + * @todo A metadata index can be recovered by a distributed process running over + * the data services. Each data service reports all index partitions. The + * reports are collected and the index is rebuilt from the reports. Much + * like a map/reduce job. + */ +public class MetadataIndex extends BTree implements IMetadataIndex { + + /** + * Used to implement find(byte[] key). + */ + private transient final MetadataIndexView view; + + public MetadataIndexMetadata getIndexMetadata() { + + return (MetadataIndexMetadata) super.getIndexMetadata(); + + } + + public IndexMetadata getScaleOutIndexMetadata() { + + return getIndexMetadata().getManagedIndexMetadata(); + + } + + /** + * Returns the value to be assigned to the next partition created on this + * {@link MetadataIndex} and then increments the counter. The counter will + * be made restart-safe iff the index is dirty, the index is registered as + * an {@link ICommitter}, and the store on which the index is stored is + * committed. + * <p> + * Note: The metadata index uses a 32-bit partition identifier rather than + * the {@link #getCounter()}. The reason is that the {@link Counter} uses + * the partition identifier in the high word and a partition local counter + * in the low word. Therefore we have to centralize the assignment of the + * partition identifier, even when the metadata index is itself split into + * partitions. Requests for partition identifiers need to be directed to the + * root partition (L0) for the {@link MetadataIndex}. + */ + public int incrementAndGetNextPartitionId() { + + final int tmp = nextPartitionId++; + + /* + * Notify listener that the index is dirty. + */ + + fireDirtyEvent(); + + return tmp; + + } + + private int nextPartitionId; + + /** + * Create a new {@link MetadataIndex}. + * + * @param store + * The backing store. + * @param indexUUID + * The unique identifier for the metadata index. + * @param managedIndexMetadata + * The metadata template for the managed scale-out index. + */ + public static MetadataIndex create(IRawStore store, UUID indexUUID, + IndexMetadata managedIndexMetadata) { + + final MetadataIndexMetadata metadata = new MetadataIndexMetadata( + managedIndexMetadata.getName(), indexUUID, managedIndexMetadata); + + /* + * @todo the metadata index should use probably delete markers so that + * we can do compacting merges on it, but that is really moot until we + * support overflow of the metadataService and partitioning of the + * metadata index. + */ + + metadata.setDeleteMarkers(true); + + /* + * Override the implementation class. + */ + + metadata.setBTreeClassName(MetadataIndex.class.getName()); + + /* + * Override the checkpoint record implementation class. + */ + metadata.setCheckpointClassName(MetadataIndexCheckpoint.class.getName()); + + /* + * Tuple serializer. + */ + metadata.setTupleSerializer(PartitionLocatorTupleSerializer.newInstance()); + + return (MetadataIndex) BTree.create(store, metadata); + + } + + /** + * Required ctor. + * + * @param store + * @param checkpoint + * @param metadata + */ + public MetadataIndex(IRawStore store, Checkpoint checkpoint, IndexMetadata metadata, boolean readOnly) { + + super(store, checkpoint, metadata, readOnly); + + /* + * copy the initial value from the checkpoint record. + */ + + nextPartitionId = ((MetadataIndexCheckpoint)checkpoint).getNextPartitionId(); + + view = new MetadataIndexView(this); + + } + + /** + * Extended to require a checkpoint if {@link #incrementAndGetNextPartitionId()} has been + * invoked. + */ + public boolean needsCheckpoint() { + + if(nextPartitionId != ((MetadataIndexCheckpoint)getCheckpoint()).getNextPartitionId()) { + + return true; + + } + + return super.needsCheckpoint(); + ... [truncated message content] |