public class SortedEvictionPolicy<K,V> extends Object implements EvictionPolicy<K,V>, SortedEvictionPolicyMBean, Externalizable
The eviction starts in the following cases:
batchSize elements greater than the maximum size.maxMemSize == 0).
batchSize elements will be evicted in this case. The default batchSize value is 1.
Entries comparison based on Comparator instance if provided.
Default Comparator behaviour is use cache entries keys for comparison that imposes a requirement for keys
to implement Comparable interface.
User defined comparator should implement Serializable interface.
| Constructor and Description |
|---|
SortedEvictionPolicy()
Constructs sorted eviction policy with all defaults.
|
SortedEvictionPolicy(Comparator<EvictableEntry<K,V>> comp)
Constructs sorted eviction policy with given maximum size and given entry comparator.
|
SortedEvictionPolicy(int max)
Constructs sorted eviction policy with maximum size.
|
SortedEvictionPolicy(int max,
Comparator<EvictableEntry<K,V>> comp)
Constructs sorted eviction policy with given maximum size and given entry comparator.
|
SortedEvictionPolicy(int max,
int batchSize,
Comparator<EvictableEntry<K,V>> comp)
Constructs sorted eviction policy with given maximum size, eviction batch size and entries comparator.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getBatchSize()
Gets batch size.
|
long |
getCurrentMemorySize()
Gets current sorted entries queue size in bytes.
|
int |
getCurrentSize()
Gets current size.
|
long |
getMaxMemorySize()
Gets maximum allowed cache size in bytes.
|
int |
getMaxSize()
Gets maximum allowed size of cache before entry will start getting evicted.
|
void |
onEntryAccessed(boolean rmv,
EvictableEntry<K,V> entry)
Callback for whenever entry is accessed.
|
Collection<EvictableEntry<K,V>> |
queue()
Gets read-only view of backed queue in proper order.
|
void |
readExternal(ObjectInput in) |
void |
setBatchSize(int batchSize)
Sets batch size.
|
void |
setMaxMemorySize(long maxMemSize)
Sets maximum allowed cache size in bytes.
|
void |
setMaxSize(int max)
Sets maximum allowed size of cache before entry will start getting evicted.
|
void |
writeExternal(ObjectOutput out) |
public SortedEvictionPolicy()
public SortedEvictionPolicy(int max)
max - Maximum allowed size of cache before entry will start getting evicted.public SortedEvictionPolicy(int max,
@Nullable
Comparator<EvictableEntry<K,V>> comp)
max - Maximum allowed size of cache before entry will start getting evicted.comp - Entries comparator.public SortedEvictionPolicy(int max,
int batchSize,
@Nullable
Comparator<EvictableEntry<K,V>> comp)
max - Maximum allowed size of cache before entry will start getting evicted.batchSize - Batch size.comp - Entries comparator.public SortedEvictionPolicy(@Nullable
Comparator<EvictableEntry<K,V>> comp)
comp - Entries comparator.public int getMaxSize()
getMaxSize in interface SortedEvictionPolicyMBeanpublic void setMaxSize(int max)
setMaxSize in interface SortedEvictionPolicyMBeanmax - Maximum allowed size of cache before entry will start getting evicted.public int getBatchSize()
getBatchSize in interface SortedEvictionPolicyMBeanpublic void setBatchSize(int batchSize)
setBatchSize in interface SortedEvictionPolicyMBeanbatchSize - Batch size.public int getCurrentSize()
getCurrentSize in interface SortedEvictionPolicyMBeanpublic long getMaxMemorySize()
getMaxMemorySize in interface SortedEvictionPolicyMBeanpublic void setMaxMemorySize(long maxMemSize)
setMaxMemorySize in interface SortedEvictionPolicyMBeanpublic long getCurrentMemorySize()
getCurrentMemorySize in interface SortedEvictionPolicyMBeanpublic Collection<EvictableEntry<K,V>> queue()
public void onEntryAccessed(boolean rmv,
EvictableEntry<K,V> entry)
onEntryAccessed in interface EvictionPolicy<K,V>rmv - True if entry has been removed, false otherwise.entry - Accessed entry.public void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundException
Follow @ApacheIgnite
Ignite Fabric : ver. 1.5.11 Release Date : April 8 2016