com.caucho.db.store
Class Transaction

java.lang.Object
  extended by com.caucho.db.store.StoreTransaction
      extended by com.caucho.db.store.Transaction

public class Transaction
extends StoreTransaction

Represents a single transaction.


Method Summary
 void addAddInode(Inode inode)
          Adds inode which should be deleted on a rollback.
 void addDeleteInode(Inode inode)
          Adds inode which should be deleted on a commit.
 void addUpdateBlock(Block block)
          Adds a block for update.
 Block allocateRow(Store store)
          Returns a modified block.
 void autoCommit()
           
 void autoCommitRead(Lock lock)
          If auto-commit, commit the read
 void autoCommitWrite(Lock lock)
          If auto-commit, commit the write
 void commit()
           
static Transaction create()
           
static Transaction create(ConnectionImpl conn)
           
 Block createAutoCommitWriteBlock(Block block)
          Returns a modified block.
 WriteBlock createWriteBlock(Block block)
          Returns a modified block.
 Block createWriteBlock(Store store, long blockAddress)
          Returns a modified block.
 void deallocateBlock(Block block)
          Returns a modified block.
 WriteBlock getWriteBlock(long blockId)
          Returns a modified block.
 boolean hasReadLock(Lock lock)
          Acquires a new read lock.
 boolean isAutoCommit()
          Returns true for an auto-commit transaction.
 void lockRead(Lock lock)
          Acquires a new write lock.
 void lockReadAndWrite(Lock lock)
          Acquires a new write lock.
 boolean lockReadAndWriteNoWait(Lock lock)
          Conditionally a new write lock, if no contention exists.
 void lockWrite(Lock lock)
          Acquires a new write lock.
 Block readBlock(Store store, long blockAddress)
          Returns a read block.
 void rollback()
           
 void setAutoCommit(boolean autoCommit)
          Returns true for an auto-commit transaction.
 void setRollbackOnly()
           
 void setRollbackOnly(java.sql.SQLException e)
           
 void setTimeout(long timeout)
          Sets the transaction timeout.
 void unlockRead(Lock lock)
           
 void unlockReadAndWrite(Lock lock)
           
 void unlockWrite(Lock lock)
           
 void writeData()
           
 
Methods inherited from class com.caucho.db.store.StoreTransaction
addUpdateFragmentBlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static Transaction create(ConnectionImpl conn)

create

public static Transaction create()

setTimeout

public void setTimeout(long timeout)
Sets the transaction timeout.


hasReadLock

public boolean hasReadLock(Lock lock)
Acquires a new read lock.


isAutoCommit

public boolean isAutoCommit()
Returns true for an auto-commit transaction.


setAutoCommit

public void setAutoCommit(boolean autoCommit)
Returns true for an auto-commit transaction.


lockRead

public void lockRead(Lock lock)
              throws java.sql.SQLException
Acquires a new write lock.

Throws:
java.sql.SQLException

lockReadAndWrite

public void lockReadAndWrite(Lock lock)
                      throws java.sql.SQLException
Acquires a new write lock.

Throws:
java.sql.SQLException

lockReadAndWriteNoWait

public boolean lockReadAndWriteNoWait(Lock lock)
                               throws java.sql.SQLException
Conditionally a new write lock, if no contention exists.

Throws:
java.sql.SQLException

lockWrite

public void lockWrite(Lock lock)
               throws java.sql.SQLException
Acquires a new write lock.

Throws:
java.sql.SQLException

addUpdateBlock

public void addUpdateBlock(Block block)
Adds a block for update.

Specified by:
addUpdateBlock in class StoreTransaction

autoCommitRead

public void autoCommitRead(Lock lock)
                    throws java.sql.SQLException
If auto-commit, commit the read

Throws:
java.sql.SQLException

unlockRead

public void unlockRead(Lock lock)
                throws java.sql.SQLException
Throws:
java.sql.SQLException

autoCommitWrite

public void autoCommitWrite(Lock lock)
                     throws java.sql.SQLException
If auto-commit, commit the write

Throws:
java.sql.SQLException

unlockReadAndWrite

public void unlockReadAndWrite(Lock lock)
                        throws java.sql.SQLException
Throws:
java.sql.SQLException

unlockWrite

public void unlockWrite(Lock lock)
                 throws java.sql.SQLException
Throws:
java.sql.SQLException

readBlock

public Block readBlock(Store store,
                       long blockAddress)
                throws java.io.IOException
Returns a read block.

Specified by:
readBlock in class StoreTransaction
Throws:
java.io.IOException

getWriteBlock

public WriteBlock getWriteBlock(long blockId)
Returns a modified block.


createWriteBlock

public WriteBlock createWriteBlock(Block block)
                            throws java.io.IOException
Returns a modified block.

Specified by:
createWriteBlock in class StoreTransaction
Throws:
java.io.IOException

createAutoCommitWriteBlock

public Block createAutoCommitWriteBlock(Block block)
                                 throws java.io.IOException
Returns a modified block.

Overrides:
createAutoCommitWriteBlock in class StoreTransaction
Throws:
java.io.IOException

allocateRow

public Block allocateRow(Store store)
                  throws java.io.IOException
Returns a modified block.

Throws:
java.io.IOException

deallocateBlock

public void deallocateBlock(Block block)
                     throws java.io.IOException
Returns a modified block.

Throws:
java.io.IOException

createWriteBlock

public Block createWriteBlock(Store store,
                              long blockAddress)
                       throws java.io.IOException
Returns a modified block.

Throws:
java.io.IOException

addDeleteInode

public void addDeleteInode(Inode inode)
Adds inode which should be deleted on a commit.


addAddInode

public void addAddInode(Inode inode)
Adds inode which should be deleted on a rollback.


autoCommit

public void autoCommit()
                throws java.sql.SQLException
Throws:
java.sql.SQLException

setRollbackOnly

public void setRollbackOnly(java.sql.SQLException e)

setRollbackOnly

public void setRollbackOnly()

commit

public void commit()
            throws java.sql.SQLException
Throws:
java.sql.SQLException

writeData

public void writeData()
               throws java.sql.SQLException
Throws:
java.sql.SQLException

rollback

public void rollback()
              throws java.sql.SQLException
Throws:
java.sql.SQLException