com.bigdata.service
Class LocalDataServiceFederation<T>

java.lang.Object
  extended by com.bigdata.service.AbstractFederation<T>
      extended by com.bigdata.service.LocalDataServiceFederation<T>
Type Parameters:
T - The generic type of the client or service.
All Implemented Interfaces:
IIndexManager, IIndexStore, IBigdataFederation<T>, IFederationDelegate<T>

public class LocalDataServiceFederation<T>
extends AbstractFederation<T>

Integration provides a view of a local DataService as if it were a federation. The LocalDataServiceFederation runs its own embedded AbstractTransactionService and LoadBalancerService to support its embedded DataService. Since there is no MetadataService, overflow processing is disabled.

Version:
$Id: LocalDataServiceFederation.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
See Also:
LocalDataServiceClient
TODO:
The EDS/LDS should use their own options in their own namespace to specify the data directory for the federation. Ditto for the "transient" or "createTempFile" properties. Everything is namespaced now and the overridden semantics of com.bigdata.journal.Options.CREATE_TEMP_FILE and StoreManager#DATA_DIR are just getting us into trouble. Look at all uses of these options in the unit tests and decouple them from the journal's options.

Nested Class Summary
static class LocalDataServiceFederation.DataServiceIndexCache
          Concrete implementation for a LocalDataServiceFederation.
 class LocalDataServiceFederation.LocalDataServiceImpl
          The embedded DataService.
 
Nested classes/interfaces inherited from class com.bigdata.service.AbstractFederation
AbstractFederation.ReportTask, AbstractFederation.StartDeferredTasksTask
 
Field Summary
 
Fields inherited from class com.bigdata.service.AbstractFederation
log
 
Constructor Summary
LocalDataServiceFederation(LocalDataServiceClient<T> client)
           
 
Method Summary
 void destroy()
          Destroys the embedded services and disconnects from the federation.
 void dropIndex(String name)
          Drop a scale-out index.
 LocalDataServiceFederation.LocalDataServiceImpl getAnyDataService()
          Returns the local IDataService.
 LocalDataServiceClient<T> getClient()
          Extended for type-safe return.
 LocalDataServiceFederation.LocalDataServiceImpl getDataService()
          Return the local DataService.
 IDataService getDataService(UUID serviceUUID)
          Returns the embedded data service IFF the given serviceUUID is the UUID for the embedded data service and null otherwise.
 IDataService getDataServiceByName(String name)
          Return an IDataService joined with this IBigdataFederation and having the specified service name.
 UUID getDataServiceUUID()
          Return the UUID that identifies the local IDataService.
 UUID[] getDataServiceUUIDs(int maxCount)
          Returns an array containing one element - the UUID of the local IDataService.
 DataServiceIndex getIndex(String name, long timestamp)
          Strengthens the return type.
protected  LocalDataServiceFederation.DataServiceIndexCache getIndexCache()
          Return the cache for IIndex objects.
 long getLastCommitTime()
          Return the last commit time for the federation (the timestamp of the most recent commit point across all IDataServices).
 ILoadBalancerService getLoadBalancerService()
          Return the load balancer service (or a proxy for that service).
 IMetadataIndex getMetadataIndex(String name, long timestamp)
          Return a read-only view of the index partitions for the named scale-out index.
 IMetadataService getMetadataService()
          Return the metadata service (or a proxy for the metadata service).
 IResourceLockService getResourceLockService()
          The service that may be used to acquire synchronous distributed locks without deadlock detection.
 ITransactionService getTransactionService()
          Return the ITransactionService (or a proxy for that service).
 boolean isDistributed()
          Return false.
 boolean isScaleOut()
          Return false.
 boolean isStable()
          Return true iff the federation is backed by "stable" (vs transient) storage.
 void registerIndex(IndexMetadata metadata)
          Registers an index that does not support scale-out.
 UUID registerIndex(IndexMetadata metadata, byte[][] separatorKeys, UUID[] dataServiceUUIDs)
          Since key-range partitioned indices are not supported this method will log a warning and register the index on the local IDataService as an unpartitioned index.
 UUID registerIndex(IndexMetadata metadata, UUID dataServiceUUID)
          Registers an index that does not support scale-out.
 void shutdown()
          Extended to shutdown the embedded services.
 void shutdownNow()
          Extended to shutdown the embedded services.
 
