public class MemStrategy extends Object implements IBufferStrategy, IRWStrategy, IAllocationManagerStore
IMemoryManager.NULL| Constructor and Description |
|---|
MemStrategy(IMemoryManager mmgr) |
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
A method that requires the implementation to discard its buffered write
set (if any).
|
void |
abortContext(IAllocationContext context)
Indicates that the allocation context will no longer be used and that the
allocations made within the context should be discarded.
|
int |
checkDeferredFrees(AbstractJournal abstractJournal)
This method is invoked during the commit protocol and gives the backing
store an opportunity to check whether storage associated with deferred
frees can now be released.
|
void |
close()
Close the store immediately.
|
void |
closeForWrites()
Seals the store against further writes and discards any write caches
since they will no longer be used.
|
void |
commit()
A method that removes assumptions of how a specific strategy commits
data.
|
void |
delete(long addr)
Delete the data (unisolated).
|
void |
delete(long addr,
IAllocationContext context)
Delete the data associated with the address within the allocation
context.
|
void |
deleteResources()
Deletes the backing file(s) (if any).
|
void |
destroy()
Closes the store immediately (if open) and deletes its persistent
resources.
|
void |
detachContext(IAllocationContext context)
Indicates that the allocation context will no longer be used, but that
the allocations made within the context should be preserved.
|
void |
force(boolean metadata)
Force the data to stable storage.
|
IAddressManager |
getAddressManager() |
BufferMode |
getBufferMode()
The buffer mode supported by the implementation
|
int |
getByteCount(long addr)
The length of the datum in bytes.
|
Lock |
getCommitLock()
Optionally return a
Lock that must be used (when non-
null) to make the IBufferStrategy.commit() /
IRWStrategy.postCommit() strategy atomic. |
CounterSet |
getCounters()
Return the performance counter hierarchy.
|
long |
getExtent()
The current size of the journal in bytes.
|
File |
getFile()
The backing file -or-
null if there is no backing file
for the store. |
int |
getHeaderSize()
The size of the journal header, including MAGIC, version, and both root
blocks.
|
long |
getInitialExtent()
The initial extent.
|
InputStream |
getInputStream(long addr)
Return an input stream from which a previously written stream may be read
back.
|
long |
getLastReleaseTime()
If history is retained this returns the time for which data was most
recently released.
|
long |
getMaximumExtent()
The maximum extent allowable before a buffer overflow operation will be
rejected.
|
int |
getMaxRecordSize() |
long |
getMetaBitsAddr()
The RWStrategy requires meta allocation info in the root block, this
method is the hook to enable access.
|
long |
getMetaStartAddr()
The RWStrategy requires meta allocation info in the root block, this
method is the hook to enable access.
|
long |
getNextOffset()
The next offset at which a data item would be written on the store as an
offset into the user extent.
|
long |
getOffset(long addr)
The offset on the store at which the datum is stored.
|
int |
getOffsetBits() |
IPSOutputStream |
getOutputStream()
Return an output stream which can be used to write on the backing store.
|
IPSOutputStream |
getOutputStream(IAllocationContext context)
Return an output stream which can be used to write on the backing store
within the given allocation context.
|
long |
getPhysicalAddress(long addr)
Determine the unencoded physical address
|
IResourceMetadata |
getResourceMetadata()
A description of this store in support of the scale-out architecture.
|
IMemoryManager |
getStore()
Return the backing
IStore. |
long |
getUserExtent()
The size of the user data extent in bytes.
|
UUID |
getUUID()
|
boolean |
isCommitted(long addr)
Return
true iff the allocation having that address is
flagged as committed. |
boolean |
isDirty()
Return
true if the store has been modified since the last
IBufferStrategy.commit() or IBufferStrategy.abort(). |
boolean |
isFullyBuffered()
True iff the store is fully buffered (all reads are against memory).
|
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.
|
IAllocationContext |
newAllocationContext(boolean isolated)
Creates a context to be used to isolate updates to within the context until it
is released to the parent environment.
|
IRawTx |
newTx()
A hook used to support session protection by incrementing and
decrementing a transaction counter within the
IStore. |
void |
postCommit()
Called post commit to dispose any transient commit state retained to
support reset/rollback.
|
ByteBuffer |
read(long addr)
Read the data (unisolated).
|
ByteBuffer |
readRootBlock(boolean rootBlock0)
Read the specified root block from the backing file.
|
void |
registerExternalCache(ConcurrentWeakValueCache<Long,ICommitter> historicalIndexCache,
int byteCount)
Call made from AbstractJournal to register the cache used.
|
boolean |
requiresCommit(IRootBlockView block)
A method that removes assumptions of how a specific strategy determines
whether a transaction commit is required.
|
long |
saveDeferrals()
Saves the current list of delete blocks, returning the address allocated.
|
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 |
transferTo(RandomAccessFile out)
A block operation that transfers the serialized records (aka the written
on portion of the user extent) en mass from the buffer onto an output
file.
|
void |
truncate(long extent)
Either truncates or extends the journal.
|
boolean |
useChecksums()
Return
true if the store uses per-record checksums. |
long |
write(ByteBuffer data)
Write the data (unisolated).
|
long |
write(ByteBuffer data,
IAllocationContext context)
FIXME There are two unit tests for the
MemStore which are failing
due to this method not being implemented. |
void |
writeRootBlock(IRootBlockView rootBlock,
ForceEnum forceOnCommitEnum)
Write the root block onto stable storage (ie, flush it through to disk).
|
public MemStrategy(IMemoryManager mmgr)
public IMemoryManager getStore()
IRWStrategyIStore.getStore in interface IRWStrategypublic void abort()
IBufferStrategyabort in interface IBufferStrategypublic void closeForWrites()
IBufferStrategycloseForWrites in interface IBufferStrategypublic void commit()
IBufferStrategycommit in interface IBufferStrategypublic Lock getCommitLock()
IRWStrategyLock that must be used (when non-
null) to make the IBufferStrategy.commit() /
IRWStrategy.postCommit() strategy atomic.getCommitLock in interface IRWStrategypublic void postCommit()
IRWStrategy
Note: It is the responsibility of the commit protocol layers to wind up
calling IBufferStrategy.abort() if there is a failure during the
commit protocol.
postCommit in interface IRWStrategypublic IAddressManager getAddressManager()
getAddressManager in interface IBufferStrategypublic BufferMode getBufferMode()
IBufferStrategygetBufferMode in interface IBufferStrategypublic CounterSet getCounters()
IBufferStrategygetCounters in interface ICounterSetAccessgetCounters in interface IBufferStrategypublic long getExtent()
IBufferStrategyOptions.INITIAL_EXTENT.getExtent in interface IBufferStrategypublic int getHeaderSize()
IBufferStrategygetHeaderSize in interface IBufferStrategypublic long getInitialExtent()
IBufferStrategygetInitialExtent in interface IBufferStrategypublic int getMaxRecordSize()
getMaxRecordSize in interface IBufferStrategypublic long getMaximumExtent()
IBufferStrategy
Note: The semantics here differ from those defined by
Options.MAXIMUM_EXTENT. The latter specifies the threshold at
which a journal will overflow (onto another journal) while this specifies
the maximum size to which a buffer is allowed to grow.
Note: This is normally zero (0L), which basically means that
the maximum extent is ignored by the IBufferStrategy but
respected by the AbstractJournal, resulting in a soft limit
on journal overflow.
getMaximumExtent in interface IBufferStrategy0L
iff no limit is imposed.public long getMetaBitsAddr()
IBufferStrategygetMetaBitsAddr in interface IBufferStrategypublic long getMetaStartAddr()
IBufferStrategygetMetaStartAddr in interface IBufferStrategypublic long getNextOffset()
IBufferStrategygetNextOffset in interface IBufferStrategypublic int getOffsetBits()
getOffsetBits in interface IBufferStrategypublic long getUserExtent()
IBufferStrategy
Note: The size of the user extent is always generally smaller than the
value reported by IBufferStrategy.getExtent() since the latter also reports the
space allocated to the journal header and root blocks.
getUserExtent in interface IBufferStrategypublic ByteBuffer readRootBlock(boolean rootBlock0)
IBufferStrategyreadRootBlock in interface IBufferStrategypublic boolean requiresCommit(IRootBlockView block)
IBufferStrategyrequiresCommit in interface IBufferStrategyblock - The root block held by the client, can be checked against the
state of the Buffer Strategypublic long transferTo(RandomAccessFile out) throws IOException
IBufferStrategyNote: Implementations of this method MUST be synchronized so that the operation is atomic with respect to concurrent writers.
transferTo in interface IBufferStrategyout - The file to which the buffer contents will be transferred.IOExceptionpublic void truncate(long extent)
IBufferStrategyNote: Implementations of this method MUST be synchronized so that the operation is atomic with respect to concurrent writers.
truncate in interface IBufferStrategyextent - The new extent of the journal. This value represent the total
extent of the journal, including any root blocks together with
the user extent.public boolean useChecksums()
IBufferStrategytrue if the store uses per-record checksums. When
true, an additional 4 bytes are written after the record on
the disk. Those bytes contain the checksum of the record.useChecksums in interface IBufferStrategypublic void writeRootBlock(IRootBlockView rootBlock, ForceEnum forceOnCommitEnum)
IBufferStrategywriteRootBlock in interface IBufferStrategyrootBlock - The root block. Which root block is indicated by
IRootBlockView.isRootBlock0().public void close()
IRawStorepublic void delete(long addr)
IRawStoreAfter 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()
IRawStoredeleteResources in interface IRawStorepublic void destroy()
IRawStoreIllegalStateException if the store
is already closed, but still deletes the backing resources.destroy in interface IRawStoreIRawStore.deleteResources()public void force(boolean metadata)
IRawStorepublic File getFile()
IRawStorenull if there is no backing file
for the store.public IResourceMetadata getResourceMetadata()
IRawStoregetResourceMetadata in interface IRawStorepublic boolean isFullyBuffered()
IRawStoreNote: This does not guarantee that the OS will not swap the buffer onto disk.
isFullyBuffered in interface IRawStorepublic boolean isOpen()
IRawStoretrue iff the store is open.public boolean isReadOnly()
IRawStoretrue iff the store does not allow writes.isReadOnly in interface IRawStorepublic boolean isStable()
IRawStorepublic ByteBuffer read(long addr)
IRawStoreread in interface IRawStoreaddr - 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()
IRawStorepublic long write(ByteBuffer data)
IRawStorewrite in interface IRawStoredata - 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)
IAddressManagerIRawStore.getByteCount in interface IAddressManageraddr - The opaque identifier that is the within store locator for
some datum.public long getOffset(long addr)
IAddressManagergetOffset in interface IAddressManageraddr - The opaque identifier that is the within store locator for
some datum.public long getPhysicalAddress(long addr)
IAddressManagergetPhysicalAddress in interface IAddressManageraddr - The encoded addresspublic long toAddr(int nbytes,
long offset)
IAddressManagertoAddr in interface IAddressManagernbytes - The byte count.offset - The byte offset.public String toString(long addr)
IAddressManagertoString in interface IAddressManageraddr - The opaque identifier that is the within store locator for
some datum.public IRawTx newTx()
IHistoryManagerIStore. As long as
a transaction is active we can not release data which is currently marked
as freed but was committed at the point the session started.newTx in interface IHistoryManagerpublic void abortContext(IAllocationContext context)
IAllocationManagerabortContext in interface IAllocationManagercontext - The application object which serves as the allocation context.public void detachContext(IAllocationContext context)
IAllocationManagerIStore is the top-level parent of
allocation contexts. The allocators associated with the allocation
context are return to the global list of available allocators.detachContext in interface IAllocationManagercontext - The application object which serves as the allocation context.public int checkDeferredFrees(AbstractJournal abstractJournal)
IHistoryManagercheckDeferredFrees in interface IHistoryManagerAbstractJournal#commitNow()public void delete(long addr,
IAllocationContext context)
IAllocationManagerStoredelete in interface IAllocationManagerStoreaddr - The address whose allocation is to be deleted.context - The allocation context.public long getLastReleaseTime()
IHistoryManagergetLastReleaseTime in interface IHistoryManagerpublic void registerExternalCache(ConcurrentWeakValueCache<Long,ICommitter> historicalIndexCache, int byteCount)
IHistoryManagerNote: It is not safe to clear at the point of the delete request since the data could still be loaded if the data is retained for a period due to a non-zero retention period or session protection.
registerExternalCache in interface IHistoryManagerpublic long saveDeferrals()
IHistoryManagerWrites the content of currentTxnFreeList to the store.
These are the current buffered frees that have yet been saved into a block referenced from the deferredFreeList
saveDeferrals in interface IHistoryManagerDeleteBlockCommitterpublic long write(ByteBuffer data, IAllocationContext context)
MemStore which are failing
due to this method not being implemented. Those methods are using an
abstract task within an isolated action journal context.write in interface IAllocationManagerStoredata - The data.context - The allocation context.public boolean isCommitted(long addr)
IRWStrategytrue iff the allocation having that address is
flagged as committed. The caller must be holding the allocation lock in
order for the result to remain valid outside of the method call.isCommitted in interface IRWStrategyaddr - The address.true iff the address is currently committed.public InputStream getInputStream(long addr)
IStreamStoregetInputStream in interface IStreamStoreaddr - The address at which the stream was written.public IPSOutputStream getOutputStream()
IStreamStoreIPSOutputStream.getOutputStream in interface IStreamStorepublic IPSOutputStream getOutputStream(IAllocationContext context)
IAllocationManagerStoreIPSOutputStream.getOutputStream in interface IAllocationManagerStorecontext - The context within which any allocations are made by the
returned IPSOutputStream.public boolean isDirty()
IBufferStrategytrue if the store has been modified since the last
IBufferStrategy.commit() or IBufferStrategy.abort().isDirty in interface IBufferStrategyIBufferStrategy.commit() or
IBufferStrategy.abort().public IAllocationContext newAllocationContext(boolean isolated)
IAllocationManagernewAllocationContext in interface IAllocationManagerCopyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.