tyrex.tm.impl

Class TransactionDomainImpl

public class TransactionDomainImpl extends TransactionDomain implements Runnable, DomainMetrics

Implementation of a transaction domain.

Version: $Revision: 1.34 $ $Date: 2005/11/30 13:21:03 $

Author: Assaf Arkin

Field Summary
static intTABLE_SIZE
The size of the hash table.
protected Category_category
The log4J category for this transaction domain.
protected Journal_journal
The transaction journal used by this domain.
protected ORB_orb
The CORBA ORB used by this transaction domain, or null if no CORBA ORB is used.
protected TransactionManagerImpl_txManager
A singleton transaction manager implementation.
Constructor Summary
TransactionDomainImpl(DomainConfig config)
Constructs a new transaction domain.
Method Summary
voidaddInterceptor(TransactionInterceptor interceptor)
protected TransactionImplcreateTransaction(TransactionImpl parent, long timeout)
Creates a new transaction.
protected voiddelistThread(ThreadContext context, Thread thread)
Called to dissociatethe transaction from the thread.
protected voiddumpTransactionList(PrintWriter writer)
protected booleanenlistThread(TransactionImpl tx, ThreadContext context, Thread thread)
Called to associate the transaction with the thread.
TransactionImplfindTransaction(Xid xid)
TransactionImplfindTransaction(String xid)
protected voidforgetTransaction(TransactionImpl tx)
Called by forget to forget about the transaction once it has been commited/rolledback.
intgetActive()
floatgetAvgDuration()
DomainMetricsgetDomainMetrics()
StringgetDomainName()
booleangetNestedTransactions()
TransactionDomainImplgetNextDomain()
ResourcesgetResources()
intgetState()
intgetTotalCommitted()
intgetTotalRolledback()
TransactionFactorygetTransactionFactory()
TransactionManagergetTransactionManager()
intgetTransactionTimeout()
protected intgetTransactionTimeout(TransactionImpl tx)
Called by ControlImpl to obtain the timeout on a transaction for the purpose of the propagation context.
UserTransactiongetUserTransaction()
voididentifyORB(ORB orb, TSIdentification tsi, Properties prop)
protected Transaction[]listTransactions()
protected voidnotifyCommit(TransactionImpl tx)
protected voidnotifyCompletion(TransactionImpl tx, int heuristic)
protected voidnotifyRollback(TransactionImpl tx)
voidrecover()
protected TransactionImplrecreateTransaction(PropagationContext pgContext)
Creates a new transaction to represent a remote OTS transaction, but does not activate it yet.
voidremoveInterceptor(TransactionInterceptor interceptor)
voidreset()
voidrun()
Background thread that looks for transactions that have timed out and terminates them.
voidsetNextDomain(TransactionDomainImpl nextDomain)
protected voidsetTransactionTimeout(int timeout)
Called to set the timeout of all transactions created from this domain.
protected voidsetTransactionTimeout(TransactionImpl tx, int timeout)
Called to change the timeout of the transaction and all the resources enlisted with that transaction.
voidterminate()
StringtoString()

Field Detail

TABLE_SIZE

public static final int TABLE_SIZE
The size of the hash table. This must be a prime value.

_category

protected final Category _category
The log4J category for this transaction domain.

_journal

protected final Journal _journal
The transaction journal used by this domain.

_orb

protected ORB _orb
The CORBA ORB used by this transaction domain, or null if no CORBA ORB is used.

_txManager

protected final TransactionManagerImpl _txManager
A singleton transaction manager implementation.

Constructor Detail

TransactionDomainImpl

public TransactionDomainImpl(DomainConfig config)
Constructs a new transaction domain.

Parameters: config The domain configuration object

Throws: DomainConfigurationException Failed to create the transaction domain

Method Detail

addInterceptor

public void addInterceptor(TransactionInterceptor interceptor)

createTransaction

protected TransactionImpl createTransaction(TransactionImpl parent, long timeout)
Creates a new transaction. If parent is not null, the transaction is nested within its parent. The transaction timeout is specified in seconds, or zero to use the default transaction timeout. Throws a SystemException if we have reached the quota for new transactions or active transactions, or the server has not been started.

Parameters: parent The parent transaction timeout The default timeout for the new transaction, specified in seconds

Returns: The newly created transaction

Throws: SystemException Reached the quota for new transactions

delistThread

