ehcache

net.sf.ehcache.constructs.nonstop.store
Class TransactionalExecutorServiceStore

java.lang.Object
  extended by net.sf.ehcache.constructs.nonstop.store.ExecutorServiceStore
      extended by net.sf.ehcache.constructs.nonstop.store.TransactionalExecutorServiceStore
All Implemented Interfaces:
NonstopStore, RejoinAwareNonstopStore, Store, TerracottaStore

public class TransactionalExecutorServiceStore
extends ExecutorServiceStore

This implementation is identical to TransactionalExecutorServiceStore except that it ensures the transactional context gets propagated to the executor thread.

Author:
Ludovic Orban
See Also:
ExecutorServiceStore

Field Summary
 
Fields inherited from class net.sf.ehcache.constructs.nonstop.store.ExecutorServiceStore
nonstopConfiguration
 
Fields inherited from interface net.sf.ehcache.store.Store
CLUSTER_COHERENT, NODE_COHERENT
 
Constructor Summary
TransactionalExecutorServiceStore(NonstopActiveDelegateHolder nonstopActiveDelegateHolder, NonstopConfiguration nonstopConfiguration, NonstopTimeoutBehaviorStoreResolver timeoutBehaviorResolver, CacheCluster cacheCluster, TransactionManagerLookup transactionManagerLookup, ExplicitLockingContextThreadLocal explicitLockingContextThreadLocal)
          Constructor
 
Method Summary
 boolean containsKey(Object key)
          A check to see if a key is in the Store.
 Element get(Object key)
          Gets an item from the cache.
 List getKeys()
          Gets an Array of the keys for all elements in the disk store.
 Element getQuiet(Object key)
          Gets an Element from the Store, without updating statistics
 int getSize()
          Returns the current local store size
 int getTerracottaClusteredSize()
          Returns the current Terracotta clustered store size
 boolean put(Element element)
          Puts an item into the store.
 Element putIfAbsent(Element element)
          Put an element in the store if no element is currently mapped to the elements key.
 boolean putWithWriter(Element element, CacheWriterManager writerManager)
          Puts an item into the store and the cache writer manager in an atomic operation
 Element remove(Object key)
          Removes an item from the cache.
 void removeAll()
          Remove all of the elements from the store.
 Element removeElement(Element element, ElementValueComparator comparator)
          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.
 Element removeWithWriter(Object key, CacheWriterManager writerManager)
          Removes an item from the store and the cache writer manager in an atomic operation.
 Element replace(Element element)
          Replace the cached element only if an Element is currently cached for this key
 boolean replace(Element old, Element element, ElementValueComparator comparator)
          Replace the cached element only if the value of the current Element is equal to the value of the supplied old Element.
 
Methods inherited from class net.sf.ehcache.constructs.nonstop.store.ExecutorServiceStore
addStoreListener, bufferFull, clusterRejoined, containsKeyInMemory, containsKeyOffHeap, containsKeyOnDisk, dispose, executeClusterOperation, executeClusterOperationNoTimeout, executeQuery, executeWithExecutor, executeWithExecutor, expireElements, flush, getAll, getAllQuiet, getInMemoryEvictionPolicy, getInMemorySize, getInMemorySizeInBytes, getInternalContext, getLocalKeys, getMBean, getOffHeapSize, getOffHeapSizeInBytes, getOnDiskSize, getOnDiskSizeInBytes, getSearchAttribute, getStatus, getTransactionalMode, hasAbortedSizeOf, isCacheCoherent, isClusterCoherent, isNodeCoherent, isPinned, putAll, recalculateSize, removeAll, removeStoreListener, resolveTimeoutBehaviorStore, setAttributeExtractors, setInMemoryEvictionPolicy, setNodeCoherent, setPinned, underlyingTerracottaStore, unlockedGet, unlockedGetQuiet, unpinAll, unsafeGet, unsafeGetQuiet, waitUntilClusterCoherent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionalExecutorServiceStore

public TransactionalExecutorServiceStore(NonstopActiveDelegateHolder nonstopActiveDelegateHolder,
                                         NonstopConfiguration nonstopConfiguration,
                                         NonstopTimeoutBehaviorStoreResolver timeoutBehaviorResolver,
                                         CacheCluster cacheCluster,
                                         TransactionManagerLookup transactionManagerLookup,
                                         ExplicitLockingContextThreadLocal explicitLockingContextThreadLocal)
Constructor

Parameters:
explicitLockingContextThreadLocal -
Method Detail

put

public boolean put(Element element)
            throws CacheException
Puts an item into the store...

Specified by:
put in interface Store
Overrides:
put in class ExecutorServiceStore
Returns:
true if this is a new put for the key or element is null. Returns false if it was an update.
Throws:
CacheException

