net.jini.lookup
Class JoinManager.ProxyReg.DiscLeaseListener

java.lang.Object
  extended by net.jini.lookup.JoinManager.ProxyReg.DiscLeaseListener
All Implemented Interfaces:
EventListener, LeaseListener
Enclosing class:
JoinManager.ProxyReg

private class JoinManager.ProxyReg.DiscLeaseListener
extends Object
implements LeaseListener

Class that is registered as a listener with this join manager's lease renewal manager. That lease renewal manager manages the lease granted to this join manager's associated service by the lookup service referenced in the proxy object associated with this class (ProxyReg). If the lease expires in the lookup service before the lease renewal manager requests renewal of the lease, then upon sending that renewal request, the lease renewal manager will receive an UnknownLeaseException from the lookup service. As a result, the lease renewal manager removes the expired lease so that no further renewal attempts are made for that lease, and then sends to this listener a LeaseRenewalEvent, containing an UnknownLeaseException. Alternatively, suppose that at the time the lease renewal manager is about to request the renewal of the lease, the lease renewal manager determines that the expiration time of the lease has actually passed. In this case, since there is no reason to send the renewal request, the lease renewal manager instead removes the expired lease (again, so that no further renewal attempts are made for that lease), and then sends a LeaseRenewalEvent to this listener to indicate that the lease has expired. The difference between this case, and the case described previously is that in this case the LeaseRenewalEvent contains no exception (that is, LeaseRenewalEvent.getException returns null). Both situations described above indicate that the lease referenced by the event received by this listener has expired. Thus, the normal course of action should be to attempt to re-register the service with the lookup service that originally granted the lease that has expired. Prior to re-registering the service, the joinSet is examined to determine if it contains a ProxyReg object that is equivalent to the ProxyReg object referencing the current instance of this listener class. That is, using equals, it is determined whether the joinSet contains either ProxyReg.this, or a new instance of ProxyReg that is equal to ProxyReg.this. If the joinSet does not contain such a ProxyReg, then the lookup service must have been discarded and not yet re-discovered; in which case, there is no need to attempt to re-register with that lookup service, since it is unavailable. If it is determined that the joinSet does contain either ProxyReg.this or a new ProxyReg equivalent to ProxyReg.this, then re-registration should be attempted, but only if the lease associated with the ProxyReg in the joinSet is equal to the expired lease referenced in the event received by this listener. Equality of those leases is an indication that the lease on the service's current registration has expired; thus, an attempt to re-register the service should be made. If the lease associated with the ProxyReg from the joinSet does not equal the expired lease from the event, then re-registration should not be attempted. This is because the inequality of the leases is an indication that the lease renewal event received by this listener was the result of an UnknownLeaseException that occurs when the ProxyReg in the joinSet is a new ProxyReg, different from ProxyReg.this, and the lease renewal manager requests the renewal of the (now invalid) lease associated with that old ProxyReg.this; not the valid lease associated with the new ProxyReg. A scenario such as that just described can occur when the lookup service is discarded, rediscovered, and the service is re-registered, resulting in a new ProxyReg (with new lease) being placed in the joinSet, replacing the previous ProxyReg (ProxyReg.this). But before the old, expired lease is removed from the lease renewal manager, an attempt to renew the old lease is made. Such an attempt can occur because the lease renewal manager may be in the process of requesting the renewal of that lease (or may have queued such a request) just prior to, or at the same time as, when the lease removal request is made during discard processing. When the request is made to renew the expired lease, an UnknownLeaseException occurs and a lease renewal event is sent to this listener. If, upon receiving an event such as that just described, the service were to be re-registered, the current valid service registration would be replaced, a new lease would be granted, and the corresponding ProxyReg currently contained in the joinSet would be replaced with a new ProxyReg. Additionally, the now invalid lease corresponding to the ProxyReg that was just replaced would remain in the lease renewal manager. This means that an attempt to renew that lease will eventually be made and will fail, and the cycle just described will repeat indefinitely. Thus, for the reasons stated above, re-registration is attempted only if the lease associated with the ProxyReg contained in the joinSet is equal to the expired lease referenced in the lease renewal event received by this listener.


Constructor Summary
private JoinManager.ProxyReg.DiscLeaseListener()
           
 
Method Summary
 void notify(LeaseRenewalEvent e)
          Called by the LeaseRenewalManager when it cannot renew a lease that it is managing, and the lease's desired expiration time has not yet been reached.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JoinManager.ProxyReg.DiscLeaseListener

private JoinManager.ProxyReg.DiscLeaseListener()
Method Detail

notify

public void notify(LeaseRenewalEvent e)
Description copied from interface: LeaseListener
Called by the LeaseRenewalManager when it cannot renew a lease that it is managing, and the lease's desired expiration time has not yet been reached.

Note that, prior to invoking this method, the LeaseRenewalManager removes the affected lease from the managed set of leases. Note also that, because of the reentrancy guarantee made by the LeaseRenewalManager, new leases can be safely added by this method.

Specified by:
notify in interface LeaseListener
Parameters:
e - instance of LeaseRenewalEvent containing information about the lease that the LeaseRenewalManager was unable to renew, as well as information about the condition that made the LeaseRenewalManager fail to renew the lease


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.