|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.service.AbstractFederation<T>
com.bigdata.service.AbstractScaleOutFederation<T>
T - The generic type of the client or service.public abstract class AbstractScaleOutFederation<T>
Abstract base class for federation implementations using the scale-out index architecture (federations that support key-range partitioned indices).
| Nested Class Summary | |
|---|---|
static class |
AbstractScaleOutFederation.ForceOverflowTask
Task forces immediate overflow of the specified data service, returning once both synchronous AND asynchronous overflow are complete. |
static class |
AbstractScaleOutFederation.PurgeResourcesTask
Task directs a DataService to purge any unused resources and to
optionally truncate the extent of the live journal. |
| Nested classes/interfaces inherited from class com.bigdata.service.AbstractFederation |
|---|
AbstractFederation.ReportTask, AbstractFederation.StartDeferredTasksTask |
| Field Summary | |
|---|---|
protected AbstractScaleOutClient.MetadataIndexCachePolicy |
metadataIndexCachePolicy
|
| Fields inherited from class com.bigdata.service.AbstractFederation |
|---|
log |
| Constructor Summary | |
|---|---|
AbstractScaleOutFederation(IBigdataClient<T> client)
|
|
| Method Summary | |
|---|---|
UUID[] |
awaitServices(int minDataServices,
long timeout)
Await the availability of an IMetadataService and the specified
minimum #of IDataServices. |
void |
forceOverflow(boolean truncateJournal)
Force overflow of each data service in the scale-out federation (only scale-out federations support overflow processing). |
ClientIndexView |
getIndex(String name,
long timestamp)
Strengthens the return type. |
protected IndexCache |
getIndexCache()
Return the cache for IIndex objects. |
IMetadataIndex |
getMetadataIndex(String name,
long timestamp)
Return a read-only view onto an IMetadataIndex. |
protected MetadataIndexCache |
getMetadataIndexCache()
Return the cache for IMetadataIndex objects. |
boolean |
isScaleOut()
Return true. |
Iterator<PartitionLocator> |
locatorScan(String name,
long timestamp,
byte[] fromKey,
byte[] toKey,
boolean reverseScan)
Returns an iterator that will visit the PartitionLocators for
the specified scale-out index key range. |
void |
shutdown()
Normal shutdown allows any existing client requests to federation services to complete but does not schedule new requests, disconnects from the federation, and then terminates any background processing that is being performed on the behalf of the client (service discovery, etc). |
void |
shutdownNow()
Immediate shutdown terminates any client requests to federation services, disconnects from the federation, and then terminate any background processing that is being performed on the behalf of the client (service discovery, etc). |
| 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.IBigdataFederation |
|---|
getAnyDataService, getDataService, getDataServiceByName, getDataServiceUUIDs, getLastCommitTime, getLoadBalancerService, getMetadataService, getTransactionService, isDistributed, isStable |
| Methods inherited from interface com.bigdata.journal.IIndexStore |
|---|
getResourceLockService |
| Field Detail |
|---|
protected final AbstractScaleOutClient.MetadataIndexCachePolicy metadataIndexCachePolicy
| Constructor Detail |
|---|
public AbstractScaleOutFederation(IBigdataClient<T> client)
client - | Method Detail |
|---|
public ClientIndexView getIndex(String name,
long timestamp)
AbstractIndexCache and strengthens the return type.
Obtain a view on a partitioned index.
getIndex in interface IIndexStoregetIndex in interface IBigdataFederation<T>getIndex in class AbstractFederation<T>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.
null if the index does not exist.public void shutdown()
AbstractFederationNote: concrete implementations MUST extend this method.
Note: Clients use IBigdataClient.disconnect(boolean) to
disconnect from a federation. The federation implements that disconnect
using either AbstractFederation.shutdown() or AbstractFederation.shutdownNow().
The implementation must be a NOP if the federation is already shutdown.
shutdown in class AbstractFederation<T>public void shutdownNow()
AbstractFederation
Note: concrete implementations MUST extend this method to either
disconnect from the remote federation or close the embedded federation
and then clear the #fed reference so that the client is no longer
"connected" to the federation.
Note: Clients use IBigdataClient.disconnect(boolean) to disconnect
from a federation. The federation implements that disconnect using either
AbstractFederation.shutdown() or AbstractFederation.shutdownNow().
The implementation must be a NOP if the federation is already shutdown.
shutdownNow in class AbstractFederation<T>
public IMetadataIndex getMetadataIndex(String name,
long timestamp)
IMetadataIndex.
name - The name of the scale-out index.timestamp - The timestamp for the view.
IMetadataIndex for the named scale-out index -or-
null iff there is no such scale-out index.There are three kinds of queries that we do against the metadata index: (1) get(key); (2) find(key); and (3) locatorScan(fromKey,toKey). The first is only used by the unit tests. The second is used when we start a locator scan, when we split a batch operation against the index partitions, and when we map an index procedure over a key range or use a key range iterator. This is the most costly of the queries, but it is also the one that is the least easy to cache. The locator scan itself is heavily buffered - a cache would only help for frequently scanned and relatively small key ranges. For this purpose, it may be better to cache the iterator result itself locally to the client (for historical reads or transactional reads).
The difficulty with caching find(key) is that we need to use the
ILinearList API to locate the appropriate index partition.
However, since it is a cache, there can be cache misses. These
would show up as a "gap" in the (leftSeparator, rightSeparator)
coverage.
If we do not cache access to the remote metadata index then we will
impose additional latency on clients, traffic on the network, and
demands on the metadata service. However, with high client
concurrency mitigates the increase in access latency to the
metadata index., Use a weak-ref cache with an LRU (or hard reference cache) to evict
cached PartitionLocator. The client needs access by {
indexName, timestamp, key }. We need to eventually evict the cached
locators to prevent the client from building up too much state
locally. Also the cached locators can not be shared across
different timestamps, so clients will build up a locator cache when
working on a transaction but then never go back to that cache once
the transaction completes.
While it may be possible to share cached locators between
historical reads and transactions for the same point in history, we
do not have enough information on hand to make those decisions.
What we would need to know is the historical commit time
corresponding to an assigned transaction startTime. This is not
one-to-one since the start times for transactions must be unique
(among those in play). See ITransactionService.newTx(long)
for more on this., cache leased information about index partitions of interest to the
client. The cache will be a little tricky since we need to know
when the client does not possess a partition definition. Index
partitions are defined by the separator key - the first key that
lies beyond that partition. the danger then is that a client will
presume that any key before the first leased partition is part of
that first partition. To guard against that the client needs to
know both the separator key that represents the upper and lower
bounds of each partition. If a lookup in the cache falls outside of
any known partitions upper and lower bounds then it is a cache miss
and we have to ask the metadata service for a lease on the
partition. the cache itself is just a btree data structure with the
proviso that some cache entries represent missing partition
definitions (aka the lower bounds for known partitions where the
left sibling partition is not known to the client).
With even a modest #of partitions, a locator scan against the MDS
will be cheaper than attempting to fill multiple "gaps" in a local
locator cache, so such a cache might be reserved for point tests.
Such point tests are used by the sparse row store for its row local
operations (vs scans) but are less common for JOINs., Just create cache view when MDI is large and then cache on demand., If the IMetadataIndex.get(byte[]) and
IMetadataIndex.find(byte[]) methods are to be invoked
remotely then we should return the byte[] rather than the
de-serialized PartitionLocator so that we don't
de-serialize them from the index only to serialize them for RMI and
then de-serialize them again on the client., the easiest way to handle a scale-out metadata index is to make it
hash-partitioned (vs range-partitioned). We can just flood queries
to the hash partitioned index. For the iterator, we have to buffer
the results and place them back into order. A fused view style
iterator could be used to merge the iterator results from each
partition into a single totally ordered iterator.
public Iterator<PartitionLocator> locatorScan(String name,
long timestamp,
byte[] fromKey,
byte[] toKey,
boolean reverseScan)
PartitionLocators for
the specified scale-out index key range.
The method fetches a chunk of locators at a time from the metadata index. Unless the #of index partitions spanned is very large, this will be an atomic read of locators from the metadata index. When the #of index partitions spanned is very large, then this will allow a chunked approach.
Note: It is possible that a split, join or move could occur during the
process of mapping the procedure across the index partitions. When the
view is ITx.UNISOLATED or ITx.READ_COMMITTED this could
make the set of mapped index partitions inconsistent in the sense that it
might double count some parts of the key range or that it might skip some
parts of the key range. In order to avoid this problem the caller MUST
use read-consistent semantics. If the ClientIndexView
is not already isolated by a transaction, then the caller MUST create a
read-only transaction use the global last commit time of the federation.
name - The name of the scale-out index.timestamp - The timestamp of the view. It is the responsibility of the
caller to choose timestamp so as to provide
read-consistent semantics for the locator scan.fromKey - The scale-out index first key that will be visited
(inclusive). When null there is no lower bound.toKey - The first scale-out index key that will NOT be visited
(exclusive). When null there is no upper bound.reverseScan - true if you need to visit the index partitions
in reverse key order (this is done when the partitioned
iterator is scanning backwards).
public final boolean isScaleOut()
true.
IndexMetadataprotected IndexCache getIndexCache()
AbstractFederationIIndex objects.
getIndexCache in class AbstractFederation<T>protected MetadataIndexCache getMetadataIndexCache()
IMetadataIndex objects.
public UUID[] awaitServices(int minDataServices,
long timeout)
throws InterruptedException,
TimeoutException
IMetadataService and the specified
minimum #of IDataServices.
minDataServices - The minimum #of data services.timeout - The timeout (ms).
UUIDs of the IDataServices
that have been discovered by this client. Note that at
least minDataServices elements will be present in this
array but that ALL discovered data services MAY be reported.
IllegalArgumentException - if minDataServices is non-positive.
IllegalArgumentException - if timeout is non-positive.
IllegalStateException - if the client is not connected to the federation.
InterruptedException - if this thread is interrupted while awaiting the availability
of the MetadataService or the specified #of
DataServices.
TimeoutException - If a timeout occurs.public void forceOverflow(boolean truncateJournal)
DataServices have
initiated and completed overflow processing. Any unused resources (as
determined by the StoreManager) will have been purged.
truncateJournal - When true, the live journal will be truncated
to its minimum extent (all writes will be preserved but there
will be no free space left in the journal). This may be used
to force the DataService to its minimum possible
footprint.MetadataService
we will have to modify this to also trigger overflow for those
services.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||