GemFire 5.5.1

com.gemstone.gemfire.cache
Class EvictionAttributes

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

public abstract class EvictionAttributes
extends Object
implements Serializable

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

Constructor Summary
EvictionAttributes()
           
 
Method Summary
static EvictionAttributes createLRUEntryAttributes()
           Convenience method to replace instantiation of an LRUCapacityController.
static EvictionAttributes createLRUEntryAttributes(int maximumEntries)
          Convenience method for LRUCapacityController
static EvictionAttributes createLRUEntryAttributes(int maximumEntries, EvictionAction evictionAction)
          Convenience method for LRUCapacityController
static EvictionAttributes createLRUHeapAttributes()
           Convenience method to replace the HeapLRUCapacityController Creates EvictionAttributes for an eviction controller which removes Entries based on the percentage of Java VM heap memory that is currently being used.
static EvictionAttributes createLRUHeapAttributes(int heapPercentage)
          Convenience method for HeapLRUCapacityController
static EvictionAttributes createLRUHeapAttributes(int heapPercentage, int evictorInterval, EvictionAction evictionAction)
          Convenience method for HeapLRUCapacityController
static EvictionAttributes createLRUMemoryAttributes()
           Convenience method for MemLRUCapacityController 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)
          Convenience method for eviction of MemLRUCapacityController
static EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes, ObjectSizer sizer)
          Convenience method for MemLRUCapacityController
static EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes, ObjectSizer sizer, EvictionAction evictionAction)
          Convenience method for MemLRUCapacityController
 boolean equals(Object obj)
           
abstract  EvictionAction getAction()
           
abstract  EvictionAlgorithm getAlgorithm()
          The algorithm is used to identify entries that will be evicited.
abstract  long getInterval()
          The interval is used by the EvictionAlgorithm.LRU_HEAP algorithm to determine when to check the JVM heap.
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
 

Constructor Detail

EvictionAttributes

public EvictionAttributes()
Method Detail

createLRUEntryAttributes

public static final EvictionAttributes createLRUEntryAttributes()

Convenience method to replace instantiation of an LRUCapacityController.

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 locally destroyed when evicted by the eviction controller.

This is not supported when mirroring is enabled.

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:
an EvictionAttributes for the previously depricated LRUCapacityController

createLRUEntryAttributes

public static final EvictionAttributes createLRUEntryAttributes(int maximumEntries)
Convenience method for LRUCapacityController

Returns:
an EvictionAttributes for the previously deprecated LRUCapacityController
See Also:
createLRUEntryAttributes()

createLRUEntryAttributes

public static final EvictionAttributes createLRUEntryAttributes(int maximumEntries,
                                                                EvictionAction evictionAction)
Convenience method for LRUCapacityController

Returns:
an EvictionAttributes for the previously deprecated LRUCapacityController
See Also:
createLRUEntryAttributes()

createLRUHeapAttributes

public static final EvictionAttributes createLRUHeapAttributes()

Convenience method to replace the HeapLRUCapacityController

Creates EvictionAttributes for an eviction controller which removes Entries based on the percentage of Java VM heap memory that is currently being used. If the percentage of Java VM heap memory in use exceeds the given percentage, then the least recently used entry of the region is 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, a daemon thread (the "evictor thread") periodically, based on the evictorInterval, evicts the LRU entry (and write pending data to disk to free up heap space) if the percentage of VM heap being used exceeds the threshold.

GemStone has found that a heap based eviction controller has the most effect on a VM that is lauched with both the -Xmx and -Xms switches used. 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. In particular, we have found improved behavior when running with Sun's HotSpot VM, the -XX:+UseConcMarkSweepGC and -XX:+UseParNewGC options. 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 maximum="90" action="overflow-to-disk" interval="200"/>
            </eviction-attributes>
         </region-attributes>
 

Returns:
an EvictionAttributes that mimics the the previously deprecated HeapLRUCapacityController

createLRUHeapAttributes

public static final EvictionAttributes createLRUHeapAttributes(int heapPercentage)
Convenience method for HeapLRUCapacityController

Returns:
an EvictionAttributes for the previously deprecated HeapLRUCapacityController
See Also:
createLRUHeapAttributes()

createLRUHeapAttributes

public static final EvictionAttributes createLRUHeapAttributes(int heapPercentage,
                                                               int evictorInterval,
                                                               EvictionAction evictionAction)
Convenience method for HeapLRUCapacityController

Returns:
an EvictionAttributes for the previously deprecated HeapLRUCapacityController
See Also:
createLRUHeapAttributes()

createLRUMemoryAttributes

public static final EvictionAttributes createLRUMemoryAttributes()

Convenience method for MemLRUCapacityController

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 effcient 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.

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:
an EvictionAttributes that mimics the previously deprecated MemLRUCapacityController

createLRUMemoryAttributes

public static final EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes)
Convenience method for eviction of MemLRUCapacityController

Returns:
an EvictionAttributes for the previously deprecated MemLRUCapacityController
See Also:
createLRUMemoryAttributes()

createLRUMemoryAttributes

public static final EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes,
                                                                 ObjectSizer sizer)
Convenience method for MemLRUCapacityController

Returns:
an EvictionAttributes for the previously deprecated MemLRUCapacityController
See Also:
createLRUMemoryAttributes()

createLRUMemoryAttributes

public static final EvictionAttributes createLRUMemoryAttributes(int maximumMegabytes,
                                                                 ObjectSizer sizer,
                                                                 EvictionAction evictionAction)
Convenience method for MemLRUCapacityController

Returns:
an EvictionAttributes for the previously deprecated MemLRUCapacityController
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.

getInterval

public abstract long getInterval()
The interval is used by the EvictionAlgorithm.LRU_HEAP algorithm to determine when to check the JVM heap.

Returns:
the interval in milli-seconds, defaults to zero if any other EvictionAlgorithm than EvictionAlgorithm.LRU_HEAP is used.

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

GemFire 5.5.1

Copyright © 2002-2008 GemStone Systems, Inc. All Rights Reserved.