T
- the cache tier store typeU
- the authority tier store typepublic abstract class FrontEndCacheTier<T extends TierableStore,U extends TierableStore> extends AbstractStore
Modifier and Type | Field and Description |
---|---|
protected U |
authority
The authority tier store
|
protected T |
cache
The cache tier store
|
attributeExtractors
CLUSTER_COHERENT, NODE_COHERENT
Constructor and Description |
---|
FrontEndCacheTier(T cache,
U authority,
ReadWriteCopyStrategy<Element> copyStrategy,
SearchManager searchManager,
boolean copyOnWrite,
boolean copyOnRead)
Constructor for FrontEndCacheTier
|
Modifier and Type | Method and Description |
---|---|
boolean |
bufferFull()
Some store types, such as the disk stores can fill their write buffers if puts
come in too fast.
|
boolean |
containsKey(Object key)
A check to see if a key is in the Store.
|
boolean |
containsKeyInMemory(Object key)
A check to see if a key is in the Store and is currently held in memory.
|
boolean |
containsKeyOffHeap(Object key)
A check to see if a key is in the Store and is currently held off-heap.
|
boolean |
containsKeyOnDisk(Object key)
A check to see if a key is in the Store and is currently held on disk.
|
protected Element |
copyElementForReadIfNeeded(Element element)
Perform copy on read on an element if configured
|
protected Element |
copyElementForWriteIfNeeded(Element element)
Perform copy on write on an element if configured
|
void |
dispose()
Prepares for shutdown.
|
void |
expireElements()
Expire all elements.
|
void |
flush()
Flush elements to persistent store.
|
Element |
get(Object key)
Gets an item from the cache.
|
protected List<ReadWriteLockSync> |
getAllLocks()
Returns all ReadWriteLockSyncs guarding this store.
|
Policy |
getInMemoryEvictionPolicy() |
int |
getInMemorySize()
Returns the current local in-memory store size
|
long |
getInMemorySizeInBytes()
Gets the size of the in-memory portion of the store, in bytes.
|
Object |
getInternalContext()
This should not be used, and will generally return null
|
List<?> |
getKeys()
Gets an Array of the keys for all elements in the disk store.
|
ReadWriteLock |
getLockFor(Object key)
Returns the ReadWriteLock guarding this key.
|
int |
getOffHeapSize()
Returns the current local off-heap store size
|
long |
getOffHeapSizeInBytes()
Gets the size of the off-heap portion of the store, in bytes.
|
int |
getOnDiskSize()
Returns the current local on-disk store size
|
long |
getOnDiskSizeInBytes()
Gets the size of the on-disk portion of the store, in bytes.
|
Element |
getQuiet(Object key)
Gets an
Element from the Store, without updating statistics |
int |
getSize()
Returns the current local store size
|
Status |
getStatus()
Returns the cache status.
|
int |
getTerracottaClusteredSize()
Returns the current Terracotta clustered store size
|
boolean |
hasAbortedSizeOf()
Checks if the cache may contain elements for which the SizeOf engine gave up and only
partially calculated the size.
|
boolean |
isCached(Object key)
Checks whether the key is held in the fronting cache
|
boolean |
isEvictionCandidate(Element e)
Checks whether the element can be safely evicted.
|
boolean |
isPinned(Object key)
Check if the key is pinned
|
boolean |
notifyEvictionFromCache(Serializable key)
Whether evicting this from the cache should fire when evicting from upper tiers
|
boolean |
put(Element e)
Puts an item into the store.
|
Element |
putIfAbsent(Element e)
Put an element in the store if no element is currently mapped to the elements key.
|
boolean |
putWithWriter(Element e,
CacheWriterManager writer)
Puts an item into the store and the cache writer manager in an atomic operation
|
void |
recalculateSize(Object key)
Recalculate size of the element mapped to the key
|
Element |
remove(Object key)
Removes an item from the cache.
|
void |
removeAll()
Remove all of the elements from the store.
|
Element |
removeElement(Element e,
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 e)
Replace the cached element only if an Element is currently cached for this key
|
boolean |
replace(Element old,
Element e,
ElementValueComparator comparator)
Replace the cached element only if the value of the current Element is equal to the value of the
supplied old Element.
|
void |
setInMemoryEvictionPolicy(Policy policy)
Sets the eviction policy strategy.
|
void |
setPinned(Object key,
boolean pinned)
Mark the key as pinned or not
|
void |
unpinAll()
unpin all pinned keys
|
addStoreListener, executeQuery, getAll, getAllQuiet, getEventListenerList, getSearchAttribute, isCacheCoherent, isClusterCoherent, isNodeCoherent, putAll, removeAll, removeStoreListener, setAttributeExtractors, setNodeCoherent, waitUntilClusterCoherent
protected final T extends TierableStore cache
protected final U extends TierableStore authority
public FrontEndCacheTier(T cache, U authority, ReadWriteCopyStrategy<Element> copyStrategy, SearchManager searchManager, boolean copyOnWrite, boolean copyOnRead)
cache
- the caching tierauthority
- the authority tiercopyStrategy
- the copyStrategy to usesearchManager
- the search manager to usecopyOnWrite
- whether to copy on writes, false otherwisecopyOnRead
- whether to copy on reads, false otherwisepublic void unpinAll()
public boolean isPinned(Object key)
key
- the key to be checkedtrue
if the element is pinnedpublic void setPinned(Object key, boolean pinned)
key
- the key to be pinned or notpinned
- true if the key should be pinned, false otherwiseprotected Element copyElementForReadIfNeeded(Element element)
element
- the element to copy for readprotected Element copyElementForWriteIfNeeded(Element element)
element
- the element to copy for writepublic Element getQuiet(Object key)
Element
from the Store, without updating statisticspublic boolean put(Element e)
public boolean putWithWriter(Element e, CacheWriterManager writer)
public Element removeWithWriter(Object key, CacheWriterManager writerManager) throws CacheException
CacheException
public Element putIfAbsent(Element e) throws NullPointerException
e
- element to be addedNullPointerException
- if the element is null, or has a null keypublic Element removeElement(Element e, ElementValueComparator comparator) throws NullPointerException
e
- Element to be removedcomparator
- ElementValueComparator to use to compare elementsNullPointerException
- if the element is null, or has a null keypublic boolean replace(Element old, Element e, ElementValueComparator comparator) throws NullPointerException, IllegalArgumentException
old
- Element to be test againste
- Element to be cachedcomparator
- ElementValueComparator to use to compare elementsNullPointerException
- if the either Element is null or has a null keyIllegalArgumentException
- if the two Element keys are non-null but not equalpublic Element replace(Element e) throws NullPointerException
e
- Element to be cachedNullPointerException
- if the Element is null or has a null keypublic boolean containsKey(Object key)
key
- The Element keypublic boolean containsKeyOnDisk(Object key)
key
- The Element keypublic boolean containsKeyOffHeap(Object key)
key
- The Element keypublic boolean containsKeyInMemory(Object key)
key
- The Element keypublic List<?> getKeys()
Serializable
keyspublic void removeAll() throws CacheException
CacheEventListener
s they are notified of the expiry or removal
of the Element
as each is removed.CacheException
public void dispose()
public int getSize()
public int getInMemorySize()
public int getOffHeapSize()
public int getOnDiskSize()
public int getTerracottaClusteredSize()
public long getInMemorySizeInBytes()
public long getOffHeapSizeInBytes()
public long getOnDiskSizeInBytes()
public void expireElements()
public void flush() throws IOException
IOException
- if any IO error occurspublic boolean bufferFull()
public ReadWriteLock getLockFor(Object key)
key
- key of interestprotected List<ReadWriteLockSync> getAllLocks()
public Status getStatus()
public Policy getInMemoryEvictionPolicy()
Store.setInMemoryEvictionPolicy(Policy)
public void setInMemoryEvictionPolicy(Policy policy)
policy
- the new policypublic final Object getInternalContext()
public boolean isEvictionCandidate(Element e)
Failing to obey this, might result in firing an Element Evicted Event, while it is still present in higher tiers
e
- The element we want to evictpublic boolean isCached(Object key)
key
- the key to check forpublic boolean notifyEvictionFromCache(Serializable key)
key
- the key to the elementpublic boolean hasAbortedSizeOf()
hasAbortedSizeOf
in interface Store
hasAbortedSizeOf
in class AbstractStore
public void recalculateSize(Object key)
AbstractStore
recalculateSize
in interface Store
recalculateSize
in class AbstractStore
key
- the keyCopyright © 2003-2013 Terracotta, Inc.. All Rights Reserved.