public abstract class EvictionAttributes extends Object implements DataSerializable
Attributes that describe how a Region
's size is managed through an eviction controller. Eviction
controllers are defined by an EvictionAlgorithm
and a EvictionAction
. Once a Region
is created with an eviction controller, it can
not be removed, however it can be changed through an EvictionAttributesMutator
.
AttributesFactory.setEvictionAttributes(EvictionAttributes)
,
AttributesMutator
,
Serialized FormDataSerializable.Replaceable
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_ENTRIES_MAXIMUM
The default maximum for entry LRU.
|
static int |
DEFAULT_MEMORY_MAXIMUM
The default maximum for memory LRU.
|
Constructor and Description |
---|
EvictionAttributes() |
Modifier and Type | Method and Description |
---|---|
static EvictionAttributes |
createLIFOEntryAttributes(int maximumEntries,
EvictionAction evictionAction) |
static EvictionAttributes |
createLIFOMemoryAttributes(int maximumMegabytes,
EvictionAction evictionAction) |
static EvictionAttributes |
createLRUEntryAttributes()
|
static EvictionAttributes |
createLRUEntryAttributes(EvictionAction evictionAction)
|
static EvictionAttributes |
createLRUEntryAttributes(int maximumEntries)
|
static EvictionAttributes |
createLRUEntryAttributes(int maximumEntries,
EvictionAction evictionAction)
Creates and returns entry LRU eviction attributes
with given
evictionAction
and given maximumEntries . |
static EvictionAttributes |
createLRUHeapAttributes()
|
static EvictionAttributes |
createLRUHeapAttributes(ObjectSizer sizer)
|
static EvictionAttributes |
createLRUHeapAttributes(ObjectSizer sizer,
EvictionAction evictionAction)
|
static EvictionAttributes |
createLRUMemoryAttributes()
Creates and returns memory LRU eviction attributes
with default action,
default sizer,
and default maximum.
|
static EvictionAttributes |
createLRUMemoryAttributes(int maximumMegabytes)
Creates and returns memory LRU eviction attributes
with default action,
default sizer,
and given
maximumMegabytes . |
static EvictionAttributes |
createLRUMemoryAttributes(int maximumMegabytes,
ObjectSizer sizer)
Creates and returns memory LRU eviction attributes
with default action,
given
sizer ,
and given maximumMegabytes . |
static EvictionAttributes |
createLRUMemoryAttributes(int maximumMegabytes,
ObjectSizer sizer,
EvictionAction evictionAction)
Creates and returns memory LRU eviction attributes
with the given
evictionAction ,
given sizer ,
and given maximumMegabytes . |
static EvictionAttributes |
createLRUMemoryAttributes(ObjectSizer sizer)
Creates and returns memory LRU eviction attributes
with default action,
given
sizer ,
and default maximum. |
static EvictionAttributes |
createLRUMemoryAttributes(ObjectSizer sizer,
EvictionAction evictionAction)
Creates and returns memory LRU eviction attributes
with given
evictionAction ,
given sizer ,
and default maximum. |
boolean |
equals(Object obj) |
abstract EvictionAction |
getAction() |
abstract EvictionAlgorithm |
getAlgorithm()
The algorithm is used to identify entries that will be evicted.
|
abstract int |
getMaximum()
The unit of this value is determined by the definition of the
EvictionAlgorithm set by one of the creation
methods e.g. |
abstract ObjectSizer |
getObjectSizer()
An
ObjectSizer is used by the EvictionAlgorithm.LRU_MEMORY algorithm to measure the size of each
Entry as it is entered into a Region. |
int |
hashCode() |
String |
toString() |
fromData, toData
public static final int DEFAULT_ENTRIES_MAXIMUM
900
entries.public static final int DEFAULT_MEMORY_MAXIMUM
10
megabytes.public static EvictionAttributes createLRUEntryAttributes()
EvictionAttributes
cause regions to evict the least recently used (LRU)
entry once the region reaches a maximum capacity. The entry is either locally destroyed or its value overflows
to disk when evicted.
This is not supported when replication is enabled.
For a region with DataPolicy.PARTITION
, the EvictionAttribute maximum
, indicates the number of
entries allowed in the region, collectively for its primary buckets and redundant copies for this JVM. Once there
are maximum
entries in the region's primary buckets and redundant copies for this JVM, the least
recently used entry will be evicted from the bucket in which the subsequent put takes place.
If you are using a cache.xml
file to create a Cache Region declaratively, you can include the
following to configure a region for eviction
<region-attributes> <eviction-attributes> <lru-entry-count maximum="900" action="local-destroy"/> </eviction-attributes> </region-attributes>
public static EvictionAttributes createLRUEntryAttributes(int maximumEntries)
maximumEntries
- the number of entries to keep in the RegionmaximumEntries
createLRUEntryAttributes()
public static EvictionAttributes createLRUEntryAttributes(EvictionAction evictionAction)
evictionAction
- the action to perform when evicting an entryevictionAction
createLRUEntryAttributes()
public static EvictionAttributes createLRUEntryAttributes(int maximumEntries, EvictionAction evictionAction)
evictionAction
and given maximumEntries
.maximumEntries
- the number of entries to keep in the RegionevictionAction
- the action to perform when evicting an entryevictionAction
and given maximumEntries
createLRUEntryAttributes()
public static EvictionAttributes createLRUHeapAttributes()
Region.Entry
when heap usage exceeds the
ResourceManager
eviction heap threshold. If the eviction heap threshold is exceeded the least recently used
Region.Entry
s are evicted.
With other LRU-based eviction controllers, only cache actions (such as puts
and
gets
) cause the LRU entry to be evicted. However, with heap LRU, because the JVM's heap may be effected
by more than just the GemFire cache operations, a daemon thread will perform the eviction if no operations are being done
on the region.
The eviction attribute's sizer is used to estimate how much the heap will be reduced by an
eviction.
When using Heap LRU, the JVM must be launched with the -Xmx
and -Xms
switches set to the
same values. Many virtual machine implementations have additional JVM switches to control the behavior of the
garbage collector. We suggest that you investigate tuning the garbage collector when using this type of eviction
controller. A collector that frequently collects is needed to keep our heap usage up to date. In particular, on
the Sun HotSpot JVM, the
-XX:+UseConcMarkSweepGC
flag needs to be set, and -XX:CMSInitiatingOccupancyFraction=N
should be set with N being a percentage that is less than the ResourceManager
eviction heap threshold.
The JRockit JVM has similar flags, -Xgc:gencon
and -XXgcTrigger:N
, which are required if
using this LRU algorithm. Please Note: the JRockit gcTrigger flag is based on heap free, not heap in use like the
GemFire parameter. This means you need to set gcTrigger to 100-N. for example, if your eviction threshold is 30
percent, you will need to set gcTrigger to 70 percent.
On the IBM JVM, the flag to get a similar collector is -Xgcpolicy:gencon
, but there is no corollary to
the gcTrigger/CMSInitiatingOccupancyFraction flags, so when using this feature with an IBM JVM, the heap usage
statistics might lag the true memory usage of the JVM, and thresholds may need to be set sufficiently high that the
JVM will initiate GC before the thresholds are crossed.
If you are using a cache.xml
file to create a Cache Region declaratively, you can include the
following to create an LRU heap eviction controller:
<region-attributes> <eviction-attributes> <lru-heap-percentage action="local-destroy" </eviction-attributes> </region-attributes>
public static EvictionAttributes createLRUHeapAttributes(ObjectSizer sizer)
sizer
- the sizer implementation used to determine the size of each entry in this regionsizer
createLRUHeapAttributes()
public static EvictionAttributes createLRUHeapAttributes(ObjectSizer sizer, EvictionAction evictionAction)
sizer
- the sizer implementation used to determine the size of each entry in this regionevictionAction
- the way in which entries should be evictedevictionAction
and given sizer
createLRUHeapAttributes()
public static EvictionAttributes createLRUMemoryAttributes()
ObjectSizer
.
For a region with DataPolicy.PARTITION
, the EvictionAttribute maximum
, is always equal to
" local max memory "
specified for the PartitionAttributes
. It signifies the amount of memory allowed in the region, collectively for its primary buckets
and redundant copies for this JVM. It can be different for the same region in different JVMs.
If you are using a cache.xml
file to create a Cache Region declaratively, you can include the
following to create an LRU memory eviction controller:
<region-attributes> <eviction-attributes> <lru-memory-size maximum="10" action="local-destroy"> <class-name>com.foo.MySizer</class-name> <parameter name="name"> <string>Super Sizer</string> </parameter> </lru-memory-size> </eviction-attributes> </region-attributes>
public static EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes)
maximumMegabytes
.
For a region with DataPolicy.PARTITION
, even if maximumMegabytes are supplied, the EvictionAttribute
maximum
, is always set to " local max memory
"
specified for the PartitionAttributes
.
maximumMegabytes
- the maximum allowed bytes in the RegionmaximumMegabytes
createLRUMemoryAttributes()
public static EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes, ObjectSizer sizer)
sizer
,
and given maximumMegabytes
.
For a region with DataPolicy.PARTITION
, even if maximumMegabytes are supplied, the EvictionAttribute
maximum
, is always set to " local max
memory "
specified for the PartitionAttributes
.
maximumMegabytes
- the maximum allowed bytes in the Regionsizer
- calculates the size in bytes of the key and value for an entry.sizer
,
and given maximumMegabytes
createLRUMemoryAttributes()
public static EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes, ObjectSizer sizer, EvictionAction evictionAction)
evictionAction
,
given sizer
,
and given maximumMegabytes
.
For a region with DataPolicy.PARTITION
, even if maximumMegabytes are supplied, the EvictionAttribute
maximum
, is always set to " local max
memory "
specified for the PartitionAttributes
.
maximumMegabytes
- the maximum allowed bytes in the Regionsizer
- calculates the size in bytes of the key and value for an entry.evictionAction
- the action to take when the maximum has been reached.evictionAction
,
given sizer
,
and given maximumMegabytes
createLRUMemoryAttributes()
public static EvictionAttributes createLRUMemoryAttributes(ObjectSizer sizer)
sizer
,
and default maximum.
For a region with DataPolicy.PARTITION
, even if maximumMegabytes are supplied, the EvictionAttribute
maximum
, is always set to " local max
memory "
specified for the PartitionAttributes
.
sizer
- calculates the size in bytes of the key and value for an entry.sizer
,
and default maximumcreateLRUMemoryAttributes()
public static EvictionAttributes createLRUMemoryAttributes(ObjectSizer sizer, EvictionAction evictionAction)
evictionAction
,
given sizer
,
and default maximum.
For a region with DataPolicy.PARTITION
, even if maximumMegabytes are supplied, the EvictionAttribute
maximum
, is always set to " local max
memory "
specified for the PartitionAttributes
.
sizer
- calculates the size in bytes of the key and value for an entry.evictionAction
- the action to take when the maximum has been reached.evictionAction
,
given sizer
,
and default maximumcreateLRUMemoryAttributes()
public abstract ObjectSizer getObjectSizer()
ObjectSizer
is used by the EvictionAlgorithm.LRU_MEMORY
algorithm to measure the size of each
Entry as it is entered into a Region. A default implementation is provided, see createLRUMemoryAttributes()
for more.
An ObjectSizer
is used by EvictionAlgorithm.LRU_HEAP
to estimate how much heap will be saved
when evicting a region entry.EvictionAlgorithm.LRU_MEMORY
or EvictionAlgorithm.LRU_HEAP
, for all other algorithms null is returned.public abstract EvictionAlgorithm getAlgorithm()
public abstract int getMaximum()
EvictionAlgorithm
set by one of the creation
methods e.g. createLRUEntryAttributes()
EvictionAlgorithm
which determines when the EvictionAction
is
performed.public abstract EvictionAction getAction()
EvictionAlgorithm
takes when the maximum value is reached.public static EvictionAttributes createLIFOEntryAttributes(int maximumEntries, EvictionAction evictionAction)
public static EvictionAttributes createLIFOMemoryAttributes(int maximumMegabytes, EvictionAction evictionAction)
Copyright © 1997-2017 Pivotal Software, Inc. All rights reserved.