com.netflix.eureka.lease
Class Lease<T>

java.lang.Object
  extended by com.netflix.eureka.lease.Lease<T>

public class Lease<T>
extends java.lang.Object

Describes a time-based availability of a 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.


Field Summary
static int DEFAULT_DURATION_IN_SECS
           
 
Constructor Summary
Lease(T r, int durationInSecs)
           
 
Method Summary
 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.
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DURATION_IN_SECS

public static final int DEFAULT_DURATION_IN_SECS
See Also:
Constant Field Values
Constructor Detail

Lease

public Lease(T r,
             int durationInSecs)
Method Detail

renew

public 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


cancel

public void cancel()
Cancels the lease by updating the eviction time.


isExpired

public boolean isExpired()
Checks if the lease of a given InstanceInfo has expired or not.


getRegistrationTimestamp

public long getRegistrationTimestamp()
Gets the milliseconds since epoch when the lease was registered.

Returns:
the milliseconds since epoch when the lease was registered.

getLastRenewalTimestamp

public long getLastRenewalTimestamp()
Gets the milliseconds since epoch when the lease was last renewed.

Returns:
the milliseconds since epoch when the lease was last renewed.

getEvictionTimestamp

public long getEvictionTimestamp()
Gets the milliseconds since epoch when the lease was evicted.

Returns:
the milliseconds since epoch when the lease was evicted.

getHolder

public T getHolder()
Returns the holder of the lease.