protected long calculateDuration(LeasedResource resource,long requestedDuration){
  if (requestedDuration == Lease.FOREVER)   requestedDuration=Long.MAX_VALUE;
 else   if (requestedDuration == Lease.ANY)   requestedDuration=defaultLength;
 else   if (requestedDuration < 0)   throw new IllegalArgumentException("Negative lease duration " + "requested");
  return Math.min(requestedDuration,maximum);
}

protected long calculateDuration ( LeasedResource resource , long requestedDuration ) { if ( requestedDuration == Lease . FOREVER ) requestedDuration = Long . MAX_VALUE ; else if ( requestedDuration == Lease . ANY ) requestedDuration = defaultLength ; else if ( requestedDuration < 0 ) throw new IllegalArgumentException ( "Negative lease duration " + "requested" ) ; return Math . min ( requestedDuration , maximum ) ; }
returns the duration this policy is willing to grant for the passed resource at this time . the duration actually granted will be shorter if the duration extends pass the end of the epoch . must return a positive number . < p > note the duration returned by this method will be shorter than the final duration granted if the requested duration extends past the current expiration , and duration return by this method is before the current expiration .
