public class BoundedMeter extends NotifyingMeter implements ResourceMeter, ResourceRequest
Modifier | Constructor and Description |
---|---|
protected |
BoundedMeter(ResourceType type,
long bound,
ResourceRequest parent,
ResourceApprover approver)
Constructor of a BoundedMeter.
|
Modifier and Type | Method and Description |
---|---|
static BoundedMeter |
create(ResourceType type,
long bound)
Returns a new BoundedMeter with the type and upper bound.
|
static BoundedMeter |
create(ResourceType type,
long bound,
ResourceApprover approver)
Returns a new BoundedMeter with the type, upper bound, and approver.
|
static BoundedMeter |
create(ResourceType type,
long bound,
ResourceRequest parent)
Returns a new BoundedMeter with the type, upper bound, and parent.
|
static BoundedMeter |
create(ResourceType type,
long bound,
ResourceRequest parent,
ResourceApprover approver)
Returns a new BoundedMeter with the type, upper bound, parent, and
approver.
|
long |
getBound()
Returns the upper bound for the meter.
|
long |
setBound(long bound)
Sets the bound.
|
String |
toString()
Returns a string representation of the meter.
|
protected long |
validate(long previous,
long amount,
ResourceId id)
Returns the amount validated by the approver.
|
create, create, getApprover, getGranularity, setGranularity
create, create, equals, getAllocated, getParent, getType, getValue, hashCode, request
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getAllocated, getType, getValue
request
protected BoundedMeter(ResourceType type, long bound, ResourceRequest parent, ResourceApprover approver)
type
- the ResourceType of the meterbound
- the initial upper boundparent
- a ResourceRequest to request from; may be null
approver
- the ResourceApprover to be notified; may be null
public static BoundedMeter create(ResourceType type, long bound)
type
- the ResourceTypebound
- the upper bound; must be zero or greaterIllegalArgumentException
- if the bound is less than zeropublic static BoundedMeter create(ResourceType type, long bound, ResourceRequest parent)
type
- the ResourceTypebound
- the upper bound; must be zero or greaterparent
- a ResourceRequest to request from; may be null
IllegalArgumentException
- if the bound is less than zeropublic static BoundedMeter create(ResourceType type, long bound, ResourceRequest parent, ResourceApprover approver)
type
- the ResourceTypebound
- the upper bound; must be zero or greaterparent
- a ResourceRequest to request from; may be null
approver
- the ResourceApprover to be notified; may be null
IllegalArgumentException
- if the bound is less than zeropublic static BoundedMeter create(ResourceType type, long bound, ResourceApprover approver)
type
- the ResourceTypebound
- the upper bound; must be zero or greaterapprover
- the ResourceApprover to be notified; may be null
IllegalArgumentException
- if the bound is less than zeroprotected long validate(long previous, long amount, ResourceId id)
NotifyingMeter
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.validate
in class NotifyingMeter
previous
- the previous meter valueamount
- the amount to validate; if zero nothing is doneid
- the ResourceId for the resource instance; may be null
public final long getBound()
public final long setBound(long bound)
bound
- the bound; must be zero or greaterIllegalArgumentException
- if the bound is less than zeropublic String toString()
SimpleMeter
toString
in class SimpleMeter
Copyright © 2014, 2016, Oracle and/or its affiliates. All rights reserved.