putWithWriter

public boolean putWithWriter(Element element,
                             CacheWriterManager writerManager)
                      throws CacheException
Puts an item into the store and the cache writer manager in an atomic operation..

Specified by:
putWithWriter in interface Store
Overrides:
putWithWriter in class ExecutorServiceStore
Returns:
true if this is a new put for the key or element is null. Returns false if it was an update.
Throws:
CacheException

get

public Element get(Object key)
Gets an item from the cache...

Specified by:
get in interface Store
Overrides:
get in class ExecutorServiceStore

getQuiet

public Element getQuiet(Object key)
Gets an Element from the Store, without updating statistics..

Specified by:
getQuiet in interface Store
Overrides:
getQuiet in class ExecutorServiceStore
Returns:
The element

getKeys

public List getKeys()
Gets an Array of the keys for all elements in the disk store...

Specified by:
getKeys in interface Store
Overrides:
getKeys in class ExecutorServiceStore
Returns:
An List of Serializable keys

remove

public Element remove(Object key)
Removes an item from the cache...

Specified by:
remove in interface Store
Overrides:
remove in class ExecutorServiceStore

removeWithWriter

public Element removeWithWriter(Object key,
                                CacheWriterManager writerManager)
                         throws CacheException
Removes an item from the store and the cache writer manager in an atomic operation...

Specified by:
removeWithWriter in interface Store
Overrides:
removeWithWriter in class ExecutorServiceStore
Throws:
CacheException

removeAll

public void removeAll()
               throws CacheException
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.. The timeout used by this method is NonstopConfiguration.getBulkOpsTimeoutMultiplyFactor() times the timeout value in the config.. The timeout used by this method is NonstopConfiguration.getBulkOpsTimeoutMultiplyFactor() times the timeout value in the config.

Specified by:
removeAll in interface Store
Overrides:
removeAll in class ExecutorServiceStore
Throws:
CacheException

putIfAbsent

public Element putIfAbsent(Element element)
                    throws NullPointerException
Put an element in the store if no element is currently mapped to the elements key...

Specified by:
putIfAbsent in interface Store
Overrides:
putIfAbsent in class ExecutorServiceStore
Parameters:
element - element to be added
Returns:
the element previously cached for this key, or null if none.
Throws:
NullPointerException - if the element is null, or has a null key

removeElement

public Element removeElement(Element element,
                             ElementValueComparator comparator)
                      throws NullPointerException
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...

Specified by:
removeElement in interface Store
Overrides:
removeElement in class ExecutorServiceStore
Parameters:
element - Element to be removed
comparator - ElementValueComparator to use to compare elements
Returns:
the Element removed or null if no Element was removed
Throws:
NullPointerException - if the element is null, or has a null key

replace

public boolean replace(Element old,
                       Element element,
                       ElementValueComparator comparator)
                throws NullPointerException,
                       IllegalArgumentException
Replace the cached element only if the value of the current Element is equal to the value of the supplied old Element...

Specified by:
replace in interface Store
Overrides:
replace in class ExecutorServiceStore
Parameters:
old - Element to be test against
element - Element to be cached
comparator - ElementValueComparator to use to compare elements
Returns:
true is the Element was replaced
Throws:
NullPointerException - if the either Element is null or has a null key
IllegalArgumentException - if the two Element keys are non-null but not equal

replace

public Element replace(Element element)
                throws NullPointerException
Replace the cached element only if an Element is currently cached for this key..

Specified by:
replace in interface Store
Overrides:
replace in class ExecutorServiceStore
Parameters:
element - Element to be cached
Returns:
the Element previously cached for this key, or null if no Element was cached
Throws:
NullPointerException - if the Element is null or has a null key

getSize

public int getSize()
Returns the current local store size..

Specified by:
getSize in interface Store
Overrides:
getSize in class ExecutorServiceStore
Returns:
the count of the Elements in the Store on the local machine

getTerracottaClusteredSize

public int getTerracottaClusteredSize()
Returns the current Terracotta clustered store size..

Specified by:
getTerracottaClusteredSize in interface Store
Overrides:
getTerracottaClusteredSize in class ExecutorServiceStore
Returns:
the count of the Elements in the Store across the cluster

containsKey

public boolean containsKey(Object key)
A check to see if a key is in the Store...

Specified by:
containsKey in interface Store
Overrides:
containsKey in class ExecutorServiceStore
Parameters:
key - The Element key
Returns:
true if found. No check is made to see if the Element is expired. 1.2

ehcache

Copyright © 2003-2012 Terracotta, Inc.. All Rights Reserved.