- java.lang.Object
-
- jdk.management.resource.SimpleMeter
-
- All Implemented Interfaces:
ResourceMeter
,ResourceRequest
- Direct Known Subclasses:
NotifyingMeter
@Deprecated(since="10", forRemoval=true) public class SimpleMeter extends Object implements ResourceMeter, ResourceRequest
Deprecated, for removal: This API element is subject to removal in a future version.Resource Management is deprecated for removal with no replacement.A SimpleMeter counts resource requests and releases and allocates from an optional parent. The amount is validated before requesting allocation from the parent. Subclasses can override the validation to include bounds checking, notification, callbacks, etc.- Since:
- 8u40
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimpleMeter(ResourceType type, ResourceRequest parent)
Deprecated, for removal: This API element is subject to removal in a future version.Constructor for subclasses.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static SimpleMeter
create(ResourceType type)
Deprecated, for removal: This API element is subject to removal in a future version.Returns a new SimpleMeter with the ResourceType.static SimpleMeter
create(ResourceType type, ResourceRequest parent)
Deprecated, for removal: This API element is subject to removal in a future version.Returns a new SimpleMeter with the ResourceType and allocating from a parent.boolean
equals(Object obj)
Deprecated, for removal: This API element is subject to removal in a future version.Indicates whether some other object is the same object as this one.ResourceRequest
getParent()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the parent ResourceRequest.int
hashCode()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the hashcode from for this object.long
request(long amount, ResourceId id)
Deprecated, for removal: This API element is subject to removal in a future version.Returns the validated and allocated amount and adjusts the meter.String
toString()
Deprecated, for removal: This API element is subject to removal in a future version.Returns a string representation of the meter.protected long
validate(long previous, long amount, ResourceId id)
Deprecated, for removal: This API element is subject to removal in a future version.Validate the amount returning the validated amount.-
Methods declared in class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods declared in interface jdk.management.resource.ResourceMeter
getAllocated, getType, getValue
-
-
-
-
Constructor Detail
-
SimpleMeter
protected SimpleMeter(ResourceType type, ResourceRequest parent)
Deprecated, for removal: This API element is subject to removal in a future version.Constructor for subclasses.- Parameters:
type
- the ResourceType for the meterparent
- a ResourceRequest used as the parent to allocate from; may benull
-
-
Method Detail
-
create
public static SimpleMeter create(ResourceType type)
Deprecated, for removal: This API element is subject to removal in a future version.Returns a new SimpleMeter with the ResourceType.- Parameters:
type
- the ResourceType- Returns:
- a new SimpleMeter
-
create
public static SimpleMeter create(ResourceType type, ResourceRequest parent)
Deprecated, for removal: This API element is subject to removal in a future version.Returns a new SimpleMeter with the ResourceType and allocating from a parent.- Parameters:
type
- the ResourceTypeparent
- the parent ResourceMeter; may benull
- Returns:
- a new SimpleMeter
-
getParent
public final ResourceRequest getParent()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the parent ResourceRequest.- Returns:
- Returns the parent ResourceRequest; may be null
-
request
public final long request(long amount, ResourceId id)
Deprecated, for removal: This API element is subject to removal in a future version.Returns the validated and allocated amount and adjusts the meter. For allocation, amount greater than zero, the amount is applied to the meter before validation so it is immediately visible. If the validation or allocation from the parent is for a different amount the delta is restored to the meter. For releasing a resource, amount less than zero, the amount is applied after validation to avoid premature release of the resource.- Specified by:
request
in interfaceResourceRequest
- Parameters:
amount
- the amount to allocate; if zero nothing is doneid
- the ResourceId for the resource instance; may benull
- Returns:
- the allocated amount, zero, positive or negative
-
validate
protected long validate(long previous, long amount, ResourceId id) throws ResourceRequestDeniedException
Deprecated, for removal: This API element is subject to removal in a future version.Validate the amount returning the validated amount. Override to apply bounds checks and callbacks.For allocation, positive amounts, the amount is applied to the meter before validation so it is immediately visible. For releasing a resource, negative amounts, the amount is applied after validation to avoid premature release of the resource. If the amount returned is different than requested the meter will be corrected with the difference.
- Parameters:
previous
- the meter value before the current requestamount
- an amount, positive to allocate, negative to releaseid
- the ResourceId for the resource instance; may benull
- Returns:
- the validated amount, zero or throw an exception to deny;
return a value with the same sign as the
amount
- Throws:
ResourceRequestDeniedException
- if the amount cannot be satisfied
-
toString
public String toString()
Deprecated, for removal: This API element is subject to removal in a future version.Returns a string representation of the meter.
-
hashCode
public final int hashCode()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the hashcode from for this object.- Overrides:
hashCode
in classObject
- Returns:
- a hashcode for this object
- See Also:
Object.equals(java.lang.Object)
,System.identityHashCode(java.lang.Object)
-
equals
public final boolean equals(Object obj)
Deprecated, for removal: This API element is subject to removal in a future version.Indicates whether some other object is the same object as this one.- Overrides:
equals
in classObject
- Parameters:
obj
- the reference object with which to compare- Returns:
true
if this object is the same as the obj argument;false
otherwise- See Also:
Object.hashCode()
,HashMap
-
-