Top Description Inners Fields Constructors Methods
net.sf.ehcache

public final Class TransactionController

extends Object
Class Inheritance
Imports
net.sf.ehcache.transaction.TransactionException, .TransactionID, .TransactionIDFactory, .TransactionTimeoutException, net.sf.ehcache.transaction.local.LocalRecoveryManager, .LocalTransactionContext, net.sf.ehcache.util.lang.VicariousThreadLocal, org.slf4j.Logger, .LoggerFactory, .MDC, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, java.util.concurrent.atomic.AtomicLong

TransactionController is used to begin, commit and rollback local transactions
Author
Ludovic Orban

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
TransactionController.TransactionControllerStatistics

Holder for TransactionController statistics

Field Summary

Modifier and TypeField and Description
private final ConcurrentMap<TransactionID, LocalTransactionContext>
private final VicariousThreadLocal<TransactionID>
private volatile int
private final LocalRecoveryManager
private static final Logger
private static final String
private final TransactionController.TransactionControllerStatistics
private final TransactionIDFactory

Constructor Summary

AccessConstructor and Description
pack-priv
TransactionController(TransactionIDFactory
the TransactionIDFactory
transactionIDFactory
,
int
the default transaction timeout in seconds
defaultTransactionTimeoutInSeconds
)

Create a TransactionController instance

Method Summary

Modifier and TypeMethod and Description
public void
begin()

Begin a new transaction and bind its context to the current thread

public void
begin(int
the timeout foe this transaction in seconds
transactionTimeoutSeconds
)

Begin a new transaction with the specified timeout and bind its context to the current thread

public void
commit()

Commit the transaction bound to the current thread

public void
commit(boolean
true if the transaction should be committed no matter if it timed out or not
ignoreTimeout
)

Commit the transaction bound to the current thread, ignoring if the transaction timed out

public LocalTransactionContext

Returns:

the transaction context bond to the current thread or null if no transaction started on the current thread
getCurrentTransactionContext
()

Get the transaction context bond to the current thread

public int

Returns:

the default transaction timeout
getDefaultTransactionTimeout
()

Get the default transaction timeout in seconds

public LocalRecoveryManager

Returns:

the local transactions recovery manager
getRecoveryManager
()

Get the local transactions recovery manager of this cache manager

public long

Returns:

the committed transactions count
getTransactionCommittedCount
()

Get the committed transactions count

public long

Returns:

the rolled back transactions count
getTransactionRolledBackCount
()

Get the rolled back transactions count

public long

Returns:

the timed out transactions count
getTransactionTimedOutCount
()

Get the timed out transactions count.

public void
rollback()

Rollback the transaction bound to the current thread

public void
setDefaultTransactionTimeout(int
the default transaction timeout
defaultTransactionTimeoutSeconds
)

Set the default transaction timeout in seconds, it must be > 0

public void
setRollbackOnly()

Mark the transaction bound to the current thread for rollback only

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextMapback to summary
private final ConcurrentMap<TransactionID, LocalTransactionContext> contextMap
currentTransactionIdThreadLocalback to summary
private final VicariousThreadLocal<TransactionID> currentTransactionIdThreadLocal
defaultTransactionTimeoutback to summary
private volatile int defaultTransactionTimeout
localRecoveryManagerback to summary
private final LocalRecoveryManager localRecoveryManager
LOGback to summary
private static final Logger LOG
MDC_KEYback to summary
private static final String MDC_KEY
statisticsback to summary
private final TransactionController.TransactionControllerStatistics statistics
transactionIDFactoryback to summary
private final TransactionIDFactory transactionIDFactory

Constructor Detail

TransactionControllerback to summary
pack-priv TransactionController(TransactionIDFactory transactionIDFactory, int defaultTransactionTimeoutInSeconds)

Create a TransactionController instance

Parameters
transactionIDFactory:TransactionIDFactory

the TransactionIDFactory

defaultTransactionTimeoutInSeconds:int

the default transaction timeout in seconds

Method Detail

beginback to summary
public void begin()

Begin a new transaction and bind its context to the current thread

beginback to summary
public void begin(int transactionTimeoutSeconds)

Begin a new transaction with the specified timeout and bind its context to the current thread

Parameters
transactionTimeoutSeconds:int

the timeout foe this transaction in seconds

commitback to summary
public void commit()

Commit the transaction bound to the current thread

commitback to summary
public void commit(boolean ignoreTimeout)

Commit the transaction bound to the current thread, ignoring if the transaction timed out

Parameters
ignoreTimeout:boolean

true if the transaction should be committed no matter if it timed out or not

getCurrentTransactionContextback to summary
public LocalTransactionContext getCurrentTransactionContext()

Get the transaction context bond to the current thread

Returns:LocalTransactionContext

the transaction context bond to the current thread or null if no transaction started on the current thread

getDefaultTransactionTimeoutback to summary
public int getDefaultTransactionTimeout()

Get the default transaction timeout in seconds

Returns:int

the default transaction timeout

getRecoveryManagerback to summary
public LocalRecoveryManager getRecoveryManager()

Get the local transactions recovery manager of this cache manager

Returns:LocalRecoveryManager

the local transactions recovery manager

getTransactionCommittedCountback to summary
public long getTransactionCommittedCount()

Get the committed transactions count

Returns:long

the committed transactions count

getTransactionRolledBackCountback to summary
public long getTransactionRolledBackCount()

Get the rolled back transactions count

Returns:long

the rolled back transactions count

getTransactionTimedOutCountback to summary
public long getTransactionTimedOutCount()

Get the timed out transactions count. Note that only transactions which failed to commit due to a timeout are taken into account

Returns:long

the timed out transactions count

rollbackback to summary
public void rollback()

Rollback the transaction bound to the current thread

setDefaultTransactionTimeoutback to summary
public void setDefaultTransactionTimeout(int defaultTransactionTimeoutSeconds)

Set the default transaction timeout in seconds, it must be > 0

Parameters
defaultTransactionTimeoutSeconds:int

the default transaction timeout

setRollbackOnlyback to summary
public void setRollbackOnly()

Mark the transaction bound to the current thread for rollback only

net.sf.ehcache back to summary

private Class TransactionController.TransactionControllerStatistics

extends Object
Class Inheritance
  • java.lang.Object
  • net.sf.ehcache.TransactionController.TransactionControllerStatistics

Holder for TransactionController statistics

Field Summary

Modifier and TypeField and Description
private final AtomicLong
private final AtomicLong
private final AtomicLong

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv long
pack-priv long
pack-priv long
pack-priv void
pack-priv void
pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

committedback to summary
private final AtomicLong committed
rolledBackback to summary
private final AtomicLong rolledBack
timedOutback to summary
private final AtomicLong timedOut

Constructor Detail

TransactionControllerStatisticsback to summary
private TransactionControllerStatistics()

Method Detail

getTransactionCommittedCountback to summary
pack-priv long getTransactionCommittedCount()
getTransactionRolledBackCountback to summary
pack-priv long getTransactionRolledBackCount()
getTransactionTimedOutCountback to summary
pack-priv long getTransactionTimedOutCount()
transactionCommittedback to summary
pack-priv void transactionCommitted()
transactionRolledBackback to summary
pack-priv void transactionRolledBack()
transactionTimedOutback to summary
pack-priv void transactionTimedOut()