Top Description Fields Constructors Methods
net.sf.ehcache.transaction

public abstract Class AbstractTransactionStore

extends AbstractStore
implements TerracottaStore
Class Inheritance
All Implemented Interfaces
net.sf.ehcache.store.TerracottaStore, net.sf.ehcache.store.Store
Known Direct Subclasses
net.sf.ehcache.transaction.local.JtaLocalTransactionStore, net.sf.ehcache.transaction.local.LocalTransactionStore, net.sf.ehcache.transaction.xa.XATransactionStore
Imports
net.sf.ehcache.CacheException, .Element, .Status, net.sf.ehcache.config.CacheConfiguration, .InvalidConfigurationException, net.sf.ehcache.search.Attribute, .Results, net.sf.ehcache.search.attribute.AttributeExtractor, net.sf.ehcache.store.AbstractStore, .Policy, .Store, .StoreQuery, .TerracottaStore, net.sf.ehcache.terracotta.TerracottaNotRunningException, net.sf.ehcache.writer.writebehind.WriteBehind, org.terracotta.context.annotations.ContextChild, java.io.IOException, java.util.Map, .Set

Abstract transactional store which provides implementation of all non-transactional methods
Author
Ludovic Orban

Field Summary

Modifier and TypeField and Description
protected final Store
underlyingStore

The underlying store wrapped by this store

Inherited from net.sf.ehcache.store.AbstractStore:
attributeExtractorssearchManager

Constructor Summary

AccessConstructor and Description
protected
AbstractTransactionStore(Store
the underlying store
underlyingStore
)

Constructor

Method Summary

Modifier and TypeMethod and Description
public boolean
bufferFull()

Implements net.sf.ehcache.store.Store.bufferFull.

Some store types, such as the disk stores can fill their write buffers if puts come in too fast.
public boolean
containsKeyInMemory(Object
The Element key
key
)

Implements net.sf.ehcache.store.Store.containsKeyInMemory.

A check to see if a key is in the Store and is currently held in memory.
public boolean
containsKeyOffHeap(Object
The Element key
key
)

Implements net.sf.ehcache.store.Store.containsKeyOffHeap.

A check to see if a key is in the Store and is currently held off-heap.
public boolean
containsKeyOnDisk(Object
The Element key
key
)

Implements net.sf.ehcache.store.Store.containsKeyOnDisk.

A check to see if a key is in the Store and is currently held on disk.
public WriteBehind
public void
dispose()

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

Prepares for shutdown.
public Results
executeQuery(StoreQuery
query to execute
query
)

Overrides net.sf.ehcache.store.AbstractStore.executeQuery.

Implements net.sf.ehcache.store.Store.executeQuery.

Execute the given query on this store
public void
public void
flush()

Implements net.sf.ehcache.store.Store.flush.

Flush elements to persistent store.
public Policy
public int
getInMemorySize()

Implements net.sf.ehcache.store.Store.getInMemorySize.

Returns the current local in-memory store size
public long
getInMemorySizeInBytes()

Implements net.sf.ehcache.store.Store.getInMemorySizeInBytes.

Gets the size of the in-memory portion of the store, in bytes.
public Object
getInternalContext()

Implements net.sf.ehcache.store.Store.getInternalContext.

This should not be used, and will generally return null
public Set<E>
getLocalKeys()

Implements net.sf.ehcache.store.TerracottaStore.getLocalKeys.

Returns set of keys from the cache which are present in the node locally.
public Object
getMBean()

Implements net.sf.ehcache.store.Store.getMBean.

Optional implementation specific MBean exposed by the store.
public int
getOffHeapSize()

Implements net.sf.ehcache.store.Store.getOffHeapSize.

Returns the current local off-heap store size
public long
getOffHeapSizeInBytes()

Implements net.sf.ehcache.store.Store.getOffHeapSizeInBytes.

Gets the size of the off-heap portion of the store, in bytes.
public Element

Returns:

the mapped element, outside of any transaction
getOldElement
(Object
the key to look for
key
)

Method to get to the Element matching the key, oblivious of any in-flight transaction.

