com.bigdata.journal
Interface IResourceManager

All Superinterfaces:
IServiceShutdown
All Known Implementing Classes:
IndexManager, Journal, OverflowManager, ResourceManager, StoreManager

public interface IResourceManager
extends IServiceShutdown

Interface manging the resources on which indices are stored. The resources may be either a journal, which contains BTrees, or an IndexSegmentStore containing a single IndexSegment.

Note: For historical reasons there are two implementations of this interface. The Journal uses an implementation that does not support overflow() since the managed "journal" is always the actual Journal reference. The ResourceManager supports overflow() and decouples the management of the journal and index segment resources and the concurrency control from the journal itself.

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

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.bigdata.service.IServiceShutdown
IServiceShutdown.Options
 
Method Summary
 void deleteResources()
          Deletes all resources.
 CounterSet getCounters()
          Statistics about the IResourceManager.
 File getDataDir()
          The directory for managed resources.
 DataService getDataService()
          The local DataService whose resources are being managed.
 UUID getDataServiceUUID()
          Return the UUID of the IDataService whose resources are being managed.
 IBigdataFederation getFederation()
          The federation whose resources are being managed.
 ILocalBTreeView getIndex(String name, long timestamp)
          Return a view of the named index as of the specified timestamp.
 StaleLocatorReason getIndexPartitionGone(String name)
          Return non-null iff name is the name of an ITx.UNISOLATED index partition that was located on the associated DataService but which is now gone.
 File getIndexSegmentFile(IndexMetadata indexMetadata)
          Return the file on which a new IndexSegment should be written.
 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.
 AbstractJournal getJournal(long timestamp)
          Return the reference to the journal which has the most current data for the given timestamp.
 AbstractJournal getLiveJournal()
          The journal on which writes are made.
 File getTmpDir()
          The directory for temporary files.
 boolean isOverflowEnabled()
          true if overflow processing is enabled and false if overflow processing was disabled as a configuration option, in which case overflow processing can not be performed.
 IRawStore openStore(UUID uuid)
          Opens an IRawStore.
 Future<Object> overflow()
          Overflow processing creates a new journal, migrates the named indices on the current journal the new journal, and continues operations on the new journal.
 boolean shouldOverflow()
          Return true if the pre-conditions for overflow of the live journal have been met.
 
Methods inherited from interface com.bigdata.service.IServiceShutdown
isOpen, shutdown, shutdownNow
 

Method Detail

getTmpDir

File getTmpDir()
The directory for temporary files.


getDataDir

File getDataDir()
The directory for managed resources.


getLiveJournal

AbstractJournal getLiveJournal()
The journal on which writes are made. This is updated by overflow().


getJournal

AbstractJournal getJournal(long timestamp)
Return the reference to the journal which has the most current data for the given timestamp. If necessary, the journal will be opened.

Parameters:
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 corresponding journal for that timestamp -or- null if no journal has data for that timestamp, including when a historical journal with data for that timestamp has been deleted.

openStore

IRawStore openStore(UUID uuid)
Opens an IRawStore.

Parameters:
uuid - The UUID identifying that store file.
Returns:
The open IRawStore.
Throws:
RuntimeException - if something goes wrong.

getIndexSources

AbstractBTree[] getIndexSources(String name,
                                long timestamp)
Return the ordered AbstractBTree sources for an index or a view of an index partition. The AbstractBTrees 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.

Parameters:
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.
Returns:
The sources for the index view or null if the index was not defined as of the timestamp.
See Also:
FusedView

getIndexSources

AbstractBTree[] getIndexSources(String name,
                                long timestamp,
                                BTree btree)
Examine the partition metadata (if any) for the 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.

Parameters:
btree - A BTree.
Returns:
The source(s) for the view associated with that BTree.

getIndex

ILocalBTreeView getIndex(String name,
                         long timestamp)
Return a view of the named index as of the specified timestamp.

Note: An index view loaded from a historical timestamp (vs the live unisolated index view) will always be read-only.

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 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.
Throws:
IllegalArgumentException - if name is null
StaleLocatorException - if the named index does not exist at the time the operation is executed and the IResourceManager has information which indicates that the index partition has been split, joined or moved.
See Also:
IIndexStore.getIndex(String, long)

getIndexPartitionGone

StaleLocatorReason getIndexPartitionGone(String name)
Return non-null iff name is the name of an ITx.UNISOLATED index partition that was located on the associated DataService but which is now gone.

Parameters:
name - The name of an index partition.
Returns:
The reason (split, join, or move) -or- null iff the index partition is not known to be gone.

getCounters

CounterSet getCounters()
Statistics about the IResourceManager.


shouldOverflow

boolean shouldOverflow()
Return true if the pre-conditions for overflow of the live journal have been met. In general, this means that the live journal is within some threshold of the configured Options.MAXIMUM_EXTENT.

Returns:
true if overflow processing should occur.

isOverflowEnabled

boolean isOverflowEnabled()
true if overflow processing is enabled and false if overflow processing was disabled as a configuration option, in which case overflow processing can not be performed.


overflow

Future<Object> overflow()
Overflow processing creates a new journal, migrates the named indices on the current journal the new journal, and continues operations on the new journal. Typically this involves updating the view of the named indices such that they read from a fused view of an empty index on the new journal and the last committed state of the index on the old journal.

Note: When this method returns true journal references MUST NOT be presumed to survive this method. In particular, the old journal MAY be closed out by this method and marked as read-only henceforth.

Note: The caller MUST ensure that they have an exclusive lock on the WriteExecutorService such that no task is running with write access to the live journal.

Note: The implementation MUST NOT write on the old journal - those writes will not be made restart safe by the WriteExecutorService - but it MAY write on the new journal.

Returns:
The Future for the task handling post-processing of the old journal.

deleteResources

void deleteResources()
Deletes all resources.

Throws:
IllegalStateException - if the IResourceManager is open.

getIndexSegmentFile

File getIndexSegmentFile(IndexMetadata indexMetadata)
Return the file on which a new IndexSegment should be written. The file will exist but will have zero length.

Parameters:
indexMetadata - The index metadata.
Returns:
The file.

getDataServiceUUID

UUID getDataServiceUUID()
Return the UUID of the IDataService whose resources are being managed.


getDataService

DataService getDataService()
The local DataService whose resources are being managed.

Throws:
UnsupportedOperationException - if the IResourceManager is not part of an IBigdataFederation.

getFederation

IBigdataFederation getFederation()
The federation whose resources are being managed.

Throws:
UnsupportedOperationException - if the IResourceManager is not part of an IBigdataFederation.


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