Class JoinManager
In order for a service to maintain its residency in the lookup services it has joined, the service must provide for the coordination, systematic renewal, and overall management of all leases on that residency. In addition to handling all discovery and join duties, as well as managing all leases on lookup service residency, the service must also provide for the coordination and management of any attribute sets with which it may have registered with the lookup services in which it resides.
This class performs all of the functions related to
discovery, joining, service lease renewal, and attribute management which is required of a
well-behaved service. Each of these activities is intimately involved with the maintenance of a
service's residency in one or more lookup services (the service's join state), thus the name
JoinManager.
This class should be employed by services, not clients. The use of this class in a wide variety of services can help minimize the work resulting from having to repeatedly implement this required functionality in each service. Note that this class is not remote. Services that wish to use this class will create an instance of this class in the service's address space to manage the entity's join state locally.
- Author:
- Sun Microsystems, Inc.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Constructor Summary
ConstructorsConstructorDescriptionJoinManager(Object serviceProxy, Entry[] attrSets, ServiceID serviceID, DiscoveryManagement discoveryMgr, LeaseRenewalManager leaseMgr) Constructs an instance of this class that will register the service with all discovered lookup services, using the suppliedServiceID.JoinManager(Object serviceProxy, Entry[] attrSets, ServiceID serviceID, DiscoveryManagement discoveryMgr, LeaseRenewalManager leaseMgr, Configuration config) Constructs an instance of this class, configured using the items retrieved through the givenConfiguration, that will register the service with all discovered lookup services, using the suppliedServiceID.JoinManager(Object serviceProxy, Entry[] attrSets, ServiceIDListener callback, DiscoveryManagement discoveryMgr, LeaseRenewalManager leaseMgr) Constructs an instance of this class that will register the given service reference with all discovered lookup services and, through an event sent to the givenServiceIDListenerobject, communicate the service ID assigned by the first lookup service with which the service is registered.JoinManager(Object serviceProxy, Entry[] attrSets, ServiceIDListener callback, DiscoveryManagement discoveryMgr, LeaseRenewalManager leaseMgr, Configuration config) Constructs an instance of this class, configured using the items retrieved through the givenConfigurationobject, that will register the given service reference with all discovered lookup services and, through an event sent to the givenServiceIDListenerobject, communicate the service ID assigned by the first lookup service with which the service is registered. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttributes(Entry[] attrSets) Associates a new set of attributes with the service, in addition to the service's current set of attributes.voidaddAttributes(Entry[] attrSets, boolean checkSC) Associates a new set of attributes with the service, in addition to the service's current set of attributes.addAttributes(Entry[] attrSets, boolean checkSC, JoinManager.ModifyAttributesLatchFactory latchFactory) Entry[]Returns an array containing the set of attributes currently associated with the service.Returns the instance ofDiscoveryManagementthat was either passed into the constructor, or that was created as a result ofnullbeing input to that parameter.Returns an array ofServiceRegistrarobjects, each corresponding to a lookup service with which the service is currently registered (joined).Returns the instance of theLeaseRenewalManagerclass that was either passed into the constructor, or that was created as a result ofnullbeing input to that parameter.voidmodifyAttributes(Entry[] attrSetTemplates, Entry[] attrSets) Changes the service's current set of attributes using the same semantics as themodifyAttributesmethod of theServiceRegistrationclass.voidmodifyAttributes(Entry[] attrSetTemplates, Entry[] attrSets, boolean checkSC) Changes the service's current set of attributes using the same semantics as themodifyAttributesmethod of theServiceRegistrationclass.modifyAttributes(Entry[] attrSetTemplates, Entry[] attrSets, boolean checkSC, JoinManager.ModifyAttributesLatchFactory latchFactory) voidreplaceRegistration(Object serviceProxy) Registers a new reference to the service with all current and future discovered lookup services.voidreplaceRegistration(Object serviceProxy, Entry[] attrSets) Registers a new reference to the service with all current and future discovered lookup services, applying semantics identical to the one-argument form of this method, except with respect to the registration of the given attribute sets.voidsetAttributes(Entry[] attrSets) Replaces the service's current set of attributes with a new set of attributes.setAttributes(Entry[] attrSets, JoinManager.ModifyAttributesLatchFactory latchFactory) voidPerforms cleanup duties related to the termination of the lookup service discovery event mechanism, as well as the lease and thread management performed by theJoinManager.
-
Constructor Details
-
JoinManager
public JoinManager(Object serviceProxy, Entry[] attrSets, ServiceIDListener callback, DiscoveryManagement discoveryMgr, LeaseRenewalManager leaseMgr) throws IOException Constructs an instance of this class that will register the given service reference with all discovered lookup services and, through an event sent to the givenServiceIDListenerobject, communicate the service ID assigned by the first lookup service with which the service is registered. This constructor is typically used by services which have not yet been assigned a service ID.The value input to the
serviceProxyparameter represents the service reference (proxy) to register with each discovered lookup service. If theObjectinput to that parameter is notSerializable, anIllegalArgumentExceptionis thrown. Ifnullis input to that parameter, aNullPointerExceptionis thrown.The value input to the
attrSetsparameter is an array ofEntryobjects, none of whose elements may benull, that represents the new set of attributes to associate with the new service reference to be registered. Passingnullas the value of theattrSetsparameter is equivalent to passing an empty array. If any of the elements of theattrSetsarray arenull, aNullPointerExceptionis thrown. The set of attributes passed in this parameter will be associated with the service in all future join processing until those attributes are changed through an invocation of a method on this class such as,addAttributes,setAttributes,modifyAttributes, orreplaceRegistration.When constructing this utility, the service supplies an object through which notifications that indicate a lookup service has been discovered or discarded will be received. At a minimum, the object supplied (through the
discoveryMgrparameter) must satisfy the contract defined in theDiscoveryManagementinterface. That is, the object supplied must provide this utility with the ability to set discovery listeners and to discard previously discovered lookup services when they are found to be unavailable. A value ofnullmay be input to thediscoveryMgrparameter. Whennullis input to that parameter, an instance ofLookupDiscoveryManageris used to listen for events announcing the discovery of only those lookup services that are members of the public group.The object input to the
leaseMgrparameter provides for the coordination, systematic renewal, and overall management of all leases on the given service reference's residency in the lookup services that have been joined. As with thediscoveryMgrparameter, a value ofnullmay be input to this parameter. Whennull is input to this parameter, an instance ofLeaseRenewalManager, initially managing noLeaseobjects will be used. This feature allows a service to either use a single entity to manage all of its leases, or to use separate entities: one to manage the leases unrelated to the join process, and one to manage the leases that result from the join process, that are accessible only within the current instance of theJoinManager.- Parameters:
serviceProxy- the service reference (proxy) to register with all discovered lookup servicesattrSets- array ofEntryconsisting of the attribute sets with which to register the servicecallback- reference to the object that should receive the event containing the service ID, assigned to the service by the first lookup service with which the service reference is registereddiscoveryMgr- reference to theDiscoveryManagementobject this class should use to manage lookup service discovery on behalf of the given serviceleaseMgr- reference to theLeaseRenewalManagerobject this class should use to manage the leases on the given service's residency in the lookup services that have been joined- Throws:
IllegalArgumentException- if the object input to theserviceProxyparameter is not serializableNullPointerException- if eithernullis input to theserviceProxyparameter, or at least one of the elements of theattrSetsparameter isnullIOException- if initiation of discovery process results inIOExceptionwhen socket allocation occursIllegalStateException- if this method is called on a terminatedJoinManagerinstance. Note that this exception is implementation-specific.- See Also:
-
JoinManager
public JoinManager(Object serviceProxy, Entry[] attrSets, ServiceIDListener callback, DiscoveryManagement discoveryMgr, LeaseRenewalManager leaseMgr, Configuration config) throws IOException, ConfigurationException Constructs an instance of this class, configured using the items retrieved through the givenConfigurationobject, that will register the given service reference with all discovered lookup services and, through an event sent to the givenServiceIDListenerobject, communicate the service ID assigned by the first lookup service with which the service is registered. This constructor is typically used by services which have not yet been assigned a service ID, and which wish to allow for deployment-time configuration of the service's join processing.The items used to configure the current instance of this class are obtained through the object input to the
configparameter. Ifnullis input to that parameter, aNullPointerExceptionis thrown.The object this utility will use to manage lookup service discovery on behalf of the given service can be supplied through either the
discoveryMgrparameter or through an entry contained in the givenConfiguration. Ifnullis input to thediscoveryMgrparameter, an attempt will first be made to retrieve from the givenConfiguration, an entry named "discoveryManager" (described above). If such an object is successfully retrieved from the givenConfiguration, that object will be used to perform the lookup service discovery management required by this utility.If
nullis input to thediscoveryMgrparameter, and no entry named "discoveryManager" is specified in the givenConfiguration, then an instance of the utility classLookupDiscoveryManagerwill be used to listen for events announcing the discovery of only those lookup services that are members of the public group.As with the
discoveryMgrparameter, the object this utility will use to perform lease management on behalf of the given service can be supplied through either theleaseMgrparameter or through an entry contained in the givenConfiguration. Ifnullis input to theleaseMgrparameter, an attempt will first be made to retrieve from the givenConfiguration, an entry named "leaseManager" (described above). If such an object is successfully retrieved from the givenConfiguration, that object will be used to perform the lease management required by this utility.If
nullis input to theleaseMgrparameter, and no entry named "leaseManager" is specified in the givenConfiguration, then an instance of the utility classLeaseRenewalManagerthat takes the givenConfigurationwill be created (initially managing no leases) and used to perform all required lease renewal management on behalf of the given service.Except for the
configparameter and the additional semantics imposed by that parameter (as noted above), all other parameters of this form of the constructor, along with their associated semantics, are identical to that of the five-argument constructor that takes aServiceIDListener.- Parameters:
serviceProxy- the service reference (proxy) to register with all discovered lookup servicesattrSets- array ofEntryconsisting of the attribute sets with which to register the servicecallback- reference to theServiceIDListenerobject that should receive the event containing the service ID assigned to the service by the first lookup service with which the service reference is registereddiscoveryMgr- reference to theDiscoveryManagementobject this class should use to manage lookup service discovery on behalf of the given serviceleaseMgr- reference to theLeaseRenewalManagerobject this class should use to manage the leases on the given service's residency in the lookup services that have been joinedconfig- instance ofConfigurationthrough which the items used to configure the current instance of this class are obtained- Throws:
IllegalArgumentException- if the object input to theserviceProxyparameter is not serializableNullPointerException- ifnullis input to theserviceProxyparameter or theconfigparameter, or if at least one of the elements of theattrSetsparameter isnullIOException- if initiation of discovery process results inIOExceptionwhen socket allocation occursConfigurationException- if an exception occurs while retrieving an item from the givenConfigurationobjectIllegalStateException- if this method is called on a terminatedJoinManagerinstance. Note that this exception is implementation-specific.- See Also:
-
JoinManager
public JoinManager(Object serviceProxy, Entry[] attrSets, ServiceID serviceID, DiscoveryManagement discoveryMgr, LeaseRenewalManager leaseMgr) throws IOException Constructs an instance of this class that will register the service with all discovered lookup services, using the suppliedServiceID. This constructor is typically used by services which have already been assigned a service ID (possibly by the service provider itself or as a result of a prior registration with some lookup service), and which do not wish to allow for deployment-time configuration of the service's join processing.Except that the desired
ServiceIDis supplied through theserviceIDparameter rather than through a notification sent to aServiceIDListener, all other parameters of this form of the constructor, along with their associated semantics, are identical to that of the five-argument constructor that takes aServiceIDListener.- Parameters:
serviceProxy- a reference to the service requesting the services of this classattrSets- array ofEntryconsisting of the attribute sets with which to register the serviceserviceID- an instance ofServiceIDwith which to register the service with all desired lookup servicesdiscoveryMgr- reference to theDiscoveryManagementobject this class should use to manage the given service's lookup service discovery dutiesleaseMgr- reference to theLeaseRenewalManagerobject this class should use to manage the leases on the given service's residency in the lookup services that have been joined- Throws:
IllegalArgumentException- if the object input to theserviceProxyparameter is not serializableNullPointerException- if eithernullis input to theserviceProxyparameter, or at least one of the elements of theattrSetsparameter isnullIOException- if initiation of discovery process results inIOExceptionwhen socket allocation occursIllegalStateException- if this method is called on a terminatedJoinManagerinstance. Note that this exception is implementation-specific.- See Also:
-
JoinManager
public JoinManager(Object serviceProxy, Entry[] attrSets, ServiceID serviceID, DiscoveryManagement discoveryMgr, LeaseRenewalManager leaseMgr, Configuration config) throws IOException, ConfigurationException Constructs an instance of this class, configured using the items retrieved through the givenConfiguration, that will register the service with all discovered lookup services, using the suppliedServiceID. This constructor is typically used by services which have already been assigned a service ID (possibly by the service provider itself or as a result of a prior registration with some lookup service), and which wish to allow for deployment-time configuration of the service's join processing.The items used to configure the current instance of this class are obtained through the object input to the
configparameter. Ifnullis input to that parameter, aNullPointerExceptionis thrown.Except that the desired
ServiceIDis supplied through theserviceIDparameter rather than through a notification sent to aServiceIDListener, all other parameters of this form of the constructor, along with their associated semantics, are identical to that of the six-argument constructor that takes aServiceIDListener.- Parameters:
serviceProxy- a reference to the service requesting the services of this classattrSets- array ofEntryconsisting of the attribute sets with which to register the service.serviceID- an instance ofServiceIDwith which to register the service with all desired lookup servicesdiscoveryMgr- reference to theDiscoveryManagementobject this class should use to manage lookup service discovery on behalf of the given serviceleaseMgr- reference to theLeaseRenewalManagerobject this class should use to manage the leases on the given service's residency in the lookup services that have been joinedconfig- instance ofConfigurationthrough which the items used to configure the current instance of this class are obtained- Throws:
IllegalArgumentException- if the object input to theserviceProxyparameter is not serializableNullPointerException- ifnullis input to theserviceProxyparameter or theconfigparameter, or if at least one of the elements of theattrSetsparameter isnullIOException- if initiation of discovery process results inIOExceptionwhen socket allocation occursConfigurationException- if an exception occurs while retrieving an item from the givenConfigurationobjectIllegalStateException- if this method is called on a terminatedJoinManagerinstance. Note that this exception is implementation-specific.- See Also:
-
-
Method Details
-
getDiscoveryManager
Returns the instance ofDiscoveryManagementthat was either passed into the constructor, or that was created as a result ofnullbeing input to that parameter.The object returned by this method encapsulates the mechanism by which either the
JoinManageror the entity itself can set discovery listeners and discard previously discovered lookup services when they are found to be unavailable.- Returns:
- the instance of the
DiscoveryManagementinterface that was either passed into the constructor, or that was created as a result ofnullbeing input to that parameter. - See Also:
-
getLeaseRenewalManager
Returns the instance of theLeaseRenewalManagerclass that was either passed into the constructor, or that was created as a result ofnullbeing input to that parameter.The object returned by this method manages the leases requested and held by the
JoinManager. Although it may also manage leases unrelated to the join process that are requested and held by the service itself, the leases with which theJoinManageris concerned are the leases that correspond to the service registration requests made with each lookup service the service wishes to join.- Returns:
- the instance of the
LeaseRenewalManagerclass that was either passed into the constructor, or that was created as a result ofnullbeing input to that parameter. - See Also:
-
getJoinSet
Returns an array ofServiceRegistrarobjects, each corresponding to a lookup service with which the service is currently registered (joined). If there are no lookup services with which the service is currently registered, this method returns the empty array. This method returns a new array upon each invocation.- Returns:
- array of instances of
ServiceRegistrar, each corresponding to a lookup service with which the service is currently registered - See Also:
-
getAttributes
Returns an array containing the set of attributes currently associated with the service. If the service is not currently associated with an attribute set, this method returns the empty array. This method returns a new array upon each invocation.- Returns:
- array of instances of
Entryconsisting of the set of attributes with which the service is registered in each lookup service that it has joined - See Also:
-
addAttributes
Associates a new set of attributes with the service, in addition to the service's current set of attributes. The association of this new set of attributes with the service will be propagated to each lookup service with which the service is registered. Note that this propagation is performed asynchronously, thus there is no guarantee that the propagation of the attributes to all lookup services with which the service is registered will have completed upon return from this method.An invocation of this method with duplicate elements in the
attrSetsparameter (where duplication means attribute equality as defined by calling theMarshalledObject.equalsmethod on field values) is equivalent to performing the invocation with the duplicates removed from that parameter.Note that because there is no guarantee that attribute propagation will have completed upon return from this method, services that invoke this method must take care not to modify the contents of the
attrSetsparameter. Doing so could cause the service's attribute state to be corrupted or inconsistent on a subset of the lookup services with which the service is registered as compared with the state reflected on the remaining lookup services. It is for this reason that the effects of modifying the contents of theattrSetsparameter, after this method is invoked, are undefined.- Parameters:
attrSets- array ofEntryconsisting of the attribute sets with which to augment the service's current set of attributes- Throws:
NullPointerException- if eithernullis input to theattrSetsparameter, or one or more of the elements of theattrSetsparameter isnull- See Also:
-
addAttributes
Associates a new set of attributes with the service, in addition to the service's current set of attributes. The association of this new set of attributes with the service will be propagated to each lookup service with which the service is registered. Note that this propagation is performed asynchronously, thus there is no guarantee that the propagation of the attributes to all lookup services with which the service is registered will have completed upon return from this method.An invocation of this method with duplicate elements in the
attrSetsparameter (where duplication means attribute equality as defined by calling theMarshalledObject.equalsmethod on field values) is equivalent to performing the invocation with the duplicates removed from that parameter.Note that because there is no guarantee that attribute propagation will have completed upon return from this method, services that invoke this method must take care not to modify the contents of the
attrSetsparameter. Doing so could cause the service's attribute state to be corrupted or inconsistent on a subset of the lookup services with which the service is registered as compared with the state reflected on the remaining lookup services. It is for this reason that the effects of modifying the contents of theattrSetsparameter, after this method is invoked, are undefined.A service typically employs this version of
addAttributesto prevent clients or other services from attempting to add what are referred to as "service controlled attributes" to the service's set. A service controlled attribute is an attribute that implements theServiceControlledmarker interface.Consider a printer service. With printers, there are often times error conditions, that only the printer can detect (for example, a paper jam or a toner low condition). To report conditions such as these to interested parties, the printer typically adds an attribute to its attribute set, resulting in an event being sent that notifies clients that have registered interest in such events. When the condition is corrected, the printer would then remove the attribute from its set by invoking the
modifyAttributesmethod in the appropriate manner.Attributes representing conditions that only the service can know about or control are good candidates for being defined as service controlled attributes. That is, the service provider (the developer of the printer service for example) would define the attributes that represent conditions such as those just described to implement the
ServiceControlledmarker interface. Thus, when other entities attempt to add new attributes, services that wish to employ such service controlled attributes should ultimately invoke only this version ofaddAttributes(with thecheckSCparameter set totrue), resulting in aSecurityExceptionif any of the attributes being added happen to be service controlled attributes. In this way, only the printer itself would be able to set a "paper jammed" or "toner low" attribute, not some arbitrary client.- Parameters:
attrSets- array ofEntryconsisting of the attribute sets with which to augment the service's current set of attributescheckSC-booleanflag indicating whether the elements of the set of attributes to add should be checked to determine if they are service controlled attributes- Throws:
NullPointerException- if eithernullis input to theattrSetsparameter, or one or more of the elements of theattrSetsparameter isnullSecurityException- if thecheckSCparameter istrue, and at least one of the attributes to be added is an instance of theServiceControlledmarker interface- See Also:
-
addAttributes
public JoinManager.ModifyAttributesLatch addAttributes(Entry[] attrSets, boolean checkSC, JoinManager.ModifyAttributesLatchFactory latchFactory) -
setAttributes
Replaces the service's current set of attributes with a new set of attributes. The association of this new set of attributes with the service will be propagated to each lookup service with which the service is registered. Note that this propagation is performed asynchronously, thus there is no guarantee that the propagation of the attributes to all lookup services with which the service is registered will have completed upon return from this method.An invocation of this method with duplicate elements in the
attrSetsparameter (where duplication means attribute equality as defined by calling theMarshalledObject.equalsmethod on field values) is equivalent to performing the invocation with the duplicates removed from that parameter.Note that because there is no guarantee that attribute propagation will have completed upon return from this method, services that invoke this method must take care not to modify the contents of the
attrSetsparameter. Doing so could cause the service's attribute state to be corrupted or inconsistent on a subset of the lookup services with which the service is registered as compared with the state reflected on the remaining lookup services. It is for this reason that the effects of modifying the contents of theattrSetsparameter, after this method is invoked, are undefined.- Parameters:
attrSets- array ofEntryconsisting of the attribute sets with which to replace the service's current set of attributes- Throws:
NullPointerException- if eithernullis input to theattrSetsparameter, or one or more of the elements of theattrSetsparameter isnull.- See Also:
-
setAttributes
public JoinManager.ModifyAttributesLatch setAttributes(Entry[] attrSets, JoinManager.ModifyAttributesLatchFactory latchFactory) -
modifyAttributes
Changes the service's current set of attributes using the same semantics as themodifyAttributesmethod of theServiceRegistrationclass.The association of the new set of attributes with the service will be propagated to each lookup service with which the service is registered. Note that this propagation is performed asynchronously, thus there is no guarantee that the propagation of the attributes to all lookup services with which the service is registered will have completed upon return from this method.
Note that if the length of the array containing the templates does not equal the length of the array containing the modifications, an
IllegalArgumentExceptionwill be thrown and propagated through this method.Note also that because there is no guarantee that attribute propagation will have completed upon return from this method, services that invoke this method must take care not to modify the contents of the
attrSetsparameter. Doing so could cause the service's attribute state to be corrupted or inconsistent on a subset of the lookup services with which the service is registered as compared with the state reflected on the remaining lookup services. It is for this reason that the effects of modifying the contents of theattrSetsparameter, after this method is invoked, are undefined.- Parameters:
attrSetTemplates- array ofEntryused to identify which elements to modify from the service's current set of attributesattrSets- array ofEntrycontaining the actual modifications to make in the matching sets found using theattrSetTemplatesparameter- Throws:
IllegalArgumentException- if the array containing the templates does not equal the length of the array containing the modifications- See Also:
-
modifyAttributes
Changes the service's current set of attributes using the same semantics as themodifyAttributesmethod of theServiceRegistrationclass.The association of the new set of attributes with the service will be propagated to each lookup service with which the service is registered. Note that this propagation is performed asynchronously, thus there is no guarantee that the propagation of the attributes to all lookup services with which the service is registered will have completed upon return from this method.
Note that if the length of the array containing the templates does not equal the length of the array containing the modifications, an
IllegalArgumentExceptionwill be thrown and propagated through this method.Note also that because there is no guarantee that attribute propagation will have completed upon return from this method, services that invoke this method must take care not to modify the contents of the
attrSetsparameter. Doing so could cause the service's attribute state to be corrupted or inconsistent on a subset of the lookup services with which the service is registered as compared with the state reflected on the remaining lookup services. It is for this reason that the effects of modifying the contents of theattrSetsparameter, after this method is invoked, are undefined.A service typically employs this version of
modifyAttributesto prevent clients or other services from attempting to modify what are referred to as "service controlled attributes" in the service's set. A service controlled attribute is an attribute that implements theServiceControlledmarker interface.Attributes representing conditions that only the service can know about or control are good candidates for being defined as service controlled attributes. When other entities attempt to modify a service's attributes, if the service wishes to employ such service controlled attributes, the service should ultimately invoke only this version of
modifyAttributes(with thecheckSCparameter set totrue), resulting in aSecurityExceptionif any of the attributes being modified happen to be service controlled attributes.- Parameters:
attrSetTemplates- array ofEntryused to identify which elements to modify from the service's current set of attributesattrSets- array ofEntrycontaining the actual modifications to make in the matching sets found using theattrSetTemplatesparametercheckSC-booleanflag indicating whether the elements of the set of attributes to modify should be checked to determine if they are service controlled attributes- Throws:
IllegalArgumentException- if the array containing the templates does not equal the length of the array containing the modificationsSecurityException- if thecheckSCparameter istrue, and at least one of the attributes to be modified is an instance of theServiceControlledmarker interface- See Also:
-
modifyAttributes
public JoinManager.ModifyAttributesLatch modifyAttributes(Entry[] attrSetTemplates, Entry[] attrSets, boolean checkSC, JoinManager.ModifyAttributesLatchFactory latchFactory) -
terminate
public void terminate()Performs cleanup duties related to the termination of the lookup service discovery event mechanism, as well as the lease and thread management performed by theJoinManager. This method will cancel all of the service's managed leases that were granted by the lookup services with which the service is registered, and will terminate all threads that have been created.Note that if the discovery manager employed by the instance of this class that is being terminated was created by the instance itself, this method will terminate all discovery processing being performed by that manager object on behalf of the service; otherwise, the discovery manager supplied by the service is still valid.
Whether an instance of the
LeaseRenewalManagerclass was supplied by the service or created by theJoinManageritself, any reference to that object obtained by the service prior to termination will still be valid after termination. Note also this class makes certain concurrency guarantees with respect to an invocation of the terminate method while other method invocations are in progress. The termination process will not begin until completion of all invocations of the methods defined in the public interface of this class. Furthermore, once the termination process has begun, no further remote method invocations will be made by this class, and all other method invocations made on this class will not return until the termination process has completed.Upon completion of the termination process, the semantics of all current and future method invocations on the instance of this class that was just terminated are undefined; although the reference to the
LeaseRenewalManagerobject employed by that instance ofJoinManageris still valid. -
replaceRegistration
Registers a new reference to the service with all current and future discovered lookup services. The new service reference will replace the reference that was previously registered as a result of either constructing this utility, or a prior invocation of one of the forms of this method. The new service reference will be registered using the sameServiceIDwith which previous registrations were made through this utility.The value input to the
serviceProxyparameter represents the new service reference (proxy) to register with each discovered lookup service. If theObjectinput to that parameter is notSerializable, anIllegalArgumentExceptionis thrown. Ifnullis input to that parameter, aNullPointerExceptionis thrown.The attribute sets that this method associates with the new service reference are the same attribute sets as those associated with the old registration.
- Parameters:
serviceProxy- the new service reference (proxy) to register with all current and future discovered lookup services- Throws:
IllegalArgumentException- if the object input to theserviceProxyparameter is not serializableNullPointerException- ifnullis input to theserviceProxyparameterIllegalStateException- if this method is called on a terminatedJoinManagerinstance. Note that this exception is implementation-specific.
-
replaceRegistration
Registers a new reference to the service with all current and future discovered lookup services, applying semantics identical to the one-argument form of this method, except with respect to the registration of the given attribute sets.This form of <code<replaceRegistration takes as its second parameter, an array of
Entryobjects (attrSets), none of whose elements may benull, that represents the new set of attributes to associate with the new service reference to be registered. As with the constructor to this utility, passingnullas the value of theattrSetsparameter is equivalent to passing an empty array. If any of the elements ofattrSetsarenull, aNullPointerExceptionis thrown. This new set of attributes will be associated with the service in all future join processing.- Parameters:
serviceProxy- the new service reference (proxy) to register with all current and future discovered lookup servicesattrSets- array ofEntryconsisting of the attribute sets with which to register the new service reference. Passingnullas the value of this parameter is equivalent to passing an emptyEntryarray- Throws:
IllegalArgumentException- if the object input to theserviceProxyparameter is not serializableNullPointerException- if eithernullis input to theserviceProxyparameter, or at least one of the elements of theattrSetsparameter isnullIllegalStateException- if this method is called on a terminatedJoinManagerinstance. Note that this exception is implementation-specific.
-