// are did they?
if (desiredExpiration == Lease.FOREVER && desiredRenewal == Lease.ANY) {
if (extension != Lease.ANY) {
setRsltIfNeeded("LRS asked for " + extension +
" when it should have asked for Lease.ANY");
throw new LeaseDeniedException("Next time ask for Lease.ANY");
}
} else if (extension > desiredRenewal) {
// If desiredRenewal is not Lease.ANY extension must be less
// than or equal to desiredRenewal
setRsltIfNeeded("LRS asked for " + extension + " when it " +
"should have asked for no more than " +
desiredRenewal);
throw new LeaseDeniedException("Next time ask for no more than " +
desiredRenewal);
} else if (desiredRenewal + slop > desiredExpiration - now) {
// Make sure they are asking for the remander of the
// desiredExpiration
final long requestedExp = now + extension;
if (requestedExp < 0) {
// Overflow, ignore slop and just check to see if
// desired expiration is forever
if (desiredExpiration != Long.MAX_VALUE) {
setRsltIfNeeded("Renewal service asked for a new " +
"expiration of " + requestedExp +
" should have asked for " + desiredExpiration +
" (a diffrence of " +
(requestedExp - desiredExpiration) + " milliseconds)");
throw new LeaseDeniedException("Too MUCH!");
}
} else {
// No overflow...no...forever check to see if the diff
// is less than the slop, or if it asked for
// desiredRenewal
final long diff = Math.abs(requestedExp - desiredExpiration);
if (diff > slop) {
setRsltIfNeeded("Renewal service asked for a new " +
"expiration of " + requestedExp +
" should have asked for " + desiredExpiration +
" (a diffrence of " + diff + " milliseconds)");
throw new LeaseDeniedException("A bit off");
}
}
} else if (desiredRenewal != extension) {
// Should have asked for exactly desiredRenewal
setRsltIfNeeded("Renewal service asked for an extention " +
"of " + extension + " should have asked for " + desiredRenewal);
throw new LeaseDeniedException("Next time ask for " +
desiredRenewal);
}
// Seem to ask for the right extension
// Calculate the renewal grant __DURATION__