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>,com.oracle.datagrid.persistence.PersistenceEnvironment<ReadBuffer>,PersistenceEnvironmentInfo
public abstract class AbstractPersistenceEnvironment extends Base implements com.oracle.datagrid.persistence.PersistenceEnvironment<ReadBuffer>, PersistenceEnvironmentInfo
Abstract implementation of a ReadBuffer-based PersistentEnvironment.- Author:
- jh 2013.05.21
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractPersistenceEnvironment.DefaultFailureContinuationContinuation implementation that accepts a Throwable and throws a PersistenceException.-
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringDELETED_PREFIXA filename prefix for deleted snapshots used to handle concurrent deletions.protected AtomicIntegerf_atomicRemovesCounterAn atomic counter counter used duringsnapshot removal.protected Filef_fileActiveThe data directory of the active persistence manager.protected Filef_fileBackupThe data directory of the backup persistence manager.protected Filef_fileEventsThe events directory of the events persistence manager.protected Filef_fileSnapshotThe snapshot directory.protected Filef_fileTrashAn optional trash directory.protected Map<String,AbstractPersistenceManager>f_mapSnapshotsThe map of snapshots, keyed by snapshot name.protected AbstractPersistenceManager<?>m_managerActiveThis singleton active manager.protected AbstractPersistenceManager<?>m_managerBackupThis singleton backup manager.protected AbstractPersistenceManager<?>m_managerEventsThis singleton events manager.protected com.tangosol.internal.util.DaemonPoolm_poolAn optional DaemonPool used to execute tasks.protected static String[]NO_STRINGSAn empty String array (by definition immutable).
-
Constructor Summary
Constructors Constructor Description AbstractPersistenceEnvironment(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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected 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.DaemonPoolgetDaemonPool()Return the optional DaemonPool used to execute tasks.FilegetPersistenceActiveDirectory()Return the directory under which cached data is actively persisted by the environment.longgetPersistenceActiveSpaceUsed()Return the total size in bytes used by the persistence layer to persist mutating cache operations.FilegetPersistenceBackupDirectory()Return the directory under which cached data is actively persisted by the environment.longgetPersistenceBackupSpaceUsed()Return the total size in bytes used by the persistence layer to persist backups of mutating cache operations.FilegetPersistenceEventsDirectory()Return the directory under which cached data is actively persisted by the environment.FilegetPersistenceSnapshotDirectory()Return the directory under which copies of cached data are persisted by the environment.FilegetPersistenceTrashDirectory()Return the directory under which potentially corrupted persisted data is stored by the environment.String[]listSnapshots()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>openActive()Open and return the singleton active PersistenceManager.protected abstract AbstractPersistenceManageropenActiveInternal()Open the active manager.com.oracle.coherence.persistence.PersistenceManager<ReadBuffer>openBackup()Open and return a singleton PersistenceManager to store backup data.protected abstract AbstractPersistenceManageropenBackupInternal()Open the backup manager.com.oracle.coherence.persistence.PersistenceManager<ReadBuffer>openEvents()Open and return a singleton PersistenceManager to store MapEvents.protected abstract AbstractPersistenceManageropenEventsInternal()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 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.StringtoString()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, wait
-
-
-
-
Field Detail
-
NO_STRINGS
protected static final String[] NO_STRINGS
An empty String array (by definition immutable).
-
DELETED_PREFIX
protected static final String DELETED_PREFIX
A filename prefix for deleted snapshots used to handle concurrent deletions.- See Also:
- Constant Field Values
-
f_atomicRemovesCounter
protected final AtomicInteger f_atomicRemovesCounter
An atomic counter counter used duringsnapshot removal.
-
f_fileActive
protected final File f_fileActive
The data directory of the active persistence manager.
-
f_fileBackup
protected final File f_fileBackup
The data directory of the backup persistence manager.
-
f_fileEvents
protected final File f_fileEvents
The events directory of the events persistence manager.
-
f_fileSnapshot
protected final File f_fileSnapshot
The snapshot directory.
-
f_fileTrash
protected final File f_fileTrash
An optional trash directory.
-
m_managerActive
protected AbstractPersistenceManager<?> m_managerActive
This singleton active manager.
-
m_managerBackup
protected AbstractPersistenceManager<?> m_managerBackup
This singleton backup manager.
-
m_managerEvents
protected AbstractPersistenceManager<?> m_managerEvents
This singleton events manager.
-
f_mapSnapshots
protected final Map<String,AbstractPersistenceManager> f_mapSnapshots
The map of snapshots, keyed by snapshot name.
-
m_pool
protected com.tangosol.internal.util.DaemonPool m_pool
An optional DaemonPool used to execute tasks.
-
-
Constructor Detail
-
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 Detail
-
openBackup
public com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> 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
public com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> 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
public com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> 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
public boolean removeSnapshot(String sSnapshot)
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
public String[] 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
public File getPersistenceActiveDirectory()
Return the directory under which cached data is actively persisted by the environment.- Specified by:
getPersistenceActiveDirectoryin interfacePersistenceEnvironmentInfo- Returns:
- the active directory
-
getPersistenceBackupDirectory
public File getPersistenceBackupDirectory()
Return the directory under which cached data is actively persisted by the environment.- Specified by:
getPersistenceBackupDirectoryin interfacePersistenceEnvironmentInfo- Returns:
- the backup directory
-
getPersistenceEventsDirectory
public File getPersistenceEventsDirectory()
Return the directory under which cached data is actively persisted by the environment.- Specified by:
getPersistenceEventsDirectoryin interfacePersistenceEnvironmentInfo- Returns:
- the events directory
-
getPersistenceSnapshotDirectory
public File getPersistenceSnapshotDirectory()
Return the directory under which copies of cached data are persisted by the environment.- Specified by:
getPersistenceSnapshotDirectoryin interfacePersistenceEnvironmentInfo- Returns:
- the snapshot directory
-
getPersistenceTrashDirectory
public File 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
protected void onReleased(AbstractPersistenceManager manager)
Called by the specified manager when it has been released.- Parameters:
manager- the manager that was released
-
openActiveInternal
protected abstract AbstractPersistenceManager 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
protected abstract AbstractPersistenceManager 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
protected abstract AbstractPersistenceManager 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
protected boolean removeSnapshotInternal(File fileSnapshot, String sSnapshot)
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
protected Path createHiddenSnapshotDirectory(String sPrefix)
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
public String 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
-
-