PS
- the type of AbstractPersistentStorepublic abstract class AbstractPersistenceManager<PS extends AbstractPersistenceManager.AbstractPersistentStore> extends Base implements com.oracle.datagrid.persistence.PersistenceManager<ReadBuffer>
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractPersistenceManager.AbstractPersistenceSnapshotTools
Abstract implementation of PersistenceTools which can be extended to
support local snapshot operations for specific implementations.
|
class |
AbstractPersistenceManager.AbstractPersistentStore
Abstract implementation of a ReadBuffer-based PersistentStore.
|
class |
AbstractPersistenceManager.Task
Runnable extension that adds the ability to notify the task that it
has been canceled.
|
Base.LoggingWriter, Base.StackFrame
Modifier and Type | Field and Description |
---|---|
protected File |
f_dirActive
The directory used to store persisted data.
|
protected File |
f_dirLock
The directory used to store lock files (to protect against multi-process
file system clean up).
|
protected File |
f_dirTrash
The directory used to store "safe-deleted" data.
|
protected ConcurrentMap<String,PS> |
f_mapStores
Map of open AbstractPersistentStore instances.
|
protected Set<AbstractPersistenceManager.Task> |
f_setTasks
Set of outstanding tasks.
|
protected String |
f_sName
The name of this AbstractPersistenceManager.
|
protected AbstractPersistenceEnvironment |
m_env
The environment that created this AbstractPersistenceManager.
|
protected boolean |
m_fReleased
Whether this PersistenceManager has been released.
|
protected com.tangosol.internal.util.DaemonPool |
m_pool
An optional DaemonPool used to execute tasks.
|
protected static long[] |
NO_LONGS
An empty long array (by definition immutable).
|
protected static String[] |
NO_STRINGS
An empty String array (by definition immutable).
|
protected static int |
STORE_STATE_CLOSED
The state of a PersistenceStore once it has been released and closed.
|
protected static int |
STORE_STATE_INITIALIZED
The initial state of a PersistenceStore.
|
protected static int |
STORE_STATE_OPENING
The state of a PersistenceStore when it is in the process of being opened.
|
protected static int |
STORE_STATE_READY
The state of a PersistenceStore once it has been opened and is ready
to process requests.
|
Constructor and Description |
---|
AbstractPersistenceManager(File fileData,
File fileTrash,
String sName)
Create a new AbstractPersistenceManager.
|
Modifier and Type | Method and Description |
---|---|
void |
close(String sId)
Close the associated PersistentStore and release exclusive access to
the associated resources.
|
PS |
createStore(String sId)
Create a
PersistentStore associated with the specified
identifier. |
boolean |
delete(String sId,
boolean fSafe)
Remove the PersistentStore associated with the specified identifier.
|
protected void |
ensureActive()
Return control if this PersistenceManager is still active, otherwise
throw an exception.
|
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 |
executeTask(AbstractPersistenceManager.Task task)
Execute the specified task with the calling thread.
|
protected void |
executeTaskExclusive(AbstractPersistenceManager.Task task)
Execute the specified task with the calling thread.
|
com.tangosol.internal.util.DaemonPool |
getDaemonPool()
Return the optional DaemonPool used to execute tasks.
|
File |
getDataDirectory()
Return the directory used to store persisted data.
|
protected abstract int |
getImplVersion()
Return the implementation version of this manager.
|
protected File |
getLockDirectory()
Return the directory used to store lock files.
|
protected Properties |
getMetadata()
Return metadata for this manager.
|
String |
getName()
Return the name of this manager.
|
protected AbstractPersistenceEnvironment |
getPersistenceEnvironment()
Return the environment that created this manager.
|
com.oracle.datagrid.persistence.PersistenceTools |
getPersistenceTools()
Return an instance of
PersistenceTools allowing offline operations
to be performed against the associated PersistenceManager and appropriate
PersistentStore . |
Map<String,PS> |
getPersistentStoreMap()
Return the map of open PersistentStore instances keyed by their identifiers.
|
protected abstract String |
getStorageFormat()
Return the storage format used by this manager.
|
protected abstract int |
getStorageVersion()
Return the version of the storage format used by this manager.
|
File |
getTrashDirectory()
Return the directory used to store "safe-deleted" persisted data.
|
protected abstract com.oracle.datagrid.persistence.PersistenceTools |
instantiatePersistenceTools(com.oracle.datagrid.persistence.OfflinePersistenceInfo info)
Factory method to create a
PersistenceTools implementation. |
protected abstract PS |
instantiatePersistentStore(String sId)
Factory method for PersistentStore implementations managed by this
PersistenceManager.
|
protected boolean |
isMetadataCompatible(Properties prop)
Determine if the given metadata is compatible with this manager.
|
protected boolean |
isMetadataComplete(Properties prop)
Determine if the given metadata in the
Properties is complete. |
String[] |
list()
Return the identifiers of the PersistentStores known to this manager.
|
String[] |
listOpen()
Return the identifiers of PersistentStores that are currently open.
|
com.oracle.coherence.persistence.PersistentStore<ReadBuffer> |
open(String sId,
com.oracle.coherence.persistence.PersistentStore<ReadBuffer> storeFrom)
Open or create a
PersistentStore associated with the specified
identifier and based on the provided store . |
com.oracle.coherence.persistence.PersistentStore<ReadBuffer> |
open(String sId,
com.oracle.coherence.persistence.PersistentStore<ReadBuffer> storeFrom,
com.oracle.coherence.common.base.Collector<Object> collector)
Open or create a
PersistentStore associated with the specified
identifier and based on the provided store . |
void |
read(String sId,
InputStream in)
Read the PersistenceStore associated with the specified identifier
from the given input stream, making it available to this manager.
|
protected Properties |
readMetadata(File fileDir)
Read persistence metadata from the specified directory.
|
void |
release()
Release all resources held by this manager.
|
void |
setDaemonPool(com.tangosol.internal.util.DaemonPool pool)
Configure the DaemonPool used to execute tasks.
|
protected void |
setPersistenceEnvironment(AbstractPersistenceEnvironment env)
Configure the environment that created this manager.
|
protected void |
submitTask(AbstractPersistenceManager.Task task)
Submit the given task for execution by the daemon pool.
|
String |
toString()
Return a human readable description of this AbstractPersistenceManager.
|
String |
validatePersistentStoreId(String sId)
Validate that the given identifier can be used for a persistent store.
|
void |
write(String sId,
OutputStream out)
Write the PersistentStore associated with the specified identifier to
the given output stream.
|
protected void |
writeMetadata(File fileDir)
Write persistence metadata for this manager to the specified directory.
|
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 static final long[] NO_LONGS
protected static final String[] NO_STRINGS
protected static final int STORE_STATE_INITIALIZED
protected static final int STORE_STATE_OPENING
protected static final int STORE_STATE_READY
protected static final int STORE_STATE_CLOSED
protected final File f_dirActive
protected final File f_dirTrash
protected final File f_dirLock
protected final String f_sName
protected final ConcurrentMap<String,PS extends AbstractPersistenceManager.AbstractPersistentStore> f_mapStores
protected final Set<AbstractPersistenceManager.Task> f_setTasks
protected volatile boolean m_fReleased
protected AbstractPersistenceEnvironment m_env
protected com.tangosol.internal.util.DaemonPool m_pool
public AbstractPersistenceManager(File fileData, File fileTrash, String sName) throws IOException
fileData
- the directory used to store persisted datafileTrash
- an optional trash directorysName
- an optional name to give the new managerIOException
- on error creating the data or trash directorypublic String getName()
getName
in interface com.oracle.coherence.persistence.PersistenceManager<ReadBuffer>
public PS createStore(String sId)
PersistentStore
associated with the specified
identifier.
Creation of a store suggests its registration but has no usage
until it transitions into a state of open. The implementation may
choose to forgo any resource allocation until the caller
opens
the same identifier.
createStore
in interface com.oracle.coherence.persistence.PersistenceManager<ReadBuffer>
sId
- a unique identifier of the storepublic com.oracle.coherence.persistence.PersistentStore<ReadBuffer> open(String sId, com.oracle.coherence.persistence.PersistentStore<ReadBuffer> storeFrom)
PersistentStore
associated with the specified
identifier and based on the provided store
.
Upon a new store being created the provided store should be used as the basis for the new store such that the extents and associated data is available in the returned store. This provides an opportunity for an implementation to optimize initializing the new store based upon knowledge of the storage mechanics.
open
in interface com.oracle.coherence.persistence.PersistenceManager<ReadBuffer>
sId
- a unique identifier for the storestoreFrom
- the PersistenceStore the new store should be based uponpublic com.oracle.coherence.persistence.PersistentStore<ReadBuffer> open(String sId, com.oracle.coherence.persistence.PersistentStore<ReadBuffer> storeFrom, com.oracle.coherence.common.base.Collector<Object> collector)
PersistentStore
associated with the specified
identifier and based on the provided store
.
Upon a new store being created the provided store should be used as the basis for the new store such that the extents and associated data is available in the returned store. This provides an opportunity for an implementation to optimize initializing the new store based upon knowledge of the storage mechanics.
Providing a Collector
allows the open operation to be performed
asynchronously. This may be desirable when the calling thread can not
be blocked on IO operations that are required when creating a new store
based on an old store (storeFrom
). Open is only non-blocking when
both an old store and a Collector are provided. Upon completion
of an asynchronous open request the provided Collector is called with
either a String (GUID) or an AsyncPersistenceException, thus notifying
the collector of success of failure respectively.
Note: the behavior of a returned store that has not been opened is undefined.
open
in interface com.oracle.coherence.persistence.PersistenceManager<ReadBuffer>
sId
- a unique identifier for the storestoreFrom
- the PersistenceStore the new store should be based uponcollector
- the Collector to notify once the store has been opened
or failed to open; the collector will either receive
a String (GUID) or an AsyncPersistenceExceptionpublic void close(String sId)
close
in interface com.oracle.coherence.persistence.PersistenceManager<ReadBuffer>
sId
- a unique identifier of the store to closepublic boolean delete(String sId, boolean fSafe)
delete
in interface com.oracle.coherence.persistence.PersistenceManager<ReadBuffer>
sId
- a unique identifier of the store to removefSafe
- if true, remove the store by moving it to a restorable
location (if possible) rather than deleting itpublic String[] list()
list
in interface com.oracle.coherence.persistence.PersistenceManager<ReadBuffer>
public String[] listOpen()
listOpen
in interface com.oracle.coherence.persistence.PersistenceManager<ReadBuffer>
public void read(String sId, InputStream in) throws IOException
read
in interface com.oracle.coherence.persistence.PersistenceManager<ReadBuffer>
sId
- a unique identifier of the store to readin
- the stream to read fromIOException
- if an error occurred while reading from the streampublic void write(String sId, OutputStream out) throws IOException
write
in interface com.oracle.coherence.persistence.PersistenceManager<ReadBuffer>
sId
- a unique identifier of the store to writeout
- the stream to write toIOException
- if an error occurred while writing to the streampublic void release()
release
in interface com.oracle.coherence.persistence.PersistenceManager<ReadBuffer>
public com.oracle.datagrid.persistence.PersistenceTools getPersistenceTools()
com.oracle.datagrid.persistence.PersistenceManager
PersistenceTools
allowing offline operations
to be performed against the associated PersistenceManager and appropriate
PersistentStore
.getPersistenceTools
in interface com.oracle.coherence.persistence.PersistenceManager<ReadBuffer>
public String toString()
protected Properties getMetadata()
protected Properties readMetadata(File fileDir) throws IOException
fileDir
- the directory to read metadata fromIOException
- on error reading the metadata fileprotected void writeMetadata(File fileDir) throws IOException
fileDir
- the directory to write metadata toIOException
- on error writing the metadata fileprotected boolean isMetadataComplete(Properties prop)
Properties
is complete.prop
- the metadata to analyzeprotected boolean isMetadataCompatible(Properties prop)
prop
- the metadata to analyzeprotected abstract int getImplVersion()
protected abstract String getStorageFormat()
protected abstract int getStorageVersion()
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 void ensureActive()
IllegalStateException
- if this PersistenceManager has been releasedpublic String validatePersistentStoreId(String sId)
sId
- the identifier to checkprotected void submitTask(AbstractPersistenceManager.Task task)
task
- the task to submitprotected void executeTask(AbstractPersistenceManager.Task task)
task
- the task to executeprotected void executeTaskExclusive(AbstractPersistenceManager.Task task)
task
- the task to executeprotected abstract PS instantiatePersistentStore(String sId)
sId
- the identifier of the store to createprotected abstract com.oracle.datagrid.persistence.PersistenceTools instantiatePersistenceTools(com.oracle.datagrid.persistence.OfflinePersistenceInfo info)
PersistenceTools
implementation.info
- the OfflinePersistenceInfo
relevant to the PersistenceToolspublic com.tangosol.internal.util.DaemonPool getDaemonPool()
public void setDaemonPool(com.tangosol.internal.util.DaemonPool pool)
pool
- the DaemonPoolpublic File getDataDirectory()
public File getTrashDirectory()
protected File getLockDirectory()
protected AbstractPersistenceEnvironment getPersistenceEnvironment()
protected void setPersistenceEnvironment(AbstractPersistenceEnvironment env)
env
- the environment that created this managerpublic Map<String,PS> getPersistentStoreMap()
Note: The return map is "live". Any attempt to access or mutate it should be done while holding a monitor on this manager.