Top Description Inners Fields Constructors Methods
net.sf.ehcache.store.cachingtier

public Class OnHeapCachingTier<K, V>

extends Object
implements CachingTier<K, V>
Class Inheritance
All Implemented Interfaces
net.sf.ehcache.store.CachingTier
Type Parameters
<K>
The key type
<V>
the value type
Imports
net.sf.ehcache.CacheException, .Ehcache, .Element, net.sf.ehcache.config.AbstractCacheConfigurationListener, .PinningConfiguration, .SizeOfPolicyConfiguration, net.sf.ehcache.pool.Pool, .Size, .SizeOfEngine, .SizeOfEngineLoader, net.sf.ehcache.pool.sizeof.annotations.IgnoreSizeOf, net.sf.ehcache.store.CachingTier, .FifoPolicy, .LfuPolicy, .LruPolicy, .MemoryStoreEvictionPolicy, .Policy, .StoreOperationOutcomes.GetOutcome, .StoreOperationOutcomes.PutOutcome, .StoreOperationOutcomes.RemoveOutcome, java.util.List, .Map, java.util.concurrent.Callable, .CopyOnWriteArrayList, org.terracotta.context.annotations.ContextChild, org.terracotta.statistics.Statistic, org.terracotta.statistics.observer.OperationObserver

An instance of this class will delegate the storage to the backing HeapCacheBackEnd.
Adding :
Author
Alex Snaps

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final HeapCacheBackEnd<K, Object>
private final OperationObserver<StoreOperationOutcomes.GetOutcome>
private volatile List<CachingTier.Listener<K, V>>
private final OperationObserver<StoreOperationOutcomes.PutOutcome>
private final OperationObserver<StoreOperationOutcomes.RemoveOutcome>

Constructor Summary

AccessConstructor and Description
public
OnHeapCachingTier(final HeapCacheBackEnd<K, Object>
the HeapCacheBackEnd that will back this CachingTier
backEnd
)

A Constructor

Method Summary

Modifier and TypeMethod and Description
public void
addListener(final CachingTier.Listener<K, V>
the listener to add
listener
)

Implements net.sf.ehcache.store.CachingTier.addListener.

Adds a Listener to the cache
public void
clear()

Implements net.sf.ehcache.store.CachingTier.clear.

Clears the cache...
public void
clearAndNotify()

Implements net.sf.ehcache.store.CachingTier.clearAndNotify.

Clears the cache notifying listeners
public boolean
contains(final K key)

Implements net.sf.ehcache.store.CachingTier.contains.

This should go away once the stats are in As the method is only there to know what tier the key is going to be fetched from
public static OnHeapCachingTier<Object, Element>

Returns:

the OnHeapCachingTier properly configured for this cache
createOnHeapCache
(final Ehcache
the cache we're planning to back
cache
,
final Pool
the pool, if any, to use
onHeapPool
)

Factory method

pack-priv static Policy

Returns:

the chosen eviction policy
determineEvictionPolicy
(Ehcache
the cache
cache
)

Chooses the Policy from the cache configuration

public V
get(final K
the key to look up
key
,
final Callable<V>
the source to use, in the case of no mapping present
source
,
final boolean
true to update the stats, false otherwise
updateStats
)

Implements net.sf.ehcache.store.CachingTier.get.

Returns the value associated with the key, or populates the mapping using the Callable instance
private static long
public Policy
getEvictionPolicy()

Implements net.sf.ehcache.store.CachingTier.getEvictionPolicy.

queries the potential eviction policy for the heap caching tier
public int
getInMemorySize()

Implements net.sf.ehcache.store.CachingTier.getInMemorySize.

Can we avoid having this somehow ?
public long
getInMemorySizeInBytes()

Implements net.sf.ehcache.store.CachingTier.getInMemorySizeInBytes.

CacheTier could keep hold of the PoolAccessors for each tier...
public int
getOffHeapSize()

Implements net.sf.ehcache.store.CachingTier.getOffHeapSize.

Can we avoid having this somehow ?
public long
getOffHeapSizeInBytes()

Implements net.sf.ehcache.store.CachingTier.getOffHeapSizeInBytes.

