Resource Management is a commercial feature that must be unlocked before being used. To learn more about commercial features and how to unlock them visit http://www.oracle.com/technetwork/java/javaseproducts/
jdk.management.resource

## Class NotifyingMeter

- java.lang.Object
- - jdk.management.resource.SimpleMeter
  - - jdk.management.resource.NotifyingMeter

- All Implemented Interfaces:
    ResourceMeter, ResourceRequest
  Direct Known Subclasses:
    BoundedMeter, ThrottledMeter

      public class NotifyingMeter
      extends SimpleMeter

  A NotifyingMeter provides an approver callback for changes and allocates from an optional parent. The granularity applies only to the approval callback, the amount requested or freed is the same as the amount requested. The granularity may be set at any time. Approval callbacks occur upon crossing the granularity threshold for either allocations or releases. The callback can return the amount requested or zero to indicate the request is denied. Most applications are not resilient to changes to the size of I/O operations or availability of resources.
  Since:
    8u40

- - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `NotifyingMeter(ResourceType type, ResourceRequest parent, ResourceApprover approver)` | Constructor for subclasses.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static NotifyingMeter` | `create(ResourceType type, ResourceApprover approver)` | Returns a new NotifyingMeter with the type and approver.
    `static NotifyingMeter` | `create(ResourceType type, ResourceRequest parent, ResourceApprover approver)` | Returns a new NotifyingMeter with the type, approver and parent approver.
    `ResourceApprover` | `getApprover()` | Return the ResourceApprover.
    `long` | `getGranularity()` | Returns the granularity.
    `long` | `setGranularity(long granularity)` | Sets the granularity.
    `protected long` | `validate(long previous, long amount, ResourceId id)` | Returns the amount validated by the approver.

    - ### Methods inherited from class jdk.management.resource.SimpleMeter

      `create, create, equals, getAllocated, getParent, getType, getValue, hashCode, request, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### NotifyingMeter

          protected NotifyingMeter(ResourceType type,
                                   ResourceRequest parent,
                                   ResourceApprover approver)

      Constructor for subclasses. The granularity is initialized to 1.
      Parameters:
        `type` - the ResourceType
        `parent` - a ResourceRequest to request from; may be `null`
        `approver` - the ResourceApprover to be notified; may be `null`

  - ### Method Detail

    - #### create

          public static NotifyingMeter create(ResourceType type,
                                              ResourceApprover approver)

      Returns a new NotifyingMeter with the type and approver. The granularity is initialized to 1.
      Parameters:
        `type` - the ResourceType
        `approver` - the ResourceApprover to be notified; may be `null`
      Returns:
        a new NotifyingMeter with the type and notify

    - #### create

          public static NotifyingMeter create(ResourceType type,
                                              ResourceRequest parent,
                                              ResourceApprover approver)

      Returns a new NotifyingMeter with the type, approver and parent approver. The granularity is initialized to 1.
      Parameters:
        `type` - the ResourceType
        `approver` - the ResourceApprover to notify; may be `null`
        `parent` - a ResourceRequest to request from; may be `null`
      Returns:
        a new NotifyingMeter with the type, notify, and parent approver

    - #### validate

          protected long validate(long previous,
                                  long amount,
                                  ResourceId id)

      Returns the amount validated by the approver. The `ResourceApprover.request` must return only the amount requested, zero, or throw a `ResourceRequestDeniedException`. If the amount returned is any other value, it is ignored and the requested amount is returned.
      Overrides:
        `validate` in class `SimpleMeter`
      Parameters:
        `previous` - the previous meter value
        `amount` - the amount to validate; if zero nothing is done
        `id` - the ResourceId for the resource instance; may be `null`
      Returns:
        the value validated zero, positive or negative

    - #### getGranularity

          public final long getGranularity()

      Returns the granularity.
      Returns:
        the granularity

    - #### setGranularity

          public final long setGranularity(long granularity)

      Sets the granularity.
      Parameters:
        `granularity` - Sets the granularity; the granularity must be greater than zero
      Returns:
        the previous granularity value
      Throws:
        `IllegalArgumentException` - if the granularity is less than or equal to zero

    - #### getApprover

          public final ResourceApprover getApprover()

      Return the ResourceApprover.
      Returns:
        the approver

Copyright © 2014, 2026, Oracle and/or its affiliates. All rights reserved.