ozone core API

org.ozoneDB.core
Class TransactionManager

java.lang.Object
  |
  +--org.ozoneDB.core.ServerComponent
        |
        +--org.ozoneDB.core.TransactionManager

public final class TransactionManager
extends ServerComponent

The transaction manager is the factory for transactions and locks.

Version:
$Revision: 1.2 $Date: 2002/06/08 00:49:38 $
Author:
SMB
, Medium.net

Field Summary
protected  long acquireCount
           
protected  boolean alsoNotifySomeSleepingTransactions
          If we notify all transactions, they not-blocked-ones may wake up from sleeping.
protected  Transaction deadlockTA
          Used to signal a deadlock and which Transaction should abort.
protected  java.lang.Thread exclusiveThread
          True if one thread runs exclusively.
protected  DxMap taTable
          All currently running transactions.
protected  DxMap threadTable
          In local mode this maps threads to transactions.
 
Fields inherited from class org.ozoneDB.core.ServerComponent
env
 
Constructor Summary
TransactionManager(Env _env)
           
 
Method Summary
protected  void abortTransaction(Transaction ta, DbCommand command)
           
protected  void beginExclusion()
           
 void checkDeadlocks()
          This method checks for deadlocks between all current transaction.
 void checkExclusion()
          Blocks execution until there is no thread scheduled for exclusive execution or the exclusive thread is the current thread.
protected  void commitTransaction(Transaction ta, DbCommand command)
           
protected  void completeTransaction(DbCommand command, User user)
          Perform the specified command within a new transaction.
 Transaction currentTA()
          der aktuelle thread is auch die aktuelle transaktion (wenn der thread ueberhaupt eine transaktion ist)
 void deleteTransaction()
          Delete the transaction that is associated with the current thread.
protected  void endExclusion()
           
 void handleCommand(DbCommand command, DbInvokeClient client)
          Handle the specified command on behalf of the current thread/transaction.
 void handleCommand(DbCommand command, User user)
          Handle the specified command on behalf of the current thread/transaction.
 boolean isDeadlockTA(Transaction ta)
          Check if the given transaction should abort because of a deadlock.
 Lock newLock()
          Factory method to generate proper Lock objects.
 Transaction newTransaction(User owner)
           
 void notifyWaitingTransactions()
          Notify each thread that is associated with a currently blocked transaction by calling notifyAll() on the blocked transaction.
protected  boolean performCommand(Transaction ta, DbCommand command)
          Perform the specified command on behalf of the specified thread/transaction.
protected  boolean prepareTransaction(Transaction ta, DbCommand command)
          Prepare the specified transaction.
 void save()
          Save the internal state in the state to the server state properties.
 void shutdown()
           
 void startGarbageCollectionWaitForCurrentTransactionsToCompletePhase(GarbageCollector garbageCollector)
          Starts the GarbageColection pre-phase.
 void startup()
          Start up and load the internal state from the server state properties.
 Transaction taForID(TransactionID taID)
           
 int taTableCount()
           
 
Methods inherited from class org.ozoneDB.core.ServerComponent
clearChanged, hasChanged, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

taTable

protected DxMap taTable
All currently running transactions. taID -> ta


threadTable

protected DxMap threadTable
In local mode this maps threads to transactions.


deadlockTA

protected Transaction deadlockTA
Used to signal a deadlock and which Transaction should abort.


exclusiveThread

protected java.lang.Thread exclusiveThread
True if one thread runs exclusively.


acquireCount

protected long acquireCount

alsoNotifySomeSleepingTransactions

protected boolean alsoNotifySomeSleepingTransactions
If we notify all transactions, they not-blocked-ones may wake up from sleeping.

Constructor Detail

TransactionManager

public TransactionManager(Env _env)
Method Detail

startup

public void startup()
             throws java.lang.Exception
Description copied from class: ServerComponent
Start up and load the internal state from the server state properties.

Specified by:
startup in class ServerComponent
java.lang.Exception

shutdown

public void shutdown()
              throws java.lang.Exception
Specified by:
shutdown in class ServerComponent
java.lang.Exception

save

public void save()
          throws java.lang.Exception
Description copied from class: ServerComponent
Save the internal state in the state to the server state properties.

Specified by:
save in class ServerComponent
java.lang.Exception

newLock

public Lock newLock()
Factory method to generate proper Lock objects. These Lock objects are used in the store backend but they have to be generated in the core to meet the requirements of the transaction implementation.


taTableCount

public int taTableCount()

taForID

public Transaction taForID(TransactionID taID)

currentTA

public Transaction currentTA()
der aktuelle thread is auch die aktuelle transaktion (wenn der thread ueberhaupt eine transaktion ist)


newTransaction

public Transaction newTransaction(User owner)
                           throws org.ozoneDB.TransactionExc
org.ozoneDB.TransactionExc

deleteTransaction

public void deleteTransaction()
Delete the transaction that is associated with the current thread.


notifyWaitingTransactions

public void notifyWaitingTransactions()
Notify each thread that is associated with a currently blocked transaction by calling notifyAll() on the blocked transaction.


handleCommand

public void handleCommand(DbCommand command,
                          DbInvokeClient client)
Handle the specified command on behalf of the current thread/transaction. This method is called by the InvokeServer after it has handled InvokeServer specific command.


handleCommand

public void handleCommand(DbCommand command,
                          User user)
Handle the specified command on behalf of the current thread/transaction. This method is called by the InvokeServer after it has handled InvokeServer specific command.


completeTransaction

protected void completeTransaction(DbCommand command,
                                   User user)
                            throws java.lang.Exception
Perform the specified command within a new transaction.

java.lang.Exception

performCommand

protected boolean performCommand(Transaction ta,
                                 DbCommand command)
                          throws java.lang.Exception
Perform the specified command on behalf of the specified thread/transaction. If the transaction has performed only one command until now, this handles deadlocks by re-performing the command again until it throws an exception or completes sucessfully. Otherwise an exception is thrown

Returns:
True if the command did not throw an exception
Throws:
java.lang.Exception - Any exception always signals an internal error.

prepareTransaction

protected boolean prepareTransaction(Transaction ta,
                                     DbCommand command)
                              throws java.lang.Exception
Prepare the specified transaction. Return true on success and false if something failed. In this case the transaction is rolled back. This method throws an exception only if an internal server error occured.

java.lang.Exception

commitTransaction

protected void commitTransaction(Transaction ta,
                                 DbCommand command)
                          throws java.lang.Exception
java.lang.Exception

abortTransaction

protected void abortTransaction(Transaction ta,
                                DbCommand command)
                         throws java.lang.Exception
java.lang.Exception

checkExclusion

public void checkExclusion()
Blocks execution until there is no thread scheduled for exclusive execution or the exclusive thread is the current thread.


beginExclusion

protected void beginExclusion()

endExclusion

protected void endExclusion()

checkDeadlocks

public void checkDeadlocks()
                    throws java.lang.Exception
This method checks for deadlocks between all current transaction.

java.lang.Exception

isDeadlockTA

public boolean isDeadlockTA(Transaction ta)
Check if the given transaction should abort because of a deadlock.


startGarbageCollectionWaitForCurrentTransactionsToCompletePhase

public void startGarbageCollectionWaitForCurrentTransactionsToCompletePhase(GarbageCollector garbageCollector)
Starts the GarbageColection pre-phase. This is the time where all transactions have to complete (either commit or rollback) until there are no transactions left which were created before this call.


ozone core API

Copyright (C) The Ozone Database Project - www.ozone-db.org. All rights reserved.