Class SortedEvictionPolicy<K,V>
- java.lang.Object
- 
- org.apache.ignite.cache.eviction.AbstractEvictionPolicy<K,V>
- 
- org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicy<K,V>
 
 
- 
- All Implemented Interfaces:
- Externalizable,- Serializable,- EvictionPolicy<K,V>,- IgniteMBeanAware
 
 public class SortedEvictionPolicy<K,V> extends AbstractEvictionPolicy<K,V> implements IgniteMBeanAware Cache eviction policy which will select the minimum cache entry for eviction.The eviction starts in the following cases: - The cache size becomes batchSizeelements greater than the maximum size.
- The size of cache entries in bytes becomes greater than the maximum memory size. The size of cache entry calculates as sum of key size and value size.
 maxMemSize == 0).batchSizeelements will be evicted in this case. The defaultbatchSizevalue is1.Entries comparison based on Comparatorinstance if provided. DefaultComparatorbehaviour is use cache entries keys for comparison that imposes a requirement for keys to implementComparableinterface.User defined comparator should implement Serializableinterface.- See Also:
- Serialized Form
 
- 
- 
Field Summary- 
Fields inherited from class org.apache.ignite.cache.eviction.AbstractEvictionPolicymemSize
 
- 
 - 
Constructor SummaryConstructors Constructor Description SortedEvictionPolicy()Constructs sorted eviction policy with all defaults.SortedEvictionPolicy(int max)Constructs sorted eviction policy with maximum size.SortedEvictionPolicy(int max, int batchSize, @Nullable Comparator<EvictableEntry<K,V>> comp)Constructs sorted eviction policy with given maximum size, eviction batch size and entries comparator.SortedEvictionPolicy(int max, @Nullable Comparator<EvictableEntry<K,V>> comp)Constructs sorted eviction policy with given maximum size and given entry comparator.SortedEvictionPolicy(@Nullable Comparator<EvictableEntry<K,V>> comp)Constructs sorted eviction policy with given maximum size and given entry comparator.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetCurrentSize()ObjectgetMBean()Collection<EvictableEntry<K,V>>queue()Gets read-only view of backed queue in proper order.voidreadExternal(ObjectInput in)protected booleanremoveMeta(Object meta)Removes holder from backed queue and marks holder as removed.SortedEvictionPolicy<K,V>setBatchSize(int batchSize)Sets batch size.SortedEvictionPolicy<K,V>setMaxMemorySize(long maxMemSize)Sets maximum allowed cache size in bytes.SortedEvictionPolicy<K,V>setMaxSize(int max)Sets maximum allowed size of cache before entry will start getting evicted.protected intshrink0()Tries to remove one item from queue.protected booleantouch(EvictableEntry<K,V> entry)voidwriteExternal(ObjectOutput out)- 
Methods inherited from class org.apache.ignite.cache.eviction.AbstractEvictionPolicygetBatchSize, getCurrentMemorySize, getMaxMemorySize, getMaxSize, onEntryAccessed, shrink
 
- 
 
- 
- 
- 
Constructor Detail- 
SortedEvictionPolicypublic SortedEvictionPolicy() Constructs sorted eviction policy with all defaults.
 - 
SortedEvictionPolicypublic SortedEvictionPolicy(int max) Constructs sorted eviction policy with maximum size.- Parameters:
- max- Maximum allowed size of cache before entry will start getting evicted.
 
 - 
SortedEvictionPolicypublic SortedEvictionPolicy(int max, @Nullable @Nullable Comparator<EvictableEntry<K,V>> comp)Constructs sorted eviction policy with given maximum size and given entry comparator.- Parameters:
- max- Maximum allowed size of cache before entry will start getting evicted.
- comp- Entries comparator.
 
 - 
SortedEvictionPolicypublic SortedEvictionPolicy(int max, int batchSize, @Nullable @Nullable Comparator<EvictableEntry<K,V>> comp)Constructs sorted eviction policy with given maximum size, eviction batch size and entries comparator.- Parameters:
- max- Maximum allowed size of cache before entry will start getting evicted.
- batchSize- Batch size.
- comp- Entries comparator.
 
 - 
SortedEvictionPolicypublic SortedEvictionPolicy(@Nullable @Nullable Comparator<EvictableEntry<K,V>> comp)Constructs sorted eviction policy with given maximum size and given entry comparator.- Parameters:
- comp- Entries comparator.
 
 
- 
 - 
Method Detail- 
setMaxMemorySizepublic SortedEvictionPolicy<K,V> setMaxMemorySize(long maxMemSize) Sets maximum allowed cache size in bytes.- Overrides:
- setMaxMemorySizein class- AbstractEvictionPolicy<K,V>
- Parameters:
- maxMemSize- Maximum allowed cache size in bytes.
- Returns:
- thisfor chaining.
 
 - 
setMaxSizepublic SortedEvictionPolicy<K,V> setMaxSize(int max) Sets maximum allowed size of cache before entry will start getting evicted.- Overrides:
- setMaxSizein class- AbstractEvictionPolicy<K,V>
- Parameters:
- max- Maximum allowed size of cache before entry will start getting evicted.
- Returns:
- thisfor chaining.
 
 - 
setBatchSizepublic SortedEvictionPolicy<K,V> setBatchSize(int batchSize) Sets batch size.- Overrides:
- setBatchSizein class- AbstractEvictionPolicy<K,V>
- Parameters:
- batchSize- Batch size.
- Returns:
- thisfor chaining.
 
 - 
queuepublic Collection<EvictableEntry<K,V>> queue() Gets read-only view of backed queue in proper order.- Returns:
- Read-only view of backed queue.
 
 - 
touchprotected boolean touch(EvictableEntry<K,V> entry) - Specified by:
- touchin class- AbstractEvictionPolicy<K,V>
- Parameters:
- entry- Entry to touch.
- Returns:
- Trueif backed queue has been changed by this call.
 
 - 
getCurrentSizepublic int getCurrentSize() - Specified by:
- getCurrentSizein class- AbstractEvictionPolicy<K,V>
- Returns:
- Size of the container with trackable entries.
 
 - 
shrink0protected int shrink0() Tries to remove one item from queue.- Specified by:
- shrink0in class- AbstractEvictionPolicy<K,V>
- Returns:
- number of bytes that was free. -1if queue is empty.
 
 - 
getMBeanpublic Object getMBean() - Specified by:
- getMBeanin interface- IgniteMBeanAware
- Returns:
- MBean for this object.
 
 - 
writeExternalpublic void writeExternal(ObjectOutput out) throws IOException - Specified by:
- writeExternalin interface- Externalizable
- Overrides:
- writeExternalin class- AbstractEvictionPolicy<K,V>
- Throws:
- IOException
 
 - 
readExternalpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException - Specified by:
- readExternalin interface- Externalizable
- Overrides:
- readExternalin class- AbstractEvictionPolicy<K,V>
- Throws:
- IOException
- ClassNotFoundException
 
 - 
removeMetaprotected boolean removeMeta(Object meta) Removes holder from backed queue and marks holder as removed.- Specified by:
- removeMetain class- AbstractEvictionPolicy<K,V>
- Parameters:
- meta- Holder.
- Returns:
- Trueif meta was successfully removed from the container.
 
 
- 
 
-