Class ShadowingStore

All Implemented Interfaces:
BaseStore, ObjectStoreAPI, ParticipantStore, RecoveryStore, TxLog
Direct Known Subclasses:
ShadowNoFileLockStore

public class ShadowingStore extends FileSystemStore
A shadowing file store implementation. Each version of the object's state is maintained in a separate file. So, the original is stored in one file, and the shadow (the updated state) is stored in another. When the transaction commits, the shadow is made the original. If the transaction rolls back then the shadow is simply removed from the object store.
Since:
1.0
Version:
$Id: ShadowingStore.java 2342 2006-03-30 13:06:17Z $
Author:
Mark Little (mark@arjuna.com)
  • Field Details

  • Constructor Details

  • Method Details

    • currentState

      public int currentState(Uid objUid, String tName) throws ObjectStoreException
      Parameters:
      objUid - The object to query.
      tName - The type of the object to query.
      Returns:
      current state of object. Assumes that genPathName allocates enough extra space to allow extra chars to be added. State search is ordered OS_SHADOW, OS_UNCOMMITTED_HIDDEN, OS_ORIGINAL, OS_COMMITTED_HIDDEN.
      Throws:
      ObjectStoreException
    • commit_state

      public boolean commit_state(Uid objUid, String tName) throws ObjectStoreException
      Commit a previous write_state operation which was made with the SHADOW StateType argument. This is achieved by renaming the shadow and removing the hidden version.
      Parameters:
      objUid - The object to work on.
      tName - The type of the object to work on.
      Returns:
      true if no errors occurred, false otherwise.
      Throws:
      ObjectStoreException
    • hide_state

      public boolean hide_state(Uid objUid, String tName) throws ObjectStoreException
      Hide/reveal an object regardless of state. Hidden objects cannot be read but they can be written (Crash recovery needs this).
      Parameters:
      objUid - The object to work on.
      tName - The type of the object to work on.
      Returns:
      true if no errors occurred, false otherwise.
      Throws:
      ObjectStoreException
    • reveal_state

      public boolean reveal_state(Uid objUid, String tName) throws ObjectStoreException
      Description copied from interface: RecoveryStore
      Reveal a hidden object's state.
      Parameters:
      objUid - The object to work on.
      tName - The type of the object to work on.
      Returns:
      true if no errors occurred, false otherwise.
      Throws:
      ObjectStoreException
    • genPathName

      protected String genPathName(Uid objUid, String tName, int ft) throws ObjectStoreException
      Overrides:
      genPathName in class FileSystemStore
      Returns:
      the file name for the state of the object identified by the Uid and TypeName. If the StateType argument is OS_SHADOW then the Uid part of the name includes # characters. Builds on lower level genPathName which allocates enough slop to accomodate the extra chars.
      Throws:
      ObjectStoreException
    • revealedId

      protected String revealedId(String name)
      Description copied from class: ObjectStore
      Given a type id which is possibly hidden (e.g., has a ! at the end), make it a valid Uid so we can return it.
      Overrides:
      revealedId in class ObjectStore
    • read_state

      protected InputObjectState read_state(Uid objUid, String tName, int ft) throws ObjectStoreException
      Specified by:
      read_state in class FileSystemStore
      Throws:
      ObjectStoreException
    • remove_state

      protected boolean remove_state(Uid objUid, String name, int ft) throws ObjectStoreException
      Specified by:
      remove_state in class FileSystemStore
      Throws:
      ObjectStoreException
    • write_state

      protected boolean write_state(Uid objUid, String tName, OutputObjectState state, int ft) throws ObjectStoreException
      write_state saves the ObjectState in a file named by the type and Uid of the ObjectState. If the second argument is SHADOW, then the file name is different so that a subsequent commit_state invocation will rename the file.
      Specified by:
      write_state in class FileSystemStore
      Throws:
      ObjectStoreException