Class 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.String FLOCK_EXT
      The name of the file extention of the file lock on this conglomerate.
      private java.io.FileOutputStream lock_file
      The lock file.
      private java.io.File path
      The path in the filesystem where the data files are located.
      private boolean read_only
      True if the stores are read-only.
      private TransactionSystem system
      The TransactionSystem that contains the various configuration options for the database.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean closeStore​(Store store)
      Closes a store that has been either created or opened with the 'createStore' or 'openStore' methods.
      private JournalledFileStore createFileStore​(java.lang.String file_name)
      Creates the JournalledFileStore object for this table.
      Store createStore​(java.lang.String name)
      Creates and returns a new persistent Store object given the unique name of the store.
      boolean deleteStore​(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.
      void lock​(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.
      Store openStore​(java.lang.String name)
      Opens an existing persistent Store object in the system and returns the Store object that contains its data.
      void setCheckPoint()
      Sets a new check point at the current state of this store system.
      boolean storeExists​(java.lang.String name)
      Returns true if the store with the given name exists within the system, or false otherwise.
      void unlock​(java.lang.String name)
      Unlocks the exclusive access to the persistent store objects.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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: StoreSystem
        Returns true if the store with the given name exists within the system, or false otherwise.
        Specified by:
        storeExists in interface StoreSystem
      • createStore

        public Store createStore​(java.lang.String name)
        Description copied from interface: StoreSystem
        Creates 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:
        createStore in interface StoreSystem
        Parameters:
        name - a unique identifier string representing the name of the store.
      • openStore

        public Store openStore​(java.lang.String name)
        Description copied from interface: StoreSystem
        Opens 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:
        openStore in interface StoreSystem
        Parameters:
        name - a unique identifier string representing the name of the store.
      • closeStore

        public boolean closeStore​(Store store)
        Description copied from interface: StoreSystem
        Closes 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:
        closeStore in interface StoreSystem
      • deleteStore

        public boolean deleteStore​(Store store)
        Description copied from interface: StoreSystem
        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. 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:
        deleteStore in interface StoreSystem
      • setCheckPoint

        public void setCheckPoint()
        Description copied from interface: StoreSystem
        Sets 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:
        setCheckPoint in interface StoreSystem
      • lock

        public void lock​(java.lang.String name)
                  throws java.io.IOException
        Description copied from interface: StoreSystem
        Attempts 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:
        lock in interface StoreSystem
        Throws:
        java.io.IOException
      • unlock

        public void unlock​(java.lang.String name)
                    throws java.io.IOException
        Description copied from interface: StoreSystem
        Unlocks the exclusive access to the persistent store objects. After this method completes, access to the store system by other processes is allowed.
        Specified by:
        unlock in interface StoreSystem
        Throws:
        java.io.IOException