public int
getOnDiskSize()

Implements net.sf.ehcache.store.Store.getOnDiskSize.

Returns the current local on-disk store size
public long
getOnDiskSizeInBytes()

Implements net.sf.ehcache.store.Store.getOnDiskSizeInBytes.

Gets the size of the on-disk portion of the store, in bytes.
public <T> Attribute<T>
getSearchAttribute(String
the name of the attribute to retrieve
attributeName
)

Overrides net.sf.ehcache.store.AbstractStore.getSearchAttribute.

Implements net.sf.ehcache.store.Store.getSearchAttribute.

Retrieve the given named search attribute
public Set<Attribute<T>>
public Status
getStatus()

Implements net.sf.ehcache.store.Store.getStatus.

Returns the cache status.
public CacheConfiguration.TransactionalMode
getTransactionalMode()

Implements net.sf.ehcache.store.TerracottaStore.getTransactionalMode.

Get the transactional mode of this store.
public boolean
hasAbortedSizeOf()

Overrides net.sf.ehcache.store.AbstractStore.hasAbortedSizeOf.

Implements net.sf.ehcache.store.Store.hasAbortedSizeOf.

Checks if the cache may contain elements for which the SizeOf engine gave up and only partially calculated the size.
public boolean
isCacheCoherent()

Overrides net.sf.ehcache.store.AbstractStore.isCacheCoherent.

Implements net.sf.ehcache.store.Store.isCacheCoherent.

Indicates whether this store provides a coherent view of all the elements in a cache.
public boolean
isClusterCoherent()

Overrides net.sf.ehcache.store.AbstractStore.isClusterCoherent.

Implements net.sf.ehcache.store.Store.isClusterCoherent.

Returns true if the cache is in coherent mode cluster-wide.
public boolean
isNodeCoherent()

Overrides net.sf.ehcache.store.AbstractStore.isNodeCoherent.

Implements net.sf.ehcache.store.Store.isNodeCoherent.

Returns true if the cache is in coherent mode for the current node.
public void
notifyCacheEventListenersChanged()

Implements net.sf.ehcache.store.TerracottaStore.notifyCacheEventListenersChanged.

Notify the underlying store that some change has occured in the set of registered cache listeners.
public void
quickClear()

Implements net.sf.ehcache.store.TerracottaStore.quickClear.

Remove all the contents of the store.
public int
quickSize()

Implements net.sf.ehcache.store.TerracottaStore.quickSize.

Get an approximate count of elements in the store.
public void
public void
setInMemoryEvictionPolicy(Policy
the new policy
policy
)

Implements net.sf.ehcache.store.Store.setInMemoryEvictionPolicy.

Sets the eviction policy strategy.
public void
setNodeCoherent(boolean
true transitions to coherent mode, false to incoherent mode
coherent
)

Overrides net.sf.ehcache.store.AbstractStore.setNodeCoherent.

Implements net.sf.ehcache.store.Store.setNodeCoherent.

Sets the cache in coherent or incoherent mode for the current node depending on the parameter.
public Element
unsafeGet(Object
the key
key
)

Implements net.sf.ehcache.store.TerracottaStore.unsafeGet.

Returns the local value associated with the key.
public void
waitUntilClusterCoherent()

Overrides net.sf.ehcache.store.AbstractStore.waitUntilClusterCoherent.

Implements net.sf.ehcache.store.Store.waitUntilClusterCoherent.

This method waits until the cache is in coherent mode in all the connected nodes.
Inherited from net.sf.ehcache.store.AbstractStore:
addStoreListenergetAllgetAllQuietgetEventListenerListputAllrecalculateSizeremoveAllremoveStoreListener

Field Detail

underlyingStoreback to summary
protected final Store underlyingStore

The underlying store wrapped by this store

Annotations
@ContextChild

Constructor Detail

AbstractTransactionStoreback to summary
protected AbstractTransactionStore(Store underlyingStore)

Constructor

Parameters
underlyingStore:Store

the underlying store

Method Detail

bufferFullback to summary
public boolean bufferFull()

