Package com.tangosol.persistence
Class AbstractSnapshotArchiver
java.lang.Object
com.tangosol.persistence.AbstractSnapshotArchiver
- All Implemented Interfaces:
SnapshotArchiver
- Direct Known Subclasses:
DirectorySnapshotArchiver
An abstract implementation of a
SnapshotArchiver
which must be extended
to create a specific implementation.- Since:
- 12.2.1
- Author:
- tam 2014.08.22
-
Field Summary
Modifier and TypeFieldDescriptionprotected final String
The cluster name.protected final String
The service name.protected long
The start time of the last operation.protected long
The maxiumum time in millis to archive or retrieve a snapshot store.protected long
The minimum time in millis to archive or retrieve a snapshot store.protected long
The total time in millis taken to archive or retrieve snapshot stores. -
Constructor Summary
ConstructorDescriptionAbstractSnapshotArchiver
(String sClusterName, String sServiceName) Create a new AbstractSnapshotArchiver which is used to archive and retrieve snapshot parts to/from a common archive location.
There will be one instance of a AbstractSnapshotArchiver implementation per storage node / per configured Persistence service. -
Method Summary
Modifier and TypeMethodDescriptionvoid
archive
(Snapshot snapshot, com.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer> env) Archive the specified snapshot.protected abstract void
archiveInternal
(Snapshot snapshot, com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> mgr) Internal implementation to Archive the specified snapshot.protected com.oracle.coherence.persistence.PersistenceEnvironment
<ReadBuffer> createTempEnvironment
(File fileBaseDir, String sStorageFormat) Create a temporary PersistenceEnvironment to write archived snapshots to in the given format.protected void
displayStatistics
(Snapshot snapshot, String sType) Display the collected statistics for the given snapshot and type of operation.Return aSnapshot
which represents the archived snapshot with the given identifier.protected abstract Properties
getMetadata
(String sSnapshot) Internal implementation to retrieve the metadata stored for the archived snapshot.com.oracle.coherence.persistence.PersistenceTools
getPersistenceTools
(String sSnapshot) Return an instance ofPersistenceTools
allowing offline operations to be performed against the associated PersistenceManager and appropriatePersistentStore
.protected boolean
hasArchivedSnapshot
(String sSnapshot) Return true if the specified snapshot exists for this archiver.protected boolean
hasLocalSnapshot
(com.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer> env, String sSnapshot) Return true if the specified snapshot exists for the PersistenceEnvironment.protected com.oracle.coherence.persistence.PersistenceTools
instantiatePersistenceTools
(com.oracle.coherence.persistence.OfflinePersistenceInfo info, String sSnapshot) Instantiate an instance ofPersistenceTools
relevant to this archiver and the provided snapshot.String[]
list()
Return the identifiers of the archived snapshots known to this archiver.protected abstract String[]
Internal implementation to return the identifiers of the archived snapshots known to this archiver.protected abstract String[]
listStoresInternal
(String sSnapshot) List the stores for a given snapshot.protected void
Record the end time of the operation and update min and max values.protected void
Record the start time of the operation.boolean
Remove the archived snapshot with the specified identifier.protected abstract boolean
removeInternal
(String sSnapshot) Internal implementation to remove the specified archived snapshot.protected void
Reset the statistics recording the archive and retrieve times.void
retrieve
(Snapshot snapshot, com.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer> env) Retrieve the specified archived snapshot.protected abstract void
retrieveInternal
(Snapshot snapshot, com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> mgr) Internal implementation to retrieve the specified snapshot.toString()
protected void
writeMetadata
(File fileDir, com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> mgr, String sStore) Write the metadata using given manager for a particular store to a destination directory.
-
Field Details
-
f_sClusterName
The cluster name. -
f_sServiceName
The service name. -
m_cMillisTotal
protected long m_cMillisTotalThe total time in millis taken to archive or retrieve snapshot stores. -
m_cMillisMax
protected long m_cMillisMaxThe maxiumum time in millis to archive or retrieve a snapshot store. -
m_cMillisMin
protected long m_cMillisMinThe minimum time in millis to archive or retrieve a snapshot store. -
m_cMillisLastStart
protected long m_cMillisLastStartThe start time of the last operation.
-
-
Constructor Details
-
AbstractSnapshotArchiver
Create a new AbstractSnapshotArchiver which is used to archive and retrieve snapshot parts to/from a common archive location.
There will be one instance of a AbstractSnapshotArchiver implementation per storage node / per configured Persistence service.- Parameters:
sClusterName
- the name of the clustersServiceName
- the service name
-
-
Method Details
-
list
Description copied from interface:SnapshotArchiver
Return the identifiers of the archived snapshots known to this archiver.- Specified by:
list
in interfaceSnapshotArchiver
- Returns:
- a list of the known archived snapshot identifiers
-
get
Description copied from interface:SnapshotArchiver
Return aSnapshot
which represents the archived snapshot with the given identifier.- Specified by:
get
in interfaceSnapshotArchiver
- Parameters:
sSnapshot
- the identifier of the archived snapshot- Returns:
- the
Snapshot
-
remove
Description copied from interface:SnapshotArchiver
Remove the archived snapshot with the specified identifier.- Specified by:
remove
in interfaceSnapshotArchiver
- Parameters:
sSnapshot
- the identifier of the archived snapshot- Returns:
- true if the snapshot was successfully deleted, false otherwise
-
archive
public void archive(Snapshot snapshot, com.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer> env) Description copied from interface:SnapshotArchiver
Archive the specified snapshot.- Specified by:
archive
in interfaceSnapshotArchiver
- Parameters:
snapshot
- the snapshot to archiveenv
- the PersistenceEnvironment used to read the snapshot
-
retrieve
public void retrieve(Snapshot snapshot, com.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer> env) Description copied from interface:SnapshotArchiver
Retrieve the specified archived snapshot.- Specified by:
retrieve
in interfaceSnapshotArchiver
- Parameters:
snapshot
- the snapshot to retrieveenv
- the PersistenceEnvironment used to write the snapshot
-
getPersistenceTools
Description copied from interface:SnapshotArchiver
Return an instance ofPersistenceTools
allowing offline operations to be performed against the associated PersistenceManager and appropriatePersistentStore
.- Specified by:
getPersistenceTools
in interfaceSnapshotArchiver
- Parameters:
sSnapshot
- the snapshot to return tools for- Returns:
- a PersistenceTools implementation
-
listInternal
Internal implementation to return the identifiers of the archived snapshots known to this archiver.- Returns:
- a list of the known archived snapshot identifiers
-
archiveInternal
protected abstract void archiveInternal(Snapshot snapshot, com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> mgr) Internal implementation to Archive the specified snapshot.- Parameters:
snapshot
- the snapshot to archivemgr
- the PersistenceManager used to read the stores from
-
retrieveInternal
protected abstract void retrieveInternal(Snapshot snapshot, com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> mgr) Internal implementation to retrieve the specified snapshot.- Parameters:
snapshot
- the snapshot to retrievemgr
- the PersistenceManager used to write the stores to
-
removeInternal
Internal implementation to remove the specified archived snapshot. (Called by JMX operation removeArchivedSnapshot)- Parameters:
sSnapshot
- the snapshot name to remove- Returns:
- true if the snapshot was removed
-
listStoresInternal
List the stores for a given snapshot.- Parameters:
sSnapshot
- the snapshot name to list stores for- Returns:
- a
String
[] of store names
-
getMetadata
Internal implementation to retrieve the metadata stored for the archived snapshot.- Parameters:
sSnapshot
- the snapshot name to retrieve metadata- Returns:
- the metadata for the archived snapshot
- Throws:
IOException
- if any I/O related problems
-
instantiatePersistenceTools
protected com.oracle.coherence.persistence.PersistenceTools instantiatePersistenceTools(com.oracle.coherence.persistence.OfflinePersistenceInfo info, String sSnapshot) Instantiate an instance ofPersistenceTools
relevant to this archiver and the provided snapshot.- Parameters:
info
- the information about this archived snapshotsSnapshot
- the snapshot name to use- Returns:
- an instance of PersistenceTools
-
resetStatistics
protected void resetStatistics()Reset the statistics recording the archive and retrieve times. -
recordStartTime
protected void recordStartTime()Record the start time of the operation. -
recordEndTime
protected void recordEndTime()Record the end time of the operation and update min and max values. -
displayStatistics
Display the collected statistics for the given snapshot and type of operation.- Parameters:
snapshot
- the snapshot that was archived or retrievedsType
- the type of operation, either "archive" or "retrieve"
-
toString
-
hasLocalSnapshot
protected boolean hasLocalSnapshot(com.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer> env, String sSnapshot) Return true if the specified snapshot exists for the PersistenceEnvironment.- Parameters:
env
- thePersistenceEnvironment
to querysSnapshot
- the snapshot name to check for- Returns:
- true if the specified snapshot exists
-
hasArchivedSnapshot
Return true if the specified snapshot exists for this archiver.- Parameters:
sSnapshot
- the snapshot name to check for- Returns:
- true if the specified snapshot exists
-
createTempEnvironment
protected com.oracle.coherence.persistence.PersistenceEnvironment<ReadBuffer> createTempEnvironment(File fileBaseDir, String sStorageFormat) throws IOException Create a temporary PersistenceEnvironment to write archived snapshots to in the given format.- Parameters:
fileBaseDir
- the directory off which to create the environmentsStorageFormat
- the storage format to use- Returns:
- a PersistenceEnvironment which can be used to write archived snapshots to
- Throws:
IOException
- if any I/O related errors.
-
writeMetadata
protected void writeMetadata(File fileDir, com.oracle.coherence.persistence.PersistenceManager<ReadBuffer> mgr, String sStore) throws IOException Write the metadata using given manager for a particular store to a destination directory.- Parameters:
fileDir
- the directory to write metadata tomgr
- the PersistenceManager used to write the metadatasStore
- a store to use to read the partition count from- Throws:
IOException
- if any errors writing metadata
-