Package org.apache.ignite.cache.eviction
Class AbstractEvictionPolicy<K,V>
- java.lang.Object
- 
- org.apache.ignite.cache.eviction.AbstractEvictionPolicy<K,V>
 
- 
- All Implemented Interfaces:
- Externalizable,- Serializable,- EvictionPolicy<K,V>
 - Direct Known Subclasses:
- FifoEvictionPolicy,- LruEvictionPolicy,- SortedEvictionPolicy
 
 public abstract class AbstractEvictionPolicy<K,V> extends Object implements EvictionPolicy<K,V>, Externalizable Common functionality implementation for eviction policies with max size/max memory and batch eviction support.- See Also:
- Serialized Form
 
- 
- 
Constructor SummaryConstructors Constructor Description AbstractEvictionPolicy()
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intgetBatchSize()Gets batch size.longgetCurrentMemorySize()Gets current queue size in bytes.protected abstract intgetCurrentSize()longgetMaxMemorySize()Gets maximum allowed cache size in bytes.intgetMaxSize()Gets maximum allowed size of cache before entry will start getting evicted.voidonEntryAccessed(boolean rmv, EvictableEntry<K,V> entry)Callback for whenever entry is accessed.voidreadExternal(ObjectInput in)protected abstract booleanremoveMeta(Object meta)AbstractEvictionPolicy<K,V>setBatchSize(int batchSize)Sets batch size.AbstractEvictionPolicy<K,V>setMaxMemorySize(long maxMemSize)Sets maximum allowed cache size in bytes.AbstractEvictionPolicy<K,V>setMaxSize(int max)Sets maximum allowed size of cache before entry will start getting evicted.protected voidshrink()Shrinks backed container to maximum allowed size.protected abstract intshrink0()protected abstract booleantouch(EvictableEntry<K,V> entry)voidwriteExternal(ObjectOutput out)
 
- 
- 
- 
Field Detail- 
memSizeprotected final LongAdder memSize Memory size occupied by elements in container.
 
- 
 - 
Method Detail- 
shrinkprotected void shrink() Shrinks backed container to maximum allowed size.
 - 
onEntryAccessedpublic void onEntryAccessed(boolean rmv, EvictableEntry<K,V> entry)Callback for whenever entry is accessed.- Specified by:
- onEntryAccessedin interface- EvictionPolicy<K,V>
- Parameters:
- rmv-- Trueif entry has been removed,- falseotherwise.
- entry- Accessed entry.
 
 - 
getCurrentSizeprotected abstract int getCurrentSize() - Returns:
- Size of the container with trackable entries.
 
 - 
shrink0protected abstract int shrink0() - Returns:
- Size of the memory which was shrinked.
 
 - 
removeMetaprotected abstract boolean removeMeta(Object meta) - Parameters:
- meta- Meta-information shipped to an entry.
- Returns:
- Trueif meta was successfully removed from the container.
 
 - 
touchprotected abstract boolean touch(EvictableEntry<K,V> entry) - Parameters:
- entry- Entry to touch.
- Returns:
- Trueif container has been changed by this call.
 
 - 
setMaxMemorySizepublic AbstractEvictionPolicy<K,V> setMaxMemorySize(long maxMemSize) Sets maximum allowed cache size in bytes.- Parameters:
- maxMemSize- Maximum allowed cache size in bytes.
- Returns:
- thisfor chaining.
 
 - 
getMaxMemorySizepublic long getMaxMemorySize() Gets maximum allowed cache size in bytes.- Returns:
- maximum allowed cache size in bytes.
 
 - 
getCurrentMemorySizepublic long getCurrentMemorySize() Gets current queue size in bytes.- Returns:
- current queue size in bytes.
 
 - 
setMaxSizepublic AbstractEvictionPolicy<K,V> setMaxSize(int max) Sets maximum allowed size of cache before entry will start getting evicted.- Parameters:
- max- Maximum allowed size of cache before entry will start getting evicted.
- Returns:
- thisfor chaining.
 
 - 
getMaxSizepublic int getMaxSize() Gets maximum allowed size of cache before entry will start getting evicted.- Returns:
- Maximum allowed size of cache before entry will start getting evicted.
 
 - 
setBatchSizepublic AbstractEvictionPolicy<K,V> setBatchSize(int batchSize) Sets batch size.- Parameters:
- batchSize- Batch size.
- Returns:
- thisfor chaining.
 
 - 
getBatchSizepublic int getBatchSize() Gets batch size.- Returns:
- batch size.
 
 - 
writeExternalpublic void writeExternal(ObjectOutput out) throws IOException - Specified by:
- writeExternalin interface- Externalizable
- Throws:
- IOException
 
 - 
readExternalpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException - Specified by:
- readExternalin interface- Externalizable
- Throws:
- IOException
- ClassNotFoundException
 
 
- 
 
-