Class V1HeapStoreSystem

  • All Implemented Interfaces:
    StoreSystem

    class V1HeapStoreSystem
    extends java.lang.Object
    implements StoreSystem
    An implementation of StoreSystem that stores all persistent data on the heap using HeapStore objects.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.HashMap name_store_map
      A mapping from name to Store object for this heap store system.
      private java.util.HashMap store_name_map
      A mapping from Store object to name.
    • Constructor Summary

      Constructors 
      Constructor Description
      V1HeapStoreSystem()
      Constructor.
    • 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.
      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 lock_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 lock_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

      • name_store_map

        private java.util.HashMap name_store_map
        A mapping from name to Store object for this heap store system.
      • store_name_map

        private java.util.HashMap store_name_map
        A mapping from Store object to name.
    • Constructor Detail

      • V1HeapStoreSystem

        V1HeapStoreSystem()
        Constructor.
    • Method Detail

      • 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 lock_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 lock_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