public class JournalDelegate extends Object implements IJournal
IJournal
delegation pattern.NULL
Constructor and Description |
---|
JournalDelegate(AbstractJournal source) |
Modifier and Type | Method and Description |
---|---|
void |
abort()
Abandon the current write set (synchronous).
|
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 |
awaitHAReady(long timeout,
TimeUnit units)
Await the service being ready to partitipate in an HA quorum.
|
void |
close()
Close the store immediately.
|
long |
commit()
Atomic commit (synchronous).
|
void |
delete(long addr)
Delete the data (unisolated).
|
void |
deleteResources()
Deletes the backing file(s) (if any).
|
void |
destroy()
Closes the store immediately (if open) and deletes its persistent
resources.
|
void |
dropIndex(String name)
Drops the named index.
|
void |
force(boolean metadata)
Force the data to stable storage.
|
int |
getByteCount(long addr)
The length of the datum in bytes.
|
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. |
ICommitRecord |
getCommitRecord(long timestamp)
Return the
ICommitRecord for the most recent committed state
whose commit timestamp is less than or equal to timestamp. |
CounterSet |
getCounters()
Return performance counters.
|
ExecutorService |
getExecutorService()
A
ExecutorService that may be used to parallelize operations. |
File |
getFile()
The backing file -or-
null if there is no backing file
for the store. |
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.
|
IIndex |
getIndex(String name)
Return the unisolated view of the named index (the mutable view of the
live index object).
|
IIndex |
getIndex(String name,
long timestamp)
Return a view of the named index as of the specified timestamp.
|
ICheckpointProtocol |
getIndexLocal(String name,
long commitTime)
Core implementation for access to historical index views.
|
InputStream |
getInputStream(long addr)
Return an input stream from which a previously written stream may be read
back.
|
long |
getLastCommitTime()
The database wide timestamp of the most recent commit on the store or 0L
iff there have been no commits.
|
ILocalTransactionManager |
getLocalTransactionManager()
Return the object providing the local transaction manager for this
journal.
|
long |
getOffset(long addr)
The offset on the store at which the datum is stored.
|
IPSOutputStream |
getOutputStream()
Return an output stream which can be used to write on the backing store.
|
long |
getPhysicalAddress(long addr)
Determine the unencoded physical address
|
Properties |
getProperties()
A copy of the properties used to initialize this journal.
|
Quorum<HAGlue,QuorumService<HAGlue>> |
getQuorum()
The
Quorum for this service -or- null if the service
is not running with a quorum. |
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.
|
IResourceMetadata |
getResourceMetadata()
A description of this store in support of the scale-out architecture.
|
long |
getRootAddr(int index)
The last address stored in the specified root slot as of the last
committed state of the store.
|
IRootBlockView |
getRootBlockView()
Return a read-only view of the current root block.
|
TemporaryStore |
getTempStore()
A factory for
TemporaryStore s. |
ICheckpointProtocol |
getUnisolatedIndex(String name)
Return the mutable view of the named persistence capable data structure
(aka the "live" or
ITx.UNISOLATED view). |
UUID |
getUUID()
|
Iterator<String> |
indexNameScan(String prefix,
long timestamp)
Iterator visits the names of all indices spanned by the given prefix.
|
boolean |
isDirty()
Return
true if the store has been modified since the last
IAtomicStore.commit() or IAtomicStore.abort() . |
boolean |
isFullyBuffered()
True iff the store is fully buffered (all reads are against memory).
|
boolean |
isGroupCommit()
Return true if the index manager supports group commit semantics.
|
boolean |
isHAJournal()
Convenience method created in BLZG-1370 to factor out bigdata-jini
artifact dependencies.
|
boolean |
isOpen()
true iff the store is open. |
boolean |
isReadOnly()
true iff the store does not allow writes. |
boolean |
isStable()
True iff backed by stable storage.
|
ByteBuffer |
read(long addr)
Read the data (unisolated).
|
ICheckpointProtocol |
register(String name,
IndexMetadata metadata)
Method creates and registers a named persistence capable data structure.
|
void |
registerIndex(IndexMetadata indexMetadata)
Register a named index.
|
IIndex |
registerIndex(String name,
BTree btree)
Register a named index.
|
IIndex |
registerIndex(String name,
IndexMetadata indexMetadata)
Register a named index.
|
void |
setCommitter(int index,
ICommitter committer)
Set a persistence capable data structure for callback during the commit
protocol.
|
void |
shutdown()
Shutdown the journal politely.
|
void |
shutdownNow()
Immediate shutdown.
|
long |
size()
The #of application data bytes written on the store (does not count any
headers or root blocks that may exist for the store).
|
long |
toAddr(int nbytes,
long offset)
Converts a byte count and offset into a long integer.
|
String |
toString(long addr)
A human readable representation of the address.
|
long |
write(ByteBuffer data)
Write the data (unisolated).
|
public JournalDelegate(AbstractJournal source)
public boolean isHAJournal()
IJournal
isHAJournal
in interface IJournal
public Properties getProperties()
IJournal
getProperties
in interface IJournal
public void shutdown()
IJournal
public void shutdownNow()
IJournal
shutdownNow
in interface IJournal
public void abort()
IAtomicStore
abort
in interface IAtomicStore
public long commit()
IAtomicStore
Note: if the commit fails (by throwing any kind of exception) then you
MUST invoke IAtomicStore.abort()
to abandon the current write set.
commit
in interface IAtomicStore
ICommitRecord
-or- 0L if
there were no data to commit.public ICommitRecord getCommitRecord(long timestamp)
IAtomicStore
ICommitRecord
for the most recent committed state
whose commit timestamp is less than or equal to timestamp. This
is used by a transaction
to locate the committed state that is
the basis for its operations.getCommitRecord
in interface IAtomicStore
timestamp
- The timestamp of interest.ICommitRecord
for the most recent committed state
whose commit timestamp is less than or equal to timestamp
-or- null
iff there are no ICommitRecord
s
that satisfy the probe.public long getRootAddr(int index)
IAtomicStore
getRootAddr
in interface IAtomicStore
index
- The index of the root address to be retrieved.public IRootBlockView getRootBlockView()
IAtomicStore
getRootBlockView
in interface IAtomicStore
public void setCommitter(int index, ICommitter committer)
IAtomicStore
Note: the committers must be reset after restart or whenever
setCommitter
in interface IAtomicStore
index
- The slot in the root block where the address of the
ICommitter
will be recorded.committer
- The committer.public void close()
IRawStore
public void delete(long addr)
IRawStore
After this operation subsequent reads on the address MAY fail and the caller MUST NOT depend on the ability to read at that address.
public void deleteResources()
IRawStore
deleteResources
in interface IRawStore
public void destroy()
IRawStore
IllegalStateException
if the store
is already closed, but still deletes the backing resources.destroy
in interface IIndexStore
destroy
in interface IRawStore
IRawStore.deleteResources()
public void force(boolean metadata)
IRawStore
public CounterSet getCounters()
ICounterSetAccess
getCounters
in interface ICounterSetAccess
public File getFile()
IRawStore
null
if there is no backing file
for the store.public IResourceMetadata getResourceMetadata()
IRawStore
getResourceMetadata
in interface IRawStore
public boolean isFullyBuffered()
IRawStore
Note: This does not guarantee that the OS will not swap the buffer onto disk.
isFullyBuffered
in interface IRawStore
public boolean isOpen()
IRawStore
true
iff the store is open.public boolean isReadOnly()
IRawStore
true
iff the store does not allow writes.isReadOnly
in interface IRawStore
public boolean isStable()
IRawStore
public ByteBuffer read(long addr)
IRawStore
read
in interface IRawStore
addr
- A long integer that encodes both the offset from which the
data will be read and the #of bytes to be read. See
IAddressManager.toAddr(int, long)
.public long size()
IRawStore
public long write(ByteBuffer data)
IRawStore
write
in interface IRawStore
data
- The data. The bytes from the current
Buffer.position()
to the
Buffer.limit()
will be written and the
Buffer.position()
will be advanced to the
Buffer.limit()
. The caller may subsequently
modify the contents of the buffer without changing the state
of the store (i.e., the data are copied into the store).IAddressManager
.public int getByteCount(long addr)
IAddressManager
IRawStore
.getByteCount
in interface IAddressManager
addr
- The opaque identifier that is the within store locator for
some datum.public long getOffset(long addr)
IAddressManager
getOffset
in interface IAddressManager
addr
- The opaque identifier that is the within store locator for
some datum.public long getPhysicalAddress(long addr)
IAddressManager
getPhysicalAddress
in interface IAddressManager
addr
- The encoded addresspublic long toAddr(int nbytes, long offset)
IAddressManager
toAddr
in interface IAddressManager
nbytes
- The byte count.offset
- The byte offset.public String toString(long addr)
IAddressManager
toString
in interface IAddressManager
addr
- The opaque identifier that is the within store locator for
some datum.public IIndex getIndex(String name)
IBTreeManager
getIndex
in interface IBTreeManager
name
- The name of the index.null
iff there
is no index registered with that name.public IIndex registerIndex(String name, BTree btree)
IBTreeManager
registerIndex
in interface IBTreeManager
name
- The name that can be used to recover the index.btree
- The btree.IBTreeManager.getIndex(String)
.IGISTManager.registerIndex(IndexMetadata)
,
IIndexManager.getIndex(String, long)
,
IGISTLocalManager.getIndexLocal(String, long)
public IIndex registerIndex(String name, IndexMetadata indexMetadata)
IBTreeManager
This variant allows you to register an index under a name other than the
value returned by IndexMetadata.getName()
.
Note: This variant is generally by the IMetadataService
when it
needs to register a index partition of some scale-out index on a
IDataService
. In this case the name is the name of the
index partition while the value reported by
IndexMetadata.getName()
is the name of the scale-out index. In
nearly all other cases you can use IGISTManager.registerIndex(IndexMetadata)
instead. The same method signature is also declared by
IDataService.registerIndex(String, IndexMetadata)
in order to
support registration of index partitions.
Note: Due to the method signature, this method CAN NOT be used to create
and register persistence capable data structures other than an
IIndex
(aka B+Tree).
registerIndex
in interface IBTreeManager
name
- The name that can be used to recover the index.indexMetadata
- The metadata describing the index.IBTreeManager.getIndex(String)
.IIndexManager.getIndex(String, long)
,
FIXME GIST Due to the method signature, this method CAN NOT be used
to create and register persistence capable data structures other
than an {@link IIndex} (aka B+Tree). It is difficult to reconcile
this method with other method signatures since this method is
designed for scale-out and relies on {@link IIndex}. However, only
the B+Tree is an {@link IIndex}. Therefore, this method signature
can not be readily reconciled with the {@link HTree}. The only
interface which the {@link BTree} and {@link HTree} share is the
{@link ICheckpointProtocol} interface, but that is a purely local
(not remote) interface and is therefore not suitable to scale-out.
Also, it is only in scale-out where the returned object can be a
different type than the simple {@link BTree} class, e.g., a
{@link FusedView} or even an {@link IClientIndex}.
public void dropIndex(String name)
IGISTManager
Note: Whether or not and when index resources are reclaimed is dependent on the store. For example, an immortal store will retain all historical states for all indices. Likewise, a store that uses index partitions may be able to delete index segments immediately.
dropIndex
in interface IGISTManager
name
- The name of the index to be dropped.public void registerIndex(IndexMetadata indexMetadata)
IGISTManager
Note: The name property MUST be set on the IndexMetadata
and the index will be registered under that name.
registerIndex
in interface IGISTManager
indexMetadata
- The metadata describing the index.IGISTLocalManager.getIndexLocal(String, long)
public ExecutorService getExecutorService()
IIndexStore
ExecutorService
that may be used to parallelize operations.
This service is automatically used when materializing located resources.
While the service does not impose concurrency controls, tasks run on this
service may submit operations to a ConcurrencyManager
.getExecutorService
in interface IIndexStore
public BigdataFileSystem getGlobalFileSystem()
IIndexStore
getGlobalFileSystem
in interface IIndexStore
BigdataFileSystem
public SparseRowStore getGlobalRowStore()
IIndexStore
SparseRowStore
used to
store named property sets.getGlobalRowStore
in interface IIndexStore
GlobalRowStoreSchema
public SparseRowStore getGlobalRowStore(long timestamp)
IIndexStore
SparseRowStore
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 IIndexStore
timestamp
- The timestamp of the view.null
if no view
exists as of that timestamp.public IIndex getIndex(String name, long timestamp)
IIndexManager
getIndex
in interface IIndexManager
name
- 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.IGISTLocalManager.getIndexLocal(String, long)
public long getLastCommitTime()
IIndexStore
This method is useful if you plan to issue a series of read-consistent requests against the most current commit point of the database.
getLastCommitTime
in interface IIndexStore
IRootBlockView.getLastCommitTime()
public IResourceLocator getResourceLocator()
IIndexStore
getResourceLocator
in interface IIndexStore
public ILocalTransactionManager getLocalTransactionManager()
IJournal
getLocalTransactionManager
in interface IJournal
public IResourceLockService getResourceLockService()
IIndexStore
getResourceLockService
in interface IIndexStore
public TemporaryStore getTempStore()
IIndexStore
TemporaryStore
s. TemporaryStore
s are
thread-safe and may be used by multiple processes at once. Old
TemporaryStore
s 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 IIndexStore
TemporaryStore
.public ScheduledFuture<?> addScheduledTask(Runnable task, long initialDelay, long delay, TimeUnit unit)
IIndexStore
addScheduledTask
in interface IIndexStore
task
- The task.initialDelay
- The initial delay.delay
- The delay between invocations.unit
- The units for the delay parameters.ScheduledFuture
for that task.public boolean getCollectPlatformStatistics()
IIndexStore
true
iff performance counters will be collected for the
platform on which the client is running.getCollectPlatformStatistics
in interface IIndexStore
public boolean getCollectQueueStatistics()
IIndexStore
true
iff statistics will be collected for work queues.getCollectQueueStatistics
in interface IIndexStore
public int getHttpdPort()
IIndexStore
getHttpdPort
in interface IIndexStore
public Iterator<String> indexNameScan(String prefix, long timestamp)
IGISTManager
indexNameScan
in interface IGISTManager
prefix
- The prefix (optional). When given, this MUST include a
.
if you want to restrict the scan to only those
indices in a given namespace. Otherwise you can find indices
in kb2
if you provide the prefix kb
where both kb and kb2 are namespaces since the indices spanned
by kb
would include both kb.xyz
and
kb2.xyx
.timestamp
- A timestamp which represents either a possible commit time on
the store or a read-only transaction identifier.public IPSOutputStream getOutputStream()
IStreamStore
IPSOutputStream
.getOutputStream
in interface IStreamStore
public InputStream getInputStream(long addr)
IStreamStore
getInputStream
in interface IStreamStore
addr
- The address at which the stream was written.public boolean isDirty()
IAtomicStore
true
if the store has been modified since the last
IAtomicStore.commit()
or IAtomicStore.abort()
.isDirty
in interface IAtomicStore
IAtomicStore.commit()
or
IAtomicStore.abort()
.public boolean isGroupCommit()
IIndexManager
isGroupCommit
in interface IIndexManager
(NSS GROUP COMMIT)
public ICheckpointProtocol register(String name, IndexMetadata metadata)
IGISTLocalManager
register
in interface IGISTLocalManager
name
- The name of the index.metadata
- The metadata that describes the data structure to be created.IGISTManager.registerIndex(IndexMetadata)
,
Checkpoint.create(IRawStore, IndexMetadata)
public ICheckpointProtocol getIndexLocal(String name, long commitTime)
IGISTLocalManager
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 index cache on the journal. If the transaction passes the startTime instead, then all startTimes will be different and the cache will be defeated.
getIndexLocal
in interface IGISTLocalManager
IIndexStore#getIndex(String, long)
,
Add
cache for access to historical index views on the Journal by name
and commitTime. ,
GIST
FIXME GIST : Reconcile with
{@link IResourceManager#getIndex(String, long)}. They are returning
types that do not overlap ({@link ICheckpointProtocol} and
{@link ILocalBTreeView}). This is blocking the support of GIST in
{@link AbstractTask}.public ICheckpointProtocol getUnisolatedIndex(String name)
IGISTLocalManager
ITx.UNISOLATED
view).
Note: IIndexManager#getIndex(String)
delegates to this method and
then casts the result to an IIndex
. This is the core
implementation to access an existing named index.
getUnisolatedIndex
in interface IGISTLocalManager
IIndexManager#getIndex(String)
,
GIST public Quorum<HAGlue,QuorumService<HAGlue>> getQuorum()
IJournal
Quorum
for this service -or- null
if the service
is not running with a quorum.public final long awaitHAReady(long timeout, TimeUnit units) throws InterruptedException, TimeoutException, AsynchronousQuorumCloseException
IJournal
#setQuorumToken(long)
commitCounter:=0
, then the root blocks from the leader have
been installed on the follower.awaitHAReady
in interface IJournal
timeout
- The timeout to await this condition.units
- The units for that timeout.InterruptedException
TimeoutException
AsynchronousQuorumCloseException
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.