public abstract class AbstractPersistenceManager.AbstractPersistentStore extends Base implements com.oracle.coherence.persistence.PersistentStore<ReadBuffer>
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractPersistenceManager.AbstractPersistentStore.BatchTask
Runnable implementation that is used to perform and commit a
sequence of mutating persistent store operations asynchronously.
|
protected class |
AbstractPersistenceManager.AbstractPersistentStore.DeleteExtentTask
A Task implementation that deletes an extent from the associated
store.
|
protected class |
AbstractPersistenceManager.AbstractPersistentStore.OpenTask
An OpenTask opens the store (parent of this inner class) with the
provided store and notifies the Collector when complete.
|
Base.LoggingWriter, Base.StackFrame
Modifier and Type | Field and Description |
---|---|
protected File |
f_dirStore
The directory used to store persisted data.
|
protected File |
f_fileLock
The file used to prevent concurrent access to the data directory
underlying this persistent store.
|
protected ReadWriteLock |
f_lock
The ReadWriteLock used to protect against concurrent read/write
operations.
|
protected Set<Long> |
f_setDeletedIds
The set of extent identifiers that are in the process of being
deleted.
|
protected Set<Long> |
f_setExtentIds
The set of valid extent identifiers known to this persistent store.
|
protected String |
f_sId
The identifier of this persistent store.
|
protected FileLock |
m_lockFile
The FileLock used to prevent concurrent access to the data
directory underlying this persistent store.
|
protected int |
m_nState
The state of the PersistenceStore.
|
Constructor and Description |
---|
AbstractPersistentStore(String sId)
Create a new AbstractPersistentStore with the given identifier.
|
Modifier and Type | Method and Description |
---|---|
void |
abort(Object oToken)
Abort an atomic sequence of mutating operations.
|
protected abstract void |
abortInternal(Object oToken)
Abort an atomic sequence of mutating operations.
|
Object |
begin()
Begin a new sequence of mutating operations that should be committed
to the store as an atomic unit.
|
Object |
begin(com.oracle.coherence.common.base.Collector<Object> collector,
Object oReceipt)
Begin a new sequence of mutating operations that should be committed
to the store asynchronously as an atomic unit.
|
protected abstract Object |
beginInternal()
Begin a sequence of mutating operations that should be committed
atomically and return a token that represents the atomic unit.
|
void |
commit(Object oToken)
Commit a sequence of mutating operations represented by the given
token as an atomic unit.
|
protected abstract void |
commitInternal(Object oToken)
Commit a sequence of mutating operations represented by the given
token as an atomic unit.
|
protected void |
copyAndOpenInternal(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> storeFrom)
Copy the provided store to ensure both the contents are available
in the new store and it is open thus ready to receive requests.
|
protected abstract void |
createExtentInternal(long lExtentId)
Create the extent with the given identifier in the persistent
store.
|
protected boolean |
delete(boolean fSafe)
Release any resources held by this persistent store and delete any
underlying persistent storage.
|
void |
deleteExtent(long lExtentId)
Delete the specified extent from the persistent store, ensuring that
any key-value mappings associated with the extent are no longer valid.
|
protected abstract void |
deleteExtentInternal(long lExtentId)
Delete the specified extent from the persistent store.
|
protected abstract boolean |
deleteInternal()
Remove the underlying persistent storage.
|
boolean |
ensureExtent(long lExtentId)
Ensure that an extent with the given identifier exists in the
persistent store, returning true iff the extent was created.
|
protected boolean |
ensureExtentInternal(long lExtentId)
Ensure the provided extent id has been registered and created, thus
allowing subsequent load and store operations against the same extent
id.
|
protected com.oracle.coherence.persistence.PersistenceException |
ensurePersistenceException(Throwable eCause)
Return a PersistenceException with the given cause.
|
protected com.oracle.coherence.persistence.PersistenceException |
ensurePersistenceException(Throwable eCause,
String sMessage)
Return a PersistenceException with the given cause and detail
message.
|
protected void |
ensureReady()
Block the calling thread until the store is either ready to accept
requests or the store has been closed.
|
void |
erase(long lExtentId,
ReadBuffer bufKey,
Object oToken)
Remove the specified key from the underlying store if present.
|
protected abstract void |
eraseInternal(long lExtentId,
ReadBuffer bufKey,
Object oToken)
Remove the specified key from the underlying persistent storage
if present.
|
AutoCloseable |
exclusively()
Suggest to this PersistentStore that the caller requires exclusive access
to this store until
close is called on the
returned AutoCloseable . |
long[] |
extents()
Return a list of the extent identifiers in the underlying store.
|
File |
getDataDirectory()
The directory used to store persisted data.
|
String |
getId()
Return the identifier of this store.
|
protected AutoCloseable |
instantiateExclusiveClosable()
Return an
AutoCloseable that will transition this PersistentStore
out of exclusive mode. |
protected boolean |
isClosed()
Return true if the store has been closed.
|
protected boolean |
isExclusive()
Return true if this store is in exclusive mode.
|
protected boolean |
isReady()
Return true if the store is ready to accept requests.
|
void |
iterate(com.oracle.coherence.persistence.PersistentStore.Visitor<ReadBuffer> visitor)
Iterate the key-value pairs in the persistent store, applying the
specified visitor to each key-value pair.
|
protected abstract void |
iterateInternal(com.oracle.coherence.persistence.PersistentStore.Visitor<ReadBuffer> visitor)
Iterate the key-value pairs in the underlying persistent storage,
applying the specified visitor to each key-value pair.
|
ReadBuffer |
load(long lExtentId,
ReadBuffer bufKey)
Return the value associated with the specified key, or null if the key
does not have an associated value in the underlying store.
|
protected abstract void |
loadExtentIdsInternal(Set<Long> setIds)
Populate the given set with the identifiers of extents in the
underlying persistent storage.
|
protected abstract ReadBuffer |
loadInternal(long lExtentId,
ReadBuffer bufKey)
Load and return the value associated with the specified key from
the underlying persistent storage.
|
protected void |
lockRead()
Acquire a read lock on this persistent store.
|
protected boolean |
lockStorage()
Acquire an exclusive lock on the data directory underlying this
persistent store.
|
protected void |
lockWrite()
Acquire a write lock on this persistent store.
|
void |
moveExtent(long lOldExtentId,
long lNewExtentId)
Move the specified extent from the old extent id to the new extent id.
|
protected void |
moveExtentInternal(long lOldExtentId,
long lNewExtentId)
Move the specified extent from the old extent id to the new extent id.
|
protected boolean |
open(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> storeFrom)
Open this persistent store.
|
protected abstract void |
openInternal()
Open the underlying persistent storage.
|
protected void |
release()
Release any resources held by this persistent store.
|
protected abstract void |
releaseInternal()
Release the underlying persistent storage.
|
protected void |
setState(int nState)
Set the state of this store.
|
void |
store(long lExtentId,
ReadBuffer bufKey,
ReadBuffer bufValue,
Object oToken)
Store the specified value under the specific key in the underlying
store.
|
protected abstract void |
storeInternal(long lExtentId,
ReadBuffer bufKey,
ReadBuffer bufValue,
Object oToken)
Store the specified value under the specific key in the underlying
persistent storage.
|
protected void |
submitOpen(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> storeFrom,
com.oracle.coherence.common.base.Collector<Object> collector)
Open this store either asynchronously, iff both a store to open
from and a collector have been provided, or synchronously.
|
String |
toString()
Return a human readable description of this AbstractPersistentStore.
|
void |
truncateExtent(long lExtentId)
Truncate the specified extent from the persistent store, ensuring that
any key-value mappings associated with the extent are removed.
|
protected abstract void |
truncateExtentInternal(long lExtentId)
Truncate the specified extent from the persistent store.
|
protected void |
unlockRead()
Release a read lock on this persistent store.
|
protected void |
unlockStorage()
Release an exclusive lock on the data directory underlying this
persistent store.
|
protected void |
unlockWrite()
Release a write lock on this persistent store.
|
protected void |
validateExtentId(long lExtentId)
Validate the given extent identifier.
|
protected void |
validateMetadata()
Validate the metadata
|
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
protected final String f_sId
protected final File f_dirStore
protected final File f_fileLock
protected volatile int m_nState
protected FileLock m_lockFile
protected final ReadWriteLock f_lock
protected final Set<Long> f_setExtentIds
public AbstractPersistentStore(String sId)
sId
- the identifier for the new storeIllegalArgumentException
- if the identifier is invalidpublic String getId()
getId
in interface com.oracle.coherence.persistence.PersistentStore<ReadBuffer>
public boolean ensureExtent(long lExtentId)
ensureExtent
in interface com.oracle.coherence.persistence.PersistentStore<ReadBuffer>
lExtentId
- the identifier of the extent to ensurepublic void deleteExtent(long lExtentId)
Removal of the key-value mappings associated with the extent from the underlying storage is the responsibility of the implementation, and may (for example) be performed immediately, asynchronously, or deferred until space is required.
deleteExtent
in interface com.oracle.coherence.persistence.PersistentStore<ReadBuffer>
lExtentId
- the identifier of the extent to deletepublic void moveExtent(long lOldExtentId, long lNewExtentId)
Upon control being returned the implementation guarantees that any data
data that used to reside against the old extent id is accessible from
new extent id using the load
API. In addition,
calls to store
are permitted
immediately after control is returned.
moveExtent
in interface com.oracle.coherence.persistence.PersistentStore<ReadBuffer>
lOldExtentId
- the old extent identifierlNewExtentId
- the new extent identifierpublic void truncateExtent(long lExtentId)
Removal of the key-value mappings associated with the extent from the underlying storage is the responsibility of the implementation, and may (for example) be performed immediately, asynchronously, or deferred until space is required.
truncateExtent
in interface com.oracle.coherence.persistence.PersistentStore<ReadBuffer>
lExtentId
- the identifier of the extent to truncatepublic long[] extents()
extents
in interface com.oracle.coherence.persistence.PersistentStore<ReadBuffer>
public AutoCloseable exclusively()
com.oracle.coherence.persistence.PersistentStore
close
is called on the
returned AutoCloseable
.
Note: the caller must call close
on
the returned object
exclusively
in interface com.oracle.coherence.persistence.PersistentStore<ReadBuffer>
AutoCloseable
object that requires close to be
called on it when exclusive access is no longer neededpublic ReadBuffer load(long lExtentId, ReadBuffer bufKey)
load
in interface com.oracle.coherence.persistence.PersistentStore<ReadBuffer>
lExtentId
- the extent identifier for the keybufKey
- key whose associated value is to be returnedpublic void store(long lExtentId, ReadBuffer bufKey, ReadBuffer bufValue, Object oToken)
store
in interface com.oracle.coherence.persistence.PersistentStore<ReadBuffer>
lExtentId
- the extent identifier for the key-value pairbufKey
- key to store the value underbufValue
- value to be storedoToken
- optional token that represents a set of mutating
operations to be committed as an atomic unit; if
null, the given key-value pair will be committed to
the store automatically by this methodpublic void erase(long lExtentId, ReadBuffer bufKey, Object oToken)
erase
in interface com.oracle.coherence.persistence.PersistentStore<ReadBuffer>
lExtentId
- the extent identifier for the keybufKey
- key whose mapping is to be removedoToken
- optional token that represents a set of mutating
operations to be committed as an atomic unit; if
null, the removal of the given key will be committed
to the store automatically by this methodpublic void iterate(com.oracle.coherence.persistence.PersistentStore.Visitor<ReadBuffer> visitor)
iterate
in interface com.oracle.coherence.persistence.PersistentStore<ReadBuffer>
visitor
- the visitor to applypublic Object begin()
committed
to the store or the atomic unit must
be aborted
.begin
in interface com.oracle.coherence.persistence.PersistentStore<ReadBuffer>
public Object begin(com.oracle.coherence.common.base.Collector<Object> collector, Object oReceipt)
committed
to the store or the
atomic unit must be aborted
.
If a collector is passed to this method, the specified receipt will be
added to it when the unit is committed. If the operation is aborted
or an error occurs during the commit, an AsyncPersistenceException
that wraps the cause and
specified receipt will be added. Finally, the collector will be flushed.
begin
in interface com.oracle.coherence.persistence.PersistentStore<ReadBuffer>
collector
- an optional collectoroReceipt
- a receipt to be added to the collector (if any) when
the unit is committedpublic void commit(Object oToken)
commit
in interface com.oracle.coherence.persistence.PersistentStore<ReadBuffer>
oToken
- a token that represents the atomic unit to commitpublic void abort(Object oToken)
abort
in interface com.oracle.coherence.persistence.PersistentStore<ReadBuffer>
oToken
- a token that represents the atomic unit to abortprotected void submitOpen(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> storeFrom, com.oracle.coherence.common.base.Collector<Object> collector)
storeFrom
- a PersistentStore
to copy fromcollector
- a collector
to notify when the
open completesprotected boolean open(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> storeFrom)
storeFrom
- the PersistenceStore the new store should be based uponprotected void release()
protected boolean delete(boolean fSafe)
fSafe
- if true, remove the store by moving it to a restorable
location (if possible) rather than deleting itprotected void ensureReady()
com.oracle.coherence.persistence.PersistenceException
- if the store has been closed or the
thread was interruptedprotected boolean isReady()
protected boolean isClosed()
protected void setState(int nState)
nState
- the state the store should be transitioned toprotected boolean isExclusive()
protected AutoCloseable instantiateExclusiveClosable()
AutoCloseable
that will transition this PersistentStore
out of exclusive mode.public String toString()
protected com.oracle.coherence.persistence.PersistenceException ensurePersistenceException(Throwable eCause)
eCause
- an optional causeprotected com.oracle.coherence.persistence.PersistenceException ensurePersistenceException(Throwable eCause, String sMessage)
eCause
- an optional causesMessage
- an optional detail messageprotected final boolean lockStorage()
protected final void unlockStorage()
protected final void lockRead()
protected final void unlockRead()
protected final void lockWrite()
protected final void unlockWrite()
protected void validateExtentId(long lExtentId)
lExtentId
- the extent identifierprotected void validateMetadata()
protected boolean ensureExtentInternal(long lExtentId)
Note: the caller is assumed to have exclusive access to this store.
lExtentId
- the extent id to register and createprotected void copyAndOpenInternal(com.oracle.coherence.persistence.PersistentStore<ReadBuffer> storeFrom)
Note: overriders of this method must guarantee openInternal()
is called by either delegating to super or calling it directly.
storeFrom
- the store to copy fromprotected abstract void openInternal()
Note: this method is guaranteed to only be called by a thread that holds a write lock on this persistent store.
com.oracle.coherence.persistence.PersistenceException
- if a general persistence error occursprotected abstract void releaseInternal()
Note: this method is guaranteed to only be called by a thread that holds a write lock on this persistent store.
com.oracle.coherence.persistence.PersistenceException
- if a general persistence error occursprotected abstract boolean deleteInternal()
Note: this method is guaranteed to only be called by a thread that holds a write lock on this persistent store.
true
on successful removalcom.oracle.coherence.persistence.PersistenceException
- if a general persistence error occursprotected abstract void loadExtentIdsInternal(Set<Long> setIds)
Note: this method is guaranteed to only be called by a thread that holds a write lock on this persistent store.
setIds
- a set of idscom.oracle.coherence.persistence.PersistenceException
- if a general persistence error occursprotected abstract void createExtentInternal(long lExtentId)
Note: this method is guaranteed to only be called by a thread that holds a write lock on this persistent store.
lExtentId
- the identifier of the extent to createcom.oracle.coherence.persistence.PersistenceException
- if a general persistence error occursprotected abstract void deleteExtentInternal(long lExtentId)
Note: this method is guaranteed to only be called by a thread that holds a write lock on this persistent store.
lExtentId
- the identifier of the extent to deletecom.oracle.coherence.persistence.PersistenceException
- if a general persistence error occursprotected void moveExtentInternal(long lOldExtentId, long lNewExtentId)
Note: this method is guaranteed to only be called by a thread that holds a write lock on this persistent store.
lOldExtentId
- the old extent identifierlNewExtentId
- the new extent identifiercom.oracle.coherence.persistence.PersistenceException
- if a general persistence error occursprotected abstract void truncateExtentInternal(long lExtentId)
Note: this method is guaranteed to only be called by a thread that holds a write lock on this persistent store.
lExtentId
- the identifier of the extent to truncatecom.oracle.coherence.persistence.PersistenceException
- if a general persistence error occursprotected abstract ReadBuffer loadInternal(long lExtentId, ReadBuffer bufKey)
Note: this method is guaranteed to only be called by a thread that holds a read lock on this persistent store.
lExtentId
- the extent identifier for the keybufKey
- key whose associated value is to be returnedcom.oracle.coherence.persistence.PersistenceException
- if a general persistence error occursprotected abstract void storeInternal(long lExtentId, ReadBuffer bufKey, ReadBuffer bufValue, Object oToken)
Note: this method is guaranteed to only be called by a thread that holds a read lock on this persistent store.
lExtentId
- the extent identifier for the keybufKey
- key to store the value underbufValue
- value to be storedoToken
- a token that represents an atomic unit to commitcom.oracle.coherence.persistence.PersistenceException
- if a general persistence error occursIllegalArgumentException
- if the token is invalidprotected abstract void eraseInternal(long lExtentId, ReadBuffer bufKey, Object oToken)
Note: this method is guaranteed to only be called by a thread that holds a read lock on this persistent store.
lExtentId
- the extent identifier for the keybufKey
- key whose mapping is to be removed from the mapoToken
- a token that represents an atomic unit to commitcom.oracle.coherence.persistence.PersistenceException
- if a general persistence error occursIllegalArgumentException
- if the token is invalidprotected abstract void iterateInternal(com.oracle.coherence.persistence.PersistentStore.Visitor<ReadBuffer> visitor)
Note: this method is guaranteed to only be called by a thread that holds a read lock on this persistent store.
visitor
- the visitor to applycom.oracle.coherence.persistence.PersistenceException
- if a general persistence error occursprotected abstract Object beginInternal()
Note: this method is guaranteed to only be called by a thread that holds a read lock on this persistent store.
com.oracle.coherence.persistence.PersistenceException
- if a general persistence error occursprotected abstract void commitInternal(Object oToken)
Note: this method is guaranteed to only be called by a thread that holds a read lock on this persistent store.
oToken
- a token that represents the atomic unit to commitcom.oracle.coherence.persistence.PersistenceException
- if a general persistence error occursIllegalArgumentException
- if the token is invalidprotected abstract void abortInternal(Object oToken)
Note: this method is guaranteed to only be called by a thread that holds a read lock on this persistent store.
oToken
- a token that represents the atomic unit to abortcom.oracle.coherence.persistence.PersistenceException
- if a general persistence error occursIllegalArgumentException
- if the token is invalidpublic File getDataDirectory()