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 TypeMethodDescriptionbooleandelete()Deletes this store from the file system.protected longReturns a pointer to the end of the current data area.booleanexists()Returns true if this store exists in the file system.protected voidInternally closes the backing area.protected voidinternalOpen(boolean read_only) Internally opens the backing area.voidIt is often useful to guarentee that a certain sequence of updates to a store is completed and not broken in the middle.protected intreadByteArrayFrom(long position, byte[] buf, int off, int len) Reads a byte array from the given position in the file.protected intreadByteFrom(long position) Reads a byte from the given position in the file.protected voidsetDataAreaSize(long new_size) Sets the size of the data area.toString()voidSee the 'lockForWrite' method description.protected voidwriteByteArrayTo(long position, byte[] buf, int off, int len) Writes a byte array to the given position in the file.protected voidwriteByteTo(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:StoreIt 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:StoreSee 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:
internalOpenin classAbstractStore- Throws:
IOException
-
internalClose
Internally closes the backing area.- Specified by:
internalClosein classAbstractStore- Throws:
IOException
-
readByteFrom
Description copied from class:AbstractStoreReads a byte from the given position in the file.- Specified by:
readByteFromin classAbstractStore- Throws:
IOException
-
readByteArrayFrom
Description copied from class:AbstractStoreReads a byte array from the given position in the file. Returns the number of bytes read.- Specified by:
readByteArrayFromin classAbstractStore- Throws:
IOException
-
writeByteTo
Description copied from class:AbstractStoreWrites a byte to the given position in the file.- Specified by:
writeByteToin classAbstractStore- Throws:
IOException
-
writeByteArrayTo
Description copied from class:AbstractStoreWrites a byte array to the given position in the file.- Specified by:
writeByteArrayToin classAbstractStore- Throws:
IOException
-
endOfDataAreaPointer
Description copied from class:AbstractStoreReturns a pointer to the end of the current data area.- Specified by:
endOfDataAreaPointerin classAbstractStore- Throws:
IOException
-
setDataAreaSize
Description copied from class:AbstractStoreSets the size of the data area.- Specified by:
setDataAreaSizein classAbstractStore- Throws:
IOException
-
toString
-