net.jini.lease
Class LeaseRenewalManager.Entry

java.lang.Object
  extended by net.jini.lease.LeaseRenewalManager.Entry
All Implemented Interfaces:
Comparable
Enclosing class:
LeaseRenewalManager

private static class LeaseRenewalManager.Entry
extends Object
implements Comparable


Field Summary
 long actualRenew
          Actual time to renew, given concurrency limitations
private static long cnt
           
 long endTime
          Current actual expiration
 Throwable ex
          Renewal exception, or null
 long expiration
          Desired expiration
 long id
          Unique id
 Lease lease
          The lease
 LeaseListener listener
          The listener, or null
 long renew
          The next time we have to do something with this lease.
 long renewDuration
          Renew duration
 
Constructor Summary
LeaseRenewalManager.Entry(Lease lease, long expiration, long renewDuration, LeaseListener listener)
           
LeaseRenewalManager.Entry(long renew)
          Create a fake entry for tailMap
 
Method Summary
 void calcRenew(long now)
          Calculate the renew time for the lease entry
 boolean canBatch(LeaseRenewalManager.Entry e)
          Returns true if the renewal of this lease can be batched with the (earlier) renewal of the given lease.
 int compareTo(Object obj)
          Sort by decreasing renew time, secondary sort by decreasing id
 void delayRenew()
          Calculate a new renew time due to an indefinite exception
 DesiredExpirationListener desiredExpirationListener()
          Return the DesiredExpirationListener associated with this lease, or null if there is none.
 long getRenewDuration(long now)
          If the renewDuration is ANY, return ANY, otherwise return the minimum of the renewDuration and the time remaining until the desired expiration.
 boolean renewalsDone()
          Return true if the actual expiration is greater than or equal to the desired expiration (e.g. we don't need to renew this lease any more.
private static boolean sameConstraints(Lease l1, Lease l2)
          Returns true if the two leases both implement RemoteMethodControl and have the same constraints for Lease methods, or both don't implement RemoteMethodControl, else returns false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cnt

private static long cnt

id

public final long id
Unique id


lease

public final Lease lease
The lease


expiration

public long expiration
Desired expiration


renewDuration

public long renewDuration
Renew duration


listener

public final LeaseListener listener
The listener, or null


endTime

public long endTime
Current actual expiration


renew

public long renew
The next time we have to do something with this lease. Usually a renewal, but could be removing it from the managed set because its desired expiration has been reached.


actualRenew

public long actualRenew
Actual time to renew, given concurrency limitations


ex

public Throwable ex
Renewal exception, or null

Constructor Detail

LeaseRenewalManager.Entry

public LeaseRenewalManager.Entry(Lease lease,
                                 long expiration,
                                 long renewDuration,
                                 LeaseListener listener)

LeaseRenewalManager.Entry

public LeaseRenewalManager.Entry(long renew)
Create a fake entry for tailMap

Method Detail

getRenewDuration

public long getRenewDuration(long now)
If the renewDuration is ANY, return ANY, otherwise return the minimum of the renewDuration and the time remaining until the desired expiration.


calcRenew

public void calcRenew(long now)
Calculate the renew time for the lease entry


delayRenew

public void delayRenew()
Calculate a new renew time due to an indefinite exception


compareTo

public int compareTo(Object obj)
Sort by decreasing renew time, secondary sort by decreasing id

Specified by:
compareTo in interface Comparable

canBatch

public boolean canBatch(LeaseRenewalManager.Entry e)
Returns true if the renewal of this lease can be batched with the (earlier) renewal of the given lease. This method must be called with an entry such that e.renew <= this.renew.

First checks that both leases require renewal, have the same client constraints, and can be batched. Then enforces additional requirements to avoid renewing the lease too much more often than necessary.

One of the following must be true:

In addition, one of the following must be true:


sameConstraints

private static boolean sameConstraints(Lease l1,
                                       Lease l2)
Returns true if the two leases both implement RemoteMethodControl and have the same constraints for Lease methods, or both don't implement RemoteMethodControl, else returns false.


desiredExpirationListener

public DesiredExpirationListener desiredExpirationListener()
Return the DesiredExpirationListener associated with this lease, or null if there is none.


renewalsDone

public boolean renewalsDone()
Return true if the actual expiration is greater than or equal to the desired expiration (e.g. we don't need to renew this lease any more.



Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.