Methods inherited from class com.bigdata.service.AbstractFederation
addScheduledTask, assertOpen, didStart, getCounterSet, getDataServices, getExecutorService, getGlobalFileSystem, getGlobalRowStore, getHostCounterSet, getHttpdURL, getIndexCounters, getResourceLocator, getScheduledExecutorService, getService, getServiceCounterPathPrefix, getServiceCounterPathPrefix, getServiceCounterSet, getServiceIface, getServiceName, getServiceUUID, getTaskCounters, getTempStore, isOpen, isServiceReady, newHttpd, reattachDynamicCounters, reportCounters, sendEvent, serviceJoin, serviceLeave
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalDataServiceFederation

public LocalDataServiceFederation(LocalDataServiceClient<T> client)
Method Detail

getClient

public LocalDataServiceClient<T> getClient()
Extended for type-safe return.

Specified by:
getClient in interface IBigdataFederation<T>
Overrides:
getClient in class AbstractFederation<T>

getDataServiceUUIDs

public UUID[] getDataServiceUUIDs(int maxCount)
Returns an array containing one element - the UUID of the local IDataService.

Parameters:
maxCount - The maximum #of data services whose UUIDs will be returned. When zero (0) the UUID for all known data services will be returned.
Returns:
An array of UUIDs for data services.

getAnyDataService

public LocalDataServiceFederation.LocalDataServiceImpl getAnyDataService()
Returns the local IDataService.

Returns:
null if there are NO known IDataServices.

getDataService

public LocalDataServiceFederation.LocalDataServiceImpl getDataService()
Return the local DataService.


getDataServiceUUID

public UUID getDataServiceUUID()
Return the UUID that identifies the local IDataService.


registerIndex

public void registerIndex(IndexMetadata metadata)
Registers an index that does not support scale-out.

Specified by:
registerIndex in interface IIndexManager
Specified by:
registerIndex in interface IBigdataFederation<T>
Overrides:
registerIndex in class AbstractFederation<T>
Parameters:
metadata - The metadata template used to create component indices for BTrees this scale-out index (this also specifies the name of the scale-out index).

registerIndex

public UUID registerIndex(IndexMetadata metadata,
                          UUID dataServiceUUID)
Registers an index that does not support scale-out.

Specified by:
registerIndex in interface IBigdataFederation<T>
Overrides:
registerIndex in class AbstractFederation<T>
Parameters:
metadata - The metadata template used to create component indices for BTrees this scale-out index (this also specifies the name of the scale-out index).
dataServiceUUID - The data service identifier (optional). When null, a data service will be selected automatically. If IndexMetadata.Options#INITIAL_DATA_SERVICE was specified, then the identified service will be used. Otherwise an underutilized service will be selected using the ILoadBalancerService.
Returns:
The UUID of the registered index.
See Also:
IndexMetadata.Options#INITIAL_DATA_SERVICE

registerIndex

public UUID registerIndex(IndexMetadata metadata,
                          byte[][] separatorKeys,
                          UUID[] dataServiceUUIDs)
Since key-range partitioned indices are not supported this method will log a warning and register the index on the local IDataService as an unpartitioned index.

