Re: LE.2.1 Characteristics of a Lease

"John McClain - Sun Microsystems, Inc." <[email protected]> Wed, 9 Jul 2008 16:51:19 -0400
Newsgroups gmane.comp.java.sun.jini
Message-ID <[email protected]>
Gregg Wonderly wrote:
> 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 ) );

Not sure what the Math.max is doing here, if someone asks for a 1 s 
lease, you shouldn't (by spec) be giving them a 5 minute one.

>     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.

It's not that the expiration can't go backwards, it is that it can only 
go backwards if the client asks for a duration that is sooner than the 
current expiration. So if after 5 minutes they ask for a renewal of an 
hour you have to give them at least the current expiration, but if after 
5 minutes they ask for a 10 minute renewal, you can't give them a 
renewal further than 10 minutes into the future.

Also, don't forget to handle Lease.ANY....

-- 
John McClain					[email protected]
Sun Microsystems, Inc.
Burlington, MA

And it is that way today. We are tricked by hope into starting
companies, beginning books, immigrating to this country and investing
in telecom networks. The challenges turn out to be tougher than we
imagined. Our excessive optimism is exposed. New skills are demanded.
But nothing important was ever begun in a prudential frame of mind.

         - David Brooks

--------------------------------------------------------------------------
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]