Implements net.sf.ehcache.store.Store.bufferFull.

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

Some store types, such as the disk stores can fill their write buffers if puts come in too fast. The thread will wait for a short time before checking again.

Returns:boolean

true if the store write buffer is backed up.

containsKeyInMemoryback to summary
public boolean containsKeyInMemory(Object key)

Implements net.sf.ehcache.store.Store.containsKeyInMemory.

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

A check to see if a key is in the Store and is currently held in memory.

Parameters
key:Object

The Element key

Returns:boolean

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

containsKeyOffHeapback to summary
public boolean containsKeyOffHeap(Object key)

Implements net.sf.ehcache.store.Store.containsKeyOffHeap.

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

A check to see if a key is in the Store and is currently held off-heap.

Parameters
key:Object

The Element key

Returns:boolean

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

containsKeyOnDiskback to summary
public boolean containsKeyOnDisk(Object key)

Implements net.sf.ehcache.store.Store.containsKeyOnDisk.

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

A check to see if a key is in the Store and is currently held on disk.

Parameters
key:Object

The Element key

Returns:boolean

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

createWriteBehindback to summary
public WriteBehind createWriteBehind()

Implements net.sf.ehcache.store.TerracottaStore.createWriteBehind.

Doc from net.sf.ehcache.store.TerracottaStore.createWriteBehind.

WriteBehind createWriteBehind

Annotations
@Override
disposeback to summary
public void dispose()

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

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

Prepares for shutdown.

executeQueryback to summary
public Results executeQuery(StoreQuery query)

Overrides net.sf.ehcache.store.AbstractStore.executeQuery.

Implements net.sf.ehcache.store.Store.executeQuery.

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

Execute the given query on this store

Parameters
query:StoreQuery

query to execute

Returns:Results

query results

Annotations
@Override
expireElementsback to summary
public void expireElements()

Implements net.sf.ehcache.store.Store.expireElements.

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

Expire all elements.

flushback to summary
public void flush() throws IOException

Implements net.sf.ehcache.store.Store.flush.

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

Flush elements to persistent store.

Exceptions
IOException:
if any IO error occurs
getInMemoryEvictionPolicyback to summary
public Policy getInMemoryEvictionPolicy()

Implements net.sf.ehcache.store.Store.getInMemoryEvictionPolicy.

Returns:Policy

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

the current eviction policy. This may not be the configured policy, if it has been dynamically set.

getInMemorySizeback to summary
public int getInMemorySize()

Implements net.sf.ehcache.store.Store.getInMemorySize.

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

Returns the current local in-memory store size

Returns:int

the count of the Elements in the Store and in-memory on the local machine

getInMemorySizeInBytesback to summary
public long getInMemorySizeInBytes()

Implements net.sf.ehcache.store.Store.getInMemorySizeInBytes.

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

Gets the size of the in-memory portion of the store, in bytes.

This method may be expensive to run, depending on implementation. Implementers may choose to return an approximate size.

Returns:long

the approximate in-memory size of the store in bytes

getInternalContextback to summary
public Object getInternalContext()

Implements net.sf.ehcache.store.Store.getInternalContext.

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

This should not be used, and will generally return null

Returns:Object

some internal context (probably null)

getLocalKeysback to summary
public Set<E> getLocalKeys()

Implements net.sf.ehcache.store.TerracottaStore.getLocalKeys.

Doc from net.sf.ehcache.store.TerracottaStore.getLocalKeys.

Returns set of keys from the cache which are present in the node locally.

Returns:Set<E>

set of keys present locally in the node

getMBeanback to summary
public Object getMBean()

Implements net.sf.ehcache.store.Store.getMBean.

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

Optional implementation specific MBean exposed by the store.

Returns:Object

implementation specific management bean

getOffHeapSizeback to summary
public int getOffHeapSize()

Implements net.sf.ehcache.store.Store.getOffHeapSize.

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

Returns the current local off-heap store size

Returns:int

the count of the Elements in the Store and off-heap on the local machine

getOffHeapSizeInBytesback to summary
public long getOffHeapSizeInBytes()

