Class TransactionReaper
java.lang.Object
com.arjuna.ats.arjuna.coordinator.TransactionReaper
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
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
addListener
(ReaperMonitor listener) final void
check()
process all entries in the timeout queue which have expired.final long
final void
doWork()
final long
getRemainingTimeoutMills
(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.final int
getTimeout
(Object control) Given a Control, return the associated timeout, or 0 if we do not know about it.final void
timeout is given in seconds, but we work in milliseconds.static void
Currently we let the reaper thread run at same priority as other threads.static boolean
final long
Return the number of timeouts registered.final long
final void
final boolean
removeListener
(ReaperMonitor listener) static void
terminate
(boolean waitForTransactions) Terminate the transaction reaper.static long
static TransactionReaper
Starting with 4.8, this method will always return an instance, will never return null.final void
-
Field Details
-
NORMAL
- See Also:
-
DYNAMIC
- See Also:
-
PERIODIC
- See Also:
-
defaultCheckPeriod
public static final long defaultCheckPeriod- See Also:
-
defaultCancelWaitPeriod
public static final long defaultCancelWaitPeriod- See Also:
-
defaultCancelFailWaitPeriod
public static final long defaultCancelFailWaitPeriod- See Also:
-
defaultUntracedPeriod
public static final long defaultUntracedPeriod- See Also:
-
defaultTracePeriod
public static final long defaultTracePeriod- See Also:
-
defaultZombieMax
public static final int defaultZombieMax- See Also:
-
-
Method Details
-
checkingPeriod
public final long checkingPeriod() -
check
public final void 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. Runs on the ReaperThread -
waitForWork
public final void waitForWork() -
doWork
public final void doWork() -
numberOfTransactions
public final long numberOfTransactions()- Returns:
- the number of items in the reaper's list.
- Since:
- JTS 2.2. Note: this is a) expensive and b) an approximation. Should be called only by test code.
-
numberOfTimeouts
public final long numberOfTimeouts()Return the number of timeouts registered. Note: this is a) expensive and b) an approximation. Should be called only by test code.- Returns:
- The number of timeouts registered.
-
addListener
-
removeListener
-
insert
timeout is given in seconds, but we work in milliseconds. Attempting to insert an element that is already present is an error (IllegalStateException) -
remove
-
getRemainingTimeoutMills
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
Given a Control, return the associated timeout, or 0 if we do not know about it. Return in seconds! Takes an Object because TransactionFactoryImple.getTransactionInfo and ArjunaTransactionImple.propagationContext use it and don't have a Reapable. -
instantiate
public static void instantiate()Currently we let the reaper thread run at same priority as other threads. Could get priority from environment. -
transactionReaper
Starting with 4.8, this method will always return an instance, will never return null. This causes the reaper to be instantiated unnecessarily in some cases, but that's cheaper than the alternatives.- Returns:
- a TransactionReaper singleton.
-
terminate
public static void terminate(boolean waitForTransactions) Terminate the transaction reaper. This is a synchronous operation and will only return once the reaper has been shutdown cleanly. Note, this method assumes that the transaction system has been shutdown already so no new transactions can be created, or we could be here for a long time!- Parameters:
waitForTransactions
- iftrue
then the reaper will wait until all transactions have terminated (or been terminated by it). Iffalse
then the reaper will call setRollbackOnly on all the transactions.
-
isDynamic
public static boolean isDynamic() -
transactionLifetime
public static long transactionLifetime()
-