Documentation of 'org.neodatis.odb.impl.core.transaction.DefaultTransaction' Java class
DefaultTransaction
org.neodatis.odb.impl.core.transaction

Class DefaultTransaction

  • All Implemented Interfaces:
    ITransaction


    public class DefaultTransaction
    extends java.lang.Object
    implements ITransaction
     The transaction class is used to guarantee ACID behavior. It keep tracks of all session
     operations. It uses the WriteAction class to store all changes that can not be written to the file
     before the commit.
     The transaction is held by The Session class and manage commits and rollbacks.
     
     All WriteActions are written in a transaction file to be sure to be able to commit and in case 
     of very big transaction where all WriteActions can not be stored in memory.
     
    • Field Detail

      • LOG_ID

        public static final java.lang.String LOG_ID
        the log module name
        See Also:
        Constant Field Values
      • currentWriteAction

        public IWriteAction currentWriteAction
        The same write action is reused for successive writes
      • currentWritePositionInWA

        public long currentWritePositionInWA
        The position of the next write for WriteAction
      • numberOfWriteActions

        public int numberOfWriteActions
        The number of write actions
      • fsi

        public IFileSystemInterface fsi
        A file interface to the transaction file - used to read/write the file
      • session

        public ISession session
        The transaction session
    • Constructor Detail

      • DefaultTransaction

        public DefaultTransaction(ISession session)
                           throws java.io.IOException
        The main constructor
        Parameters:
        session - The transaction session
        Throws:
        java.io.IOException
      • DefaultTransaction

        public DefaultTransaction(ISession session,
                                  java.lang.String overrideTransactionName)
                           throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • init

        public void init(ISession session)
      • clear

        public void clear()
        Description copied from interface: ITransaction
        clear the transaction
        Specified by:
        clear in interface ITransaction
      • reset

        public void reset()
        Reset the transaction
        Specified by:
        reset in interface ITransaction
      • addWriteAction

        public void addWriteAction(IWriteAction writeAction)
        Adds a write action to the transaction
        Parameters:
        writeAction - The write action to be added
      • addWriteAction

        public void addWriteAction(IWriteAction writeAction,
                                   boolean persistWriteAcion)
        Adds a write action to the transaction
        Parameters:
        writeAction - The write action to be added
        persistWriteAcion - To indicate if write action must be persisted
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface ITransaction
      • getCreationDateTime

        public long getCreationDateTime()
      • commit

        public void commit()
        Description copied from interface: ITransaction
        Execute the commit process of the transaction
        Specified by:
        commit in interface ITransaction
      • buildClassInfoForCommit

        public ClassInfo buildClassInfoForCommit(ClassInfo classInfo)
        Shift all unconnected infos to connected (committed) infos
        Parameters:
        classInfo -
        Returns:
        The updated class info
      • read

        public static DefaultTransaction read(java.lang.String fileName)
                                       throws java.io.IOException,
                                              java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • loadWriteActions

        public void loadWriteActions(boolean apply)
      • loadWriteActions

        public void loadWriteActions(java.lang.String filename,
                                     boolean apply)
      • loadWriteActionsBackwards

        public void loadWriteActionsBackwards(java.lang.String filename,
                                              boolean apply)
                                       throws java.io.IOException,
                                              java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isArchiveLog

        public boolean isArchiveLog()
        Specified by:
        isArchiveLog in interface ITransaction
        Returns:
        Returns the archiveLog.
      • setArchiveLog

        public void setArchiveLog(boolean archiveLog)
        Specified by:
        setArchiveLog in interface ITransaction
        Parameters:
        archiveLog - The archiveLog to set.
      • getFsi

        public IFileSystemInterface getFsi()
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • setWritePosition

        public void setWritePosition(long position)
        Set the write position (position in main database file). This is used to know if the next write can be appended to the previous one (in the same current Write Action) or not.
        Specified by:
        setWritePosition in interface ITransaction
        Parameters:
        position -
      • manageWriteAction

        public void manageWriteAction(long position,
                                      byte[] bytes)
        Description copied from interface: ITransaction
        The public method to add a write action to the transaction. If first checks if the new write action action can be appended to the current write action. It is done by checking the currentWritePositioninWA. If yes (position==currentPositioninWA, just append the WA. If not, adds the current one to the transaction and creates a new one (as current)
        Specified by:
        manageWriteAction in interface ITransaction

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.