Top Inners Fields Constructors Methods
net.sf.ehcache.transaction.xa

public Class XATransactionStore

extends AbstractTransactionStore
Class Inheritance
Imports
net.sf.ehcache.CacheEntry, .CacheException, .Ehcache, .Element, net.sf.ehcache.statistics.StatisticBuilder, net.sf.ehcache.store.ElementValueComparator, .Store, net.sf.ehcache.transaction.AbstractTransactionStore, .SoftLock, .SoftLockID, .SoftLockManager, .TransactionException, .TransactionIDFactory, .TransactionInterruptedException, .TransactionTimeoutException, net.sf.ehcache.transaction.manager.TransactionManagerLookup, net.sf.ehcache.transaction.xa.commands.StorePutCommand, .StoreRemoveCommand, net.sf.ehcache.util.LargeSet, .SetAsList, net.sf.ehcache.writer.CacheWriterManager, org.slf4j.Logger, .LoggerFactory, org.terracotta.statistics.observer.OperationObserver, java.util.Iterator, .List, .Set, java.util.concurrent.ConcurrentHashMap, .TimeUnit, javax.transaction.RollbackException, .Synchronization, .SystemException, .Transaction, javax.transaction.xa.XAException

Author
Ludovic Orban

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
XATransactionStore.CleanupTimeout

This class is used to clean up the transactionToTimeoutMap after a transaction committed or rolled back.

private class
XATransactionStore.CleanupXAResource

This class is used to clean up the transactionToXAResourceMap after a transaction committed or rolled back.

private class
XATransactionStore.UnregisterXAResource

This class is used to unregister the XAResource after a transaction committed or rolled back.

Field Summary

Modifier and TypeField and Description
private final Ehcache
private final OperationObserver<XaCommitOutcome>
private final ElementValueComparator
private static final Logger
private final OperationObserver<XaRecoveryOutcome>
private final EhcacheXAResourceImpl
private final OperationObserver<XaRollbackOutcome>
private final SoftLockManager
private final TransactionIDFactory
private final TransactionManagerLookup
private final ConcurrentHashMap<Transaction, Long>
private final ConcurrentHashMap<Transaction, EhcacheXAResource>
Inherited from net.sf.ehcache.transaction.AbstractTransactionStore:
underlyingStore

Constructor Summary

AccessConstructor and Description
public
XATransactionStore(TransactionManagerLookup
the transaction manager lookup implementation
transactionManagerLookup
,
SoftLockManager
the soft lock manager
softLockManager
,
TransactionIDFactory
the transaction ID factory
transactionIdFactory
,
Ehcache
the cache
cache
,
Store
the underlying store
store
,
ElementValueComparator comparator)

Constructor

Method Summary

Modifier and TypeMethod and Description
private long

Returns:

milliseconds left before timeout
assertNotTimedOut
()

public boolean
containsKey(Object
The Element key
key
)

Implements net.sf.ehcache.store.Store.containsKey.

A check to see if a key is in the Store.
public void
public Element
get(Object key)

Implements net.sf.ehcache.store.Store.get.

Gets an item from the cache.
private Element
getCurrentElement(final Object key, final XATransactionContext context)

private Transaction
private Element
public List<E>
getKeys()

Implements net.sf.ehcache.store.Store.getKeys.

Gets an Array of the keys for all elements in the disk store.
private XATransactionContext
public EhcacheXAResourceImpl

Returns:

the EhcacheXAResource of this store
getOrCreateXAResource
()

Get or create the XAResource of this XA store

public Element
getQuiet(Object key)

Implements net.sf.ehcache.store.Store.getQuiet.

Gets an Element from the Store, without updating statistics
private Element
public int
getSize()

Implements net.sf.ehcache.store.Store.getSize.

Returns the current local store size
public int
getTerracottaClusteredSize()

Implements net.sf.ehcache.store.Store.getTerracottaClusteredSize.

Returns the current Terracotta clustered store size
private XATransactionContext
private boolean
internalPut(final StorePutCommand putCommand)

public boolean
put(Element element)

Implements net.sf.ehcache.store.Store.put.

