Re: LE.2.1 Characteristics of a Lease

Gregg Wonderly <[email protected]> Wed, 9 Jul 2008 14:20:08 -0500
Newsgroups gmane.comp.java.sun.jini
Message-ID <[email protected]>
John McClain - Sun Microsystems, Inc. wrote:
> Does this help?

I think I've got all the ins and outs figure out now.  I'm evaluating my changes 
to my Landlord today and it should be working as needed.  We were seeing odd 
lease expiration behavior because I was assuming that the initial lease value 
was separate from what was driving LRMs renews.  My renew() implementation is 
now essentially:

public long renew( Uuid uuid, long renewDuration )
	    throws UnknownLeaseException {
     LeaseEntryHolder le;
     le = (LeaseEntryHolder)knownMap.get( uuid );
     if( le == null ) {
	throw new UnknownLeaseException(
	    uuid+": lease not found" );
     }
     long inc = Math.min( maxLeaseTime,
	Math.max( renewDuration, minLeaseTime ) );
     long now = System.currentTimeMillis();

     // Remove from time ordered list
     removeEntry( le );

     // If we can advance the lease do that

     // Insert into time ordered list
     insertEntry( le );

     // Return granted duration.
     return le.expTime - now;
}

The fragment:

     if( le.expTime < now + inc ) {
	le.expTime = now + inc;
     }

keeps the lease expiration from going backwards.  If the initial lease has an 
expiration, one hour into the future, and a renewal is attempted for 5 mins into 
the future, inside of the expiration window, I don't want to backup the 
expiration, based on what I read in the spec and my interpretation of Bob's 
posting yesterday.


Gregg Wonderly

--------------------------------------------------------------------------
Getting Started:     http://www.jini.org/wiki/Category:Getting_Started
Community Web Site:  http://jini.org
jini-users Archive:  http://archives.java.sun.com/archives/jini-users.html
Unsubscribing:       email "signoff JINI-USERS"  to [email protected]