Re: LE.2.1 Characteristics of a Lease

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

Okay, I'll remove the Math.max usage if that is not an expected behavior.  I 
guess I missed seeing that in the spec.

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

Okay, I'm not sure I see the scenario where this wouldn't be tree if I remove 
the if above and just always do

	le.expTime = now + inc;

That allows the client to do whatever they want with the lease expiry.

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

Ooops, right, I changed the 'inc' assignment to

long inc = Math.min( maxLeaseDuration,
     renewDuration == Lease.ANY ?
	maxLeaseDuration : renewDuration );

Thanks for the help all!

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]