com.bigdata.service
Class EmbeddedFederation<T>

java.lang.Object
  extended by com.bigdata.service.AbstractFederation<T>
      extended by com.bigdata.service.AbstractScaleOutFederation<T>
          extended by com.bigdata.service.EmbeddedFederation<T>
All Implemented Interfaces:
IIndexManager, IIndexStore, IBigdataFederation<T>, IFederationDelegate<T>

public class EmbeddedFederation<T>
extends AbstractScaleOutFederation<T>

An implementation that uses an embedded database rather than a distributed database. An embedded federation runs entirely in process, but uses the same DataService and MetadataService implementations as a distributed federation. All services reference the EmbeddedFederation and use the same thread pool for most operations. However, the EmbeddedFederation.EmbeddedDataServiceImpl has its own WriteExecutorService. Unlike a distributed federation, an embedded federation starts and stops with the client. An embedded federation may be used to assess or remove the overhead of network operations, to simplify testing of client code, or to deploy a scale-up (vs scale-out) solution.

Version:
$Id: EmbeddedFederation.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
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
protected  class EmbeddedFederation.EmbeddedDataServiceImpl
          Concrete implementation.
protected  class EmbeddedFederation.EmbeddedLoadBalancerServiceImpl
           
protected  class EmbeddedFederation.EmbeddedTransactionServiceImpl
           
 
Nested classes/interfaces inherited from class com.bigdata.service.AbstractScaleOutFederation
AbstractScaleOutFederation.ForceOverflowTask, AbstractScaleOutFederation.PurgeResourcesTask
 
Nested classes/interfaces inherited from class com.bigdata.service.AbstractFederation
AbstractFederation.ReportTask, AbstractFederation.StartDeferredTasksTask
 
Field Summary
 
Fields inherited from class com.bigdata.service.AbstractScaleOutFederation
metadataIndexCachePolicy
 
Fields inherited from class com.bigdata.service.AbstractFederation
log
 
Constructor Summary
protected EmbeddedFederation(EmbeddedClient<T> client)
          Start or restart an embedded bigdata federation.
 
Method Summary
 void destroy()
          Destroys all discovered services belonging to the federation and their persistent data and disconnects from the federation.
 IDataService getAnyDataService()
          Return ANY IDataService which has been (or could be) discovered and which is part of the connected federation.
 EmbeddedClient<T> getClient()
          Return the client object that was used to connect to the federation.
 File getDataDir()
          The directory in which the data files will reside.
 DataService getDataService(int index)
          There are getDataServiceCount() data services defined in the federation.
 IDataService getDataService(UUID serviceUUID)
          Return the (in process) data service given its service UUID.
 IDataService getDataServiceByName(String name)
          Return an IDataService joined with this IBigdataFederation and having the specified service name.
 int getDataServiceCount()
          The #of configured data services in the embedded federation.
 UUID[] getDataServiceUUIDs(int maxCount)
          Return an array UUIDs for IDataServices.
 long getLastCommitTime()
          This scans the DataServices and reports the most recent value.
 ILoadBalancerService getLoadBalancerService()
          The (in process) LoadBalancerService.
 IMetadataService getMetadataService()
          The (in process) MetadataService.
 IResourceLockService getResourceLockService()
          The (in process) IResourceLockService.
 ITransactionService getTransactionService()
          The (in process) ITransactionService.
 boolean isDistributed()
          Return false.
 boolean isStable()
          Return true iff the federation is backed by "stable" (vs transient) storage.
 boolean isTransient()
          Return true if the federation is not backed by disk.
 void shutdown()
          Normal shutdown of the services in the federation.
 void shutdownNow()
          Immediate shutdown of the services in the embedded federation.
 
Methods inherited from class com.bigdata.service.AbstractScaleOutFederation
awaitServices, forceOverflow, getIndex, getIndexCache, getMetadataIndex, getMetadataIndexCache, isScaleOut, locatorScan
 
Methods inherited from class com.bigdata.service.AbstractFederation
addScheduledTask, assertOpen, didStart, dropIndex, getCounterSet, getDataServices, getExecutorService, getGlobalFileSystem, getGlobalRowStore, getHostCounterSet, getHttpdURL, getIndexCounters, getResourceLocator, getScheduledExecutorService, getService, getServiceCounterPathPrefix, getServiceCounterPathPrefix, getServiceCounterSet, getServiceIface, getServiceName, getServiceUUID, getTaskCounters, getTempStore, isOpen, isServiceReady, newHttpd, reattachDynamicCounters, registerIndex, registerIndex, registerIndex, reportCounters, sendEvent, serviceJoin, serviceLeave
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmbeddedFederation

protected EmbeddedFederation(EmbeddedClient<T> client)
Start or restart an embedded bigdata federation.

Parameters:
client - The client.
Method Detail

getDataDir

public final File getDataDir()
The directory in which the data files will reside. Each directory is named for the service UUID - restart depends on this.


isTransient

public boolean isTransient()
Return true if the federation is not backed by disk.


getClient

public EmbeddedClient<T> getClient()
Description copied from interface: IBigdataFederation
Return the client object that was used to connect to the federation.

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

getTransactionService

public final ITransactionService getTransactionService()
The (in process) ITransactionService.

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

getResourceLockService

public final IResourceLockService getResourceLockService()
The (in process) IResourceLockService.


getLoadBalancerService

public final ILoadBalancerService getLoadBalancerService()
The (in process) LoadBalancerService.

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

getMetadataService

public final IMetadataService getMetadataService()
The (in process) MetadataService.

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

getDataService

public final IDataService getDataService(UUID serviceUUID)
Return the (in process) data service given its service UUID.

Parameters:
serviceUUID -
Returns:
The DataService for that UUID or null if there is no data service instance with that service UUID.

getDataServiceCount

public final int getDataServiceCount()
The #of configured data services in the embedded federation.


getDataService

public final DataService getDataService(int index)
There are getDataServiceCount() data services defined in the federation. This returns the data service with that index.

Parameters:
index - The index.
Returns:
The data service at that index.

getDataServiceUUIDs

public final UUID[] getDataServiceUUIDs(int maxCount)
Description copied from interface: IBigdataFederation
Return an array UUIDs for IDataServices.

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 final IDataService getAnyDataService()
Description copied from interface: IBigdataFederation
Return ANY IDataService which has been (or could be) discovered and which is part of the connected federation.

Note: This method is here as a failsafe when the ILoadBalancerService is not available.

Returns:
null if there are NO known IDataServices.

shutdown

public void shutdown()
Normal shutdown of the services in the federation.

Overrides:
shutdown in class AbstractScaleOutFederation<T>

shutdownNow

public void shutdownNow()
Immediate shutdown of the services in the embedded federation.

Overrides:
shutdownNow in class AbstractScaleOutFederation<T>

destroy

public void destroy()
Description copied from interface: IBigdataFederation
Destroys all discovered services belonging to the federation and their persistent data and disconnects from the federation.

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

isDistributed

public final boolean isDistributed()
Return false.


isStable

public final 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.


getLastCommitTime

public long getLastCommitTime()
This scans the DataServices and reports the most recent value.

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.