|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.journal.AbstractJournal
com.bigdata.journal.Journal
public class Journal
Concrete implementation suitable for a local and unpartitioned database.
Note: This implementation does NOT not support partitioned indices. Because
all data must reside on a single journal resource there is no point to a
view. Views are designed to have data on a mixture of the live journal, one
or more historical journals, and one or more IndexSegments.
ResourceManager, which supports views.| Nested Class Summary | |
|---|---|
static interface |
Journal.Options
Options understood by the Journal. |
| Field Summary |
|---|
| Fields inherited from class com.bigdata.journal.AbstractJournal |
|---|
deleteOnClose, doubleSync, forceOnCommit, log, properties, ROOT_NAME2ADDR, tmpDir |
| Fields inherited from interface com.bigdata.rawstore.IAddressManager |
|---|
NULL |
| Constructor Summary | |
|---|---|
Journal(Properties properties)
Create or re-open a journal. |
|
| Method Summary | ||
|---|---|---|
void |
abort(long tx)
Abort a transaction. |
|
long |
commit(long tx)
Commit a transaction. |
|
Future<Journal> |
compact(File outFile)
Compacts the named indices found on this journal as of the most recent commit point, writing their view onto a new Journal. |
|
void |
deleteResources()
Deletes the backing file(s) (if any). |
|
protected void |
discardCommitters()
This method is invoked by AbstractJournal.abort() when the store must discard
any hard references that it may be holding to objects registered as
ICommitters. |
|
ConcurrencyManager |
getConcurrencyManager()
|
|
CounterSet |
getCounters()
Return counters reporting on various aspects of the journal. |
|
File |
getDataDir()
The directory in which the journal's file is located -or- null if the journal is not backed by a file. |
|
DataService |
getDataService()
The local DataService whose resources are being managed. |
|
UUID |
getDataServiceUUID()
Return the UUID of the IDataService whose resources are
being managed. |
|
ExecutorService |
getExecutorService()
Service for running arbitrary tasks in support of IResourceLocator. |
|
IBigdataFederation |
getFederation()
The federation whose resources are being managed. |
|
BigdataFileSystem |
getGlobalFileSystem()
Return the global file system used to store block-structured files and their metadata and as a source and sink for map/reduce processing. |
|
SparseRowStore |
getGlobalRowStore()
Return the global SparseRowStore used to store named property
sets. |
|
ILocalBTreeView |
getIndex(String name,
long timestamp)
Note: ITx.READ_COMMITTED views are given read-committed semantics
using a ReadCommittedView. |
|
StaleLocatorReason |
getIndexPartitionGone(String name)
Always returns null since index partition moves are not
supported. |
|
File |
getIndexSegmentFile(IndexMetadata indexMetadata)
Return the file on which a new IndexSegment should be written. |
|
AbstractBTree[] |
getIndexSources(String name,
long timestamp)
Always returns an array containing a single BTree which is the
BTree loaded from the commit record whose commit timestamp is
less than or equal to timestamp -or- null if there
are no ICommitRecords that satisify the probe or if the named
index was not registered as of that timestamp. |
|
AbstractBTree[] |
getIndexSources(String name,
long timestamp,
BTree btree)
Always returns the BTree as the sole element of the array since
partitioned indices are not supported. |
|
AbstractJournal |
getJournal(long timestamp)
Always returns this. |
|
AbstractJournal |
getLiveJournal()
Always returns this. |
|
AbstractLocalTransactionManager |
getLocalTransactionManager()
Return the object providing the AbstractLocalTransactionManager
for this journal. |
|
DefaultResourceLocator |
getResourceLocator()
Return the default locator for resources that are logical index containers (relations and relation containers). |
|
IResourceLockService |
getResourceLockService()
The service that may be used to acquire synchronous distributed locks without deadlock detection. |
|
IResourceManager |
getResourceManager()
The object used to manage local resources. |
|
TemporaryStore |
getTempStore()
A factory for TemporaryStores. |
|
File |
getTmpDir()
The directory for temporary files. |
|
ILocalTransactionManager |
getTransactionManager()
The client side of the transaction manager. |
|
WriteExecutorService |
getWriteService()
The service on which read-write tasks are executed. |
|
|
invokeAll(Collection<? extends AbstractTask<T>> tasks)
Executes the given tasks, returning a list of Futures holding their status and results when all complete. |
|
List<Future> |
invokeAll(Collection<? extends AbstractTask> tasks,
long timeout,
TimeUnit unit)
Executes the given tasks, returning a list of Futures holding their status and results when all complete or the timeout expires, whichever happens first. |
|
boolean |
isOverflowEnabled()
Note: This implementation always returns false. |
|
long |
newTx(long timestamp)
Create a new transaction on the Journal. |
|
long |
nextTimestamp()
Deprecated. This is here for historical reasons and is only used by the test suite. Use getLocalTransactionManager() and
ITimestampService.nextTimestamp(). |
|
IRawStore |
openStore(UUID uuid)
Note: This will only succeed if the uuid identifies this journal. |
|
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()
Note: This implementation always returns false. |
|
void |
shutdown()
Note: The transaction service si shutdown first, then the executorService, then the IConcurrencyManager, the
ITransactionService and finally the IResourceLockService. |
|
void |
shutdownNow()
Note: The IConcurrencyManager is shutdown first, then the
ITransactionService and finally the IResourceManager. |
|
|
submit(AbstractTask<T> task)
Submit a task (asynchronous). |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.bigdata.service.IServiceShutdown |
|---|
isOpen |
| Constructor Detail |
|---|
public Journal(Properties properties)
properties - See Options.| Method Detail |
|---|
public AbstractLocalTransactionManager getLocalTransactionManager()
AbstractJournalAbstractLocalTransactionManager
for this journal.
getLocalTransactionManager in class AbstractJournalpublic CounterSet getCounters()
AbstractJournal
getCounters in interface IConcurrencyManagergetCounters in interface IResourceManagergetCounters in interface IRawStoregetCounters in class AbstractJournalpublic File getTmpDir()
IResourceManager
getTmpDir in interface IResourceManagerpublic File getDataDir()
null if the journal is not backed by a file.
getDataDir in interface IResourceManagerpublic IRawStore openStore(UUID uuid)
openStore in interface IResourceManageruuid - The UUID identifying that store file.
IRawStore.
public AbstractBTree[] getIndexSources(String name,
long timestamp)
BTree which is the
BTree loaded from the commit record whose commit timestamp is
less than or equal to timestamp -or- null if there
are no ICommitRecords that satisify the probe or if the named
index was not registered as of that timestamp.
getIndexSources in interface IResourceManagername - timestamp -
null if the
index was not defined as of the timestamp.
UnsupportedOperationException - If the timestamp is ITx.READ_COMMITTED. You
MUST use getIndex(String, long) in order to obtain a
view that has ITx.READ_COMMITTED semantics.FusedViewpublic final AbstractJournal getLiveJournal()
getLiveJournal in interface IResourceManagerpublic final AbstractJournal getJournal(long timestamp)
getJournal in interface IResourceManagertimestamp - 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 no journal has data for that timestamp,
including when a historical journal with data for that timestamp
has been deleted.public Future<Journal> compact(File outFile)
Journal but writes after the selected
commit point WILL NOT be reflected in the output file. Typical uses are
to reduce the space required by the backing store, to improve locality in
the backing store, and to make a backup of the most recent commit point.
outFile - The file on which the new journal will be created.
Future on which you must wait
for the CompactTask to complete. The already open journal
is accessible using Future.get(). If you are backing up
data, then be sure to shutdown the returned Journal so
that it can release its resources.
public ILocalBTreeView getIndex(String name,
long timestamp)
ITx.READ_COMMITTED views are given read-committed semantics
using a ReadCommittedView. This means that they can be cached
since the view will update automatically as commits are made against
the Journal.
getIndex in interface IIndexStoregetIndex in interface IResourceManagergetIndex in class AbstractJournalname - The index name.timestamp - A positive timestamp (a possible commit time on the store).
null iff there is no index registered
with that name for that timestamp.IndexManager.getIndex(String, long)
public AbstractBTree[] getIndexSources(String name,
long timestamp,
BTree btree)
BTree as the sole element of the array since
partitioned indices are not supported.
getIndexSources in interface IResourceManagerbtree - A BTree.
BTree.public long newTx(long timestamp)
Journal.
timestamp - A positive timestamp for a historical read-only transaction as
of the first commit point LTE the given timestamp,
ITx.READ_COMMITTED for a historical read-only
transaction as of the most current commit point on the
Journal as of the moment that the transaction is
created, or ITx.UNISOLATED for a read-write
transaction.
ITransactionService.newTx(long)public void abort(long tx)
tx - The transaction identifier.ITransactionService.abort(long)
public long commit(long tx)
throws ValidationError
tx - The transaction identifier.
ValidationErrorITransactionService.commit(long)public long nextTimestamp()
getLocalTransactionManager() and
ITimestampService.nextTimestamp().
ILocalTransactionManager.
public ConcurrencyManager getConcurrencyManager()
public void shutdown()
executorService, then the IConcurrencyManager, the
ITransactionService and finally the IResourceLockService.
shutdown in interface IConcurrencyManagershutdown in interface IJournalshutdown in interface IServiceShutdownshutdown in class AbstractJournalAbstractJournal.shutdownNow()public void shutdownNow()
IConcurrencyManager is shutdown first, then the
ITransactionService and finally the IResourceManager.
shutdownNow in interface IConcurrencyManagershutdownNow in interface IJournalshutdownNow in interface IServiceShutdownshutdownNow in class AbstractJournalAbstractJournal.shutdown()public void deleteResources()
AbstractJournalNote: This is the core implementation of delete and handles event reporting.
deleteResources in interface IResourceManagerdeleteResources in interface IRawStoredeleteResources in class AbstractJournalpublic <T> Future<T> submit(AbstractTask<T> task)
IConcurrencyManager
Note: Unisolated write tasks will NOT return before the next group commit
(exceptions may be thrown if the task fails or the commit fails). The
purpose of group commits is to provide higher throughput for writes on
the store by only syncing the data to disk periodically rather than after
every write. Group commits are scheduled by the #commitService.
The trigger conditions for group commits may be configured using
ConcurrencyManager.Options. If you are using the store in a
single threaded context then you may set
Options#WRITE_SERVICE_CORE_POOL_SIZE to ONE (1) which has the
effect of triggering commit immediately after each unisolated write.
However, note that you can not sync a disk more than ~ 30-40 times per
second so your throughput in write operations per second will never
exceed that for a single-threaded application writing on a hard disk.
(Your mileage can vary if you are writing on a transient store or using a
durable medium other than disk).
Note: The isolated indices used by a read-write transaction are NOT thread-safe. Therefore a partial order is imposed over concurrent tasks for the same transaction that seek to read or write on the same index(s). Full concurrency is allowed when different transactions access the same index(s), but write-write conflicts MAY be detected during commit processing.
Note: The following exceptions MAY be wrapped by Future.get() for
tasks submitted via this method:
ValidationErrorInterruptedExceptionIConcurrencyManager.shutdown() after the timeout has expired or
IConcurrencyManager.shutdownNow(). In either of these cases the task will not be
accepted by the journal.
submit in interface IConcurrencyManagertask - The task.
Future that may be used to resolve the outcome of the
task.
public List<Future> invokeAll(Collection<? extends AbstractTask> tasks,
long timeout,
TimeUnit unit)
throws InterruptedException
IConcurrencyManager
Note: Contract is based on
ExecutorService.invokeAll(Collection, long, TimeUnit) but only
the Futures of the submitted tasks are returned.
invokeAll in interface IConcurrencyManagertasks - The tasks.
Futures of all tasks that were
submitted prior to the expiration
of the timeout.
InterruptedException - if interrupted while waiting, in which case unfinished
tasks are cancelled.
public <T> List<Future<T>> invokeAll(Collection<? extends AbstractTask<T>> tasks)
throws InterruptedException
IConcurrencyManager
Note: Contract is per ExecutorService.invokeAll(Collection)
invokeAll in interface IConcurrencyManagertasks - The tasks.
Futures.
InterruptedException - if interrupted while waiting, in which case unfinished
tasks are cancelled.public IResourceManager getResourceManager()
IConcurrencyManager
getResourceManager in interface IConcurrencyManagerpublic ILocalTransactionManager getTransactionManager()
IConcurrencyManager
getTransactionManager in interface IConcurrencyManagerpublic WriteExecutorService getWriteService()
IConcurrencyManager
getWriteService in interface IConcurrencyManagerpublic boolean shouldOverflow()
false. As a
consequence the journal capacity will simply be extended by
AbstractJournal.write(ByteBuffer) until the available disk space is exhausted.
shouldOverflow in interface IResourceManagerfalse since overflow
is NOT supported.public boolean isOverflowEnabled()
false.
isOverflowEnabled in interface IResourceManagerpublic Future<Object> overflow()
IResourceManager
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.
overflow in interface IResourceManagerFuture for the task handling post-processing of the
old journal.public File getIndexSegmentFile(IndexMetadata indexMetadata)
IResourceManagerIndexSegment should be written.
The file will exist but will have zero length.
getIndexSegmentFile in interface IResourceManagerindexMetadata - The index metadata.
UnsupportedOperationException - since overflow() is not supported.public IBigdataFederation getFederation()
IResourceManager
getFederation in interface IResourceManagerUnsupportedOperationException - always.public DataService getDataService()
IResourceManagerDataService whose resources are being managed.
getDataService in interface IResourceManagerUnsupportedOperationException - always.public UUID getDataServiceUUID()
IResourceManagerUUID of the IDataService whose resources are
being managed.
getDataServiceUUID in interface IResourceManagerUnsupportedOperationException - always.public StaleLocatorReason getIndexPartitionGone(String name)
null since index partition moves are not
supported.
getIndexPartitionGone in interface IResourceManagername - The name of an index partition.
null iff
the index partition is not known to be gone.public SparseRowStore getGlobalRowStore()
IIndexStoreSparseRowStore used to store named property
sets.
getGlobalRowStore in interface IIndexStoreGlobalRowStoreSchemapublic BigdataFileSystem getGlobalFileSystem()
IIndexStore
getGlobalFileSystem in interface IIndexStoreBigdataFileSystemprotected void discardCommitters()
AbstractJournalAbstractJournal.abort() when the store must discard
any hard references that it may be holding to objects registered as
ICommitters.
The default implementation discards the btree mapping names to named btrees.
Subclasses MAY extend this method to discard their own committers but MUST NOT override it completely.
discardCommitters in class AbstractJournalpublic TemporaryStore getTempStore()
IIndexStoreTemporaryStores. TemporaryStores are
thread-safe and may be used by multiple processes at once. Old
TemporaryStores are eventually retired by the factory and their
storage is reclaimed once they are finalized (after they are no longer in
use by any process). The decision to retire a TemporaryStore is
either made implicitly, when it is no longer weakly reachable, or
explicitly, when it has grown large enough that no new processes should
begin using that TemporaryStore. In the latter case, the
TemporaryStore will remain available to the process(es) using it
and a new TemporaryStore will be allocated and made available to
the caller.
It is important that processes do not hold a hard reference to a
TemporaryStore beyond the end of the process as that will prevent
the TemporaryStore from being finalized. Holding reference to an
AbstractBTree created on a TemporaryStore is equivalent
to holding a hard reference to the TemporaryStore itself since
the AbstractBTree holds onto the backing IRawStore using
a hard reference.
getTempStore in interface IIndexStoreTemporaryStore.public DefaultResourceLocator getResourceLocator()
IIndexStore
getResourceLocator in interface IIndexStorepublic IResourceLockService getResourceLockService()
IIndexStore
getResourceLockService in interface IIndexStorepublic ExecutorService getExecutorService()
AbstractJournalIResourceLocator. There is no concurrency control associated
with this service, but tasks run here may submit tasks to the
ConcurrencyManager.
getExecutorService in interface IIndexStoregetExecutorService in class AbstractJournal
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||