com.bigdata.service
Class MetadataService

java.lang.Object
  extended by com.bigdata.service.AbstractService
      extended by com.bigdata.service.DataService
          extended by com.bigdata.service.MetadataService
All Implemented Interfaces:
IDataService, IMetadataService, IRemoteExecutor, IService, IServiceShutdown, ISession, ITxCommitProtocol, Remote
Direct Known Subclasses:
EmbeddedMetadataService, MetadataServer.AdministrableMetadataService

public abstract class MetadataService
extends DataService
implements IMetadataService

Implementation of a metadata service for a named scale-out index.

Version:
$Id: MetadataService.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Nested Class Summary
static class MetadataService.DropScaleOutIndexTask
          Drops a scale-out index.
protected static class MetadataService.JoinIndexPartitionTask
          Updates the MetadataIndex to reflect the join of 2 or more index partitions.
protected static class MetadataService.MoveIndexPartitionTask
          Updates the MetadataIndex to reflect the move of an index partition.
protected static class MetadataService.NextPartitionIdTask
          Task assigns the next partition identifier for a registered scale-out index in a restart-safe manner.
static interface MetadataService.Options
          Options for the MetadataService.
protected static class MetadataService.RegisterScaleOutIndexTask
          Registers a metadata index for a named scale-out index and statically partition the index using the given separator keys and data services.
protected static class MetadataService.SplitIndexPartitionTask
          Atomic operation removes the pre-existing entry for specified index partition and replaces it with N new entries giving the locators for the N new index partitions created when that index partition was split.
 
Nested classes/interfaces inherited from class com.bigdata.service.DataService
DataService.DataServiceFederationDelegate, DataService.DataServiceTransactionManager, DataService.GetIndexMetadataTask, DataService.IDataServiceCounters, DataService.RangeIteratorTask, DataService.ReadBlockCounters
 
Field Summary
protected static String ERR_DELETE_MARKERS
          Error message when a request is made to register a scale-out index but delete markers are not enabled for that index.
static String METADATA_INDEX_NAMESPACE
          The namespace for the metadata indices.
 
Fields inherited from class com.bigdata.service.DataService
log
 
Constructor Summary
protected MetadataService(Properties properties)
           
 
Method Summary
 void dropScaleOutIndex(String name)
          Drop the named scale-out index.
 PartitionLocator find(String name, long timestamp, byte[] key)
          Find and return the partition spanning the given key.
 PartitionLocator get(String name, long timestamp, byte[] key)
          The partition with that separator key or null (exact match on the separator key).
static String getMetadataIndexName(String name)
          Return the name of the metadata index.
 void joinIndexPartition(String name, PartitionLocator[] oldLocators, PartitionLocator newLocator)
          Updates the MetadataIndex for the named scale-out index to reflect the join of N index partitions (which must be siblings) into a single index partition.
 void moveIndexPartition(String name, PartitionLocator oldLocator, PartitionLocator newLocator)
          Updates the MetadataIndex for the named scale-out index to reflect the move of an index partition from one data service to another.
 int nextPartitionId(String name)
          Return the next unique partition identifier to be assigned to the named scale-out index.
 UUID registerScaleOutIndex(IndexMetadata metadata, byte[][] separatorKeys, UUID[] dataServices)
          Register and statically partition a scale-out index.
 void splitIndexPartition(String name, PartitionLocator oldLocator, PartitionLocator[] newLocators)
          Updates the MetadataIndex for the named scale-out index to reflect the split of an index partition into N new index partitions.
 MetadataService start()
          Starts the DataService.
 Future<? extends Object> submit(Callable<? extends Object> task)
          Note: You SHOULD NOT be running arbitrary tasks on a MetadataService.
 
Methods inherited from class com.bigdata.service.DataService
abort, destroy, dropIndex, forceOverflow, getAsynchronousOverflowCounter, getConcurrencyManager, getHTTPDURLFile, getIndexMetadata, getIndexPartitionName, getLocalTransactionManager, getProperties, getResourceManager, getServiceIface, getSession, isOpen, isOverflowActive, newResourceManager, prepare, purgeOldResources, rangeIterator, readBlock, registerIndex, setReleaseTime, shutdown, shutdownNow, singlePhaseCommit, submit, wrapFuture
 
Methods inherited from class com.bigdata.service.AbstractService
clearLoggingContext, getFederation, getHostname, getServiceName, getServiceUUID, setServiceUUID, setupLoggingContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.bigdata.service.IDataService
dropIndex, forceOverflow, getAsynchronousOverflowCounter, getIndexMetadata, isOverflowActive, purgeOldResources, rangeIterator, readBlock, registerIndex, submit
 
Methods inherited from interface com.bigdata.service.ITxCommitProtocol
abort, prepare, setReleaseTime, singlePhaseCommit
 
Methods inherited from interface com.bigdata.service.IService
destroy, getHostname, getServiceIface, getServiceName, getServiceUUID
 

Field Detail

ERR_DELETE_MARKERS

protected static final String ERR_DELETE_MARKERS
Error message when a request is made to register a scale-out index but delete markers are not enabled for that index.

See Also:
Constant Field Values

METADATA_INDEX_NAMESPACE

public static final String METADATA_INDEX_NAMESPACE
The namespace for the metadata indices.

See Also:
Constant Field Values
Constructor Detail

MetadataService

protected MetadataService(Properties properties)
Parameters:
properties -
Method Detail

getMetadataIndexName

public static String getMetadataIndexName(String name)
Return the name of the metadata index.

