Class ATransaction

    • Field Detail

      • CLEANUP_THRESHOLD_OPERATION

        static final int CLEANUP_THRESHOLD_OPERATION
        See Also:
        Constant Field Values
      • operationCount

        private int operationCount
      • cumulativeSize

        private int cumulativeSize
      • commitCount

        private int commitCount
        Number of commit operation since starting up.
      • clog

        private Hashtable clog
        Log of all operations already commited but not reported on disk by the "garbage" Thread. On event (at least previous log plog must be empty), it is moved to plog.
      • plog

        private Hashtable plog
        Log currently used by "garbage" Thread, its thread reports all operation it contents on disk, then it deletes it.
      • logFilePN

        protected File logFilePN
      • plogFilePN

        protected File plogFilePN
      • garbage

        private boolean garbage
      • isRunning

        private boolean isRunning
      • gThread

        private Thread gThread
      • emptyUTFString

        private static final byte[] emptyUTFString
    • Constructor Detail

      • ATransaction

        public ATransaction()
    • Method Detail

      • getDir

        public final File getDir()
      • setPhase

        protected final void setPhase​(int newPhase)
        Description copied from class: AbstractTransaction
        Changes the transaction state.
        Specified by:
        setPhase in class AbstractTransaction
        Parameters:
        newPhase - the new transaction state.
      • getList

        public final String[] getList​(String prefix)
        Description copied from interface: Transaction
        Returns an array of strings naming the objects in the component started by this prefix.
        Specified by:
        getList in interface Transaction
        Parameters:
        prefix - the prefix of searched objects.
        Returns:
        an array of strings naming the objects in the component started by this prefix.
      • saveInLog

        protected final void saveInLog​(byte[] buf,
                                       String dirName,
                                       String name,
                                       Hashtable log,
                                       boolean copy,
                                       boolean first)
                                throws IOException
        Description copied from class: AbstractTransaction
        Register the specified object in transaction log.
        Specified by:
        saveInLog in class AbstractTransaction
        Parameters:
        buf - the byte array containing the state of the object.
        dirName - the directory name of the object.
        name - the name of the object.
        log - the log to use.
        copy - the byte array can be modified, copy it.
        first - the object is a new one.
        Throws:
        IOException - an error occurs.
      • loadByteArray

        public final byte[] loadByteArray​(String dirName,
                                          String name)
                                   throws IOException
        Description copied from interface: Transaction
        Load the specified byte array.
        Specified by:
        loadByteArray in interface Transaction
        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

        public final void delete​(String dirName,
                                 String name)
        Description copied from interface: Transaction
        Deletes the specified object.
        Specified by:
        delete in interface Transaction
        Parameters:
        dirName - the directory name of the object.
        name - the name of the object.
      • commit

        public void commit​(boolean release)
                    throws IOException
        Description copied from interface: Transaction
        Commit the current transaction.
        Specified by:
        commit in interface Transaction
        Parameters:
        release - if true releases the transaction at the end of the commit.
        Throws:
        IOException - an error occurs.
      • rollback

        public final void rollback()
      • commit

        private final void commit​(Hashtable log)
                           throws IOException
        Reports all logged operations on disk.
        Parameters:
        log - the log object.
        Throws:
        IOException - an error occurs.
      • deleteDir

        private final void deleteDir​(File dir)
        Delete the specified directory if it is empty. Also recursively delete the parent directories if they are empty.
        Parameters:
        dir - the directory to delete.
      • _stop

        public final void _stop()
      • stop

        public final void stop()
        Description copied from interface: Transaction
        Stops the transaction module. It waits all transactions termination, then the module is kept in a FREE 'ready to use' state.
        Specified by:
        stop in interface Transaction
      • close

        public void close()
        Close the transaction module. It waits all transactions termination, the module will be initialized anew before reusing it.
        Specified by:
        close in interface Transaction
      • run

        public void run()
        Specified by:
        run in interface Runnable
      • backup

        public String backup​(String path)
                      throws Exception
        Backups the content of Transaction module. Produces a generic Backup/Restore file containing all living objects. Currently not implemented, throws an UnsupportedOperationException.
        Specified by:
        backup in interface Transaction
        Specified by:
        backup in interface TransactionMBean
        Parameters:
        path - Directory path to store the backup.
        Returns:
        the name of created backup file.
        Throws:
        Exception - An error occurs during backup.