Gemfire JavaDocs_test
Class EvictionAttributes
- java.lang.Object
-
- org.apache.geode.cache.EvictionAttributes
-
public abstract class EvictionAttributes extends java.lang.Object
Attributes that describe how a
Region
's size is managed through an eviction controller. Eviction controllers are defined by anEvictionAlgorithm
and aEvictionAction
. Once aRegion
is created with an eviction controller, it can not be removed, however it can be changed through anEvictionAttributesMutator
.- Since:
- GemFire 5.0
- See Also:
AttributesFactory.setEvictionAttributes(EvictionAttributes)
,AttributesMutator
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_ENTRIES_MAXIMUM
The default maximum for entry LRU.static int
DEFAULT_MEMORY_MAXIMUM
The default maximum for memory LRU.
-
Constructor Summary
Constructors Constructor Description EvictionAttributes()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description RegionAttributesType.EvictionAttributes
convertToConfigEvictionAttributes()
Deprecated.use RegionAttributesType.EvictionAttributes.generatestatic EvictionAttributes
createLIFOEntryAttributes(int maximumEntries, EvictionAction evictionAction)
Deprecated.For internal use only.static EvictionAttributes
createLIFOMemoryAttributes(int maximumMegabytes, EvictionAction evictionAction)
Deprecated.For internal use only.static EvictionAttributes
createLRUEntryAttributes()
static EvictionAttributes
createLRUEntryAttributes(int maximumEntries)
static EvictionAttributes
createLRUEntryAttributes(int maximumEntries, EvictionAction evictionAction)
Creates and returns entry LRU eviction attributes with givenevictionAction
and givenmaximumEntries
.static EvictionAttributes
createLRUEntryAttributes(EvictionAction evictionAction)
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 givenmaximumMegabytes
.static EvictionAttributes
createLRUMemoryAttributes(int maximumMegabytes, ObjectSizer sizer)
Creates and returns memory LRU eviction attributes with default action, givensizer
, and givenmaximumMegabytes
.static EvictionAttributes
createLRUMemoryAttributes(int maximumMegabytes, ObjectSizer sizer, EvictionAction evictionAction)
Creates and returns memory LRU eviction attributes with the givenevictionAction
, givensizer
, and givenmaximumMegabytes
.static EvictionAttributes
createLRUMemoryAttributes(ObjectSizer sizer)
Creates and returns memory LRU eviction attributes with default action, givensizer
, and default maximum.static EvictionAttributes
createLRUMemoryAttributes(ObjectSizer sizer, EvictionAction evictionAction)
Creates and returns memory LRU eviction attributes with givenevictionAction
, givensizer
, and default maximum.boolean
equals(java.lang.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 theEvictionAlgorithm
set by one of the creation methods e.g.abstract ObjectSizer
getObjectSizer()
AnObjectSizer
is used by theEvictionAlgorithm.LRU_MEMORY
algorithm to measure the size of each Entry as it is entered into a Region.int
hashCode()
boolean
isNoEviction()
java.lang.String
toString()
-
-
-
Field Detail
-
DEFAULT_ENTRIES_MAXIMUM
public static final int DEFAULT_ENTRIES_MAXIMUM
The default maximum for entry LRU. Currently900
entries.- See Also:
- Constant Field Values
-
DEFAULT_MEMORY_MAXIMUM
public static final int DEFAULT_MEMORY_MAXIMUM
The default maximum for memory LRU. Currently10
megabytes.- See Also:
- Constant Field Values
-
-
Method Detail
-
createLRUEntryAttributes
public static EvictionAttributes createLRUEntryAttributes()
Creates and returns entry LRU eviction attributes with default action and default maximum.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 EvictionAttributemaximum
, indicates the number of entries allowed in the region, collectively for its primary buckets and redundant copies for this JVM. Once there aremaximum
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>
-
createLRUEntryAttributes
public static EvictionAttributes createLRUEntryAttributes(int maximumEntries)
- Parameters:
maximumEntries
- the number of entries to keep in the Region- Returns:
- entry LRU eviction attributes with default
action and
maximumEntries
- See Also:
createLRUEntryAttributes()
-
createLRUEntryAttributes
public static EvictionAttributes createLRUEntryAttributes(EvictionAction evictionAction)
- Parameters:
evictionAction
- the action to perform when evicting an entry- Returns:
- entry LRU eviction attributes with default
maximum and given
evictionAction
- Since:
- GemFire 8.1
- See Also:
createLRUEntryAttributes()
-
createLRUEntryAttributes
public static EvictionAttributes createLRUEntryAttributes(int maximumEntries, EvictionAction evictionAction)
Creates and returns entry LRU eviction attributes with givenevictionAction
and givenmaximumEntries
.- Parameters:
maximumEntries
- the number of entries to keep in the RegionevictionAction
- the action to perform when evicting an entry- Returns:
- entry LRU eviction attributes with given
evictionAction
and givenmaximumEntries
- See Also:
createLRUEntryAttributes()
-
createLRUHeapAttributes
public static EvictionAttributes createLRUHeapAttributes()
Creates and returns heap LRU eviction attributes with default action and default sizer.Heap LRU EvictionAttributes evict the least recently used
Region.Entry
when heap usage exceeds theResourceManager
eviction heap threshold. If the eviction heap threshold is exceeded the least recently usedRegion.Entry
s are evicted.With other LRU-based eviction controllers, only cache actions (such as
puts
andgets
) 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, before Java 14, the-XX:+UseConcMarkSweepGC
flag needs to be set, and-XX:CMSInitiatingOccupancyFraction=N
should be set with N being a percentage that is less than theResourceManager
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>
-
createLRUHeapAttributes
public static EvictionAttributes createLRUHeapAttributes(ObjectSizer sizer)
- Parameters:
sizer
- the sizer implementation used to determine the size of each entry in this region- Returns:
- heap LRU eviction attributes with default
action and the given
sizer
- See Also:
createLRUHeapAttributes()
-
createLRUHeapAttributes
public static EvictionAttributes createLRUHeapAttributes(ObjectSizer sizer, EvictionAction evictionAction)
- Parameters:
sizer
- the sizer implementation used to determine the size of each entry in this regionevictionAction
- the way in which entries should be evicted- Returns:
- heap LRU eviction attributes with the given
evictionAction
and givensizer
- See Also:
createLRUHeapAttributes()
-
createLRUMemoryAttributes
public static EvictionAttributes createLRUMemoryAttributes()
Creates and returns memory LRU eviction attributes with default action, default sizer, and default maximum.Creates EvictionAttributes for an eviction controller that will remove the least recently used (LRU) entry from a region once the region reaches a certain byte capacity. Capacity is determined by monitoring the size of entries added and evicted. Capacity is specified in terms of megabytes. GemFire uses an efficient algorithm to determine the amount of space a region entry occupies in the JVM. However, this algorithm may not yield optimal results for all kinds of data. The user may provide their own algorithm for determining the size of objects by implementing an
ObjectSizer
.For a region with
DataPolicy.PARTITION
, the EvictionAttributemaximum
, is always equal to" local max memory "
specified for thePartitionAttributes
. 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>
- Returns:
- memory LRU eviction attributes with default action, default sizer, and default maximum
-
createLRUMemoryAttributes
public static EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes)
Creates and returns memory LRU eviction attributes with default action, default sizer, and givenmaximumMegabytes
.For a region with
DataPolicy.PARTITION
, even if maximumMegabytes are supplied, the EvictionAttributemaximum
, is always set to" local max memory "
specified for thePartitionAttributes
.- Parameters:
maximumMegabytes
- the maximum allowed bytes in the Region- Returns:
- memory LRU eviction attributes with default
action, default
sizer, and given
maximumMegabytes
- See Also:
createLRUMemoryAttributes()
-
createLRUMemoryAttributes
public static EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes, ObjectSizer sizer)
Creates and returns memory LRU eviction attributes with default action, givensizer
, and givenmaximumMegabytes
.For a region with
DataPolicy.PARTITION
, even if maximumMegabytes are supplied, the EvictionAttributemaximum
, is always set to" local max memory "
specified for thePartitionAttributes
.- Parameters:
maximumMegabytes
- the maximum allowed bytes in the Regionsizer
- calculates the size in bytes of the key and value for an entry.- Returns:
- memory LRU eviction attributes with default
action, given
sizer
, and givenmaximumMegabytes
- See Also:
createLRUMemoryAttributes()
-
createLRUMemoryAttributes
public static EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes, ObjectSizer sizer, EvictionAction evictionAction)
Creates and returns memory LRU eviction attributes with the givenevictionAction
, givensizer
, and givenmaximumMegabytes
.For a region with
DataPolicy.PARTITION
, even if maximumMegabytes are supplied, the EvictionAttributemaximum
, is always set to" local max memory "
specified for thePartitionAttributes
.- Parameters:
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.- Returns:
- memory LRU eviction attributes with the given
evictionAction
, givensizer
, and givenmaximumMegabytes
- See Also:
createLRUMemoryAttributes()
-
createLRUMemoryAttributes
public static EvictionAttributes createLRUMemoryAttributes(ObjectSizer sizer)
Creates and returns memory LRU eviction attributes with default action, givensizer
, and default maximum.For a region with
DataPolicy.PARTITION
, even if maximumMegabytes are supplied, the EvictionAttributemaximum
, is always set to" local max memory "
specified for thePartitionAttributes
.- Parameters:
sizer
- calculates the size in bytes of the key and value for an entry.- Returns:
- memory LRU eviction attributes with default
action, given
sizer
, and default maximum - Since:
- GemFire 6.0
- See Also:
createLRUMemoryAttributes()
-
createLRUMemoryAttributes
public static EvictionAttributes createLRUMemoryAttributes(ObjectSizer sizer, EvictionAction evictionAction)
Creates and returns memory LRU eviction attributes with givenevictionAction
, givensizer
, and default maximum.For a region with
DataPolicy.PARTITION
, even if maximumMegabytes are supplied, the EvictionAttributemaximum
, is always set to" local max memory "
specified for thePartitionAttributes
.- Parameters:
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.- Returns:
- memory LRU eviction attributes with given
evictionAction
, givensizer
, and default maximum - Since:
- GemFire 6.0
- See Also:
createLRUMemoryAttributes()
-
getObjectSizer
public abstract ObjectSizer getObjectSizer()
AnObjectSizer
is used by theEvictionAlgorithm.LRU_MEMORY
algorithm to measure the size of each Entry as it is entered into a Region. A default implementation is provided, seecreateLRUMemoryAttributes()
for more. AnObjectSizer
is used byEvictionAlgorithm.LRU_HEAP
to estimate how much heap will be saved when evicting a region entry.- Returns:
- the sizer used by
EvictionAlgorithm.LRU_MEMORY
orEvictionAlgorithm.LRU_HEAP
, for all other algorithms null is returned.
-
getAlgorithm
public abstract EvictionAlgorithm getAlgorithm()
The algorithm is used to identify entries that will be evicted.- Returns:
- a non-null EvictionAlgorithm instance reflecting the configured value or NONE when no eviction controller has been configured.
-
getMaximum
public abstract int getMaximum()
The unit of this value is determined by the definition of theEvictionAlgorithm
set by one of the creation methods e.g.createLRUEntryAttributes()
.- If the algorithm is LRU_ENTRY then the unit is entries.
- If the algorithm is LRU_MEMORY then the unit is megabytes.
- If the algorithm is LRU_HEAP then the unit is undefined and this method always returns zero. Note, in geode 1.4 and earlier, this method would throw UnsupportedOperationException for LRU_HEAP.
- Returns:
- maximum value used by the
EvictionAlgorithm
which determines when theEvictionAction
is performed.
-
getAction
public abstract EvictionAction getAction()
- Returns:
- action that the
EvictionAlgorithm
takes when the maximum value is reached.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
createLIFOEntryAttributes
@Deprecated public static EvictionAttributes createLIFOEntryAttributes(int maximumEntries, EvictionAction evictionAction)
Deprecated.For internal use only.- Parameters:
maximumEntries
- the number of entries to keep in the RegionevictionAction
- the action to perform when evicting an entry- Returns:
- an EvictionAttributes for the LIFOCapacityController
- Since:
- GemFire 5.7
-
createLIFOMemoryAttributes
@Deprecated public static EvictionAttributes createLIFOMemoryAttributes(int maximumMegabytes, EvictionAction evictionAction)
Deprecated.For internal use only.- Parameters:
maximumMegabytes
- the maximum allowed bytes in the RegionevictionAction
- the action to perform when evicting an entry- Returns:
- an EvictionAttributes for the MemLIFOCapacityController
- Since:
- GemFire 5.7
-
convertToConfigEvictionAttributes
@Deprecated public RegionAttributesType.EvictionAttributes convertToConfigEvictionAttributes()
Deprecated.use RegionAttributesType.EvictionAttributes.generate- Returns:
- the EvictionAttrributes
-
isNoEviction
public boolean isNoEviction()
-
-