CacheTier could keep hold of the PoolAccessors for each tier...
public long
getOnDiskSizeInBytes()

Implements net.sf.ehcache.store.CachingTier.getOnDiskSizeInBytes.

CacheTier could keep hold of the PoolAccessors for each tier...
private V
getValue(final Object cachedValue)

public boolean
loadOnPut()

Implements net.sf.ehcache.store.CachingTier.loadOnPut.

Returns true if values should be loaded to this cache on put.
public void
recalculateSize(final K
the key to perform the recalculation for
key
)

Implements net.sf.ehcache.store.CachingTier.recalculateSize.

This is evil!
public V
remove(final K
the key to the mapping to remove
key
)

Implements net.sf.ehcache.store.CachingTier.remove.

Removes the mapping associated to the key passed in
public void
setEvictionPolicy(final Policy
the policy to use
policy
)

Implements net.sf.ehcache.store.CachingTier.setEvictionPolicy.

sets the eviction policy on the heap caching tier
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

backEndback to summary
private final HeapCacheBackEnd<K, Object> backEnd
Annotations
@ContextChild
getObserverback to summary
private final OperationObserver<StoreOperationOutcomes.GetOutcome> getObserver
listenersback to summary
private volatile List<CachingTier.Listener<K, V>> listeners
putObserverback to summary
private final OperationObserver<StoreOperationOutcomes.PutOutcome> putObserver
removeObserverback to summary
private final OperationObserver<StoreOperationOutcomes.RemoveOutcome> removeObserver

Constructor Detail

OnHeapCachingTierback to summary
public OnHeapCachingTier(final HeapCacheBackEnd<K, Object> backEnd)

A Constructor

Parameters
backEnd:HeapCacheBackEnd<K, Object>

the HeapCacheBackEnd that will back this CachingTier

Method Detail

addListenerback to summary
public void addListener(final CachingTier.Listener<K, V> listener)

Implements net.sf.ehcache.store.CachingTier.addListener.

Doc from net.sf.ehcache.store.CachingTier.addListener.

Adds a Listener to the cache

Parameters
listener:CachingTier.Listener<K, V>

the listener to add

Annotations
@Override
clearback to summary
public void clear()

Implements net.sf.ehcache.store.CachingTier.clear.

Doc from net.sf.ehcache.store.CachingTier.clear.

Clears the cache... Doesn't notify any listeners

Annotations
@Override
clearAndNotifyback to summary
public void clearAndNotify()

Implements net.sf.ehcache.store.CachingTier.clearAndNotify.

Doc from net.sf.ehcache.store.CachingTier.clearAndNotify.

Clears the cache notifying listeners

Annotations
@Override
containsback to summary
public boolean contains(final K key)

Implements net.sf.ehcache.store.CachingTier.contains.

Doc from net.sf.ehcache.store.CachingTier.contains.

This should go away once the stats are in As the method is only there to know what tier the key is going to be fetched from

Annotations
@Override
createOnHeapCacheback to summary
public static OnHeapCachingTier<Object, Element> createOnHeapCache(final Ehcache cache, final Pool onHeapPool)

Factory method

Parameters
cache:Ehcache

the cache we're planning to back

onHeapPool:Pool

the pool, if any, to use

Returns:OnHeapCachingTier<Object, Element>

the OnHeapCachingTier properly configured for this cache

determineEvictionPolicyback to summary
pack-priv static Policy determineEvictionPolicy(Ehcache cache)

Chooses the Policy from the cache configuration

Parameters
cache:Ehcache

the cache

Returns:Policy

the chosen eviction policy

getback to summary
public V get(final K key, final Callable<V> source, final boolean updateStats)

Implements net.sf.ehcache.store.CachingTier.get.

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

Returns the value associated with the key, or populates the mapping using the Callable instance

Parameters
key:K

the key to look up

source:Callable<V>

the source to use, in the case of no mapping present

updateStats:boolean

true to update the stats, false otherwise

Returns:V

the value mapped to the key

Annotations
@Override
getCachingTierMaxEntryCountback to summary
private static long getCachingTierMaxEntryCount(final Ehcache cache)
getEvictionPolicyback to summary
public Policy getEvictionPolicy()