Puts an item into the store.
public Element
putIfAbsent(Element
element to be added
element
)

Implements net.sf.ehcache.store.Store.putIfAbsent.

Put an element in the store if no element is currently mapped to the elements key.
public boolean
putWithWriter(Element element, CacheWriterManager writerManager)

Implements net.sf.ehcache.store.Store.putWithWriter.

Puts an item into the store and the cache writer manager in an atomic operation
public Element
remove(Object key)

Implements net.sf.ehcache.store.Store.remove.

Removes an item from the cache.
public void
removeAll()

Implements net.sf.ehcache.store.Store.removeAll.

Remove all of the elements from the store.
public Element
removeElement(Element
Element to be removed
element
,
ElementValueComparator
ElementValueComparator to use to compare elements
comparator
)

Implements net.sf.ehcache.store.Store.removeElement.

Remove the Element mapped to the key for the supplied element if the value of the supplied Element is equal to the value of the cached Element.
private Element
public Element
removeWithWriter(Object key, CacheWriterManager writerManager)

Implements net.sf.ehcache.store.Store.removeWithWriter.

Removes an item from the store and the cache writer manager in an atomic operation.
public boolean
replace(Element
Element to be test against
old
,
Element
Element to be cached
element
,
ElementValueComparator
ElementValueComparator to use to compare elements
comparator
)

Implements net.sf.ehcache.store.Store.replace.

Replace the cached element only if the value of the current Element is equal to the value of the supplied old Element.
public Element
replace(Element
Element to be cached
element
)

Implements net.sf.ehcache.store.Store.replace.

Replace the cached element only if an Element is currently cached for this key
Inherited from net.sf.ehcache.transaction.AbstractTransactionStore:
bufferFullcontainsKeyInMemorycontainsKeyOffHeapcontainsKeyOnDiskcreateWriteBehindexecuteQueryexpireElementsflushgetInMemoryEvictionPolicygetInMemorySizegetInMemorySizeInBytesgetInternalContextgetLocalKeysgetMBeangetOffHeapSizegetOffHeapSizeInBytesgetOldElementgetOnDiskSizegetOnDiskSizeInBytesgetSearchAttributegetSearchAttributesgetStatusgetTransactionalModehasAbortedSizeOfisCacheCoherentisClusterCoherentisNodeCoherentnotifyCacheEventListenersChangedquickClearquickSizesetAttributeExtractorssetInMemoryEvictionPolicysetNodeCoherentunsafeGetwaitUntilClusterCoherent

Field Detail

cacheback to summary
private final Ehcache cache
commitObserverback to summary
private final OperationObserver<XaCommitOutcome> commitObserver
comparatorback to summary
private final ElementValueComparator comparator
LOGback to summary
private static final Logger LOG
recoveryObserverback to summary
private final OperationObserver<XaRecoveryOutcome> recoveryObserver
recoveryResourceback to summary
private final EhcacheXAResourceImpl recoveryResource
rollbackObserverback to summary
private final OperationObserver<XaRollbackOutcome> rollbackObserver
softLockManagerback to summary
private final SoftLockManager softLockManager
transactionIdFactoryback to summary
private final TransactionIDFactory transactionIdFactory
transactionManagerLookupback to summary
private final TransactionManagerLookup transactionManagerLookup
transactionToTimeoutMapback to summary
private final ConcurrentHashMap<Transaction, Long> transactionToTimeoutMap
transactionToXAResourceMapback to summary
private final ConcurrentHashMap<Transaction, EhcacheXAResource> transactionToXAResourceMap

Constructor Detail

XATransactionStoreback to summary
public XATransactionStore(TransactionManagerLookup transactionManagerLookup, SoftLockManager softLockManager, TransactionIDFactory transactionIdFactory, Ehcache cache, Store store, ElementValueComparator comparator)

Constructor

Parameters
transactionManagerLookup:TransactionManagerLookup

the transaction manager lookup implementation

softLockManager:SoftLockManager

the soft lock manager

transactionIdFactory:TransactionIDFactory

the transaction ID factory

cache:Ehcache

the cache

store:Store

the underlying store

Method Detail

assertNotTimedOutback to summary
private long assertNotTimedOut()
Returns:long

