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
Nested ClassesModifier and TypeClassDescriptionstatic classContinuation implementation that accepts a Throwable and throws a PersistenceException.Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringA filename prefix for deleted snapshots used to handle concurrent deletions.protected final AtomicIntegerAn atomic counter counter used duringsnapshot removal.protected final FileThe data directory of the active persistence manager.protected final FileThe data directory of the backup persistence manager.protected final FileThe events directory of the events persistence manager.protected final FileThe snapshot directory.protected final FileAn 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.DaemonPoolAn optional DaemonPool used to execute tasks.protected static final String[]An empty String array (by definition immutable). -
Constructor Summary
ConstructorsConstructorDescriptionAbstractPersistenceEnvironment(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 PathcreateHiddenSnapshotDirectory(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 AbstractPersistenceManagercreateSnapshotInternal(File fileSnapshot, String sSnapshot, com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> manager) Create a snapshot with the specified identifier.protected com.oracle.coherence.persistence.PersistenceExceptionensurePersistenceException(Throwable eCause) Return a PersistenceException with the given cause.protected com.oracle.coherence.persistence.PersistenceExceptionensurePersistenceException(Throwable eCause, String sMessage) Return a PersistenceException with the given cause and detail message.com.tangosol.internal.util.DaemonPoolReturn the optional DaemonPool used to execute tasks.Return the directory under which cached data is actively persisted by the environment.longReturn 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.longReturn 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 voidonReleased(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 AbstractPersistenceManagerOpen the active manager.com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> Open and return a singleton PersistenceManager to store backup data.protected abstract AbstractPersistenceManagerOpen the backup manager.com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> Open and return a singleton PersistenceManager to store MapEvents.protected abstract AbstractPersistenceManagerOpen 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 AbstractPersistenceManageropenSnapshotInternal(File fileSnapshot, String sSnapshot) Open the snapshot with the specified identifier.voidrelease()Release all resources held by this environment.booleanremoveSnapshot(String sSnapshot) Remove the persistent artifacts associated with the snapshot with the specified identifier.protected booleanremoveSnapshotInternal(File fileSnapshot, String sSnapshot) Remove the snapshot with the specified identifier.voidsetDaemonPool(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, newHashMap, newHashMap, newHashSet, newHashSet, 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, waitMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:
openBackupin 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:
openEventsin 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:
openActivein 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:
openSnapshotin 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:
createSnapshotin 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:
removeSnapshotin 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:
listSnapshotsin 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:
releasein interfacecom.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer>
-
getPersistenceActiveDirectory
Return the directory under which cached data is actively persisted by the environment.- Specified by:
getPersistenceActiveDirectoryin interfacePersistenceEnvironmentInfo- Returns:
- the active directory
-
getPersistenceBackupDirectory
Return the directory under which cached data is actively persisted by the environment.- Specified by:
getPersistenceBackupDirectoryin interfacePersistenceEnvironmentInfo- Returns:
- the backup directory
-
getPersistenceEventsDirectory
Return the directory under which cached data is actively persisted by the environment.- Specified by:
getPersistenceEventsDirectoryin interfacePersistenceEnvironmentInfo- Returns:
- the events directory
-
getPersistenceSnapshotDirectory
Return the directory under which copies of cached data are persisted by the environment.- Specified by:
getPersistenceSnapshotDirectoryin interfacePersistenceEnvironmentInfo- Returns:
- the snapshot directory
-
getPersistenceTrashDirectory
Return the directory under which potentially corrupted persisted data is stored by the environment.- Specified by:
getPersistenceTrashDirectoryin 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:
getPersistenceActiveSpaceUsedin 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:
getPersistenceBackupSpaceUsedin 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
-