Class LoggingBufferManager

java.lang.Object
com.mckoi.store.LoggingBufferManager

public class LoggingBufferManager extends Object
A paged random access buffer manager that caches access between a Store and the underlying filesystem and that also handles check point logging and crash recovery (via a JournalledSystem object).
Author:
Tobias Downer
  • Constructor Details

    • LoggingBufferManager

      public LoggingBufferManager(File journal_path, boolean read_only, int max_pages, int page_size, LoggingBufferManager.StoreDataAccessorFactory sda_factory, DebugLogger debug, boolean enable_logging)
      Constructs the manager.
    • LoggingBufferManager

      public LoggingBufferManager(File resource_path, File journal_path, boolean read_only, int max_pages, int page_size, String file_ext, long max_slice_size, DebugLogger debug, boolean enable_logging)
      Constructs the manager with a scattering store implementation that converts the resource to a file in the given path.
  • Method Details

    • start

      public void start() throws IOException
      Starts the buffer manager.
      Throws:
      IOException
    • stop

      public void stop() throws IOException
      Stops the buffer manager.
      Throws:
      IOException
    • lockForWrite

      public void lockForWrite() throws InterruptedException
      Obtains a write lock on the buffer. This will block if a 'setCheckPoint' is in progress, otherwise it will always succeed.
      Throws:
      InterruptedException
    • unlockForWrite

      public void unlockForWrite()
      Releases a write lock on the buffer. This MUST be called if the 'lockForWrite' method is called. This should be called from a 'finally' clause.
    • setCheckPoint

      public void setCheckPoint(boolean flush_journals) throws IOException, InterruptedException
      Sets a check point in the log. This logs a point in which a recovery process should at least be able to be rebuild back to. This will block if there are any write locks.

      Some things to keep in mind when using this. You must ensure that no writes can occur while this operation is occuring. Typically this will happen at the end of a commit but you need to ensure that nothing can happen in the background, such as records being deleted or items being inserted. It is required that the 'no write' restriction is enforced at a high level. If care is not taken then the image written will not be clean and if a crash occurs the image that is recovered will not be stable.

      Throws:
      IOException
      InterruptedException