GemFire 6.6.1

com.gemstone.gemfire.cache
Class EvictionAttributes

java.lang.Object
  extended by com.gemstone.gemfire.cache.EvictionAttributes
All Implemented Interfaces:
DataSerializable, Serializable

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.

Since:
5.0
See Also:
AttributesFactory.setEvictionAttributes(EvictionAttributes), AttributesMutator, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.gemstone.gemfire.DataSerializable
DataSerializable.Replaceable
 
Constructor Summary
EvictionAttributes()
           
 
Method Summary
static EvictionAttributes createLIFOEntryAttributes(int maximumEntries, EvictionAction evictionAction)
           
static EvictionAttributes createLIFOMemoryAttributes(int maximumMegabytes, EvictionAction evictionAction)
           
static EvictionAttributes createLRUEntryAttributes()
           Creates the EvictionAttributes for an eviction controller that will remove the least recently used (LRU) entry from a region once the region reaches a certain capacity.
static EvictionAttributes createLRUEntryAttributes(int maximumEntries)
          Create attributes to remove the least recently used entries when the maximum number of entries exists in the Region
static EvictionAttributes createLRUEntryAttributes(int maximumEntries, EvictionAction evictionAction)
          Create attributes to perform the given action when the maximum number of entries exists in the Region
static EvictionAttributes createLRUHeapAttributes()
           Create EvictionAttributes for evicting the least recently used Region.Entry when heap usage exceeds the ResourceManager eviction heap threshold.
static EvictionAttributes createLRUHeapAttributes(ObjectSizer sizer)
          Creates EvictionAttributes for evicting the least recently used Region.Entry when heap usage exceeds the ResourceManager critical heap threshold.
static EvictionAttributes createLRUHeapAttributes(ObjectSizer sizer, EvictionAction evictionAction)
          Creates EvictionAttributes for evicting the least recently used Region.Entry when heap usage exceeds the ResourceManager critical heap threshold.
static EvictionAttributes createLRUMemoryAttributes()
          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.
static EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes)
          Creates EvictionAttributes for an eviction controller that will remove the least recently used (LRU) entry from a region once the region reaches the given maximum capacity.
static EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes, ObjectSizer sizer)
          Creates EvictionAttributes for an eviction controller that will remove the least recently used (LRU) entry from a region once the region reaches the given maximum capacity.
static EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes, ObjectSizer sizer, EvictionAction evictionAction)
          Creates EvictionAttributes for an eviction controller that will remove the least recently used (LRU) entry from a region once the region reaches the given maximum capacity.
static EvictionAttributes createLRUMemoryAttributes(ObjectSizer sizer)
          Creates EvictionAttributes for an eviction controller that will remove the least recently used (LRU) entry from a region once the region reaches the given maximum capacity.
static EvictionAttributes createLRUMemoryAttributes(ObjectSizer sizer, EvictionAction evictionAction)
          Creates EvictionAttributes for an eviction controller that will remove the least recently used (LRU) entry from a region once the region reaches the given maximum capacity.
 boolean equals(Object obj)
           
abstract  EvictionAction getAction()
           
abstract  EvictionAlgorithm getAlgorithm()
          The algorithm is used to identify entries that will be evicited.
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()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.gemstone.gemfire.DataSerializable
fromData, toData
 

Constructor Detail

EvictionAttributes

public EvictionAttributes()
Method Detail

createLRUEntryAttributes

public static final EvictionAttributes createLRUEntryAttributes()

Creates the EvictionAttributes for an eviction controller that will remove the least recently used (LRU) entry from a region once the region reaches a certain capacity. The entry is either locally destroyed or overflows to disk when evicted by the eviction controller.

This is not supported when replication is enabled.

For a region with DataPolicy.PARTITION, the EvictionAttribute maximum, indicates number of entries allowed in the region, collectively for its primary buckets and redundant copies for this VM. Once there are maximum entries in the region's primary buckets and redundant copies for this VM, 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 create an LRU entry eviction controller

         <region-attributes>
            <eviction-attributes>
               <lru-entry-count maximum="1000" action="overflow-to-disk"/>
            </eviction-attributes>
         </region-attributes>
 

Returns:
a new EvictionAttributes instance

createLRUEntryAttributes

public static final EvictionAttributes createLRUEntryAttributes(int maximumEntries)
Create attributes to remove the least recently used entries when the maximum number of entries exists in the Region

Parameters:
maximumEntries - the number of entries to keep in the Region
Returns:
a new EvictionAttributes instance
See Also:
createLRUEntryAttributes()

createLRUEntryAttributes

public static final EvictionAttributes createLRUEntryAttributes(int maximumEntries,
                                                                EvictionAction evictionAction)
Create attributes to perform the given action when the maximum number of entries exists in the Region

Returns:
a new EvictionAttributes
See Also:
createLRUEntryAttributes()

createLRUHeapAttributes

public static final EvictionAttributes createLRUHeapAttributes()

Create EvictionAttributes for evicting the least recently used Region.Entry when heap usage exceeds the ResourceManager eviction heap threshold. If the eviction heap threshold is exceeded the least recently used Region.Entrys are evicted.

With other LRU-based eviction controllers, only cache actions (such as puts and gets) cause the LRU entry to be evicted. However, because the JVM's heap may be effected by more than just the GemFire cache operations, a daemon thread will perform the eviction in the event threads are not using the Region.

When using Heap LRU, the VM must be launched with the -Xmx and -Xms switches set to the same values. Many virtual machine implementations have additional VM 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 VM, 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 VM 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 VM, 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 VM, the heap usage statistics might lag the true memory usage of the VM, and thresholds may need to be set sufficiently high that the VM 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="overflow-to-disk"
            </eviction-attributes>
         </region-attributes>
 
