Class SafePersistenceWrappers.SafePersistenceManager<R,T extends Throwable>

java.lang.Object
com.tangosol.util.NullImplementation.NullPersistenceManager<R>
com.tangosol.persistence.SafePersistenceWrappers.SafePersistenceManager<R,T>
Type Parameters:
R - the type of a raw, environment specific object representation
T - the type of a Throwable failure to protect
All Implemented Interfaces:
com.oracle.coherence.persistence.PersistenceManager<R>, com.oracle.coherence.persistence.PersistenceTools
Enclosing class:
SafePersistenceWrappers

public static class SafePersistenceWrappers.SafePersistenceManager<R,T extends Throwable> extends NullImplementation.NullPersistenceManager<R>
SafePersistenceManager is a wrapper PersistenceManager implementation which protects all operations on the underlying manager (and any PersistentStore instances opened by the manager) from unexpected failures, delegating the exception handling to a failure Continuation.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Continuation<? super T>
    The failure continuation for this manager.
    The FailureContinuationFactory.
    protected final com.oracle.coherence.persistence.PersistenceManager<R>
    The underlying PersistenceManager.

    Fields inherited from class com.tangosol.util.NullImplementation.NullPersistenceManager

    INSTANCE
  • Constructor Summary

    Constructors
    Constructor
    Description
    SafePersistenceManager(com.oracle.coherence.persistence.PersistenceManager<R> mgr)
    Construct a SafePersistenceManager backed by the specified manager.
    SafePersistenceManager(com.oracle.coherence.persistence.PersistenceManager<R> mgr, Continuation<? super Throwable> cont)
    Construct a SafePersistenceManager backed by the specified manager.
    SafePersistenceManager(com.oracle.coherence.persistence.PersistenceManager<R> mgr, SafePersistenceWrappers.FailureContinuationFactory<R,? super T> factory)
    Construct a PersistenceManager backed by the specified manager.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close the associated PersistentStore and release exclusive access to the associated resources.
    com.oracle.coherence.persistence.PersistentStore<R>
    Create a PersistentStore associated with the specified identifier.
    boolean
    delete(String sId, boolean fSafe)
    Remove the PersistentStore associated with the specified identifier.
    com.oracle.coherence.persistence.PersistenceManager
    Return the underlying PersistenceManager.
    Return the name of this manager.
    Return the identifiers of the PersistentStores known to this manager.
    Return the identifiers of PersistentStores that are currently open.
    void
    Called to handle an unexpected exception.
    com.oracle.coherence.persistence.PersistentStore<R>
    open(String sId, com.oracle.coherence.persistence.PersistentStore<R> store)
    Open or create a PersistentStore associated with the specified identifier and based on the provided store.
    com.oracle.coherence.persistence.PersistentStore<R>
    open(String sId, com.oracle.coherence.persistence.PersistentStore<R> store, Collector<Object> collector)
    Open or create a PersistentStore associated with the specified identifier and based on the provided store.
    void
    Read the PersistenceStore associated with the specified identifier from the given input stream, making it available to this manager.
    void
    Read the PersistenceStore associated with the specified identifier from the given input stream, making it available to this manager.
    void
    Release all resources held by this manager.
    Return a human readable description of this SafePersistenceManager.
    protected com.oracle.coherence.persistence.PersistentStore<R>
    wrap(com.oracle.coherence.persistence.PersistentStore<R> store)
    Wrap the specified store in a SafePersistentStore implementation.
    void
    Write the PersistentStore associated with the specified identifier to the given output buffer.
    void
    Write the PersistentStore associated with the specified identifier to the given output stream.
    void
    Copy the PersistentStore associated with the specified identifier to the configured safe area.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.oracle.coherence.persistence.PersistenceManager

    contains
  • Field Details

    • f_manager

      protected final com.oracle.coherence.persistence.PersistenceManager<R> f_manager
      The underlying PersistenceManager.
    • f_contFailure

      protected final Continuation<? super T extends Throwable> f_contFailure
      The failure continuation for this manager.
    • f_factoryCont

      protected final SafePersistenceWrappers.FailureContinuationFactory<R,? super T extends Throwable> f_factoryCont
      The FailureContinuationFactory.
  • Constructor Details

    • SafePersistenceManager

      public SafePersistenceManager(com.oracle.coherence.persistence.PersistenceManager<R> mgr)
      Construct a SafePersistenceManager backed by the specified manager.
      Parameters:
      mgr - the underlying PersistenceManager
    • SafePersistenceManager

      public SafePersistenceManager(com.oracle.coherence.persistence.PersistenceManager<R> mgr, Continuation<? super Throwable> cont)
      Construct a SafePersistenceManager backed by the specified manager.
      Parameters:
      mgr - the underlying PersistenceManager
      cont - the failure continuation to use to handle unexpected exceptions
    • SafePersistenceManager

      public SafePersistenceManager(com.oracle.coherence.persistence.PersistenceManager<R> mgr, SafePersistenceWrappers.FailureContinuationFactory<R,? super T> factory)
      Construct a PersistenceManager backed by the specified manager.
      Parameters:
      mgr - the underlying PersistenceManager
      factory - the failure continuation factory to use to create handlers for unexpected exceptions
  • Method Details

    • getManager

      public com.oracle.coherence.persistence.PersistenceManager getManager()
      Return the underlying PersistenceManager.
      Returns:
      the underlying PersistenceManager
    • onException

      public void onException(T t)
      Called to handle an unexpected exception.
      Parameters:
      t - the Throwable
    • wrap

      protected com.oracle.coherence.persistence.PersistentStore<R> wrap(com.oracle.coherence.persistence.PersistentStore<R> store)
      Wrap the specified store in a SafePersistentStore implementation.
      Parameters:
      store - the underlying PersistentStore
      Returns:
      a "safe" PersistenceManger or null if the specified store is null
    • getName

      public String getName()
      Return the name of this manager.
      Specified by:
      getName in interface com.oracle.coherence.persistence.PersistenceManager<R>
      Overrides:
      getName in class NullImplementation.NullPersistenceManager<R>
      Returns:
      the name of this manager
    • createStore

      public com.oracle.coherence.persistence.PersistentStore<R> createStore(String sId)
      Create a PersistentStore associated with the specified identifier.

      Creation of a store suggests its registration but has no usage until it transitions into a state of open. The implementation may choose to forgo any resource allocation until the caller opens the same identifier.

      Specified by:
      createStore in interface com.oracle.coherence.persistence.PersistenceManager<R>
      Overrides:
      createStore in class NullImplementation.NullPersistenceManager<R>
      Parameters:
      sId - a unique identifier of the store
      Returns:
      a persistent store
    • open

      public com.oracle.coherence.persistence.PersistentStore<R> open(String sId, com.oracle.coherence.persistence.PersistentStore<R> store)
      Open or create a PersistentStore associated with the specified identifier and based on the provided store.

      Upon a new store being created the provided store should be used as the basis for the new store such that the extents and associated data is available in the returned store. This provides an opportunity for an implementation to optimize initializing the new store based upon knowledge of the storage mechanics.

      Specified by:
      open in interface com.oracle.coherence.persistence.PersistenceManager<R>
      Overrides:
      open in class NullImplementation.NullPersistenceManager<R>
      Parameters:
      sId - a unique identifier for the store
      store - the PersistenceStore the new store should be based upon
      Returns:
      a PersistentStore associated with the specified identifier
    • open

      public com.oracle.coherence.persistence.PersistentStore<R> open(String sId, com.oracle.coherence.persistence.PersistentStore<R> store, Collector<Object> collector)
      Open or create a PersistentStore associated with the specified identifier and based on the provided store.

      Upon a new store being created the provided store should be used as the basis for the new store such that the extents and associated data is available in the returned store. This provides an opportunity for an implementation to optimize initializing the new store based upon knowledge of the storage mechanics.

      Providing a Collector allows the open operation to be performed asynchronously. This may be desirable when the calling thread can not be blocked on IO operations that are required when creating a new store based on an old store (storeFrom). Open is only non-blocking when both an old store and a Collector are provided. Upon completion of an asynchronous open request the provided Collector is called with either a String (GUID) or an AsyncPersistenceException, thus notifying the collector of success of failure respectively.

      Note: the behavior of a returned store that has not been opened is undefined.

      Specified by:
      open in interface com.oracle.coherence.persistence.PersistenceManager<R>
      Overrides:
      open in class NullImplementation.NullPersistenceManager<R>
      Parameters:
      sId - a unique identifier for the store
      store - the PersistenceStore the new store should be based upon
      collector - the Collector to notify once the store has been opened or failed to open; the collector will either receive a String (GUID) or an AsyncPersistenceException
      Returns:
      a PersistentStore associated with the specified identifier
    • close

      public void close(String sId)
      Close the associated PersistentStore and release exclusive access to the associated resources.
      Specified by:
      close in interface com.oracle.coherence.persistence.PersistenceManager<R>
      Overrides:
      close in class NullImplementation.NullPersistenceManager<R>
      Parameters:
      sId - a unique identifier of the store to close
    • delete

      public boolean delete(String sId, boolean fSafe)
      Remove the PersistentStore associated with the specified identifier.
      Specified by:
      delete in interface com.oracle.coherence.persistence.PersistenceManager<R>
      Overrides:
      delete in class NullImplementation.NullPersistenceManager<R>
      Parameters:
      sId - a unique identifier of the store to remove
      fSafe - if true, remove the store by moving it to a restorable location (if possible) rather than deleting it
      Returns:
      true if the store was successfully removed, false otherwise
    • list

      public String[] list()
      Return the identifiers of the PersistentStores known to this manager.
      Specified by:
      list in interface com.oracle.coherence.persistence.PersistenceManager<R>
      Overrides:
      list in class NullImplementation.NullPersistenceManager<R>
      Returns:
      a list of the known store identifiers
    • listOpen

      public String[] listOpen()
      Return the identifiers of PersistentStores that are currently open.
      Specified by:
      listOpen in interface com.oracle.coherence.persistence.PersistenceManager<R>
      Overrides:
      listOpen in class NullImplementation.NullPersistenceManager<R>
      Returns:
      a list of the open store identifiers
    • read

      public void read(String sId, InputStream in) throws IOException
      Read the PersistenceStore associated with the specified identifier from the given input stream, making it available to this manager.
      Specified by:
      read in interface com.oracle.coherence.persistence.PersistenceManager<R>
      Overrides:
      read in class NullImplementation.NullPersistenceManager<R>
      Parameters:
      sId - a unique identifier of the store to read
      in - the stream to read from
      Throws:
      IOException - if an error occurred while reading from the stream
    • write

      public void write(String sId, OutputStream out) throws IOException
      Write the PersistentStore associated with the specified identifier to the given output stream.
      Specified by:
      write in interface com.oracle.coherence.persistence.PersistenceManager<R>
      Overrides:
      write in class NullImplementation.NullPersistenceManager<R>
      Parameters:
      sId - a unique identifier of the store to write
      out - the stream to write to
      Throws:
      IOException - if an error occurred while writing to the stream
    • writeSafe

      public void writeSafe(String sId)
      Copy the PersistentStore associated with the specified identifier to the configured safe area.
    • read

      public void read(String sId, ReadBuffer.BufferInput in) throws IOException
      Read the PersistenceStore associated with the specified identifier from the given input stream, making it available to this manager.
      Specified by:
      read in interface com.oracle.coherence.persistence.PersistenceManager<R>
      Overrides:
      read in class NullImplementation.NullPersistenceManager<R>
      Parameters:
      sId - a unique identifier of the store to read
      in - the stream to read from
      Throws:
      IOException - if an error occurred while reading from the stream
    • write

      public void write(String sId, WriteBuffer.BufferOutput out) throws IOException
      Write the PersistentStore associated with the specified identifier to the given output buffer.
      Specified by:
      write in interface com.oracle.coherence.persistence.PersistenceManager<R>
      Overrides:
      write in class NullImplementation.NullPersistenceManager<R>
      Parameters:
      sId - a unique identifier of the store to write
      out - the output buffer to write to
      Throws:
      IOException - if an error occurred while writing to the stream
    • release

      public void release()
      Release all resources held by this manager. Note that the behavior of all other methods on this manager is undefined after this method is called.
      Specified by:
      release in interface com.oracle.coherence.persistence.PersistenceManager<R>
      Overrides:
      release in class NullImplementation.NullPersistenceManager<R>
    • toString

      public String toString()
      Return a human readable description of this SafePersistenceManager.
      Overrides:
      toString in class Object
      Returns:
      a human readable description