Implements net.sf.ehcache.store.Store.getOffHeapSizeInBytes.

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

Gets the size of the off-heap portion of the store, in bytes.

Returns:long

the approximate off-heap size of the store in bytes

getOldElementback to summary
public Element getOldElement(Object key)

Method to get to the Element matching the key, oblivious of any in-flight transaction.

Parameters
key:Object

the key to look for

Returns:Element

the mapped element, outside of any transaction

getOnDiskSizeback to summary
public int getOnDiskSize()

Implements net.sf.ehcache.store.Store.getOnDiskSize.

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

Returns the current local on-disk store size

Returns:int

the count of the Elements in the Store and on-disk on the local machine

getOnDiskSizeInBytesback to summary
public long getOnDiskSizeInBytes()

Implements net.sf.ehcache.store.Store.getOnDiskSizeInBytes.

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

Gets the size of the on-disk portion of the store, in bytes.

Returns:long

the on-disk size of the store in bytes

getSearchAttributeback to summary
public <T> Attribute<T> getSearchAttribute(String attributeName) throws CacheException

Overrides net.sf.ehcache.store.AbstractStore.getSearchAttribute.

Implements net.sf.ehcache.store.Store.getSearchAttribute.

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

Retrieve the given named search attribute

Parameters
<T>
type of the attribute
attributeName:String

the name of the attribute to retrieve

Returns:Attribute<T>

the search attribute or null if non-existent

Annotations
@Override
getSearchAttributesback to summary
public Set<Attribute<T>> getSearchAttributes()

Overrides net.sf.ehcache.store.AbstractStore.getSearchAttributes.

Implements net.sf.ehcache.store.Store.getSearchAttributes.

Returns:Set<Attribute<T>>

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

all search attributes known to this store at the time of invoking the method

Annotations
@Override
getStatusback to summary
public Status getStatus()

Implements net.sf.ehcache.store.Store.getStatus.

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

Returns the cache status.

getTransactionalModeback to summary
public CacheConfiguration.TransactionalMode getTransactionalMode()

Implements net.sf.ehcache.store.TerracottaStore.getTransactionalMode.

Doc from net.sf.ehcache.store.TerracottaStore.getTransactionalMode.

Get the transactional mode of this store. The returned value is the String value of CacheConfiguration.TransactionalMode.

Returns:CacheConfiguration.TransactionalMode

a String representation of this store's transactional mode.

hasAbortedSizeOfback to summary
public boolean hasAbortedSizeOf()

Overrides net.sf.ehcache.store.AbstractStore.hasAbortedSizeOf.

Implements net.sf.ehcache.store.Store.hasAbortedSizeOf.

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

Checks if the cache may contain elements for which the SizeOf engine gave up and only partially calculated the size.

Returns:boolean

true if at least one partially sized element may be in the cache

Annotations
@Override
isCacheCoherentback to summary
public boolean isCacheCoherent()

Overrides net.sf.ehcache.store.AbstractStore.isCacheCoherent.

Implements net.sf.ehcache.store.Store.isCacheCoherent.

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

Indicates whether this store provides a coherent view of all the elements in a cache. Note that this is same as calling isClusterCoherent() (introduced since 2.0) Use isNodeCoherent() to find out if the cache is coherent in the current node in the cluster

Returns:boolean

true if the store is coherent; or false if the store potentially splits the cache storage with another store or isn't internally coherent

Annotations
@Override
See Also
net.sf.ehcache.store.Store#isCacheCoherent()
isClusterCoherentback to summary
public boolean isClusterCoherent()

Overrides net.sf.ehcache.store.AbstractStore.isClusterCoherent.

Implements net.sf.ehcache.store.Store.isClusterCoherent.

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

Returns true if the cache is in coherent mode cluster-wide. Returns false otherwise.

It applies to coherent clustering mechanisms only e.g. Terracotta

Returns:boolean

true if the cache is in coherent mode cluster-wide, false otherwise

Annotations
@Override
See Also
net.sf.ehcache.store.Store#isClusterCoherent()
isNodeCoherentback to summary
public boolean isNodeCoherent()

