Package com.mckoi.store
Class JournalledFileStore
java.lang.Object
com.mckoi.store.AbstractStore
com.mckoi.store.JournalledFileStore
- All Implemented Interfaces:
Store
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
-
Field Summary
Fields inherited from class com.mckoi.store.AbstractStore
BIN_AREA_OFFSET, BIN_ENTRIES, DATA_AREA_OFFSET, FIXED_AREA_OFFSET, free_bin_list, header_buf, MAGIC, read_only, total_allocated_space, wilderness_pointer
-
Constructor Summary
ConstructorsConstructorDescriptionJournalledFileStore
(String resource_name, LoggingBufferManager buffer_manager, boolean read_only) Constructs the ScatteringFileStore. -
Method Summary
Modifier and TypeMethodDescriptionboolean
delete()
Deletes this store from the file system.protected long
Returns a pointer to the end of the current data area.boolean
exists()
Returns true if this store exists in the file system.protected void
Internally closes the backing area.protected void
internalOpen
(boolean read_only) Internally opens the backing area.void
It is often useful to guarentee that a certain sequence of updates to a store is completed and not broken in the middle.protected int
readByteArrayFrom
(long position, byte[] buf, int off, int len) Reads a byte array from the given position in the file.protected int
readByteFrom
(long position) Reads a byte from the given position in the file.protected void
setDataAreaSize
(long new_size) Sets the size of the data area.toString()
void
See the 'lockForWrite' method description.protected void
writeByteArrayTo
(long position, byte[] buf, int off, int len) Writes a byte array to the given position in the file.protected void
writeByteTo
(long position, int b) Writes a byte to the given position in the file.Methods inherited from class com.mckoi.store.AbstractStore
checkPointer, close, coalescArea, createArea, deleteArea, expandDataArea, findAllocatedAreasNotIn, getAllAreas, getArea, getAreaHeader, getAreaInputStream, getMutableArea, getNextAreaHeader, getPreviousAreaHeader, isValidBoundarySize, lastCloseClean, open, openScanAndFix, readBins, reboundArea, splitArea, statsScan, totalAllocatedSinceStart, writeAllBins, writeBinIndex
-
Constructor Details
-
JournalledFileStore
public JournalledFileStore(String resource_name, LoggingBufferManager buffer_manager, boolean read_only) Constructs the ScatteringFileStore.
-
-
Method Details
-
delete
Deletes this store from the file system. This operation should only be used when the store is NOT open.- Throws:
IOException
-
exists
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
Internally opens the backing area. If 'read_only' is true then the store is opened in read only mode.- Specified by:
internalOpen
in classAbstractStore
- Throws:
IOException
-
internalClose
Internally closes the backing area.- Specified by:
internalClose
in classAbstractStore
- Throws:
IOException
-
readByteFrom
Description copied from class:AbstractStore
Reads a byte from the given position in the file.- Specified by:
readByteFrom
in classAbstractStore
- Throws:
IOException
-
readByteArrayFrom
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 classAbstractStore
- Throws:
IOException
-
writeByteTo
Description copied from class:AbstractStore
Writes a byte to the given position in the file.- Specified by:
writeByteTo
in classAbstractStore
- Throws:
IOException
-
writeByteArrayTo
Description copied from class:AbstractStore
Writes a byte array to the given position in the file.- Specified by:
writeByteArrayTo
in classAbstractStore
- Throws:
IOException
-
endOfDataAreaPointer
Description copied from class:AbstractStore
Returns a pointer to the end of the current data area.- Specified by:
endOfDataAreaPointer
in classAbstractStore
- Throws:
IOException
-
setDataAreaSize
Description copied from class:AbstractStore
Sets the size of the data area.- Specified by:
setDataAreaSize
in classAbstractStore
- Throws:
IOException
-
toString
-