- java.lang.Object
-
- jdk.management.resource.SimpleMeter
-
- jdk.management.resource.NotifyingMeter
-
- jdk.management.resource.ThrottledMeter
-
- All Implemented Interfaces:
ResourceMeter
,ResourceRequest
@Deprecated(since="10", forRemoval=true) public class ThrottledMeter extends NotifyingMeter
Deprecated, for removal: This API element is subject to removal in a future version.Resource Management is deprecated for removal with no replacement.A ThrottledMeter with bandwidth limit, an approver callback for requests and allocates from an optional parent. The rate is limited by the throttle limit and is settable at any time. The rate-per-second is the amount that can be approved each second. An amount not used in each second is accumulated up to a maximum of one seconds.- Since:
- 8u40
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static ThrottledMeter
create(ResourceType type, long ratePerSec, ResourceApprover approver)
Deprecated, for removal: This API element is subject to removal in a future version.Create a new meter with a throttle rate and approver.static ThrottledMeter
create(ResourceType type, long ratePerSec, ResourceRequest parent, ResourceApprover approver)
Deprecated, for removal: This API element is subject to removal in a future version.Create a new meter with a throttle rate, parent and approver.static ThrottledMeter
create(ResourceType type, ResourceRequest parent, ResourceApprover approver)
Deprecated, for removal: This API element is subject to removal in a future version.Create a new meter with unlimited rate, parent and approver.long
getCurrentRate()
Deprecated, for removal: This API element is subject to removal in a future version.Returns an estimate of the current rate in amount per second.long
getRatePerSec()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the current throttle rate per second.long
setRatePerSec(long ratePerSec)
Deprecated, for removal: This API element is subject to removal in a future version.Sets the throttle rate per second.long
validate(long previous, long amount, ResourceId id)
Deprecated, for removal: This API element is subject to removal in a future version.Validates the amount.-
Methods declared in class jdk.management.resource.NotifyingMeter
create, getApprover, getGranularity, setGranularity
-
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
-
-
-
-
Method Detail
-
create
public static ThrottledMeter create(ResourceType type, long ratePerSec, ResourceApprover approver)
Deprecated, for removal: This API element is subject to removal in a future version.Create a new meter with a throttle rate and approver.- Parameters:
type
- the ResourceTyperatePerSec
- the rate allowed for Throttling; bytes-per sec; must be greater than zeroapprover
- the ResourceApprover to be notified; may benull
- Returns:
- a new ThrottledMeter
- Throws:
IllegalArgumentException
- if ratePerSec is less than or equal to zero
-
create
public static ThrottledMeter create(ResourceType type, ResourceRequest parent, ResourceApprover approver)
Deprecated, for removal: This API element is subject to removal in a future version.Create a new meter with unlimited rate, parent and approver.- Parameters:
type
- the ResourceTypeparent
- a ResourceRequest to request from; may benull
approver
- the ResourceApprover to be notified; may benull
- Returns:
- a new ThrottledMeter
- Throws:
IllegalArgumentException
- if ratePerSec is less than or equal to zero
-
create
public static ThrottledMeter create(ResourceType type, long ratePerSec, ResourceRequest parent, ResourceApprover approver)
Deprecated, for removal: This API element is subject to removal in a future version.Create a new meter with a throttle rate, parent and approver.- Parameters:
type
- the ResourceTyperatePerSec
- the rate allowed for throttling; bytes-per sec; must be greater than zeroparent
- a ResourceRequest to request from; may benull
approver
- the ResourceApprover to be notified; may benull
- Returns:
- a new ThrottledMeter
- Throws:
IllegalArgumentException
- if ratePerSec is less than or equal to zero
-
validate
public long validate(long previous, long amount, ResourceId id)
Deprecated, for removal: This API element is subject to removal in a future version.Validates the amount. If returning an amount, just return it. Throttling is achieved by an algorithm similar to the token bucket. Anallowance
is maintained of the amount than can be immediately fulfilled to satisfy a request. The allowance maximum is two seconds worth at the current rate-per-second. Requests reduce the allowance by the amount of the request. If the allowance is initially positive, the request is fulfilled immediately. If the allowance is negative, the allowance is topped up based on the elapsed time, waiting until it is positive again. If multiple threads are contending for the allowance, normal thread scheduling and synchronization primitives influence the order.If an InterruptedException is caught, zero is returned, failing the validation.
The throttling of resource use is decoupled from the underlying resource implementation and only delays the start of resource consumption not the rate of consumption.
- Overrides:
validate
in classNotifyingMeter
- Parameters:
amount
- the amount requestedid
- the ResourceId for the resource instance; may benull
previous
- the previous meter value- Returns:
- the value approved
-
getCurrentRate
public final long getCurrentRate()
Deprecated, for removal: This API element is subject to removal in a future version.Returns an estimate of the current rate in amount per second.- Returns:
- an estimate of the current rate in amount per second
-
getRatePerSec
public final long getRatePerSec()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the current throttle rate per second.- Returns:
- the current throttle rate per second
-
setRatePerSec
public final long setRatePerSec(long ratePerSec)
Deprecated, for removal: This API element is subject to removal in a future version.Sets the throttle rate per second.- Parameters:
ratePerSec
- the rate per second; must be greater than zero- Returns:
- the previous throttle rate per second
- Throws:
IllegalArgumentException
- if ratePerSec is less than or equal to zero
-
-