public class Lease<T>
extends java.lang.Object
T. Purpose is to avoid
accumulation of instances in InstanceRegistry as result of ungraceful
shutdowns that is not uncommon in AWS environments.
If a lease elapses without renewals, it will eventually expire consequently
marking the associated T for immediate eviction - this is similar to
an explicit cancellation except that there is no communication between the
T and LeaseManager.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_DURATION_IN_SECS |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancels the lease by updating the eviction time.
|
long |
getEvictionTimestamp()
Gets the milliseconds since epoch when the lease was evicted.
|
T |
getHolder()
Returns the holder of the lease.
|
long |
getLastRenewalTimestamp()
Gets the milliseconds since epoch when the lease was last renewed.
|
long |
getRegistrationTimestamp()
Gets the milliseconds since epoch when the lease was registered.
|
long |
getServiceUpTimestamp()
Gets the milliseconds since epoch when the service for the lease was marked as up.
|
boolean |
isExpired()
Checks if the lease of a given
InstanceInfo has expired or not. |
void |
renew()
Renew the lease, use renewal duration if it was specified by the
associated
T during registration, otherwise default duration is
DEFAULT_DURATION_IN_SECS. |
void |
serviceUp()
Mark the service as up.
|
void |
setServiceUpTimestamp(long serviceUpTimestamp)
Set the leases service UP timestamp.
|
public static final int DEFAULT_DURATION_IN_SECS
public Lease(T r, int durationInSecs)
public void renew()
T during registration, otherwise default duration is
DEFAULT_DURATION_IN_SECS.public void cancel()
public void serviceUp()
public void setServiceUpTimestamp(long serviceUpTimestamp)
public boolean isExpired()
InstanceInfo has expired or not.public long getRegistrationTimestamp()
public long getLastRenewalTimestamp()
public long getEvictionTimestamp()
public long getServiceUpTimestamp()
public T getHolder()