milliseconds left before timeout

containsKeyback to summary
public boolean containsKey(Object key)

Implements net.sf.ehcache.store.Store.containsKey.

Doc from net.sf.ehcache.store.Store.containsKey.

A check to see if a key is in the Store.

Parameters
key:Object

The Element key

Returns:boolean

true if found. No check is made to see if the Element is expired. 1.2

disposeback to summary
public void dispose()

Overrides net.sf.ehcache.transaction.AbstractTransactionStore.dispose.

Implements net.sf.ehcache.store.Store.dispose.

Doc from net.sf.ehcache.transaction.AbstractTransactionStore.dispose.

Prepares for shutdown.

Annotations
@Override
getback to summary
public Element get(Object key)

Implements net.sf.ehcache.store.Store.get.

Doc from net.sf.ehcache.store.Store.get.

Gets an item from the cache.

getCurrentElementback to summary
private Element getCurrentElement(final Object key, final XATransactionContext context)
getCurrentTransactionback to summary
private Transaction getCurrentTransaction() throws SystemException
getFromUnderlyingStoreback to summary
private Element getFromUnderlyingStore(final Object key)
getKeysback to summary
public List<E> getKeys()

Implements net.sf.ehcache.store.Store.getKeys.

Doc from net.sf.ehcache.store.Store.getKeys.

Gets an Array of the keys for all elements in the disk store.

Returns:List<E>

An List of java.io.Serializable keys

getOrCreateTransactionContextback to summary
private XATransactionContext getOrCreateTransactionContext()
getOrCreateXAResourceback to summary
public EhcacheXAResourceImpl getOrCreateXAResource() throws SystemException

Get or create the XAResource of this XA store

Returns:EhcacheXAResourceImpl

the EhcacheXAResource of this store

Exceptions
SystemException:
when something goes wrong with the transaction manager
getQuietback to summary
public Element getQuiet(Object key)

Implements net.sf.ehcache.store.Store.getQuiet.

Doc from net.sf.ehcache.store.Store.getQuiet.

Gets an Element from the Store, without updating statistics

Returns:Element

The element

getQuietFromUnderlyingStoreback to summary
private Element getQuietFromUnderlyingStore(final Object key)
getSizeback to summary
public int getSize()

Implements net.sf.ehcache.store.Store.getSize.

Doc from net.sf.ehcache.store.Store.getSize.

Returns the current local store size

Returns:int

the count of the Elements in the Store on the local machine

getTerracottaClusteredSizeback to summary
public int getTerracottaClusteredSize()

Implements net.sf.ehcache.store.Store.getTerracottaClusteredSize.

Doc from net.sf.ehcache.store.Store.getTerracottaClusteredSize.

Returns the current Terracotta clustered store size

Returns:int

the count of the Elements in the Store across the cluster

getTransactionContextback to summary
private XATransactionContext getTransactionContext()
internalPutback to summary
private boolean internalPut(final StorePutCommand putCommand)
putback to summary
public boolean put(Element element) throws CacheException

Implements net.sf.ehcache.store.Store.put.

Doc from net.sf.ehcache.store.Store.put.

Puts an item into the store.

Returns:boolean

true if this is a new put for the key or element is null. Returns false if it was an update.

putIfAbsentback to summary
public Element putIfAbsent(Element element) throws NullPointerException

Implements net.sf.ehcache.store.Store.putIfAbsent.

Doc from net.sf.ehcache.store.Store.putIfAbsent.

Put an element in the store if no element is currently mapped to the elements key.

Parameters
element:Element

element to be added

Returns:Element

the element previously cached for this key, or null if none.

Exceptions
NullPointerException:
if the element is null, or has a null key
putWithWriterback to summary
public boolean putWithWriter(Element element, CacheWriterManager writerManager) throws CacheException

Implements net.sf.ehcache.store.Store.putWithWriter.

Doc from net.sf.ehcache.store.Store.putWithWriter.

Puts an item into the store and the cache writer manager in an atomic operation

Returns:boolean

true if this is a new put for the key or element is null. Returns false if it was an update.

removeback to summary
public Element remove(Object key)

