Package net.sf.ehcache.store
Class AbstractStore
- java.lang.Object
-
- net.sf.ehcache.store.AbstractStore
-
- All Implemented Interfaces:
Store
- Direct Known Subclasses:
AbstractTransactionStore,DiskStore,LegacyStoreWrapper,LruMemoryStore,MemoryStore
public abstract class AbstractStore extends java.lang.Object implements Store
- Author:
- gkeim
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,AttributeExtractor>attributeExtractorssearch attribute extractorsprotected SearchManagersearchManagersearch manager-
Fields inherited from interface net.sf.ehcache.store.Store
CLUSTER_COHERENT, NODE_COHERENT
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractStore()Constructor for stores that do not support searchprotectedAbstractStore(SearchManager searchManager, java.lang.String cacheName)Constructor for stores that do support search
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddStoreListener(StoreListener listener)Add a listener to the store.ResultsexecuteQuery(StoreQuery query)Execute the given query on this storejava.util.Map<java.lang.Object,Element>getAll(java.util.Collection<?> keys)Retries the elements associated with a set of keys and update the statistics Keys which are not present in the cache will have null values associated with them in the returned mapjava.util.Map<java.lang.Object,Element>getAllQuiet(java.util.Collection<?> keys)Retries the elements associated with a set of keys without updating the statistics Keys which are not present in the cache will have null values associated with them in the returned mapprotected java.util.List<StoreListener>getEventListenerList()onLoad initializer<T> Attribute<T>getSearchAttribute(java.lang.String attributeName)Retrieve the given named search attributejava.util.Set<Attribute>getSearchAttributes()booleanhasAbortedSizeOf()Checks if the cache may contain elements for which the SizeOf engine gave up and only partially calculated the size.booleanisCacheCoherent()Indicates whether this store provides a coherent view of all the elements in a cache.booleanisClusterCoherent()Returns true if the cache is in coherent mode cluster-wide.booleanisNodeCoherent()Returns true if the cache is in coherent mode for the current node.voidputAll(java.util.Collection<Element> elements)Puts a collection of elements into the store.voidrecalculateSize(java.lang.Object key)Recalculate size of the element mapped to the keyvoidremoveAll(java.util.Collection<?> keys)Removes a collection of elements from the cache.voidremoveStoreListener(StoreListener listener)Remove listener from store.voidsetAttributeExtractors(java.util.Map<java.lang.String,AttributeExtractor> extractors)Inform this store of the configured attribute extractors.voidsetNodeCoherent(boolean coherent)Sets the cache in coherent or incoherent mode for the current node depending on the parameter.voidwaitUntilClusterCoherent()This method waits until the cache is in coherent mode in all the connected nodes.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.ehcache.store.Store
bufferFull, containsKey, containsKeyInMemory, containsKeyOffHeap, containsKeyOnDisk, dispose, expireElements, flush, get, getInMemoryEvictionPolicy, getInMemorySize, getInMemorySizeInBytes, getInternalContext, getKeys, getMBean, getOffHeapSize, getOffHeapSizeInBytes, getOnDiskSize, getOnDiskSizeInBytes, getQuiet, getSize, getStatus, getTerracottaClusteredSize, put, putIfAbsent, putWithWriter, remove, removeAll, removeElement, removeWithWriter, replace, replace, setInMemoryEvictionPolicy
-
-
-
-
Field Detail
-
attributeExtractors
protected final java.util.Map<java.lang.String,AttributeExtractor> attributeExtractors
search attribute extractors
-
searchManager
protected final SearchManager searchManager
search manager
-
-
Constructor Detail
-
AbstractStore
protected AbstractStore()
Constructor for stores that do not support search
-
AbstractStore
protected AbstractStore(SearchManager searchManager, java.lang.String cacheName)
Constructor for stores that do support search- Parameters:
searchManager- the search manager to use
-
-
Method Detail
-
getEventListenerList
protected java.util.List<StoreListener> getEventListenerList()
onLoad initializer
-
isCacheCoherent
public boolean isCacheCoherent()
Indicates whether this store provides a coherent view of all the elements in a cache. Note that this is same as callingStore.isClusterCoherent()(introduced since 2.0) UseStore.isNodeCoherent()to find out if the cache is coherent in the current node in the cluster- Specified by:
isCacheCoherentin interfaceStore- Returns:
trueif the store is coherent; orfalseif the store potentially splits the cache storage with another store or isn't internally coherent- See Also:
Store.isCacheCoherent()
-
isClusterCoherent
public boolean 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
- Specified by:
isClusterCoherentin interfaceStore- Returns:
- true if the cache is in coherent mode cluster-wide, false otherwise
- See Also:
Store.isClusterCoherent()
-
isNodeCoherent
public boolean 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
- Specified by:
isNodeCoherentin interfaceStore- Returns:
- true if the cache is in coherent mode cluster-wide, false otherwise
- See Also:
Store.isNodeCoherent()
-
setNodeCoherent
public void setNodeCoherent(boolean coherent) throws java.lang.UnsupportedOperationExceptionSets the cache in coherent or incoherent mode for the current node depending on the parameter. CallingsetNodeCoherent(true)when the cache is already in coherent mode or callingsetNodeCoherent(false)when already in incoherent mode will be a no-op.It applies to coherent clustering mechanisms only e.g. Terracotta
- Specified by:
setNodeCoherentin interfaceStore- Parameters:
coherent- true transitions to coherent mode, false to incoherent mode- Throws:
java.lang.UnsupportedOperationException- if this store does not support cache coherence, like RMI replication- See Also:
Store.setNodeCoherent(boolean)
-
waitUntilClusterCoherent
public void waitUntilClusterCoherent() throws java.lang.UnsupportedOperationException, TerracottaNotRunningException, java.lang.InterruptedExceptionThis method waits until the cache is in coherent mode in all the connected nodes. If the cache is already in coherent mode it returns immediatelyIt applies to coherent clustering mechanisms only e.g. Terracotta
- Specified by:
waitUntilClusterCoherentin interfaceStore- Throws:
java.lang.InterruptedExceptionTerracottaNotRunningExceptionjava.lang.UnsupportedOperationException- if this store does not support cache coherence, like RMI replication- See Also:
Store.waitUntilClusterCoherent()
-
addStoreListener
public void addStoreListener(StoreListener listener)
Add a listener to the store.- Specified by:
addStoreListenerin interfaceStore- See Also:
Store.addStoreListener(net.sf.ehcache.store.StoreListener)
-
removeStoreListener
public void removeStoreListener(StoreListener listener)
Remove listener from store.- Specified by:
removeStoreListenerin interfaceStore- See Also:
Store.removeStoreListener(net.sf.ehcache.store.StoreListener)
-
setAttributeExtractors
public void setAttributeExtractors(java.util.Map<java.lang.String,AttributeExtractor> extractors)
Inform this store of the configured attribute extractors. Stores that will not invoke extractors are free to ignore this call- Specified by:
setAttributeExtractorsin interfaceStore
-
executeQuery
public Results executeQuery(StoreQuery query)
Execute the given query on this store- Specified by:
executeQueryin interfaceStore- Parameters:
query- query to execute- Returns:
- query results
-
getSearchAttribute
public <T> Attribute<T> getSearchAttribute(java.lang.String attributeName) throws CacheException
Retrieve the given named search attribute- Specified by:
getSearchAttributein interfaceStore- Type Parameters:
T- type of the attribute- Parameters:
attributeName- the name of the attribute to retrieve- Returns:
- the search attribute or null if non-existent
- Throws:
CacheException
-
getSearchAttributes
public java.util.Set<Attribute> getSearchAttributes()
- Specified by:
getSearchAttributesin interfaceStore- Returns:
- all search attributes known to this store at the time of invoking the method
-
putAll
public void putAll(java.util.Collection<Element> elements) throws CacheException
Puts a collection of elements into the store.- Specified by:
putAllin interfaceStore- Parameters:
elements- Collection of elements to be put in the store- Throws:
CacheException
-
removeAll
public void removeAll(java.util.Collection<?> keys)
Removes a collection of elements from the cache.
-
getAllQuiet
public java.util.Map<java.lang.Object,Element> getAllQuiet(java.util.Collection<?> keys)
Retries the elements associated with a set of keys without updating the statistics Keys which are not present in the cache will have null values associated with them in the returned map- Specified by:
getAllQuietin interfaceStore- Parameters:
keys- a collection of keys to look for- Returns:
- a map of keys and their corresponding values
-
getAll
public java.util.Map<java.lang.Object,Element> getAll(java.util.Collection<?> keys)
Retries the elements associated with a set of keys and update the statistics Keys which are not present in the cache will have null values associated with them in the returned map
-
hasAbortedSizeOf
public boolean hasAbortedSizeOf()
Checks if the cache may contain elements for which the SizeOf engine gave up and only partially calculated the size.- Specified by:
hasAbortedSizeOfin interfaceStore- Returns:
- true if at least one partially sized element may be in the cache
-
recalculateSize
public void recalculateSize(java.lang.Object key)
Recalculate size of the element mapped to the key- Specified by:
recalculateSizein interfaceStore- Parameters:
key- the key
-
-