public interface Lease extends Availability
| Modifier and Type | Method and Description |
|---|---|
static Lease |
create(int timeToLiveMillis,
int numberOfRequests) |
static Lease |
create(int timeToLiveMillis,
int numberOfRequests,
ByteBuf metadata) |
long |
expiry()
Absolute time since epoch at which this lease will expire.
|
int |
getAllowedRequests()
Number of requests allowed by this lease.
|
ByteBuf |
getMetadata()
Metadata for the lease.
|
default int |
getRemainingTimeToLiveMillis(long now)
Number of milliseconds that this lease is still valid from now.
|
default int |
getStartingAllowedRequests()
Initial number of requests allowed by this lease.
|
int |
getTimeToLiveMillis()
Number of milliseconds that this lease is valid from the time it is received.
|
default boolean |
isEmpty()
Checks if the lease is empty(default value if no lease was received yet)
|
default boolean |
isExpired()
Checks if the lease is expired now.
|
default boolean |
isExpired(long now)
Checks if the lease is expired for the passed
now. |
default boolean |
isValid()
Checks if the lease has not expired and there are allowed requests available
|
availabilitystatic Lease create(int timeToLiveMillis, int numberOfRequests)
int getAllowedRequests()
default int getStartingAllowedRequests()
int getTimeToLiveMillis()
default int getRemainingTimeToLiveMillis(long now)
now - millis since epochlong expiry()
default boolean isExpired()
true if the lease has expired.default boolean isExpired(long now)
now.now - current time in millis.true if the lease has expired.default boolean isValid()
default boolean isEmpty()