Parameters:
name - The name of the scale-out index.
Returns:
The name of the corresponding MetadataIndex that is used to manage the partitions in the named scale-out index.
See Also:
DataService.getIndexPartitionName(String, int)

start

public MetadataService start()
Description copied from class: DataService
Starts the DataService.

Overrides:
start in class DataService
Returns:
this (the return type should be strengthened by the concrete implementation to return the actual type).

submit

public Future<? extends Object> submit(Callable<? extends Object> task)
Note: You SHOULD NOT be running arbitrary tasks on a MetadataService. They are specialized for the index partition locator information and SHOULD NOT be overloaded for other purposes.

Specified by:
submit in interface IDataService
Specified by:
submit in interface IRemoteExecutor
Overrides:
submit in class DataService
Returns:
The Future for that task.
Throws:
ExecutionException
InterruptedException
See Also:
AbstractDistributedFederation.getProxy(Future)

nextPartitionId

public int nextPartitionId(String name)
                    throws IOException,
                           InterruptedException,
                           ExecutionException
Description copied from interface: IMetadataService
Return the next unique partition identifier to be assigned to the named scale-out index.

Specified by:
nextPartitionId in interface IMetadataService
Parameters:
name - The name of the scale-out index.
Returns:
The next partition identifier.
Throws:
InterruptedException
ExecutionException
IOException

get

public PartitionLocator get(String name,
                            long timestamp,
                            byte[] key)
                     throws InterruptedException,
                            ExecutionException,
                            IOException
Description copied from interface: IMetadataService
The partition with that separator key or null (exact match on the separator key).

Specified by:
get in interface IMetadataService
Parameters:
name - The name of the scale-out index.
key - The separator key (the first key that would go into that partition).
Returns:
The partition with that separator key or null.
Throws:
InterruptedException
ExecutionException
IOException

find

public PartitionLocator find(String name,
                             long timestamp,
                             byte[] key)
                      throws InterruptedException,
                             ExecutionException,
                             IOException
Description copied from interface: IMetadataService
Find and return the partition spanning the given key.

Specified by:
find in interface IMetadataService
Parameters:
name - The name of the scale-out index.
key - A key of interest for the scale-out index.
Returns:
The partition spanning the given key or null if there are no partitions defined.
Throws:
InterruptedException
ExecutionException
IOException

splitIndexPartition

public void splitIndexPartition(String name,
                                PartitionLocator oldLocator,
                                PartitionLocator[] newLocators)
                         throws IOException,
                                InterruptedException,
                                ExecutionException
Description copied from interface: IMetadataService
Updates the MetadataIndex for the named scale-out index to reflect the split of an index partition into N new index partitions. The old index partition locator is removed from the MetadataIndex and the new index partition locators are inserted in a single atomic operation.

Specified by:
splitIndexPartition in interface IMetadataService
Parameters:
name - The name of the scale-out index.
oldLocator - The partition locator that is being split.
newLocators - The locator information for the new index partitions that were created by the split of the old index partition.
Throws:
IOException
InterruptedException
ExecutionException

joinIndexPartition

public void joinIndexPartition(String name,
                               PartitionLocator[] oldLocators,
                               PartitionLocator newLocator)
                        throws IOException,
                               InterruptedException,
                               ExecutionException
Description copied from interface: IMetadataService
Updates the MetadataIndex for the named scale-out index to reflect the join of N index partitions (which must be siblings) into a single index partition. The old index partition locators are removed from the MetadataIndex and the new index partition locator is inserted in a single atomic operation.

Specified by:
joinIndexPartition in interface IMetadataService
Parameters:
name - The name of the scale-out index.
oldLocators - The partition locators for the index partitions that were joined.
newLocator - The locator for the new index partition created by that join.
Throws:
IOException
InterruptedException
ExecutionException

moveIndexPartition

public void moveIndexPartition(String name,
                               PartitionLocator oldLocator,
                               PartitionLocator newLocator)
                        throws IOException,
                               InterruptedException,
                               ExecutionException
Description copied from interface: IMetadataService
Updates the MetadataIndex for the named scale-out index to reflect the move of an index partition from one data service to another. The old index partition locator is removed from the MetadataIndex and the new index partition locator is inserted in a single atomic operation.

Specified by:
moveIndexPartition in interface IMetadataService
Parameters:
name - The name of the scale-out index.
oldLocator - The partition locator for the source index partition.
newLocator - The locator for the target index partition.
Throws:
IOException
InterruptedException
ExecutionException

registerScaleOutIndex

public UUID registerScaleOutIndex(IndexMetadata metadata,
                                  byte[][] separatorKeys,
                                  UUID[] dataServices)
                           throws IOException,
                                  InterruptedException,
                                  ExecutionException
Description copied from interface: IMetadataService
Register and statically partition a scale-out index.

Specified by:
registerScaleOutIndex in interface IMetadataService
Parameters:
metadata - The metadata template describing the scale-out index, including the name to be assigned to that index.
separatorKeys - The array of separator keys. Each separator key is interpreted as an unsigned byte[]. The first entry MUST be an empty byte[]. The entries MUST be in sorted order.
Returns:
The UUID of the scale-out index.
Throws:
IOException
InterruptedException
ExecutionException
TODO:
if if exits already? (and has consistent/inconsistent metadata)?

dropScaleOutIndex

public void dropScaleOutIndex(String name)
                       throws IOException,
                              InterruptedException,
                              ExecutionException
Description copied from interface: IMetadataService
Drop the named scale-out index.

Specified by:
dropScaleOutIndex in interface IMetadataService
Parameters:
name - The name of the scale-out index.
Throws:
IOException
InterruptedException
ExecutionException


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.