Package com.tangosol.persistence
Class AbstractPersistenceEnvironment
java.lang.Object
com.tangosol.util.Base
com.tangosol.persistence.AbstractPersistenceEnvironment
- All Implemented Interfaces:
com.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer>
,PersistenceEnvironmentInfo
public abstract class AbstractPersistenceEnvironment
extends Base
implements com.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer>, PersistenceEnvironmentInfo
Abstract implementation of a ReadBuffer-based PersistentEnvironment.
- Author:
- jh 2013.05.21
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Continuation implementation that accepts a Throwable and throws a PersistenceException.Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
A filename prefix for deleted snapshots used to handle concurrent deletions.protected final AtomicInteger
An atomic counter counter used duringsnapshot removal
.protected final File
The data directory of the active persistence manager.protected final File
The data directory of the backup persistence manager.protected final File
The events directory of the events persistence manager.protected final File
The snapshot directory.protected final File
An optional trash directory.protected final Map
<String, AbstractPersistenceManager> The map of snapshots, keyed by snapshot name.protected AbstractPersistenceManager
<?> This singleton active manager.protected AbstractPersistenceManager
<?> This singleton backup manager.protected AbstractPersistenceManager
<?> This singleton events manager.protected com.tangosol.internal.util.DaemonPool
An optional DaemonPool used to execute tasks.protected static final String[]
An empty String array (by definition immutable). -
Constructor Summary
ConstructorDescriptionAbstractPersistenceEnvironment
(File fileActive, File fileSnapshot, File fileTrash) Create a new BerkeleyDBEnvironment that manages a singleton BerkeleyDBManager with the specified directories: data - active persistence snapshot - location for snapshots trash - optional location trashed stores events - optional location for event storageAbstractPersistenceEnvironment
(File fileActive, File fileSnapshot, File fileTrash, File fileEvents) Create a new BerkeleyDBEnvironment that manages a singleton BerkeleyDBManager with the specified directories: data - active persistence snapshot - location for snapshots trash - optional location trashed stores events - optional location for event storage backup - optional location for backup storageAbstractPersistenceEnvironment
(File fileActive, File fileBackup, File fileEvents, File fileSnapshot, File fileTrash) Create a new BerkeleyDBEnvironment that manages a singleton BerkeleyDBManager with the specified directories: data - active persistence backup - optional location for backup storage events - optional location for event storage snapshot - location for snapshots trash - optional location trashed stores -
Method Summary
Modifier and TypeMethodDescriptionprotected Path
createHiddenSnapshotDirectory
(String sPrefix) Return a Path to a hidden directory within the snapshot directory that does not exist.com.oracle.coherence.persistence.PersistenceManager
<ReadBuffer> createSnapshot
(String sSnapshot, com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> manager) Create a PersistenceManager used to manage the snapshot with the specified identifier.protected abstract AbstractPersistenceManager
createSnapshotInternal
(File fileSnapshot, String sSnapshot, com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> manager) Create a snapshot with the specified identifier.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.com.tangosol.internal.util.DaemonPool
Return the optional DaemonPool used to execute tasks.Return the directory under which cached data is actively persisted by the environment.long
Return the total size in bytes used by the persistence layer to persist mutating cache operations.Return the directory under which cached data is actively persisted by the environment.long
Return the total size in bytes used by the persistence layer to persist backups of mutating cache operations.Return the directory under which cached data is actively persisted by the environment.Return the directory under which copies of cached data are persisted by the environment.Return the directory under which potentially corrupted persisted data is stored by the environment.String[]
Return the identifiers of the snapshots known to this environment.protected void
onReleased
(AbstractPersistenceManager manager) Called by the specified manager when it has been released.com.oracle.coherence.persistence.PersistenceManager
<ReadBuffer> Open and return the singleton active PersistenceManager.protected abstract AbstractPersistenceManager
Open the active manager.com.oracle.coherence.persistence.PersistenceManager
<ReadBuffer> Open and return a singleton PersistenceManager to store backup data.protected abstract AbstractPersistenceManager
Open the backup manager.com.oracle.coherence.persistence.PersistenceManager
<ReadBuffer> Open and return a singleton PersistenceManager to store MapEvents.protected abstract AbstractPersistenceManager
Open the events manager.com.oracle.coherence.persistence.PersistenceManager
<ReadBuffer> openSnapshot
(String sSnapshot) Open a PersistenceManager used to access the snapshot with the specified identifier.protected abstract AbstractPersistenceManager
openSnapshotInternal
(File fileSnapshot, String sSnapshot) Open the snapshot with the specified identifier.void
release()
Release all resources held by this environment.boolean
removeSnapshot
(String sSnapshot) Remove the persistent artifacts associated with the snapshot with the specified identifier.protected boolean
removeSnapshotInternal
(File fileSnapshot, String sSnapshot) Remove the snapshot with the specified identifier.void
setDaemonPool
(com.tangosol.internal.util.DaemonPool pool) Configure the DaemonPool used to execute tasks.toString()
Return a human readable description of this AbstractPersistenceManager.Methods inherited from class com.tangosol.util.Base
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, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, 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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.oracle.coherence.persistence.PersistenceEnvironment
createSnapshot
-
Field Details
-
NO_STRINGS
An empty String array (by definition immutable). -
DELETED_PREFIX
A filename prefix for deleted snapshots used to handle concurrent deletions.- See Also:
-
f_atomicRemovesCounter
An atomic counter counter used duringsnapshot removal
. -
f_fileActive
The data directory of the active persistence manager. -
f_fileBackup
The data directory of the backup persistence manager. -
f_fileEvents
The events directory of the events persistence manager. -
f_fileSnapshot
The snapshot directory. -
f_fileTrash
An optional trash directory. -
m_managerActive
This singleton active manager. -
m_managerBackup
This singleton backup manager. -
m_managerEvents
This singleton events manager. -
f_mapSnapshots
The map of snapshots, keyed by snapshot name. -
m_pool
protected com.tangosol.internal.util.DaemonPool m_poolAn optional DaemonPool used to execute tasks.
-
-
Constructor Details
-
AbstractPersistenceEnvironment
public AbstractPersistenceEnvironment(File fileActive, File fileSnapshot, File fileTrash) throws IOException Create a new BerkeleyDBEnvironment that manages a singleton BerkeleyDBManager with the specified directories:- data - active persistence
- snapshot - location for snapshots
- trash - optional location trashed stores
- events - optional location for event storage
- Parameters:
fileActive
- the data directory of the singleton active manager or null if an active manager shouldn't be maintained by this environmentfileSnapshot
- the snapshot directoryfileTrash
- an optional trash directory used for "safe" deletes- Throws:
IOException
- if the data directory could not be createdIllegalArgumentException
- if the data, snapshot, and trash directories are not unique
-
AbstractPersistenceEnvironment
public AbstractPersistenceEnvironment(File fileActive, File fileSnapshot, File fileTrash, File fileEvents) throws IOException Create a new BerkeleyDBEnvironment that manages a singleton BerkeleyDBManager with the specified directories:- data - active persistence
- snapshot - location for snapshots
- trash - optional location trashed stores
- events - optional location for event storage
- backup - optional location for backup storage
- Parameters:
fileActive
- the data directory of the singleton active manager or null if an active manager shouldn't be maintained by this environmentfileSnapshot
- the snapshot directoryfileTrash
- an optional trash directory used for "safe" deletesfileEvents
- an optional events directory used for to store map events- Throws:
IOException
- if the data directory could not be createdIllegalArgumentException
- if the data, snapshot, and trash directories are not unique
-
AbstractPersistenceEnvironment
public AbstractPersistenceEnvironment(File fileActive, File fileBackup, File fileEvents, File fileSnapshot, File fileTrash) throws IOException Create a new BerkeleyDBEnvironment that manages a singleton BerkeleyDBManager with the specified directories:- data - active persistence
- backup - optional location for backup storage
- events - optional location for event storage
- snapshot - location for snapshots
- trash - optional location trashed stores
- Parameters:
fileActive
- the data directory of the singleton active manager or null if an active manager shouldn't be maintained by this environmentfileBackup
- an optional backup directory used to store backup map datafileEvents
- an optional events directory used to store map eventsfileSnapshot
- the snapshot directoryfileTrash
- an optional trash directory used for "safe" deletes- Throws:
IOException
- if the data directory could not be createdIllegalArgumentException
- if the data, backup, snapshot, and trash directories are not unique
-
-
Method Details
-
openBackup
Open and return a singleton PersistenceManager to store backup data.- Specified by:
openBackup
in interfacecom.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer>
- Returns:
- the singleton backup PersistenceManager or null if an active PersistenceManager has not been configured
-
openEvents
Open and return a singleton PersistenceManager to store MapEvents.- Specified by:
openEvents
in interfacecom.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer>
- Returns:
- the singleton store of MapEvents or null if durable events is not enabled
-
openActive
Open and return the singleton active PersistenceManager.- Specified by:
openActive
in interfacecom.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer>
- Returns:
- the singleton active PersistenceManager or null if an active PersistenceManager has not been configured
-
openSnapshot
public com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> openSnapshot(String sSnapshot) Open a PersistenceManager used to access the snapshot with the specified identifier.- Specified by:
openSnapshot
in interfacecom.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer>
- Parameters:
sSnapshot
- the snapshot identifier- Returns:
- a PersistenceManager representing the snapshot
-
createSnapshot
public com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> createSnapshot(String sSnapshot, com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> manager) Create a PersistenceManager used to manage the snapshot with the specified identifier.- Specified by:
createSnapshot
in interfacecom.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer>
- Parameters:
sSnapshot
- the snapshot identifiermanager
- the optional PersistenceManager to create a snapshot of; if null, an empty snapshot will be created- Returns:
- a PersistenceManager representing the snapshot
-
removeSnapshot
Remove the persistent artifacts associated with the snapshot with the specified identifier.- Specified by:
removeSnapshot
in interfacecom.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer>
- Parameters:
sSnapshot
- the snapshot identifier- Returns:
- true if the snapshot was successfully deleted, false otherwise
-
listSnapshots
Return the identifiers of the snapshots known to this environment.- Specified by:
listSnapshots
in interfacecom.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer>
- Returns:
- a list of the known snapshot identifiers
-
release
public void release()Release all resources held by this environment. Note that the behavior of all other methods on this environment is undefined after this method is called.- Specified by:
release
in interfacecom.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer>
-
getPersistenceActiveDirectory
Return the directory under which cached data is actively persisted by the environment.- Specified by:
getPersistenceActiveDirectory
in interfacePersistenceEnvironmentInfo
- Returns:
- the active directory
-
getPersistenceBackupDirectory
Return the directory under which cached data is actively persisted by the environment.- Specified by:
getPersistenceBackupDirectory
in interfacePersistenceEnvironmentInfo
- Returns:
- the backup directory
-
getPersistenceEventsDirectory
Return the directory under which cached data is actively persisted by the environment.- Specified by:
getPersistenceEventsDirectory
in interfacePersistenceEnvironmentInfo
- Returns:
- the events directory
-
getPersistenceSnapshotDirectory
Return the directory under which copies of cached data are persisted by the environment.- Specified by:
getPersistenceSnapshotDirectory
in interfacePersistenceEnvironmentInfo
- Returns:
- the snapshot directory
-
getPersistenceTrashDirectory
Return the directory under which potentially corrupted persisted data is stored by the environment.- Specified by:
getPersistenceTrashDirectory
in interfacePersistenceEnvironmentInfo
- Returns:
- the trash directory
-
getPersistenceActiveSpaceUsed
public long getPersistenceActiveSpaceUsed()Return the total size in bytes used by the persistence layer to persist mutating cache operations.- Specified by:
getPersistenceActiveSpaceUsed
in interfacePersistenceEnvironmentInfo
- Returns:
- the total size
-
getPersistenceBackupSpaceUsed
public long getPersistenceBackupSpaceUsed()Return the total size in bytes used by the persistence layer to persist backups of mutating cache operations.- Specified by:
getPersistenceBackupSpaceUsed
in interfacePersistenceEnvironmentInfo
- Returns:
- the total size
-
ensurePersistenceException
protected com.oracle.coherence.persistence.PersistenceException ensurePersistenceException(Throwable eCause) Return a PersistenceException with the given cause. The returned exception is also initialized with this environment.- Parameters:
eCause
- an optional cause- Returns:
- a PersistenceException with the given cause
-
ensurePersistenceException
protected com.oracle.coherence.persistence.PersistenceException ensurePersistenceException(Throwable eCause, String sMessage) Return a PersistenceException with the given cause and detail message. The returned exception is also initialized with this environment.- Parameters:
eCause
- an optional causesMessage
- an optional detail message- Returns:
- a PersistenceException with the given cause and detail message
-
onReleased
Called by the specified manager when it has been released.- Parameters:
manager
- the manager that was released
-
openActiveInternal
Open the active manager.Note: this method is guaranteed to only be called by a thread that holds a monitor on this environment.
- Returns:
- the active manager
- Throws:
com.oracle.coherence.persistence.PersistenceException
- if a general persistence error occurs
-
openBackupInternal
Open the backup manager.Note: this method is guaranteed to only be called by a thread that holds a monitor on this environment.
- Returns:
- the backup manager
- Throws:
com.oracle.coherence.persistence.PersistenceException
- if a general persistence error occurs
-
openEventsInternal
Open the events manager.Note: this method is guaranteed to only be called by a thread that holds a monitor on this environment.
- Returns:
- the events manager
- Throws:
com.oracle.coherence.persistence.PersistenceException
- if a general persistence error occurs
-
openSnapshotInternal
protected abstract AbstractPersistenceManager openSnapshotInternal(File fileSnapshot, String sSnapshot) Open the snapshot with the specified identifier.Note: this method is guaranteed to only be called by a thread that holds a monitor on this environment.
- Parameters:
fileSnapshot
- the directory of the snapshotsSnapshot
- the snapshot identifier- Returns:
- the snapshot
- Throws:
com.oracle.coherence.persistence.PersistenceException
- if a general persistence error occurs
-
createSnapshotInternal
protected abstract AbstractPersistenceManager createSnapshotInternal(File fileSnapshot, String sSnapshot, com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> manager) Create a snapshot with the specified identifier.Note: this method is guaranteed to only be called by a thread that holds a monitor on this environment.
- Parameters:
fileSnapshot
- the directory of the snapshotsSnapshot
- the snapshot identifiermanager
- the optional manager to create a snapshot of; if null, an empty snapshot will be created- Returns:
- the snapshot
- Throws:
com.oracle.coherence.persistence.PersistenceException
- if a general persistence error occursIllegalArgumentException
- if the specified manager is incompatible with this environment
-
removeSnapshotInternal
Remove the snapshot with the specified identifier.Note: this method is guaranteed to only be called by a thread that holds a monitor on this environment.
- Parameters:
fileSnapshot
- the directory of the snapshotsSnapshot
- the snapshot identifier- Returns:
- true if the snapshot was successfully deleted, false otherwise
- Throws:
com.oracle.coherence.persistence.PersistenceException
- if a general persistence error occurs
-
createHiddenSnapshotDirectory
Return a Path to a hidden directory within the snapshot directory that does not exist.- Parameters:
sPrefix
- a prefix for the directory name- Returns:
- a Path to a hidden directory within the snapshot directory that does not exist
-
toString
Return a human readable description of this AbstractPersistenceManager. -
getDaemonPool
public com.tangosol.internal.util.DaemonPool getDaemonPool()Return the optional DaemonPool used to execute tasks.- Returns:
- the DaemonPool or null if one hasn't been configured
-
setDaemonPool
public void setDaemonPool(com.tangosol.internal.util.DaemonPool pool) Configure the DaemonPool used to execute tasks.- Parameters:
pool
- the DaemonPool
-