com.arjuna.ats.arjuna.coordinator
Class TransactionReaper

java.lang.Object
  extended by com.arjuna.ats.arjuna.coordinator.TransactionReaper

public class TransactionReaper
extends java.lang.Object

Class to record transactions with non-zero timeout values, and class to implement a transaction reaper thread which terminates these transactions once their timeout elapses.

Since:
JTS 1.0.
Version:
$Id: TransactionReaper.java 2342 2006-03-30 13:06:17Z $
Author:
Mark Little (mark@arjuna.com)

Field Summary
static long defaultCancelFailWaitPeriod
           
static long defaultCancelWaitPeriod
           
static long defaultCheckPeriod
           
static int defaultZombieMax
           
static java.lang.String DYNAMIC
           
static java.lang.String NORMAL
           
 
Constructor Summary
TransactionReaper(long checkPeriod)
           
 
Method Summary
 boolean check()
          process all entries in the timeout queue which have expired.
 long checkingPeriod()
           
static TransactionReaper create()
           
static TransactionReaper create(long checkPeriod)
          Currently we let the reaper thread run at same priority as other threads.
 void doCancellations()
           
 void finalize()
           
 long getRemainingTimeoutMills(java.lang.Object control)
          Given the transaction instance, this will return the time left before the transaction is automatically rolled back if it has not been terminated.
 int getTimeout(java.lang.Object control)
          Given a Control, return the associated timeout, or 0 if we do not know about it.
 boolean insert(Reapable control, int timeout)
          timeout is given in seconds, but we work in milliseconds.
 long numberOfTimeouts()
          Return the number of timeouts registered.
 long numberOfTransactions()
           
 boolean remove(java.lang.Object control)
           
static long transactionLifetime()
           
static TransactionReaper transactionReaper()
           
static TransactionReaper transactionReaper(boolean createReaper)
           
 void waitForCancellations()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORMAL

public static final java.lang.String NORMAL
See Also:
Constant Field Values

DYNAMIC

public static final java.lang.String DYNAMIC
See Also:
Constant Field Values

defaultCheckPeriod

public static final long defaultCheckPeriod
See Also:
Constant Field Values

defaultCancelWaitPeriod

public static final long defaultCancelWaitPeriod
See Also:
Constant Field Values

defaultCancelFailWaitPeriod

public static final long defaultCancelFailWaitPeriod
See Also:
Constant Field Values

defaultZombieMax

public static final int defaultZombieMax
See Also:
Constant Field Values
Constructor Detail

TransactionReaper

public TransactionReaper(long checkPeriod)
Method Detail

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object

checkingPeriod

public final long checkingPeriod()

check

public final boolean check()
process all entries in the timeout queue which have expired. entries for newly expired transactions are passed to a worker thread for cancellation and requeued for subsequent progress checks. the worker is given a kick if such checks find it is wedged. Timeout is given in milliseconds.


waitForCancellations

public final void waitForCancellations()

doCancellations

public final void doCancellations()

numberOfTransactions

public final long numberOfTransactions()
Returns:
the number of items in the reaper's list.
Since:
JTS 2.2.

numberOfTimeouts

public final long numberOfTimeouts()
Return the number of timeouts registered.

Returns:
The number of timeouts registered.

insert

public final boolean insert(Reapable control,
                            int timeout)
timeout is given in seconds, but we work in milliseconds.


remove

public final boolean remove(java.lang.Object control)

getRemainingTimeoutMills

public final long getRemainingTimeoutMills(java.lang.Object control)
Given the transaction instance, this will return the time left before the transaction is automatically rolled back if it has not been terminated.

Parameters:
control -
Returns:
the remaining time in milliseconds.

getTimeout

public final int getTimeout(java.lang.Object control)
Given a Control, return the associated timeout, or 0 if we do not know about it. Return in seconds!


create

public static TransactionReaper create(long checkPeriod)
Currently we let the reaper thread run at same priority as other threads. Could get priority from environment.


create

public static TransactionReaper create()

transactionReaper

public static TransactionReaper transactionReaper()

transactionReaper

public static TransactionReaper transactionReaper(boolean createReaper)

transactionLifetime

public static final long transactionLifetime()