LookupCache, ServiceDiscoveryListener and discard guarantees

Rick Moynihan <[email protected]>
Newsgroups gmane.comp.java.sun.jini
Message-ID <[email protected]>
Hi,

I'm writing/using some code which makes use of the LookupCache and a
ServiceDiscoveryListener and it occurred to me that there may be a risk
of a particular error/race-condition.  I am wondering whether or not the
LookupCache provides any guarantees that this does not occur.

The particular issue I'm thinking of might occur when there is a 'ghost'
on the lookup service, i.e. a prior service registration who's lease has
not yet expired.

If this ghost is discovered by a client which then tries to communicate
with the proxy it fails because the corresponding service is no longer
available.  The client then calls discard() on the LookupCache to ensure
that the service is eligible for rediscovery when the service performs
its reregistration.

By calling discard() the client ensures that (asynchronously) any
ServiceDiscoveryListeners attached to the cache receive a
serviceRemoved() method call.  Allowing some cleanup of state data in
respect of the lost service.

My question given this setup is:

Does the LookupCache guarantee that the serviceRemoved() method call in
honour of the call to discard() will occur prior to a call to
serviceAdded() due to the rediscovery of the lost service?

The fear is the admittedly unlikely event of the client issuing the
discard() just as the service is coming back online, and that
serviceAdded() is called prior to the already initiated (but not yet
run) serviceRemoved().

If this were to occur the Jini layers would know about the service but
my application wouldn't as it would have removed the newly added
service.  Are any assurances made by LookupCache that calls to discard()
will result in serviceRemoved() method invocations prior to any calls to
serviceAdded()/serviceChanged() involving the discarded service?

I've done a fair amount of searching and have read through the Jini
Service Discovery Utilities Specification[1], but can't find any mention
of this.

Is this something worth worrying about?  And do I need to ensure that
the remove is called before the add in the case of a discard?

Thanks for any assistance.

R.

[1] http://www.jini.org/wiki/Jini_Service_Discovery_Utilities_Specification

--------------------------------------------------------------------------
Getting Started:     http://www.jini.org/wiki/Category:Getting_Started
Community Web Site:  http://jini.org
jini-users Archive:  http://archives.java.sun.com/archives/jini-users.html
Unsubscribing:       email "signoff JINI-USERS"  to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.