Implements net.sf.ehcache.store.Store.remove.

Doc from net.sf.ehcache.store.Store.remove.

Removes an item from the cache.

removeAllback to summary
public void removeAll() throws CacheException

Implements net.sf.ehcache.store.Store.removeAll.

Doc from net.sf.ehcache.store.Store.removeAll.

Remove all of the elements from the store.

If there are registered CacheEventListeners they are notified of the expiry or removal of the Element as each is removed.

removeElementback to summary
public Element removeElement(Element element, ElementValueComparator comparator) throws NullPointerException

Implements net.sf.ehcache.store.Store.removeElement.

Doc from net.sf.ehcache.store.Store.removeElement.

Remove the Element mapped to the key for the supplied element if the value of the supplied Element is equal to the value of the cached Element. This is a CAS operation. It is consistent even against a distributed cache that is not coherent. If the old value is stale when this operation is attempted the remove does not take place.

Parameters
element:Element

Element to be removed

comparator:ElementValueComparator

ElementValueComparator to use to compare elements

Returns:Element

the Element removed or null if no Element was removed

Exceptions
NullPointerException:
if the element is null, or has a null key
removeInternalback to summary
private Element removeInternal(final StoreRemoveCommand command)
removeWithWriterback to summary
public Element removeWithWriter(Object key, CacheWriterManager writerManager) throws CacheException

Implements net.sf.ehcache.store.Store.removeWithWriter.

Doc from net.sf.ehcache.store.Store.removeWithWriter.

Removes an item from the store and the cache writer manager in an atomic operation.

replaceback to summary
public boolean replace(Element old, Element element, ElementValueComparator comparator) throws NullPointerException, IllegalArgumentException

Implements net.sf.ehcache.store.Store.replace.

Doc from net.sf.ehcache.store.Store.replace.

Replace the cached element only if the value of the current Element is equal to the value of the supplied old Element.

Parameters
old:Element

Element to be test against

element:Element

Element to be cached

comparator:ElementValueComparator

ElementValueComparator to use to compare elements

Returns:boolean

true is the Element was replaced

Exceptions
NullPointerException:
if the either Element is null or has a null key
IllegalArgumentException:
if the two Element keys are non-null but not equal
replaceback to summary
public Element replace(Element element) throws NullPointerException

Implements net.sf.ehcache.store.Store.replace.

Doc from net.sf.ehcache.store.Store.replace.

Replace the cached element only if an Element is currently cached for this key

Parameters
element:Element

Element to be cached

Returns:Element

the Element previously cached for this key, or null if no Element was cached

Exceptions
NullPointerException:
if the Element is null or has a null key
net.sf.ehcache.transaction.xa back to summary

private final Class XATransactionStore.CleanupTimeout

extends Object
implements Synchronization
Class Inheritance
  • java.lang.Object
  • net.sf.ehcache.transaction.xa.XATransactionStore.CleanupTimeout
All Implemented Interfaces
javax.transaction.Synchronization

This class is used to clean up the transactionToTimeoutMap after a transaction committed or rolled back.

Field Summary

Modifier and TypeField and Description
private final Transaction

Constructor Summary

AccessConstructor and Description
private
CleanupTimeout(final Transaction transaction)

Method Summary

Modifier and TypeMethod and Description
public void
afterCompletion(final int
The status of the transaction completion.
status
)

Implements javax.transaction.Synchronization.afterCompletion.

This method is called by the transaction manager after the transaction is committed or rolled back.
public void
beforeCompletion()

Implements javax.transaction.Synchronization.beforeCompletion.

The beforeCompletion method is called by the transaction manager prior to the start of the two-phase transaction commit process.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

transactionback to summary
private final Transaction transaction

Constructor Detail

CleanupTimeoutback to summary
private CleanupTimeout(final Transaction transaction)

Method Detail

afterCompletionback to summary
public void afterCompletion(final int status)

Implements javax.transaction.Synchronization.afterCompletion.

Doc from javax.transaction.Synchronization.afterCompletion.

This method is called by the transaction manager after the transaction is committed or rolled back.

Parameters
status:int

The status of the transaction completion.