Implements net.sf.ehcache.store.CachingTier.getEvictionPolicy.

Doc from net.sf.ehcache.store.CachingTier.getEvictionPolicy.

queries the potential eviction policy for the heap caching tier

Returns:Policy

the policy

Annotations
@Override
getInMemorySizeback to summary
public int getInMemorySize()

Implements net.sf.ehcache.store.CachingTier.getInMemorySize.

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

Can we avoid having this somehow ?

Returns:int

the count of entries held in heap

Annotations
@Statistic
name:size
tags:local-heap
@Override
getInMemorySizeInBytesback to summary
public long getInMemorySizeInBytes()

Implements net.sf.ehcache.store.CachingTier.getInMemorySizeInBytes.

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

CacheTier could keep hold of the PoolAccessors for each tier... But what about non pooled resources ?

Annotations
@Statistic
name:size-in-bytes
tags:local-heap
@Override
getOffHeapSizeback to summary
public int getOffHeapSize()

Implements net.sf.ehcache.store.CachingTier.getOffHeapSize.

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

Can we avoid having this somehow ?

Returns:int

the count of entries held off heap

Annotations
@Override
getOffHeapSizeInBytesback to summary
public long getOffHeapSizeInBytes()

Implements net.sf.ehcache.store.CachingTier.getOffHeapSizeInBytes.

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

CacheTier could keep hold of the PoolAccessors for each tier... But what about non pooled resources ?

Annotations
@Override
getOnDiskSizeInBytesback to summary
public long getOnDiskSizeInBytes()

Implements net.sf.ehcache.store.CachingTier.getOnDiskSizeInBytes.

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

CacheTier could keep hold of the PoolAccessors for each tier... But what about non pooled resources ?

Annotations
@Override
getValueback to summary
private V getValue(final Object cachedValue)
loadOnPutback to summary
public boolean loadOnPut()

Implements net.sf.ehcache.store.CachingTier.loadOnPut.

Doc from net.sf.ehcache.store.CachingTier.loadOnPut.

Returns true if values should be loaded to this cache on put.

This may be a dynamic decision, based for example on the occupancy of the cache.

Returns:boolean

true if values should be loaded on put

Annotations
@Override
recalculateSizeback to summary
public void recalculateSize(final K key)

Implements net.sf.ehcache.store.CachingTier.recalculateSize.

Doc from net.sf.ehcache.store.CachingTier.recalculateSize.

This is evil! Don't call this!

Parameters
key:K

the key to perform the recalculation for

Annotations
@Override
removeback to summary
public V remove(final K key)

Implements net.sf.ehcache.store.CachingTier.remove.

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

Removes the mapping associated to the key passed in

Parameters
key:K

the key to the mapping to remove

Returns:V

the value removed, null if none

Annotations
@Override
setEvictionPolicyback to summary
public void setEvictionPolicy(final Policy policy)

Implements net.sf.ehcache.store.CachingTier.setEvictionPolicy.

Doc from net.sf.ehcache.store.CachingTier.setEvictionPolicy.

sets the eviction policy on the heap caching tier

Parameters
policy:Policy

the policy to use

Annotations
@Override
net.sf.ehcache.store.cachingtier back to summary

private Class OnHeapCachingTier.Fault<V>

extends Object
Class Inheritance
Annotations
@IgnoreSizeOf

Document me

Field Summary

Modifier and TypeField and Description
private boolean
private final Callable<V>
private Throwable
private V

Constructor Summary

AccessConstructor and Description
public
Fault(final Callable<V> source)

Method Summary

Modifier and TypeMethod and Description
private void
complete(V value)

private void
fail(final Throwable t)

private V
get()

private V
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

completeback to summary
private boolean complete
sourceback to summary
private final Callable<V> source
throwableback to summary
private Throwable throwable
valueback to summary
private V value

Constructor Detail

Faultback to summary
public Fault(final Callable<V> source)

Method Detail

completeback to summary
private void complete(V value)
failback to summary
private void fail(final Throwable t)
getback to summary
private V get()
throwOrReturnback to summary
private V throwOrReturn()