• | roundTripTime | |
---|---|---|
  | Type: | long |
  | Default: | 10 * 1000 // 10 seconds |
  | Description: | The worst-case latency, expressed in milliseconds, to assume for a remote call to renew a lease. The value must be greater than zero. Unrealistically low values for this entry may result in failure to renew a lease. Leases managed by this manager should have durations exceeding the roundTripTime . This entry is obtained in the constructor. |
• | taskManager | |
---|---|---|
  | Type: | {@link TaskManager} |
  | Default: | new TaskManager(11, 15000, 1.0f) |
  | Description: | The object used to manage queuing tasks involved with renewing leases and sending notifications. The value must not be null . The default value creates a maximum of 11 threads for performing operations, waits 15 seconds before removing idle threads, and uses a load factor of 1.0 when determining whether to create a new thread. Note that the implementation of the renewal algorithm includes an assumption that the TaskManager uses a load factor of 1.0. |
Logging
This implementation uses the {@link Logger} named
net.jini.lease.LeaseRenewalManager
to log information at the following logging levels:
Level | Description |
---|---|
{@link Levels#FAILED FAILED} | Lease renewal failure events, or leases that expire before reaching the desired expiration time |
{@link Levels#HANDLED HANDLED} | Lease renewal attempts that produce indefinite exceptions |
{@link Level#FINE FINE} | Adding and removing leases, lease renewal attempts, and desired lease expiration events |
For a way of using the The renewal algorithm FAILED
and HANDLED
logging levels in standard logging configuration files, see the {@link LogManager}class. roundTripTime
, which defaults to ten seconds, represents the total time to make the remote call.
The following pseudocode was derived from the code which computes the renewal time. In this code, rtt
represents the value of the roundTripTime
:
endTime = lease.getExpiration(); delta = endTime - now; if (delta <= rtt * 2) { delta = rtt; } else if (delta <= rtt * 8) { delta /= 2; } else if (delta <= 1000 * 60 * 60 * 24 * 7) { delta /= 8; } else if (delta <= 1000 * 60 * 60 * 24 * 14) { delta = 1000 * 60 * 60 * 24; } else { delta = 1000 * 60 * 60 * 24 * 3; } renew = endTime - delta;It is important to note that
delta
is never less than rtt
when the renewal time is computed. A lease which would expire within this time range will be scheduled for immediate renewal. The use of very short lease durations (at or below rtt
) can cause the renewal manager to effectively ignore the lease duration and repeatedly schedule the lease for immediate renewal. If an attempt to renew a lease fails with an indefinite exception, a renewal is rescheduled with an updated renewal time as computed by the following pseudocode:
delta = endTime - renew; if (delta > rtt) { if (delta <= rtt * 3) { delta = rtt; } else if (delta <= 1000 * 60 * 60) { delta /= 3; } else if (delta <= 1000 * 60 * 60 * 24) { delta = 1000 * 60 * 30; } else if (delta <= 1000 * 60 * 60 * 24 * 7) { delta = 1000 * 60 * 60 * 3; } else { delta = 1000 * 60 * 60 * 8; } renew += delta; }Client leases are maintained in a collection sorted by descending renewal time. A renewal thread is spawned whenever the renewal time of the last lease in the collection is reached. This renewal thread examines all of the leases in the collection whose renewal time falls within
renewBatchTimeWindow
milliseconds of the renewal time of the last lease. If any of these leases can be batch renewed with the last lease (as determined by calling the {@link Lease#canBatch canBatch} method ofthe last lease) then a {@link LeaseMap} is created, all eligible leasesare added to it and the {@link LeaseMap#renewAll} method is called. Otherwise, thelast lease is renewed directly. The TaskManager
that manages the renewal threads has a bound on the number of simultaneous threads it will support. The renewal time of leases may be adjusted earlier in time to reduce the likelihood that the renewal of a lease will be delayed due to exhaustion of the thread pool. Actual renewal times are determined by starting with the lease with the latest (farthest off) desired renewal time and working backwards. When computing the actual renewal time for a lease, the renewals of all leases with later renewal times, which will be initiated during the round trip time of the current lease's renewal, are considered. If using the desired renewal time for the current lease would result in more in-progress renewals than the number of threads allowed, the renewal time of the current lease is shifted earlier in time, such that the maximum number of threads is not exceeded.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|