Package com.mckoi.store
Class LoggingBufferManager
- java.lang.Object
-
- com.mckoi.store.LoggingBufferManager
-
public class LoggingBufferManager extends java.lang.ObjectA 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceLoggingBufferManager.StoreDataAccessorFactoryA factory interface for creating StoreDataAccessor objects from resource names.
-
Constructor Summary
Constructors Constructor Description LoggingBufferManager(java.io.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(java.io.File resource_path, java.io.File journal_path, boolean read_only, int max_pages, int page_size, java.lang.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 Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidlockForWrite()Obtains a write lock on the buffer.voidsetCheckPoint(boolean flush_journals)Sets a check point in the log.voidstart()Starts the buffer manager.voidstop()Stops the buffer manager.voidunlockForWrite()Releases a write lock on the buffer.
-
-
-
Constructor Detail
-
LoggingBufferManager
public LoggingBufferManager(java.io.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(java.io.File resource_path, java.io.File journal_path, boolean read_only, int max_pages, int page_size, java.lang.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 Detail
-
start
public void start() throws java.io.IOExceptionStarts the buffer manager.- Throws:
java.io.IOException
-
stop
public void stop() throws java.io.IOExceptionStops the buffer manager.- Throws:
java.io.IOException
-
lockForWrite
public void lockForWrite() throws java.lang.InterruptedExceptionObtains a write lock on the buffer. This will block if a 'setCheckPoint' is in progress, otherwise it will always succeed.- Throws:
java.lang.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 java.io.IOException, java.lang.InterruptedExceptionSets 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:
java.io.IOExceptionjava.lang.InterruptedException
-
-