Interface Transaction

    • Method Detail

      • init

        void init​(String path)
           throws IOException
        Initializes the atomic storage component.
        Parameters:
        path - the path of storage directory.
        Throws:
        IOException - an error occurs.
      • getProperty

        String getProperty​(String key)
        Searches for the property with the specified key in the specific Transaction property list. If the key is not found in this property list, the Configuration property list is then checked. The method returns null if the property is not found.
        Parameters:
        key - the property key.
        Returns:
        the value corresponding to the specified key value.
      • getProperty

        String getProperty​(String key,
                           String defaultValue)
        Searches for the property with the specified key in the specific Transaction property list. If the key is not found in this property list, the Configuration property list is then checked. The method returns the default value argument if the property is not found.
        Parameters:
        key - the property key.
        defaultValue - a default value.
        Returns:
        the value corresponding to the specified key value.
      • getInteger

        Integer getInteger​(String key)
        Determines the integer value of the property with the specified name.
        Parameters:
        key - property name.
        Returns:
        the Integer value of the property.
      • getInteger

        Integer getInteger​(String key,
                           int value)
        Determines the integer value of the property with the specified name.
        Parameters:
        key - property name.
        value - a default value.
        Returns:
        the Integer value of the property.
      • getBoolean

        boolean getBoolean​(String key)
        Returns true if and only if the corresponding property exists and is equal to the string "true".
        Parameters:
        key - the property name.
        Returns:
        the boolean value of the property.
      • getPhase

        int getPhase()
        Returns the transaction state.
        Returns:
        the transaction state.
      • getPhaseInfo

        String getPhaseInfo()
        Returns a string representation of the transaction state.
        Returns:
        the string representation of the transaction state.
      • getCommitCount

        int getCommitCount()
        Returns the number of commit operation since startup.
        Returns:
        The number of commit operation.
      • begin

        void begin()
            throws IOException
        Start a transaction validation, the validation phase needs 3 phases: begin, commit and release. The begin ensure the mutual exclusion of the current transaction.
        Throws:
        IOException - an error occurs.
      • getList

        String[] getList​(String prefix)
        Returns an array of strings naming the objects in the component started by this prefix.
        Parameters:
        prefix - the prefix of searched objects.
        Returns:
        an array of strings naming the objects in the component started by this prefix.
      • useLoadAll

        boolean useLoadAll()
        Returns true if this Transaction implementation implements an optimized loadAll method.
        Returns:
        true if this Transaction implementation implements an optimized loadAll method.
      • loadAll

        void loadAll​(String prefix,
                     Map map)
        Fills the map with all objects of the component whose name begins with the prefix. Each loaded object is registered in the map with its persistent name as key.
        Parameters:
        prefix - The prefix of searched objects.
        map - The map of corresponding objects.
      • isPersistent

        boolean isPersistent()
        Returns true if the component is persistent.
        Returns:
        true if the component is persistent.
      • create

        void create​(Serializable obj,
                    String name)
             throws IOException
        Register the state of a newly created object in the current transaction.
        Parameters:
        obj - the object to store.
        name - the name of the object.
        Throws:
        IOException - an error occurs.
      • create

        void create​(Serializable obj,
                    String dirName,
                    String name)
             throws IOException
        Register the state of a newly created object in the current transaction.
        Parameters:
        obj - the object to store.
        dirName - the directory name of the object.
        name - the name of the object.
        Throws:
        IOException - an error occurs.
      • save

        void save​(Serializable obj,
                  String name)
           throws IOException
        Register the modified state of an object in the current transaction.
        Parameters:
        obj - the object to store.
        name - the name of the object.
        Throws:
        IOException - an error occurs.
      • save

        void save​(Serializable obj,
                  String dirName,
                  String name)
           throws IOException
        Register the modified state of an object in the current transaction.
        Parameters:
        obj - the object to store.
        dirName - the directory name of the object.
        name - the name of the object.
        Throws:
        IOException - an error occurs.
      • save

        void save​(Serializable obj,
                  String dirName,
                  String name,
                  boolean first)
           throws IOException
        Register the state of an object in the current transaction.
        Parameters:
        obj - the object to store.
        dirName - the directory name of the object.
        name - the name of the object.
        first - the object is a new one.
        Throws:
        IOException - an error occurs.
      • createByteArray

        void createByteArray​(byte[] buf,
                             String name)
                      throws IOException
        Register a new byte array in the current transaction.
        Parameters:
        buf - the byte array to store.
        name - the name of the object.
        Throws:
        IOException - an error occurs.
      • createByteArray

        void createByteArray​(byte[] buf,
                             String dirName,
                             String name)
                      throws IOException
        Register a new byte array in the current transaction.
        Parameters:
        buf - the byte array to store.
        dirName - the directory name of the object.
        name - the name of the object.
        Throws:
        IOException - an error occurs.
      • saveByteArray

        void saveByteArray​(byte[] buf,
                           String name)
                    throws IOException
        Register a modified byte array in the current transaction.
        Parameters:
        buf - the byte array to store.
        name - the name of the object.
        Throws:
        IOException - an error occurs.
      • saveByteArray

        void saveByteArray​(byte[] buf,
                           String dirName,
                           String name)
                    throws IOException
        Register a modified byte array in the current transaction.
        Parameters:
        buf - the byte array to store.
        dirName - the directory name of the object.
        name - the name of the object.
        Throws:
        IOException - an error occurs.
      • saveByteArray

        void saveByteArray​(byte[] buf,
                           String dirName,
                           String name,
                           boolean copy,
                           boolean first)
                    throws IOException
        Register a modified byte array in the current transaction.
        Parameters:
        buf - the byte array to store.
        dirName - the directory name of the object.
        name - the name of the object.
        copy - the byte array can be modified, copy it.
        first - the object is a new one.
        Throws:
        IOException - an error occurs.
      • loadByteArray

        byte[] loadByteArray​(String dirName,
                             String name)
                      throws IOException
        Load the specified byte array.
        Parameters:
        dirName - the directory name of the object.
        name - the name of the object.
        Returns:
        the loaded byte array.
        Throws:
        IOException - an error occurs.
      • delete

        void delete​(String name)
        Deletes the specified object.
        Parameters:
        name - the name of the object.
      • delete

        void delete​(String dirName,
                    String name)
        Deletes the specified object.
        Parameters:
        dirName - the directory name of the object.
        name - the name of the object.
      • commit

        void commit​(boolean release)
             throws IOException
        Commit the current transaction.
        Parameters:
        release - if true releases the transaction at the end of the commit.
        Throws:
        IOException - an error occurs.
      • release

        void release()
              throws IOException
        Release the mutual exclusion.
        Throws:
        IOException - an error occurs.
      • stop

        void stop()
        Stops the transaction module. It waits all transactions termination, then the module is kept in a FREE 'ready to use' state.
      • close

        void close()
        Close the transaction module. It waits all transactions termination, the module will be initialized anew before reusing it.
      • containsOperations

        boolean containsOperations()
        Indicates whether some operations have been done in this transaction.
        Returns:
        true if some operations are waiting for commit in this transaction.
      • getOperationCount

        int getOperationCount()
        Returns the number of operations to be committed.
        Returns:
        the number of operations to be committed.
      • backup

        String backup​(String path)
               throws Exception
        Backups the content of Transaction module. Produces a generic Backup/Restore file containing all living objects.
        Parameters:
        path - Directory path to store the backup.
        Returns:
        the name of created backup file.
        Throws:
        Exception - An error occurs during backup.