beforeCompletionback to summary
public void beforeCompletion()

Implements javax.transaction.Synchronization.beforeCompletion.

Doc from javax.transaction.Synchronization.beforeCompletion.

The beforeCompletion method is called by the transaction manager prior to the start of the two-phase transaction commit process. This call is executed with the transaction context of the transaction that is being committed.

net.sf.ehcache.transaction.xa back to summary

private final Class XATransactionStore.CleanupXAResource

extends Object
implements XAExecutionListener
Class Inheritance
  • java.lang.Object
  • net.sf.ehcache.transaction.xa.XATransactionStore.CleanupXAResource
All Implemented Interfaces
net.sf.ehcache.transaction.xa.XAExecutionListener

This class is used to clean up the transactionToXAResourceMap after a transaction committed or rolled back.

Field Summary

Modifier and TypeField and Description
private final Transaction

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
afterCommitOrRollback(EhcacheXAResource
the XAResource which committed or rolled back
xaResource
)

Implements net.sf.ehcache.transaction.xa.XAExecutionListener.afterCommitOrRollback.

Called when the resource committed or rolled back
public void
beforePrepare(EhcacheXAResource
the XAResource about to prepare
xaResource
)

Implements net.sf.ehcache.transaction.xa.XAExecutionListener.beforePrepare.

Called when the resource is about to prepare
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

transactionback to summary
private final Transaction transaction

Constructor Detail

CleanupXAResourceback to summary
private CleanupXAResource(Transaction transaction)

Method Detail

afterCommitOrRollbackback to summary
public void afterCommitOrRollback(EhcacheXAResource xaResource)

Implements net.sf.ehcache.transaction.xa.XAExecutionListener.afterCommitOrRollback.

Doc from net.sf.ehcache.transaction.xa.XAExecutionListener.afterCommitOrRollback.

Called when the resource committed or rolled back

Parameters
xaResource:EhcacheXAResource

the XAResource which committed or rolled back

beforePrepareback to summary
public void beforePrepare(EhcacheXAResource xaResource)

Implements net.sf.ehcache.transaction.xa.XAExecutionListener.beforePrepare.

Doc from net.sf.ehcache.transaction.xa.XAExecutionListener.beforePrepare.

Called when the resource is about to prepare

Parameters
xaResource:EhcacheXAResource

the XAResource about to prepare

net.sf.ehcache.transaction.xa back to summary

private final Class XATransactionStore.UnregisterXAResource

extends Object
implements XAExecutionListener
Class Inheritance
  • java.lang.Object
  • net.sf.ehcache.transaction.xa.XATransactionStore.UnregisterXAResource
All Implemented Interfaces
net.sf.ehcache.transaction.xa.XAExecutionListener

This class is used to unregister the XAResource after a transaction committed or rolled back.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
afterCommitOrRollback(EhcacheXAResource
the XAResource which committed or rolled back
xaResource
)

Implements net.sf.ehcache.transaction.xa.XAExecutionListener.afterCommitOrRollback.

Called when the resource committed or rolled back
public void
beforePrepare(EhcacheXAResource
the XAResource about to prepare
xaResource
)

Implements net.sf.ehcache.transaction.xa.XAExecutionListener.beforePrepare.

Called when the resource is about to prepare
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

UnregisterXAResourceback to summary
private UnregisterXAResource()

Method Detail

afterCommitOrRollbackback to summary
public void afterCommitOrRollback(EhcacheXAResource xaResource)

Implements net.sf.ehcache.transaction.xa.XAExecutionListener.afterCommitOrRollback.

Doc from net.sf.ehcache.transaction.xa.XAExecutionListener.afterCommitOrRollback.

Called when the resource committed or rolled back

Parameters
xaResource:EhcacheXAResource

the XAResource which committed or rolled back

beforePrepareback to summary
public void beforePrepare(EhcacheXAResource xaResource)

Implements net.sf.ehcache.transaction.xa.XAExecutionListener.beforePrepare.

Doc from net.sf.ehcache.transaction.xa.XAExecutionListener.beforePrepare.

Called when the resource is about to prepare

Parameters
xaResource:EhcacheXAResource

the XAResource about to prepare