com.arjuna.ats.arjuna.coordinator
Class TransactionReaper

java.lang.Object
  extended bycom.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 defaultCheckPeriod
           
static java.lang.String DYNAMIC
           
static java.lang.String NORMAL
           
 
Constructor Summary
TransactionReaper(long checkPeriod)
           
 
Method Summary
 boolean check()
          Only check for one at a time to prevent starvation.
 long checkingPeriod()
           
static TransactionReaper create()
           
static TransactionReaper create(long checkPeriod)
          Currently we let the reaper thread run at same priority as other threads.
 void finalize()
           
 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 numberOfTransactions()
           
 boolean remove(java.lang.Object control)
           
static long transactionLifetime()
           
static TransactionReaper transactionReaper()
           
static TransactionReaper transactionReaper(boolean createReaper)
           
 
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
Constructor Detail

TransactionReaper

public TransactionReaper(long checkPeriod)
Method Detail

finalize

public void finalize()

checkingPeriod

public final long checkingPeriod()

check

public final boolean check()
Only check for one at a time to prevent starvation. Timeout is given in milliseconds.


numberOfTransactions

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

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)

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()