protected void delistThread(ThreadContext context, Thread thread)
Called to dissociatethe transaction from the thread.

Parameters: tx The transaction context The thread context thread The thread

See Also: enlistThread

dumpTransactionList

protected void dumpTransactionList(PrintWriter writer)

enlistThread

protected boolean enlistThread(TransactionImpl tx, ThreadContext context, Thread thread)
Called to associate the transaction with the thread.

Parameters: tx The transaction context The thread context thread The thread

Returns: True if transaction enlisted in thread, false if failed

findTransaction

public TransactionImpl findTransaction(Xid xid)

findTransaction

public TransactionImpl findTransaction(String xid)

forgetTransaction

protected void forgetTransaction(TransactionImpl tx)
Called by forget to forget about the transaction once it has been commited/rolledback.

The transaction will no longer be available to findTransaction. The transaction's association and global identifier are forgotten as well as all thread associated with it. Subsequent calls to findTransaction and getControl will not be able to locate the transaction.

If this is the last transaction in a terminating domain, the domain will close some of its resources (e.g. journal) after this method returns.

Parameters: tx The transaction to forget about

getActive

public int getActive()

getAvgDuration

public float getAvgDuration()

getDomainMetrics

public DomainMetrics getDomainMetrics()

getDomainName

public String getDomainName()

getNestedTransactions

public boolean getNestedTransactions()

getNextDomain

public TransactionDomainImpl getNextDomain()

getResources

public Resources getResources()

getState

public int getState()

getTotalCommitted

public int getTotalCommitted()

getTotalRolledback

public int getTotalRolledback()

getTransactionFactory

public TransactionFactory getTransactionFactory()

getTransactionManager

public TransactionManager getTransactionManager()

getTransactionTimeout

public int getTransactionTimeout()

getTransactionTimeout

protected int getTransactionTimeout(TransactionImpl tx)
Called by ControlImpl to obtain the timeout on a transaction for the purpose of the propagation context.

Parameters: tx The transaction

Returns: The transaction's timeout in seconds

getUserTransaction

public UserTransaction getUserTransaction()

identifyORB

public void identifyORB(ORB orb, TSIdentification tsi, Properties prop)

listTransactions

protected Transaction[] listTransactions()

notifyCommit

protected void notifyCommit(TransactionImpl tx)

notifyCompletion

protected void notifyCompletion(TransactionImpl tx, int heuristic)

notifyRollback

protected void notifyRollback(TransactionImpl tx)

recover

public void recover()

recreateTransaction

protected TransactionImpl recreateTransaction(PropagationContext pgContext)
Creates a new transaction to represent a remote OTS transaction, but does not activate it yet. Throws a SystemException if we have reached the quota for new transactions or the server has not been started.

The newly created transaction will have a non-native Xid, therefore it cannot be distributed across two machines using the RMI interface but only through OTS propagation context.

Parameters: pgContext The OTS propagation context

Returns: The newly created transaction

Throws: SystemException Reached the quota for new transactions, or a transaction with the same identifier already exists

See Also: TransactionFactoryImpl PropagationContext

removeInterceptor

public void removeInterceptor(TransactionInterceptor interceptor)

reset

public void reset()

run

public void run()
Background thread that looks for transactions that have timed out and terminates them. Will be running in a low priority for as long as the server is active, monitoring the transaction table and terminating threads in progress.

This thread is terminated by interrupting it. This thread synchronizes on itself (thread instance) to be notified of a changed in the next timeout.

setNextDomain

public void setNextDomain(TransactionDomainImpl nextDomain)

setTransactionTimeout

protected void setTransactionTimeout(int timeout)
Called to set the timeout of all transactions created from this domain.

Parameters: timeout The new timeout in seconds, zero to restore the default timeout

setTransactionTimeout

protected void setTransactionTimeout(TransactionImpl tx, int timeout)
Called to change the timeout of the transaction and all the resources enlisted with that transaction.

Parameters: tx The transaction timeout The new timeout in seconds, zero to use the default timeout for all new transactions.

See Also: TransactionManager#setTransactionTimeout setTransactionTimeout

terminate

public void terminate()

toString

public String toString()
Original code is Copyright (c) 1999-2001, Intalio, Inc. All Rights Reserved. Contributions by MetaBoss team are Copyright (c) 2003-2005, Softaris Pty. Ltd. All Rights Reserved.