Package com.tangosol.persistence
Class AbstractSnapshotArchiver
- java.lang.Object
-
- com.tangosol.persistence.AbstractSnapshotArchiver
-
- All Implemented Interfaces:
SnapshotArchiver
- Direct Known Subclasses:
DirectorySnapshotArchiver
public abstract class AbstractSnapshotArchiver extends Object implements SnapshotArchiver
An abstract implementation of aSnapshotArchiver
which must be extended to create a specific implementation.- Since:
- 12.2.1
- Author:
- tam 2014.08.22
-
-
Field Summary
Fields Modifier and Type Field Description protected String
f_sClusterName
The cluster name.protected String
f_sServiceName
The service name.protected long
m_cMillisLastStart
The start time of the last operation.protected long
m_cMillisMax
The maxiumum time in millis to archive or retrieve a snapshot store.protected long
m_cMillisMin
The minimum time in millis to archive or retrieve a snapshot store.protected long
m_cMillisTotal
The total time in millis taken to archive or retrieve snapshot stores.
-
Constructor Summary
Constructors Constructor Description AbstractSnapshotArchiver(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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
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.Snapshot
get(String sSnapshot)
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.datagrid.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.datagrid.persistence.PersistenceTools
instantiatePersistenceTools(com.oracle.datagrid.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[]
listInternal()
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
recordEndTime()
Record the end time of the operation and update min and max values.protected void
recordStartTime()
Record the start time of the operation.boolean
remove(String sSnapshot)
Remove the archived snapshot with the specified identifier.protected abstract boolean
removeInternal(String sSnapshot)
Internal implementation to remove the specified archived snapshot.protected void
resetStatistics()
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.String
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 Detail
-
f_sClusterName
protected final String f_sClusterName
The cluster name.
-
f_sServiceName
protected final String f_sServiceName
The service name.
-
m_cMillisTotal
protected long m_cMillisTotal
The total time in millis taken to archive or retrieve snapshot stores.
-
m_cMillisMax
protected long m_cMillisMax
The maxiumum time in millis to archive or retrieve a snapshot store.
-
m_cMillisMin
protected long m_cMillisMin
The minimum time in millis to archive or retrieve a snapshot store.
-
m_cMillisLastStart
protected long m_cMillisLastStart
The start time of the last operation.
-
-
Constructor Detail
-
AbstractSnapshotArchiver
public AbstractSnapshotArchiver(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.- Parameters:
sClusterName
- the name of the clustersServiceName
- the service name
-
-
Method Detail
-
list
public String[] 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
public Snapshot get(String sSnapshot)
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
public boolean remove(String sSnapshot)
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
public com.oracle.datagrid.persistence.PersistenceTools getPersistenceTools(String sSnapshot)
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
protected abstract String[] 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
protected abstract boolean removeInternal(String sSnapshot)
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
protected abstract String[] listStoresInternal(String sSnapshot)
List the stores for a given snapshot.- Parameters:
sSnapshot
- the snapshot name to list stores for- Returns:
- a
String
[] of store names
-
getMetadata
protected abstract Properties getMetadata(String sSnapshot) throws IOException
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.datagrid.persistence.PersistenceTools instantiatePersistenceTools(com.oracle.datagrid.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
protected void displayStatistics(Snapshot snapshot, String sType)
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"
-
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
protected boolean hasArchivedSnapshot(String sSnapshot)
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
-
-