*

This is equivalent to calling createLRUHeapAttributes(ObjectSizer.DEFAULT)

Returns:
a new EvictionAttributes instance with EvictionAlgorithm.LRU_HEAP and the default heap percentage, eviction interval and eviction action.

createLRUHeapAttributes

public static final EvictionAttributes createLRUHeapAttributes(ObjectSizer sizer)
Creates EvictionAttributes for evicting the least recently used Region.Entry when heap usage exceeds the ResourceManager critical heap threshold.

Parameters:
sizer - the sizer implementation used to determine how many entries to remove
Returns:
a new instance of EvictionAttributes with EvictionAlgorithm.LRU_HEAP and the provided object sizer and eviction action.
See Also:
createLRUHeapAttributes()

createLRUHeapAttributes

public static final EvictionAttributes createLRUHeapAttributes(ObjectSizer sizer,
                                                               EvictionAction evictionAction)
Creates EvictionAttributes for evicting the least recently used Region.Entry when heap usage exceeds the ResourceManager critical heap threshold.

Parameters:
sizer - the sizer implementation used to determine how many entries to remove
evictionAction - the way in which entries should be evicted
Returns:
a new instance of EvictionAttributes with EvictionAlgorithm.LRU_HEAP and the provided object sizer and eviction action.
See Also:
createLRUHeapAttributes()

createLRUMemoryAttributes

public static final EvictionAttributes createLRUMemoryAttributes()
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 VM. However, this algorithm may not yield optimal results for all kinds of data. The user may provide his or her own algorithm for determining the size of objects by implementing an 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 VM. It can be different for the same region in different VMs.

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="1000" action="overflow-to-disk"> 
                  <class-name>com.foo.MySizer</class-name>
                  <parameter name="name">
                     <string>Super Sizer</string>
                  </parameter>
               </lru-memory-size>
            </eviction-attributes>
         </region-attributes>
 

Returns:
a new EvictionAttributes

createLRUMemoryAttributes

public static final EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes)
Creates EvictionAttributes for an eviction controller that will remove the least recently used (LRU) entry from a region once the region reaches the given maximum capacity.

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.

This is equivalent to calling createLRUMemoryAttributes(maximumMegabytes, ObjectSizer.DEFAULT)

Parameters:
maximumMegabytes - the maximum allowed bytes in the Region
Returns:
a new EvictionAttributes
See Also:
createLRUMemoryAttributes()

createLRUMemoryAttributes

public static final EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes,
                                                                 ObjectSizer sizer)
Creates EvictionAttributes for an eviction controller that will remove the least recently used (LRU) entry from a region once the region reaches the given maximum capacity.

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.

Parameters:
maximumMegabytes - the maximum allowed bytes in the Region
sizer - calculates the size in bytes of the key and value for an entry.
Returns:
a new EvictionAttributes
See Also:
createLRUMemoryAttributes()

createLRUMemoryAttributes

public static final EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes,
                                                                 ObjectSizer sizer,
                                                                 EvictionAction evictionAction)
Creates EvictionAttributes for an eviction controller that will remove the least recently used (LRU) entry from a region once the region reaches the given maximum capacity.

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.

Parameters:
maximumMegabytes - the maximum allowed bytes in the Region
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:
a new EvictionAttributes instance
See Also:
createLRUMemoryAttributes()

createLRUMemoryAttributes

public static final EvictionAttributes createLRUMemoryAttributes(ObjectSizer sizer)
Creates EvictionAttributes for an eviction controller that will remove the least recently used (LRU) entry from a region once the region reaches the given maximum capacity.

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.

Parameters:
sizer - calculates the size in bytes of the key and value for an entry.
Returns:
a new EvictionAttributes instance
Since:
6.0
See Also:
createLRUMemoryAttributes()

createLRUMemoryAttributes

public static final EvictionAttributes createLRUMemoryAttributes(ObjectSizer sizer,
                                                                 EvictionAction evictionAction)
Creates EvictionAttributes for an eviction controller that will remove the least recently used (LRU) entry from a region once the region reaches the given maximum capacity.

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.

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:
a new EvictionAttributes instance
Since:
6.0
See Also:
createLRUMemoryAttributes()

getObjectSizer

public 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. A default implementation is provided, see createLRUMemoryAttributes() for more.

Returns:
the sizer used by EvictionAlgorithm.LRU_MEMORY, for all algorithms null is returned.

getAlgorithm

public abstract EvictionAlgorithm getAlgorithm()
The algorithm is used to identify entries that will be evicited.

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 the EvictionAlgorithm set by one of the creation methods e.g. createLRUEntryAttributes()

Returns:
maximum value used by the EvictionAlgorithm which determines when the EvictionAction is performed.

getAction

public abstract EvictionAction getAction()
Returns:
action that the EvictionAlgorithm takes when the maximum value is reached.

equals

public final boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public final int hashCode()
Overrides:
hashCode in class Object

toString

public final String toString()
Overrides:
toString in class Object

createLIFOEntryAttributes

public static final EvictionAttributes createLIFOEntryAttributes(int maximumEntries,
                                                                 EvictionAction evictionAction)
Returns:
an EvictionAttributes for the LIFOCapacityController
Since:
5.7

createLIFOMemoryAttributes

public static final EvictionAttributes createLIFOMemoryAttributes(int maximumMegabytes,
                                                                  EvictionAction evictionAction)
Returns:
an EvictionAttributes for the MemLIFOCapacityController
Since:
5.7

GemFire 6.6.1

Copyright © 1997-2011 VMware, Inc. All rights reserved.