public class FifoEvictionPolicy<K,V> extends Object implements EvictionPolicy<K,V>, FifoEvictionPolicyMBean, Externalizable
First In First Out (FIFO)
algorithm and supports batch eviction.
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
.
This implementation is very efficient since it does not create any additional
table-like data structures. The FIFO
ordering information is
maintained by attaching ordering metadata to cache entries.
Constructor and Description |
---|
FifoEvictionPolicy()
Constructs FIFO eviction policy with all defaults.
|
FifoEvictionPolicy(int max)
Constructs FIFO eviction policy with maximum size.
|
FifoEvictionPolicy(int max,
int batchSize)
Constructs FIFO eviction policy with maximum size and given batch size.
|
Modifier and Type | Method and Description |
---|---|
int |
getBatchSize()
Gets batch size.
|
long |
getCurrentMemorySize()
Gets current queue size in bytes.
|
int |
getCurrentSize()
Gets current queue 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 on internal
FIFO 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.
|
String |
toString() |
void |
writeExternal(ObjectOutput out) |
public FifoEvictionPolicy()
public FifoEvictionPolicy(int max)
max
- Maximum allowed size of cache before entry will start getting evicted.public FifoEvictionPolicy(int max, int batchSize)
max
- Maximum allowed size of cache before entry will start getting evicted.batchSize
- Batch size.public int getMaxSize()
getMaxSize
in interface FifoEvictionPolicyMBean
public void setMaxSize(int max)
setMaxSize
in interface FifoEvictionPolicyMBean
max
- Maximum allowed size of cache before entry will start getting evicted.public int getBatchSize()
getBatchSize
in interface FifoEvictionPolicyMBean
public void setBatchSize(int batchSize)
setBatchSize
in interface FifoEvictionPolicyMBean
batchSize
- Batch size.public int getCurrentSize()
getCurrentSize
in interface FifoEvictionPolicyMBean
public long getMaxMemorySize()
getMaxMemorySize
in interface FifoEvictionPolicyMBean
public void setMaxMemorySize(long maxMemSize)
setMaxMemorySize
in interface FifoEvictionPolicyMBean
public long getCurrentMemorySize()
getCurrentMemorySize
in interface FifoEvictionPolicyMBean
public Collection<EvictableEntry<K,V>> queue()
FIFO
queue in proper order.'FIFO'
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 Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
Follow @ApacheIgnite
Ignite Fabric : ver. 1.2.0-incubating Release Date : June 16 2015