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 a SnapshotArchiver 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 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

    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

    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.
    get(String sSnapshot)
    Return a Snapshot 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
    Return an instance of PersistenceTools allowing offline operations to be performed against the associated PersistenceManager and appropriate PersistentStore.
    protected boolean
    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 of PersistenceTools relevant to this archiver and the provided snapshot.
    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[]
    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(String sSnapshot)
    Remove the archived snapshot with the specified identifier.
    protected abstract boolean
    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.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • 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 Details

    • 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 cluster
      sServiceName - the service name
  • Method Details

    • list

      public String[] list()
      Description copied from interface: SnapshotArchiver
      Return the identifiers of the archived snapshots known to this archiver.
      Specified by:
      list in interface SnapshotArchiver
      Returns:
      a list of the known archived snapshot identifiers
    • get

      public Snapshot get(String sSnapshot)
      Description copied from interface: SnapshotArchiver
      Return a Snapshot which represents the archived snapshot with the given identifier.
      Specified by:
      get in interface SnapshotArchiver
      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 interface SnapshotArchiver
      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 interface SnapshotArchiver
      Parameters:
      snapshot - the snapshot to archive
      env - 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 interface SnapshotArchiver
      Parameters:
      snapshot - the snapshot to retrieve
      env - the PersistenceEnvironment used to write the snapshot
    • getPersistenceTools

      public com.oracle.coherence.persistence.PersistenceTools getPersistenceTools(String sSnapshot)
      Description copied from interface: SnapshotArchiver
      Return an instance of PersistenceTools allowing offline operations to be performed against the associated PersistenceManager and appropriate PersistentStore.
      Specified by:
      getPersistenceTools in interface SnapshotArchiver
      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 archive
      mgr - 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 retrieve
      mgr - 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.coherence.persistence.PersistenceTools instantiatePersistenceTools(com.oracle.coherence.persistence.OfflinePersistenceInfo info, String sSnapshot)
      Instantiate an instance of PersistenceTools relevant to this archiver and the provided snapshot.
      Parameters:
      info - the information about this archived snapshot
      sSnapshot - 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 retrieved
      sType - the type of operation, either "archive" or "retrieve"
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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 - the PersistenceEnvironment to query
      sSnapshot - 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 environment
      sStorageFormat - 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 to
      mgr - the PersistenceManager used to write the metadata
      sStore - a store to use to read the partition count from
      Throws:
      IOException - if any errors writing metadata