public interface Lease
Modifier and Type | Field and Description |
---|---|
static int |
ABSOLUTE
The serialized form of the lease will contain the time of expiration
stored as an absolute time, represented in terms of milliseconds since
the beginning of the epoch.
|
static long |
ANY
Used by the requestor to indicate that there is no particular lease
time desired, and that the grantor of the lease should supply a time
that is most convenient for the grantor.
|
static int |
DURATION
The serialized form of the lease will convert the time of lease
expiration into a duration (in milliseconds) from the time of
serialization.
|
static long |
FOREVER
Used to request a lease that never expires.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canBatch(Lease lease)
Returns a boolean indicating whether or not the lease given as a
parameter can be batched (placed in the same LeaseMap) with the
current lease.
|
void |
cancel()
Used by the lease holder to indicate that it is no longer interested
in the resource or information held by the lease.
|
LeaseMap<? extends Lease,Long> |
createLeaseMap(long duration)
Creates a Map object that can contain leases whose renewal or
cancellation can be batched, and adds the current lease to that map.
|
long |
getExpiration()
Returns a
long that indicates the time that the
lease will expire. |
int |
getSerialFormat()
Returns the format that will be used to serialize the lease.
|
void |
renew(long duration)
Used to renew a lease for an additional period of time, specified in
milliseconds.
|
void |
setSerialFormat(int format)
Sets the format to use when serializing the lease.
|
static final long FOREVER
static final long ANY
static final int DURATION
static final int ABSOLUTE
long getExpiration()
long
that indicates the time that the
lease will expire. This time is represented as
milliseconds from the beginning of the epoch, relative to the local
clock.long
that indicates the time that the
lease will expirevoid cancel() throws UnknownLeaseException, RemoteException
UnknownLeaseException
- the lease being cancelled is unknown
to the lease grantorRemoteException
void renew(long duration) throws LeaseDeniedException, UnknownLeaseException, RemoteException
duration
- the requested duration in millisecondsLeaseDeniedException
- the lease grantor is unable or
unwilling to renew the leaseUnknownLeaseException
- the lease being renewed is unknown
to the lease grantorRemoteException
void setSerialFormat(int format)
format
- DURATION or ABSOLUTEgetSerialFormat()
int getSerialFormat()
setSerialFormat(int)
LeaseMap<? extends Lease,Long> createLeaseMap(long duration)
duration
- the duration to put into a Long and use as the
value for the current lease in the created LeaseMapboolean canBatch(Lease lease)
lease
- the Lease to be evaluated