Overrides net.sf.ehcache.store.AbstractStore.isNodeCoherent.

Implements net.sf.ehcache.store.Store.isNodeCoherent.

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

Returns true if the cache is in coherent mode for the current node. Returns false otherwise.

It applies to coherent clustering mechanisms only e.g. Terracotta

Returns:boolean

true if the cache is in coherent mode cluster-wide, false otherwise

Annotations
@Override
See Also
net.sf.ehcache.store.Store#isNodeCoherent()
notifyCacheEventListenersChangedback to summary
public void notifyCacheEventListenersChanged()

Implements net.sf.ehcache.store.TerracottaStore.notifyCacheEventListenersChanged.

Doc from net.sf.ehcache.store.TerracottaStore.notifyCacheEventListenersChanged.

Notify the underlying store that some change has occured in the set of registered cache listeners.

Annotations
@Override
quickClearback to summary
public void quickClear()

Implements net.sf.ehcache.store.TerracottaStore.quickClear.

Doc from net.sf.ehcache.store.TerracottaStore.quickClear.

Remove all the contents of the store.

Annotations
@Override
quickSizeback to summary
public int quickSize()

Implements net.sf.ehcache.store.TerracottaStore.quickSize.

Doc from net.sf.ehcache.store.TerracottaStore.quickSize.

Get an approximate count of elements in the store.

Returns:int

an approximate count of elements in the store.

Annotations
@Override
setAttributeExtractorsback to summary
public void setAttributeExtractors(Map<String, AttributeExtractor> extractors)

Overrides net.sf.ehcache.store.AbstractStore.setAttributeExtractors.

Implements net.sf.ehcache.store.Store.setAttributeExtractors.

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

Inform this store of the configured attribute extractors. Stores that will not invoke extractors are free to ignore this call

Annotations
@Override
setInMemoryEvictionPolicyback to summary
public void setInMemoryEvictionPolicy(Policy policy)

Implements net.sf.ehcache.store.Store.setInMemoryEvictionPolicy.

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

Sets the eviction policy strategy. The Store will use a policy at startup. The store may allow changing the eviction policy strategy dynamically. Otherwise implementations will throw an exception if this method is called.

Parameters
policy:Policy

the new policy

setNodeCoherentback to summary
public void setNodeCoherent(boolean coherent)

Overrides net.sf.ehcache.store.AbstractStore.setNodeCoherent.

Implements net.sf.ehcache.store.Store.setNodeCoherent.

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

Sets the cache in coherent or incoherent mode for the current node depending on the parameter. Calling setNodeCoherent(true) when the cache is already in coherent mode or calling setNodeCoherent(false) when already in incoherent mode will be a no-op.

It applies to coherent clustering mechanisms only e.g. Terracotta

Parameters
coherent:boolean

true transitions to coherent mode, false to incoherent mode

Annotations
@Override
unsafeGetback to summary
public Element unsafeGet(Object key)

Implements net.sf.ehcache.store.TerracottaStore.unsafeGet.

Doc from net.sf.ehcache.store.TerracottaStore.unsafeGet.

Returns the local value associated with the key. Local value means that the object mapped to the key is present in the VM locally. In case its not, will return null. Note that even when returning null, the value may be present in the Terracotta server array.

This operation does not acquire any locks when doing the operation and may return stale values. This Operation does not update last usage statistics

Parameters
key:Object

the key

Returns:Element

the element associated with key or null

waitUntilClusterCoherentback to summary
public void waitUntilClusterCoherent() throws TerracottaNotRunningException, UnsupportedOperationException, InterruptedException

Overrides net.sf.ehcache.store.AbstractStore.waitUntilClusterCoherent.

Implements net.sf.ehcache.store.Store.waitUntilClusterCoherent.

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

This method waits until the cache is in coherent mode in all the connected nodes. If the cache is already in coherent mode it returns immediately

It applies to coherent clustering mechanisms only e.g. Terracotta

Annotations
@Override
Exceptions
UnsupportedOperationException:
if this store does not support cache coherence, like RMI replication