public abstract class IndexManager extends StoreManager
ResourceManager
.Modifier and Type | Class and Description |
---|---|
static interface |
IndexManager.IIndexManagerCounters
Performance counters for the
IndexManager . |
static class |
IndexManager.IndexSegmentStats
Statistics about the
IndexSegment s open in the cache. |
static interface |
IndexManager.Options
Options understood by the
IndexManager . |
StoreManager.IStoreManagerCounters, StoreManager.ManagedJournal
Modifier and Type | Field and Description |
---|---|
protected ConcurrentHashMap<File,IndexSegmentBuilder> |
buildTasks
A map containing the concurrently executing index segment build tasks.
|
protected AtomicInteger |
concurrentBuildTaskCount
The #of build tasks which are executing concurrently.
|
protected AtomicInteger |
concurrentMergeTaskCount
The #of merge tasks which are executing concurrently.
|
protected LRUCache<String,StaleLocatorReason> |
staleLocatorCache
This cache is used to provide remote clients with an unambiguous
indication that an index partition has been rather than simply not
existing or having been dropped.
|
accelerateOverflowThreshold, bytesDeleted, bytesUnderManagement, dataDir, indexCacheLock, journalBytesUnderManagement, journalDeleteCount, journalReopenCount, journalsDir, lastCommitTimePreserved, lastOverflowTime, liveJournalRef, maximumJournalSizeAtOverflow, purgeResourcesMillis, segmentBytesUnderManagement, segmentsDir, segmentStoreDeleteCount, segmentStoreReopenCount, storeCache, tmpDir
Modifier | Constructor and Description |
---|---|
protected |
IndexManager(Properties properties) |
Modifier and Type | Method and Description |
---|---|
BuildResult |
buildIndexSegment(String indexPartitionName,
ILocalBTreeView src,
boolean compactingMerge,
long commitTime,
byte[] fromKey,
byte[] toKey,
Event parentEvent)
Build an
IndexSegment from an index partition. |
void |
disableWrites(String name)
Declare that the named index will no longer accept writes (transient
effect only).
|
void |
enableWrites(String name)
Declare that the named index will accept writes (default).
|
ILocalBTreeView |
getIndex(String name,
long timestamp)
Return a view of the named index as of the specified timestamp.
|
int |
getIndexCacheCapacity()
The configured capacity of the index cache.
|
int |
getIndexCacheSize()
The #of entries in the hard reference cache for
IIndex s. |
CounterSet |
getIndexCounters()
Return a
CounterSet reflecting use of the named indices. |
BTreeCounters |
getIndexCounters(String name)
Return the
BTreeCounters for the named index. |
AbstractBTree |
getIndexOnStore(String name,
long timestamp,
IRawStore store)
Return a reference to the named index as of the specified timestamp on
the identified resource.
|
StaleLocatorReason |
getIndexPartitionGone(String name)
Note: this information is based on an LRU cache with a large fixed
capacity.
|
protected long |
getIndexRetentionTime()
The earliest timestamp that MUST be retained for the read-historical
indices in the cache and
Long.MAX_VALUE if there are NO
read-historical indices in the cache. |
int |
getIndexSegmentCacheCapacity()
The configured capacity of the index segment cache.
|
int |
getIndexSegmentCacheSize()
The #of entries in the hard reference cache for
IndexSegment s. |
AbstractBTree[] |
getIndexSources(String name,
long timestamp)
Return the ordered
AbstractBTree sources for an index or a view
of an index partition. |
AbstractBTree[] |
getIndexSources(String name,
long timestamp,
BTree btree)
Examine the partition metadata (if any) for the
BTree . |
protected int |
getStaleLocatorCount()
The #of entries in the stale locator LRU.
|
boolean |
isDisabledWrites(String name)
Return
true if writes have been disabled for the named
index. |
String |
listIndexPartitions(long timestamp)
Dump index metadata as of the timestamp.
|
protected Map<String,BTreeCounters> |
markAndGetDelta()
Snapshots the index partition performance counters and returns a map
containing the net change in the performance counters for each index
partition since the last time this method was invoked (it is invoked by
IResourceManager.overflow() ). |
protected void |
setIndexPartitionGone(String name,
StaleLocatorReason reason)
Notify the
ResourceManager that the named index partition was
split, joined or moved. |
addResource, assertNotOpen, assertOpen, assertRunning, awaitRunning, deleteResource, deleteResources, getBytesUnderManagement, getCommitTimeStrictlyGreaterThan, getConcurrencyManager, getDataDir, getDataDirFreeSpace, getIndexSegmentFile, getIndexSegmentFile, getJournal, getJournalBytesUnderManagement, getLiveJournal, getManagedJournalCount, getManagedSegmentCount, getProperties, getReleaseTime, getResourceService, getResourcesForTimestamp, getSegmentBytesUnderManagement, getStoreCacheSize, getStoreCounters, getTempDirFreeSpace, getTmpDir, isOpen, isRunning, isStarting, isTransient, munge, newFileFilter, nextTimestamp, openStore, overrideJournalExtent, purgeOldResources, purgeOldResources, retentionSetAdd, retentionSetRemove, setConcurrencyManager, setReleaseTime, shutdown, shutdownNow
closeJournal, closeTx, closeUnisolatedIndex, deleteJournal, dropUnisolatedIndex, extendJournal, isolateIndex, openJournal, openTx, openUnisolatedIndex
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCounters, getDataService, getDataServiceUUID, getFederation, isOverflowEnabled, overflow, shouldOverflow
protected final LRUCache<String,StaleLocatorReason> staleLocatorCache
The keys are the name of an index partitions that has been split, joined, or moved. Such index partitions are no longer available and have been replaced by one or more new index partitions (having a distinct partition identifier) either on the same or on another data service. The value is a reason, e.g., "split", "join", or "move".
protected final ConcurrentHashMap<File,IndexSegmentBuilder> buildTasks
protected final AtomicInteger concurrentBuildTaskCount
protected final AtomicInteger concurrentMergeTaskCount
protected IndexManager(Properties properties)
public void disableWrites(String name)
public void enableWrites(String name)
public boolean isDisabledWrites(String name)
true
if writes have been disabled for the named
index.name
- The index name.true
if writes are disabled for that index.protected long getIndexRetentionTime()
Long.MAX_VALUE
if there are NO
read-historical indices in the cache.getIndexRetentionTime
in class StoreManager
StoreManager.indexCacheLock
public int getIndexCacheSize()
public int getIndexCacheCapacity()
public int getIndexSegmentCacheSize()
IndexSegment
s.
There MAY be more IndexSegment
s open than are reported by this
method if there are hard references held by the application to those
IndexSegment
s. IndexSegment
s that are not fixed by a
hard reference will be quickly finalized by the JVM.public int getIndexSegmentCacheCapacity()
public StaleLocatorReason getIndexPartitionGone(String name)
NoSuchIndexException
instead.name
- The name of an index partition.null
iff
the index partition is not known to be gone.protected void setIndexPartitionGone(String name, StaleLocatorReason reason)
ResourceManager
that the named index partition was
split, joined or moved. This effects only the unisolated view of that
index partition. Historical views will continue to exist and reside as
before.name
- The name of the index partition.reason
- The reason (split, join, or move).
FIXME Should also include "deleted" and handle case where a scale-out
index is deleted and then re-created so that we don't get the
StaleLocatorException
after the recreate.protected int getStaleLocatorCount()
public AbstractBTree getIndexOnStore(String name, long timestamp, IRawStore store)
Note: AbstractTask
handles the load of the ITx.UNISOLATED
index from the live journal in such a manner as to provide ACID semantics
for add/drop of indices.
Note: The returned index is NOT isolated. Isolation is handled by the
Tx
.
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.store
- The store from which the index will be loaded.null
if the index
was not registered on the resource as of the timestamp or if the
store has no data for that timestamp.public AbstractBTree[] getIndexSources(String name, long timestamp)
IResourceManager
AbstractBTree
sources for an index or a view
of an index partition. The AbstractBTree
s are ordered from the
most recent to the oldest and together comprise a coherent view of an
index partition.
Note: Index sources loaded from a historical timestamp (vs the live unisolated index view) will always be read-only.
name
- The name of the index.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 was not defined as of the timestamp.FusedView
public AbstractBTree[] getIndexSources(String name, long timestamp, BTree btree)
IResourceManager
BTree
. If the
BTree
is part of an index partition, then return all of the
sources for a view of that index partition (the BTree
will be the
first element in the array and, if there are no more sources for the
index partition, then it will also be the sole element of the array).
Otherwise return an array consisting of a single element, which is the
BTree
.public ILocalBTreeView getIndex(String name, long timestamp)
Note: An index view loaded from a historical timestamp (vs the live unisolated index view) will always be read-only.
Note: An ITx.READ_COMMITTED
view returned by this method WILL NOT
update if there are intervening commits. This decision was made based on
the fact that views are requested from the IndexManager
by an
AbstractTask
running on the ConcurrencyManager
. Such
tasks, and hence such views, have a relatively short life. However, the
Journal
implementation of this method is different and will
return a ReadCommittedView
precisely because objects are directly
requested from a Journal
by the application and the application
can hold onto a read-committed view for an arbitrary length of time. This
has the pragmatic effect of allowing us to cache read-committed views in
the application and in the IBigdataClient
. For the
IBigdataClient
, the view acquires its read-committed semantics
because an IClientIndex
generates AbstractTask
(s) for
each IIndex
operation and submits those task(s) to the
appropriate IDataService
(s) for evaluation. The
IDataService
will resolve the index using this method, and it
will always see the then-current read-committed view and the
IClientIndex
will appear to have read-committed semantics.
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
iff there is no index registered
with that name for that timestamp, including if the
timestamp is a transaction identifier and the transaction is
unknown or not active.Journal.getIndex(String, long)
public String listIndexPartitions(long timestamp)
timestamp
- IllegalArgumentException
- if timestamp is positive (a transaction identifier).IllegalStateException
- if the live journal is closed when this method is invoked.RuntimeException
- if the live journal is closed asynchronously while this
method is running.public BuildResult buildIndexSegment(String indexPartitionName, ILocalBTreeView src, boolean compactingMerge, long commitTime, byte[] fromKey, byte[] toKey, Event parentEvent) throws Exception
IndexSegment
from an index partition. Delete markers are
propagated to the IndexSegment
unless compactingMerge is
true
.
Note: IndexSegment
s are registered with the StoreManager
by this method but are also placed into a hard reference collection (the
retentionSet) in order to prevent their being released before
they are put to use by incorporating them into an index partition view.
The caller MUST remove the IndexSegment
from that hard reference
collection once the index has been incorporated into an index partition
view or is no longer required (e.g., has been MOVEd). However, the caller
MUST NOT remove the IndexSegment
from the hard reference
collection until after the commit point for the task which incorporates it
into the index partition view. In practice, this means that those tasks
must be encapsulated with either a post-condition action or wrapped by a
caller which provides the necessary after-action in a finally{} clause.
indexPartitionName
- The name of the index partition (not the name of the scale-out
index).src
- A view of the index partition as of the createTime.
This may be a partial view of comprised from only the first N
sources in the view, in which case compactingMerge := false.compactingMerge
- When true
the caller asserts that src
is a FusedView
and deleted index entries WILL NOT be
included in the generated IndexSegment
. Otherwise, it
is assumed that the only select component(s) of the index
partition view are being exported onto an IndexSegment
and deleted index entries will therefore be propagated to the
new IndexSegment
.commitTime
- The commit time associated with the view from which the
IndexSegment
is being generated. This value is written
into IndexSegmentCheckpoint.commitTime
.fromKey
- The lowest key that will be included (inclusive). When null
there is no lower bound.toKey
- The first key that will not be included (exclusive). When
null
there is no upper bound.BuildResult
identifying the new IndexSegment
and the source index.Exception
- if any errors are encountered then the file (if it exists)
will be deleted as a side-effect before returning control to
the caller.StoreManager.purgeOldResources(long, boolean)
public BTreeCounters getIndexCounters(String name)
IResourceManager
BTreeCounters
for the named index. If none exist, then
a new instance is atomically created and returned to the caller. This
facilitates the reuse of the same BTreeCounters
instance for all
views of the named index.name
- The name of the index.null
.protected Map<String,BTreeCounters> markAndGetDelta()
IResourceManager.overflow()
).
Note: This method has a side effect of setting a new mark. It SHOULD NOT be used except at overflow since the "mark" is used to determine the net change in the per-index partition performance counters. If used other than at overflow the net change will be under-reported.
public CounterSet getIndexCounters()
CounterSet
reflecting use of the named indices. When an
index partition is in use, its CounterSet
is reported under a
path formed from name of the scale-out index and partition identifier.CounterSet
reflecting the use of the named indices.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.