Package com.mckoi.database
Class V1FileStoreSystem
- java.lang.Object
-
- com.mckoi.database.V1FileStoreSystem
-
- All Implemented Interfaces:
StoreSystem
class V1FileStoreSystem extends java.lang.Object implements StoreSystem
An implementation of StoreSystem that manages persistant data through the native file system. Each store is represented by a ScatteringFileStore object against the current path. This implementation is compatible with versions of the database from 0.94 onwards.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringFLOCK_EXTThe name of the file extention of the file lock on this conglomerate.private java.io.FileOutputStreamlock_fileThe lock file.private java.io.FilepathThe path in the filesystem where the data files are located.private booleanread_onlyTrue if the stores are read-only.private TransactionSystemsystemThe TransactionSystem that contains the various configuration options for the database.
-
Constructor Summary
Constructors Constructor Description V1FileStoreSystem(TransactionSystem system, java.io.File path, boolean read_only)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancloseStore(Store store)Closes a store that has been either created or opened with the 'createStore' or 'openStore' methods.private JournalledFileStorecreateFileStore(java.lang.String file_name)Creates the JournalledFileStore object for this table.StorecreateStore(java.lang.String name)Creates and returns a new persistent Store object given the unique name of the store.booleandeleteStore(Store store)Permanently deletes a store from the system - use with care! Returns true if the store was successfully deleted and the resources associated with it were freed.voidlock(java.lang.String name)Attempts to lock this store system exclusively so that no other process may access or change the persistent data in the store.StoreopenStore(java.lang.String name)Opens an existing persistent Store object in the system and returns the Store object that contains its data.voidsetCheckPoint()Sets a new check point at the current state of this store system.booleanstoreExists(java.lang.String name)Returns true if the store with the given name exists within the system, or false otherwise.voidunlock(java.lang.String name)Unlocks the exclusive access to the persistent store objects.
-
-
-
Field Detail
-
FLOCK_EXT
private static final java.lang.String FLOCK_EXT
The name of the file extention of the file lock on this conglomerate.- See Also:
- Constant Field Values
-
system
private TransactionSystem system
The TransactionSystem that contains the various configuration options for the database.
-
path
private java.io.File path
The path in the filesystem where the data files are located.
-
read_only
private boolean read_only
True if the stores are read-only.
-
lock_file
private java.io.FileOutputStream lock_file
The lock file.
-
-
Constructor Detail
-
V1FileStoreSystem
public V1FileStoreSystem(TransactionSystem system, java.io.File path, boolean read_only)
Constructor.
-
-
Method Detail
-
createFileStore
private JournalledFileStore createFileStore(java.lang.String file_name) throws java.io.IOException
Creates the JournalledFileStore object for this table.- Throws:
java.io.IOException
-
storeExists
public boolean storeExists(java.lang.String name)
Description copied from interface:StoreSystemReturns true if the store with the given name exists within the system, or false otherwise.- Specified by:
storeExistsin interfaceStoreSystem
-
createStore
public Store createStore(java.lang.String name)
Description copied from interface:StoreSystemCreates and returns a new persistent Store object given the unique name of the store. If the system is read-only or the table otherwise can not be created then an exception is thrown.At the most, you should assume that this will return an implementation of AbstractStore but you should not be assured of this fact.
- Specified by:
createStorein interfaceStoreSystem- Parameters:
name- a unique identifier string representing the name of the store.
-
openStore
public Store openStore(java.lang.String name)
Description copied from interface:StoreSystemOpens an existing persistent Store object in the system and returns the Store object that contains its data. An exception is thrown if the store can not be opened.At the most, you should assume that this will return an implementation of AbstractStore but you should not be assured of this fact.
- Specified by:
openStorein interfaceStoreSystem- Parameters:
name- a unique identifier string representing the name of the store.
-
closeStore
public boolean closeStore(Store store)
Description copied from interface:StoreSystemCloses a store that has been either created or opened with the 'createStore' or 'openStore' methods. Returns true if the store was successfully closed.- Specified by:
closeStorein interfaceStoreSystem
-
deleteStore
public boolean deleteStore(Store store)
Description copied from interface:StoreSystemPermanently deletes a store from the system - use with care! Returns true if the store was successfully deleted and the resources associated with it were freed. Returns false if the store could not be deleted. Note that it is quite likely that a store may fail to delete in which case the delete operation should be re-tried after a short timeout.- Specified by:
deleteStorein interfaceStoreSystem
-
setCheckPoint
public void setCheckPoint()
Description copied from interface:StoreSystemSets a new check point at the current state of this store system. This is intended to help journalling check point and recovery systems. A check point is set whenever data is committed to the database. Some systems can be designed to be able to roll forward or backward to different check points. Each check point represents a stable state in the database life cycle.A checkpoint based system greatly improves stability because if a crash occurs in an intermediate state the changes can simply be rolled back to the last stable state.
An implementation may choose not to implement check points in which case this would be a no-op.
- Specified by:
setCheckPointin interfaceStoreSystem
-
lock
public void lock(java.lang.String name) throws java.io.IOExceptionDescription copied from interface:StoreSystemAttempts to lock this store system exclusively so that no other process may access or change the persistent data in the store. If this fails to lock, an IOException is generated, otherwise the lock is obtained and the method returns.- Specified by:
lockin interfaceStoreSystem- Throws:
java.io.IOException
-
unlock
public void unlock(java.lang.String name) throws java.io.IOExceptionDescription copied from interface:StoreSystemUnlocks the exclusive access to the persistent store objects. After this method completes, access to the store system by other processes is allowed.- Specified by:
unlockin interfaceStoreSystem- Throws:
java.io.IOException
-
-