org.axiondb.engine
Class SnapshotIsolationTransaction

java.lang.Object
  extended byorg.axiondb.engine.SnapshotIsolationTransaction
All Implemented Interfaces:
Database, TableModificationListener, Transactable, Transaction, VariableContext

public class SnapshotIsolationTransaction
extends Object
implements Transaction, TableModificationListener, VariableContext

A Transaction implementation that provides "snapshot isolation", which supports TRANSACTION_SERIALIZABLE isolation without locking.

Version:
$Revision: 1.40 $ $Date: 2004/09/09 23:47:45 $

Field Summary
 
Fields inherited from interface org.axiondb.Transaction
STATE_ABORTED, STATE_APPLIED, STATE_COMMITTED, STATE_OPEN
 
Fields inherited from interface org.axiondb.Database
COMMIT_SIZE
 
Constructor Summary
SnapshotIsolationTransaction(Database db)
           
 
Method Summary
 void addDatabaseModificationListener(DatabaseModificationListener l)
          Adds a listener to receive events on this database
 void addIndex(Index index, Table table)
          Add the given Indexto this database, associated with the given table.
 void addIndex(Index index, Table table, boolean doPopulate)
          Add the given Indexto this database, associating it with the given table and (optionally) populating it.
 void addTable(Table table)
          Add the given Tableto this database.
 void apply()
          Apply this committedtransaction..
 boolean canResolveSelectable(Selectable selectable, TableIdentifier[] tables)
           
 void checkpoint()
          Make sure any modified state or data has been written to disk.
 void columnAdded(ColumnEvent event)
           
 void commit()
          This transaction has been committed.
 void constraintAdded(ConstraintEvent event)
           
 void constraintRemoved(ConstraintEvent event)
           
 boolean containsKey(Object key)
           
 void createDatabaseLink(DatabaseLink server)
           
 void createSequence(Sequence seq)
          Create a numeric sequence
 void dropDatabaseLink(String server)
           
 void dropIndex(String name)
          Drop the given Indexfrom this database.
 void dropSequence(String name)
          Drop the specified Sequencefrom this database.
 void dropTable(String name)
          Drop the specified Tablefrom this database.
 Object get(Object key)
           
 DatabaseLink getDatabaseLink(String name)
           
 List getDatabaseModificationListeners()
          Returns all listeners set to receive events on this database
 DataType getDataType(String name)
          Get the DataTypecurrently registered for the given name, or null.
 File getDBDirectory()
          Get the directory into which table information is stored, or null.
 Object getGlobalVariable(String key)
           
 IndexFactory getIndexFactory(String name)
          Get the IndexFactorycurrently registered for the given name, or null.
 Set getModifiedTables()
          Return a Setof Tables that have been modified thus far in this transaction.
 String getName()
          Returns the name of this Database.
 Database getOpenOnTransaction()
          Get the Databaseupon which I am open (i.e., the state to which we will return to if I am rolled back.
 Set getReadTables()
          Return a Setof Tables that have been read thus far in this transaction.
 Sequence getSequence(String name)
          Get the specified Sequence, or null if no such sequence can be found.
 int getState()
          Return my current transaction state.
 Table getTable(String name)
          Get the specified Table, or null if no such table can be found.
 Table getTable(TableIdentifier table)
          Get the specified Table, or null if no such table can be found.
 TableFactory getTableFactory(String name)
          Get the TableFactorycurrently registered for the given name, or null.
 TransactionManager getTransactionManager()
          Get the TransactionManagerfor this database.
 boolean hasDatabaseLink(String name)
           
 boolean hasIndex(String name)
          Returns true iff the given Indexexists.
 boolean hasSequence(String name)
           
 boolean hasTable(String name)
           
 boolean hasTable(TableIdentifier table)
           
 boolean isReadOnly()
          Is this database read-only?
 void put(Object key, Object value)
           
 void remount(File newdir)
          Notify this database that its root directory has been moved to the given location.
 void remove(Object key)
           
 void renameTable(String oldName, String newName)
           
 void resolveFromNode(FromNode from, List aliasList)
           
 Selectable resolveSelectable(Selectable selectable, List aliasList, TableIdentifier[] tables)
           
 Selectable resolveSelectable(Selectable selectable, TableIdentifier[] tables)
          "Resolve" the given Selectablerelative to the given list of tables, converting aliased or relative references into absolute ones.
 void rollback()
          This transaction has been aborted.
 void rowDeleted(RowEvent event)
           
 void rowInserted(RowEvent event)
           
 void rowUpdated(RowEvent event)
           
 void shutdown()
          Close this database and free any resources associated with it.
 void tableAltered(Table table)
          Update metadata tables since this table has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnapshotIsolationTransaction

public SnapshotIsolationTransaction(Database db)
Method Detail

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface VariableContext

get

public Object get(Object key)
Specified by:
get in interface VariableContext

put

public void put(Object key,
                Object value)
Specified by:
put in interface VariableContext

remove

public void remove(Object key)
Specified by:
remove in interface VariableContext

getState

public int getState()
Description copied from interface: Transaction
Return my current transaction state. Returns one of Transaction.STATE_OPEN, Transaction.STATE_COMMITTED,Transaction.STATE_ABORTED,Transaction.STATE_APPLIED.

Specified by:
getState in interface Transaction

getName

public String getName()
Description copied from interface: Database
Returns the name of this Database.

Specified by:
getName in interface Database

getTable

public Table getTable(String name)
               throws AxionException
Description copied from interface: Database
Get the specified Table, or null if no such table can be found.

Table name matching is case-insensitive.

Specified by:
getTable in interface Database
Throws:
AxionException

getTable

public Table getTable(TableIdentifier table)
               throws AxionException
Description copied from interface: Database
Get the specified Table, or null if no such table can be found.

Table name matching is case-insensitive.

Specified by:
getTable in interface Database
Throws:
AxionException

hasTable

public boolean hasTable(String name)
                 throws AxionException
Specified by:
hasTable in interface Database
Throws:
AxionException

hasTable

public boolean hasTable(TableIdentifier table)
                 throws AxionException
Specified by:
hasTable in interface Database
Throws:
AxionException

dropTable

public void dropTable(String name)
               throws AxionException
Description copied from interface: Database
Drop the specified Tablefrom this database.

Table name matching is case-insensitive.

Specified by:
dropTable in interface Database
Throws:
AxionException

addTable

public void addTable(Table table)
              throws AxionException
Description copied from interface: Database
Add the given Tableto this database.

Specified by:
addTable in interface Database
Throws:
AxionException

hasIndex

public boolean hasIndex(String name)
                 throws AxionException
Description copied from interface: Database
Returns true iff the given Indexexists.

Specified by:
hasIndex in interface Database
Throws:
AxionException

dropIndex

public void dropIndex(String name)
               throws AxionException
Description copied from interface: Database
Drop the given Indexfrom this database.

Specified by:
dropIndex in interface Database
Throws:
AxionException

addIndex

public void addIndex(Index index,
                     Table table)
              throws AxionException
Description copied from interface: Database
Add the given Indexto this database, associated with the given table.

Specified by:
addIndex in interface Database
Throws:
AxionException

addIndex

public void addIndex(Index index,
                     Table table,
                     boolean doPopulate)
              throws AxionException
Description copied from interface: Database
Add the given Indexto this database, associating it with the given table and (optionally) populating it.

Specified by:
addIndex in interface Database
Parameters:
index - Index to be added and (optionally) populated
table - Table to be indexed
doPopulate - true if index should be populated by the appropriate column in table; false if index should be left as-is.
Throws:
AxionException - if error occurs during addition and/or population of index

tableAltered

public void tableAltered(Table table)
                  throws AxionException
Description copied from interface: Database
Update metadata tables since this table has changed.

Specified by:
tableAltered in interface Database
Throws:
AxionException

getDataType

public DataType getDataType(String name)
Description copied from interface: Database
Get the DataTypecurrently registered for the given name, or null.

Specified by:
getDataType in interface Database

getGlobalVariable

public Object getGlobalVariable(String key)
Specified by:
getGlobalVariable in interface Database

getIndexFactory

public IndexFactory getIndexFactory(String name)
Description copied from interface: Database
Get the IndexFactorycurrently registered for the given name, or null.

Specified by:
getIndexFactory in interface Database

getTableFactory

public TableFactory getTableFactory(String name)
Description copied from interface: Database
Get the TableFactorycurrently registered for the given name, or null.

Specified by:
getTableFactory in interface Database

getDBDirectory

public File getDBDirectory()
Description copied from interface: Database
Get the directory into which table information is stored, or null.

Specified by:
getDBDirectory in interface Database

resolveSelectable

public Selectable resolveSelectable(Selectable selectable,
                                    TableIdentifier[] tables)
                             throws AxionException
Description copied from interface: Database
"Resolve" the given Selectablerelative to the given list of tables, converting aliased or relative references into absolute ones.

Specified by:
resolveSelectable in interface Database
Throws:
AxionException

canResolveSelectable

public boolean canResolveSelectable(Selectable selectable,
                                    TableIdentifier[] tables)
Specified by:
canResolveSelectable in interface Database

resolveSelectable

public Selectable resolveSelectable(Selectable selectable,
                                    List aliasList,
                                    TableIdentifier[] tables)
                             throws AxionException
Specified by:
resolveSelectable in interface Database
Throws:
AxionException

resolveFromNode

public void resolveFromNode(FromNode from,
                            List aliasList)
                     throws AxionException
Specified by:
resolveFromNode in interface Database
Throws:
AxionException

checkpoint

public void checkpoint()
                throws AxionException
Description copied from interface: Database
Make sure any modified state or data has been written to disk.

Specified by:
checkpoint in interface Database
Throws:
AxionException

shutdown

public void shutdown()
              throws AxionException
Description copied from interface: Database
Close this database and free any resources associated with it.

Specified by:
shutdown in interface Database
Throws:
AxionException

remount

public void remount(File newdir)
             throws AxionException
Description copied from interface: Database
Notify this database that its root directory has been moved to the given location. (E.g., the CD containing the data for a CD-resident database has changed drives.)

Specified by:
remount in interface Database
Throws:
AxionException

renameTable

public void renameTable(String oldName,
                        String newName)
                 throws AxionException
Specified by:
renameTable in interface Database
Throws:
AxionException

isReadOnly

public boolean isReadOnly()
Description copied from interface: Database
Is this database read-only?

Specified by:
isReadOnly in interface Database

createSequence

public void createSequence(Sequence seq)
                    throws AxionException
Description copied from interface: Database
Create a numeric sequence

Specified by:
createSequence in interface Database
Throws:
AxionException

getSequence

public Sequence getSequence(String name)
Description copied from interface: Database
Get the specified Sequence, or null if no such sequence can be found.

Sequence name matching is case-insensitive.

Specified by:
getSequence in interface Database

dropSequence

public void dropSequence(String name)
                  throws AxionException
Description copied from interface: Database
Drop the specified Sequencefrom this database.

Sequence name matching is case-insensitive.

Specified by:
dropSequence in interface Database
Throws:
AxionException

hasSequence

public boolean hasSequence(String name)
                    throws AxionException
Specified by:
hasSequence in interface Database
Throws:
AxionException

createDatabaseLink

public void createDatabaseLink(DatabaseLink server)
                        throws AxionException
Specified by:
createDatabaseLink in interface Database
Throws:
AxionException

dropDatabaseLink

public void dropDatabaseLink(String server)
                      throws AxionException
Specified by:
dropDatabaseLink in interface Database
Throws:
AxionException

getDatabaseLink

public DatabaseLink getDatabaseLink(String name)
Specified by:
getDatabaseLink in interface Database

hasDatabaseLink

public boolean hasDatabaseLink(String name)
                        throws AxionException
Specified by:
hasDatabaseLink in interface Database
Throws:
AxionException

commit

public void commit()
            throws AxionException
Description copied from interface: Transactable
This transaction has been committed.

Specified by:
commit in interface Transactable
Throws:
AxionException

rollback

public void rollback()
              throws AxionException
Description copied from interface: Transactable
This transaction has been aborted.

Specified by:
rollback in interface Transactable
Throws:
AxionException

apply

public void apply()
           throws AxionException
Description copied from interface: Transactable
Apply this committedtransaction..

Specified by:
apply in interface Transactable
Throws:
AxionException

addDatabaseModificationListener

public void addDatabaseModificationListener(DatabaseModificationListener l)
Description copied from interface: Database
Adds a listener to receive events on this database

Specified by:
addDatabaseModificationListener in interface Database

getDatabaseModificationListeners

public List getDatabaseModificationListeners()
Description copied from interface: Database
Returns all listeners set to receive events on this database

Specified by:
getDatabaseModificationListeners in interface Database

columnAdded

public void columnAdded(ColumnEvent event)
                 throws AxionException
Specified by:
columnAdded in interface TableModificationListener
Throws:
AxionException

rowInserted

public void rowInserted(RowEvent event)
                 throws AxionException
Specified by:
rowInserted in interface TableModificationListener
Throws:
AxionException

rowDeleted

public void rowDeleted(RowEvent event)
                throws AxionException
Specified by:
rowDeleted in interface TableModificationListener
Throws:
AxionException

rowUpdated

public void rowUpdated(RowEvent event)
                throws AxionException
Specified by:
rowUpdated in interface TableModificationListener
Throws:
AxionException

constraintAdded

public void constraintAdded(ConstraintEvent event)
                     throws AxionException
Specified by:
constraintAdded in interface TableModificationListener
Throws:
AxionException

constraintRemoved

public void constraintRemoved(ConstraintEvent event)
                       throws AxionException
Specified by:
constraintRemoved in interface TableModificationListener
Throws:
AxionException

getOpenOnTransaction

public Database getOpenOnTransaction()
Description copied from interface: Transaction
Get the Databaseupon which I am open (i.e., the state to which we will return to if I am rolled back. Note that this may be another Transaction.

Specified by:
getOpenOnTransaction in interface Transaction

getModifiedTables

public Set getModifiedTables()
Description copied from interface: Transaction
Return a Setof Tables that have been modified thus far in this transaction.

Specified by:
getModifiedTables in interface Transaction

getReadTables

public Set getReadTables()
Description copied from interface: Transaction
Return a Setof Tables that have been read thus far in this transaction.

Specified by:
getReadTables in interface Transaction

getTransactionManager

public TransactionManager getTransactionManager()
Description copied from interface: Database
Get the TransactionManagerfor this database.

Specified by:
getTransactionManager in interface Database