Class JournalledFileStore

java.lang.Object
com.mckoi.store.AbstractStore
com.mckoi.store.JournalledFileStore
All Implemented Interfaces:
Store

public final class JournalledFileStore extends AbstractStore
An implementation of AbstractStore that persists to an underlying data format via a robust journalling system that supports check point and crash recovery. Note that this object is a bridge between the Store API and the journalled behaviour defined in LoggingBufferManager, JournalledSystem and the StoreDataAccessor implementations.

Note that access to the resources is abstracted via a 'resource_name' string. The LoggingBufferManager object converts the resource name into a concrete object that accesses the actual data.

Author:
Tobias Downer
  • Constructor Details

    • JournalledFileStore

      public JournalledFileStore(String resource_name, LoggingBufferManager buffer_manager, boolean read_only)
      Constructs the ScatteringFileStore.
  • Method Details

    • delete

      public boolean delete() throws IOException
      Deletes this store from the file system. This operation should only be used when the store is NOT open.
      Throws:
      IOException
    • exists

      public boolean exists() throws IOException
      Returns true if this store exists in the file system.
      Throws:
      IOException
    • lockForWrite

      public void lockForWrite()
      Description copied from interface: Store
      It is often useful to guarentee that a certain sequence of updates to a store is completed and not broken in the middle. For example, when inserting data into a table you don't want a record to be partially written when a check point is made. You want the entire sequence of modifications to be completed before the check point can run. This means that if a crash occurs, a check point will not recover to a possible corrupt file.

      To achieve this, the 'lockForWrite' and 'unlockForWrite' methods are available. When 'lockForWrite' has been called, a check point can not created until there are no write locks obtained on the table.

    • unlockForWrite

      public void unlockForWrite()
      Description copied from interface: Store
      See the 'lockForWrite' method description.
    • internalOpen

      protected void internalOpen(boolean read_only) throws IOException
      Internally opens the backing area. If 'read_only' is true then the store is opened in read only mode.
      Specified by:
      internalOpen in class AbstractStore
      Throws:
      IOException
    • internalClose

      protected void internalClose() throws IOException
      Internally closes the backing area.
      Specified by:
      internalClose in class AbstractStore
      Throws:
      IOException
    • readByteFrom

      protected int readByteFrom(long position) throws IOException
      Description copied from class: AbstractStore
      Reads a byte from the given position in the file.
      Specified by:
      readByteFrom in class AbstractStore
      Throws:
      IOException
    • readByteArrayFrom

      protected int readByteArrayFrom(long position, byte[] buf, int off, int len) throws IOException
      Description copied from class: AbstractStore
      Reads a byte array from the given position in the file. Returns the number of bytes read.
      Specified by:
      readByteArrayFrom in class AbstractStore
      Throws:
      IOException
    • writeByteTo

      protected void writeByteTo(long position, int b) throws IOException
      Description copied from class: AbstractStore
      Writes a byte to the given position in the file.
      Specified by:
      writeByteTo in class AbstractStore
      Throws:
      IOException
    • writeByteArrayTo

      protected void writeByteArrayTo(long position, byte[] buf, int off, int len) throws IOException
      Description copied from class: AbstractStore
      Writes a byte array to the given position in the file.
      Specified by:
      writeByteArrayTo in class AbstractStore
      Throws:
      IOException
    • endOfDataAreaPointer

      protected long endOfDataAreaPointer() throws IOException
      Description copied from class: AbstractStore
      Returns a pointer to the end of the current data area.
      Specified by:
      endOfDataAreaPointer in class AbstractStore
      Throws:
      IOException
    • setDataAreaSize

      protected void setDataAreaSize(long new_size) throws IOException
      Description copied from class: AbstractStore
      Sets the size of the data area.
      Specified by:
      setDataAreaSize in class AbstractStore
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object