Specified by:
registerIndex in interface IBigdataFederation<T>
Overrides:
registerIndex in class AbstractFederation<T>
Parameters:
metadata - The metadata template used to create component indices for BTrees this scale-out index (this also specifies the name of the scale-out 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.
dataServiceUUIDs - The array of data services onto which each partition defined by a separator key will be mapped (optional). When given, the #of entries in this array MUST agree with the #of entries in the separatorKeys array and all entries must be non-null. When not given, the index partitions will be auto-assigned to the discovered data services.
Returns:
The UUID of the scale-out index.

getIndexCache

protected LocalDataServiceFederation.DataServiceIndexCache getIndexCache()
Description copied from class: AbstractFederation
Return the cache for IIndex objects.

Specified by:
getIndexCache in class AbstractFederation<T>

dropIndex

public void dropIndex(String name)
Description copied from interface: IBigdataFederation
Drop a scale-out index.

Specified by:
dropIndex in interface IIndexManager
Specified by:
dropIndex in interface IBigdataFederation<T>
Overrides:
dropIndex in class AbstractFederation<T>
Parameters:
name - The index name.

getIndex

public DataServiceIndex getIndex(String name,
                                 long timestamp)
Strengthens the return type.

Specified by:
getIndex in interface IIndexStore
Specified by:
getIndex in interface IBigdataFederation<T>
Overrides:
getIndex in class AbstractFederation<T>
Parameters:
name - The index name.
timestamp - A transaction identifier, ITx.UNISOLATED for the unisolated index view, ITx.READ_COMMITTED, or timestamp for a historical view no later than the specified timestamp.
Returns:
The index or null if the index does not exist.

getMetadataService

public IMetadataService getMetadataService()
Description copied from interface: IBigdataFederation
Return the metadata service (or a proxy for the metadata service).

Returns:
The service -or- null if the service has not been discovered.
Throws:
UnsupportedOperationException - always since the metadata index is not used.

getMetadataIndex

public IMetadataIndex getMetadataIndex(String name,
                                       long timestamp)
Description copied from interface: IBigdataFederation
Return a read-only view of the index partitions for the named scale-out index.

Parameters:
name - The name of the scale-out index.
Returns:
The IMetadataIndex for the named scale-out index -or- null iff there is no such scale-out index.
Throws:
UnsupportedOperationException - always

getLoadBalancerService

public ILoadBalancerService getLoadBalancerService()
Description copied from interface: IBigdataFederation
Return the load balancer service (or a proxy for that service).

Returns:
The service -or- null if the service has not been discovered.

getTransactionService

public ITransactionService getTransactionService()
Description copied from interface: IBigdataFederation
Return the ITransactionService (or a proxy for that service).

Returns:
The service -or- null if the service has not been discovered.

getResourceLockService

public IResourceLockService getResourceLockService()
Description copied from interface: IIndexStore
The service that may be used to acquire synchronous distributed locks without deadlock detection.


getDataService

public IDataService getDataService(UUID serviceUUID)
Returns the embedded data service IFF the given serviceUUID is the UUID for the embedded data service and null otherwise.

Parameters:
serviceUUID - The identifier for a IDataService.
Returns:
The IDataService or null iff the IDataService could not be discovered from its identifier.

isScaleOut

public boolean isScaleOut()
Return false.

See Also:
IndexMetadata

isDistributed

public boolean isDistributed()
Return false.


isStable

public boolean isStable()
Description copied from interface: IBigdataFederation
Return true iff the federation is backed by "stable" (vs transient) storage. Most federation deployments are stable in this sense, but it is possible to create federation instances backed solely by transient storage and those instances will report false here. This is most typically done for testing purposes using a LocalDataServiceFederation or an EmbeddedFederation.


shutdown

public void shutdown()
Extended to shutdown the embedded services.

Overrides:
shutdown in class AbstractFederation<T>

shutdownNow

public void shutdownNow()
Extended to shutdown the embedded services.

Overrides:
shutdownNow in class AbstractFederation<T>

destroy

public void destroy()
Destroys the embedded services and disconnects from the federation.

Specified by:
destroy in interface IIndexStore
Specified by:
destroy in interface IBigdataFederation<T>
Overrides:
destroy in class AbstractFederation<T>

getLastCommitTime

public long getLastCommitTime()
Description copied from interface: IBigdataFederation
Return the last commit time for the federation (the timestamp of the most recent commit point across all IDataServices).

This is useful for ITx.READ_COMMITTED operations that need to use a consistent timestamp across a series of DataServices or a series of requests against a single DataService that must use a consistent view.

Returns:
The timestamp of the most recent commit on the store or 0L iff there have been no commits.
See Also:
IRootBlockView.getLastCommitTime()

getDataServiceByName

public IDataService getDataServiceByName(String name)
Description copied from interface: IBigdataFederation
Return an IDataService joined with this IBigdataFederation and having the specified service name. Services that are not joined will not be discovered.

Note: At least some service fabrics (such as jini) do not enforce a uniqueness constraint on the service name(s). In such cases an arbitrary IDataService method the other requirements will be returned. It is the responsibility of the administrator to ensure that each IDataService is assigned a distinct service name.

Parameters:
name - The service name.
Returns:
A service assigned that name -or- null if none is joined with the IBigdataFederation at this time.


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