|
||||||||||
| 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.IJournalCounters
Interface defines and documents the counters and counter namespaces reported by the Journal and the various services which it uses. |
static interface |
Journal.Options
Options understood by the Journal. |
| Nested classes/interfaces inherited from class com.bigdata.journal.AbstractJournal |
|---|
AbstractJournal.BasicHA |
| Field Summary |
|---|
| Fields inherited from class com.bigdata.journal.AbstractJournal |
|---|
DELETEBLOCK, deleteOnClose, doubleSync, forceOnCommit, PREV_ROOTBLOCK, properties, ROOT_ICUVERSION, ROOT_NAME2ADDR, tmpDir |
| Fields inherited from interface com.bigdata.rawstore.IAddressManager |
|---|
NULL |
| Constructor Summary | |
|---|---|
Journal(Properties properties)
Create or re-open a journal. |
|
Journal(Properties properties,
Quorum<HAGlue,QuorumService<HAGlue>> quorum)
|
|
| Method Summary | ||
|---|---|---|
protected void |
_close()
Core implementation of immediate shutdown handles event reporting. |
|
void |
abort(long tx)
Abort a transaction. |
|
void |
acquireUnisolatedConnection()
Acquire a permit for the UNISOLATED connection. |
|
ScheduledFuture<?> |
addScheduledTask(Runnable task,
long initialDelay,
long delay,
TimeUnit unit)
Adds a task which will run until canceled, until it throws an exception, or until the service is shutdown. |
|
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. |
|
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. |
|
void |
dropIndex(String name)
Drops the named index. |
|
boolean |
getCollectPlatformStatistics()
true iff performance counters will be collected for the
platform on which the client is running. |
|
boolean |
getCollectQueueStatistics()
true iff statistics will be collected for work queues. |
|
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 an unisolated view of the global SparseRowStore used to
store named property sets. |
|
SparseRowStore |
getGlobalRowStore(long timestamp)
Return a view of the global SparseRowStore used to store named
property sets as of the specified timestamp. |
|
int |
getHttpdPort()
The port on which the optional httpd service will be run. |
|
String |
getHttpdURL()
The URL that may be used to access the httpd service exposed by this client -or- null if not enabled. |
|
ILocalBTreeView |
getIndex(String name,
long timestamp)
Return a view of the named index as of the specified timestamp. |
|
BTreeCounters |
getIndexCounters(String name)
Return the BTreeCounters for the named index. |
|
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 satisfy 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 local transaction manager for this journal. |
|
LatchedExecutor |
getReadExecutor()
An executor service used to read on the local disk. |
|
IResourceLocator<?> |
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. |
|
ITransactionService |
getTransactionService()
|
|
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. |
|
protected AbstractLocalTransactionManager |
newLocalTransactionManager()
|
|
protected IResourceLocator<?> |
newResourceLocator()
Factory for the IResourceLocator for the Journal. |
|
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. |
|
void |
releaseUnisolatedConnection()
Release the permit for the UNISOLATED connection. |
|
boolean |
shouldOverflow()
Note: This implementation always returns false. |
|
void |
shutdown()
Note: The transaction service is 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.journal.IResourceManager |
|---|
deleteResources |
| Methods inherited from interface com.bigdata.service.IServiceShutdown |
|---|
isOpen |
| Constructor Detail |
|---|
public Journal(Properties properties)
properties - See Options.
public Journal(Properties properties,
Quorum<HAGlue,QuorumService<HAGlue>> quorum)
| Method Detail |
|---|
protected IResourceLocator<?> newResourceLocator()
IResourceLocator for the Journal.
protected AbstractLocalTransactionManager newLocalTransactionManager()
public AbstractLocalTransactionManager getLocalTransactionManager()
IJournal
getLocalTransactionManager in interface IJournalpublic CounterSet getCounters()
Overridden to attach additional performance counters.
getCounters in interface ICounterSetAccessgetCounters in interface IConcurrencyManagergetCounters in interface IResourceManagergetCounters 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 satisfy 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 void dropIndex(String name)
AbstractJournal
dropIndex in interface IIndexManagerdropIndex in class AbstractJournalname - The name of the index to be dropped.
public ILocalBTreeView getIndex(String name,
long timestamp)
Note: Transactions should pass in the timestamp against which they are
reading rather than the transaction identifier (aka startTime). By
providing the timestamp of the commit point, the transaction will hit the
AbstractJournal.indexCache. If the transaction passes the startTime instead,
then all startTimes will be different and the cache will be defeated.
Note: 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 timestamp which represents either a possible commit time on
the store or a read-only transaction identifier.
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()protected void _close()
Overridden to close the TemporaryStoreFactory.
_close 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 ITransactionService getTransactionService()
public 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 SparseRowStore getGlobalRowStore(long timestamp)
IIndexStoreSparseRowStore used to store named
property sets as of the specified timestamp.
The SparseRowStore only permits ITx.UNISOLATED writes, so
you MUST specify ITx.UNISOLATED as the timestamp if you intend to
write on the global row store!
You can request the most recent committed state of the global row store
by specifying ITx.READ_COMMITTED.
getGlobalRowStore in interface IIndexStoretimestamp - The timestamp of the view.
null if no view
exists as of that timestamp.public 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 IResourceLocator<?> 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 AbstractJournalpublic final String getHttpdURL()
null if not enabled.
public LatchedExecutor getReadExecutor()
IResourceManager, and
use it to do all IO, ideally using the JSR 166 fork/join
mechanisms.
This should be reconciled with the ConcurrencyManager,
which has distinct ExecutorServices for readers and writers
which control the per-task concurrency while this controls the disk
read concurrency.
We could use the same pool for readers and writers on the disk.
public ScheduledFuture<?> addScheduledTask(Runnable task,
long initialDelay,
long delay,
TimeUnit unit)
IIndexStore
addScheduledTask in interface IIndexStoretask - The task.initialDelay - The initial delay.delay - The delay between invocations.unit - The units for the delay parameters.
ScheduledFuture for that task.public final boolean getCollectPlatformStatistics()
true iff performance counters will be collected for the
platform on which the client is running.
getCollectPlatformStatistics in interface IIndexStoreJournal.Options.COLLECT_PLATFORM_STATISTICSpublic final boolean getCollectQueueStatistics()
true iff statistics will be collected for work queues.
getCollectQueueStatistics in interface IIndexStoreJournal.Options.COLLECT_QUEUE_STATISTICSpublic final int getHttpdPort()
getHttpdPort in interface IIndexStoreJournal.Options.HTTPD_PORTpublic BTreeCounters getIndexCounters(String name)
IResourceManagerBTreeCounters 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.
getIndexCounters in interface IResourceManagername - The name of the index.
null.
public void acquireUnisolatedConnection()
throws InterruptedException
InterruptedExceptionpublic void releaseUnisolatedConnection()
IllegalStateException - unless the #of permits available is zero.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||