ResourceManager (Apache Geode 2.0.2)
Description: declaration: package: org.apache.geode.cache.control, interface: ResourceManager

Package org.apache.geode.cache.control

# Interface ResourceManager

public interface ResourceManager
Provides support for managing resources used by the local `Cache`.

Re-balancing the GemFire Cache resources can be accomplished using a `RebalanceOperation`:

     ResourceManager resourceManager = cache.getResourceManager();
     RebalanceOperation rebalanceOp = resourceManager.createRebalanceFactory().start();

Monitoring of heap utilization is enabled by setting the critical heap percentage using `setCriticalHeapPercentage(float)`.

Since:
  GemFire 6.0

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final float`
  `DEFAULT_CRITICAL_PERCENTAGE`
  The default percent of heap memory at which the VM is considered in a critical state.
  `static final float`
  `DEFAULT_EVICTION_PERCENTAGE`
  The default percent of heap memory at which the VM should begin evicting data.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `RebalanceFactory`
  `createRebalanceFactory()`
  Creates a factory for defining and starting `RebalanceOperations`.
  `RestoreRedundancyOperation`
  `createRestoreRedundancyOperation()`
  Creates a `RestoreRedundancyOperation` class for defining and starting restore redundancy operations and for determining the redundancy status of regions.
  `float`
  `getCriticalHeapPercentage()`
  Get the percentage of heap at or above which the cache is considered in danger of becoming inoperable.
  `float`
  `getCriticalOffHeapPercentage()`
  Get the percentage of off-heap at or above which the cache is considered in danger of becoming inoperable.
  `float`
  `getEvictionHeapPercentage()`
  Get the percentage of heap at or above which the eviction should begin on Regions configured for HeapLRU eviction.
  `float`
  `getEvictionOffHeapPercentage()`
  Get the percentage of off-heap at or above which the eviction should begin on Regions configured for HeapLRU eviction.
  `Set<RebalanceOperation>`
  `getRebalanceOperations()`
  Returns a set of all active `RebalanceOperations` that were started locally on this member.
  `Set<CompletableFuture<RestoreRedundancyResults>>`
  `getRestoreRedundancyFutures()`
  Returns a set of all active restore redundancy futures that were started locally on this member.
  `void`
  `setCriticalHeapPercentage(float heapPercentage)`
  Set the percentage of heap at or above which the cache is considered in danger of becoming inoperable due to garbage collection pauses or out of memory exceptions.
  `void`
  `setCriticalOffHeapPercentage(float offHeapPercentage)`
  Set the percentage of off-heap at or above which the cache is considered in danger of becoming inoperable due to out of memory exceptions.
  `void`
  `setEvictionHeapPercentage(float heapPercentage)`
  Set the percentage of heap at or above which the eviction should begin on Regions configured for HeapLRU eviction.
  `void`
  `setEvictionOffHeapPercentage(float offHeapPercentage)`
  Set the percentage of off-heap at or above which the eviction should begin on Regions configured for HeapLRU eviction.

- ## Field Details

  - ### DEFAULT_CRITICAL_PERCENTAGE

    static final float DEFAULT_CRITICAL_PERCENTAGE
    The default percent of heap memory at which the VM is considered in a critical state. Current value is `0.0`.
    See Also:
      - `setCriticalHeapPercentage(float)`
      - `getCriticalHeapPercentage()`
      - Constant Field Values

  - ### DEFAULT_EVICTION_PERCENTAGE

    static final float DEFAULT_EVICTION_PERCENTAGE
    The default percent of heap memory at which the VM should begin evicting data. Current value is `0.0`. Note that if a HeapLRU is created and the eviction heap percentage has not been set then it will default `80.0` unless the critical heap percentage has been set in which case it will default to a value `5.0` less than the critical heap percentage.
    See Also:
      - `setEvictionHeapPercentage(float)`
      - `getEvictionHeapPercentage()`
      - Constant Field Values

- ## Method Details

  - ### createRebalanceFactory

    RebalanceFactory createRebalanceFactory()
    Creates a factory for defining and starting `RebalanceOperations`.
    Returns:
      a factory for defining and starting RebalanceOperations

  - ### getRebalanceOperations

    Set<RebalanceOperation> getRebalanceOperations()
    Returns a set of all active `RebalanceOperations` that were started locally on this member.
    Returns:
      a set of all active RebalanceOperations started locally

  - ### createRestoreRedundancyOperation

    RestoreRedundancyOperation createRestoreRedundancyOperation()
    Creates a `RestoreRedundancyOperation` class for defining and starting restore redundancy operations and for determining the redundancy status of regions. Similar to a rebalance operation, a restore redundancy operation will attempt to bring each included region to its configured redundancy level by creating redundant copies of buckets, and will also optionally reassign which members host the primary buckets for better load balancing. A restore redundancy operation differs from a rebalance operation in that it will not move buckets from one member to another.
    Returns:
      a class for defining and starting restore redundancy operations

  - ### getRestoreRedundancyFutures

    Set<CompletableFuture<RestoreRedundancyResults>> getRestoreRedundancyFutures()
    Returns a set of all active restore redundancy futures that were started locally on this member.
    Returns:
      a set of all active restore redundancy futures started locally.

  - ### setCriticalHeapPercentage

    void setCriticalHeapPercentage(float heapPercentage)
    Set the percentage of heap at or above which the cache is considered in danger of becoming inoperable due to garbage collection pauses or out of memory exceptions.

    Changing this value can cause `LowMemoryException` to be thrown from the following `Cache` operations:

    - `Region.put(Object, Object)`
    - `Region.put(Object, Object, Object)`
    - `Region.create(Object, Object)`
    - `Region.create(Object, Object, Object)`
    - `Region.putAll(java.util.Map)`
    - index creation
    - Execution of `Function`s whose `Function.optimizeForWrite()` returns true.

    Only one change to this attribute or the eviction heap percentage will be allowed at any given time and its effect will be fully realized before the next change is allowed. When using this threshold, 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, 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 the `ResourceManager` critical and eviction heap thresholds. The JRockit VM has similar flags, `-Xgc:gencon` and `-XXgcTrigger:N`, which are required if using this feature. 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.

    Parameters:
      `heapPercentage` - a percentage of the maximum tenured heap for the VM
    Throws:
      `IllegalStateException` - if the heapPercentage value is not >= 0 or <= 100 or when less than the current eviction heap percentage
    Since:
      GemFire 6.0
    See Also:
      - `getCriticalHeapPercentage()`
      - `getEvictionHeapPercentage()`

  - ### getCriticalHeapPercentage

    float getCriticalHeapPercentage()
    Get the percentage of heap at or above which the cache is considered in danger of becoming inoperable.
    Returns:
      either the current or recently used percentage of the maximum tenured heap
    Since:
      GemFire 6.0
    See Also:
      - `setCriticalHeapPercentage(float)`

  - ### setCriticalOffHeapPercentage

    void setCriticalOffHeapPercentage(float offHeapPercentage)
    Set the percentage of off-heap at or above which the cache is considered in danger of becoming inoperable due to out of memory exceptions.

    Changing this value can cause `LowMemoryException` to be thrown from the following `Cache` operations:

    - `Region.put(Object, Object)`
    - `Region.put(Object, Object, Object)`
    - `Region.create(Object, Object)`
    - `Region.create(Object, Object, Object)`
    - `Region.putAll(java.util.Map)`
    - index creation
    - Execution of `Function`s whose `Function.optimizeForWrite()` returns true.

    Only one change to this attribute or the eviction off-heap percentage will be allowed at any given time and its effect will be fully realized before the next change is allowed.

    Parameters:
      `offHeapPercentage` - a percentage of the maximum off-heap memory available
    Throws:
      `IllegalStateException` - if the ofHeapPercentage value is not >= 0 or <= 100 or when less than the current eviction off-heap percentage
    Since:
      Geode 1.0
    See Also:
      - `getCriticalOffHeapPercentage()`
      - `getEvictionOffHeapPercentage()`

  - ### getCriticalOffHeapPercentage

    float getCriticalOffHeapPercentage()
    Get the percentage of off-heap at or above which the cache is considered in danger of becoming inoperable.
    Returns:
      either the current or recently used percentage of the maximum off-heap memory
    Since:
      Geode 1.0
    See Also:
      - `setCriticalOffHeapPercentage(float)`

  - ### setEvictionHeapPercentage

    void setEvictionHeapPercentage(float heapPercentage)
    Set the percentage of heap at or above which the eviction should begin on Regions configured for HeapLRU eviction.

    Changing this value may cause eviction to begin immediately.

    Only one change to this attribute or critical heap percentage will be allowed at any given time and its effect will be fully realized before the next change is allowed. This feature requires additional VM flags to perform properly. See setCriticalHeapPercentage() for details.

    Parameters:
      `heapPercentage` - a percentage of the maximum tenured heap for the VM
    Throws:
      `IllegalStateException` - if the heapPercentage value is not >= 0 or <= 100 or when greater than the current critical heap percentage.
    Since:
      GemFire 6.0
    See Also:
      - `getEvictionHeapPercentage()`
      - `getCriticalHeapPercentage()`

  - ### getEvictionHeapPercentage

    float getEvictionHeapPercentage()
    Get the percentage of heap at or above which the eviction should begin on Regions configured for HeapLRU eviction.
    Returns:
      either the current or recently used percentage of the maximum tenured heap
    Since:
      GemFire 6.0
    See Also:
      - `setEvictionHeapPercentage(float)`

  - ### setEvictionOffHeapPercentage

    void setEvictionOffHeapPercentage(float offHeapPercentage)
    Set the percentage of off-heap at or above which the eviction should begin on Regions configured for HeapLRU eviction.

    Changing this value may cause eviction to begin immediately.

    Only one change to this attribute or critical off-heap percentage will be allowed at any given time and its effect will be fully realized before the next change is allowed.

    Parameters:
      `offHeapPercentage` - a percentage of the maximum off-heap memory available
    Throws:
      `IllegalStateException` - if the offHeapPercentage value is not >= 0 or <= 100 or when greater than the current critical off-heap percentage.
    Since:
      Geode 1.0
    See Also:
      - `getEvictionOffHeapPercentage()`
      - `getCriticalOffHeapPercentage()`

  - ### getEvictionOffHeapPercentage

    float getEvictionOffHeapPercentage()
    Get the percentage of off-heap at or above which the eviction should begin on Regions configured for HeapLRU eviction.
    Returns:
      either the current or recently used percentage of the maximum off-heap memory
    Since:
      Geode 1.0
    See Also:
      - `setEvictionOffHeapPercentage(float)`