Skip to main content

About getRemoteAdvertisements?

1 reply [Last post]
pablinkus
Offline
Joined: 2007-06-28
Points: 0

This issue has been talked in the forum a lot of times but I've seen different answers and I would like to know if something is possible.
I have two different networks with two rendezvous and in every network there is one node. I'm not using multicast.

Node A ---- Rendezvous 1 ---- Rendezvous 2 ---- Node B

If I look for the node B with
getRemoteAdvertisements(null, DiscoveryService.PEER, "Name", "Node B", 1, this);
I get a DiscoveryEvent.

I think Rendezvous 1 is giving me the answer because if I shutdown Node B and Rendezvous 2, I still get a DiscoveryEvent. But if I shutdown Rendezvous 1 I don't get any more events.
I suppose the Peer Advertisements of Node B are stored in the Rendezvous 2 and then repropagated to Rendezvous 1 (I don't make any publish or remotePublish of the peer advertisement)
The DiscoveryService API says:
"It is important to note that what is shared with the rendezvous peer is the index and expiration of the advertisement, not the advertisement"
I understand that the Rendezvous knows where is the advertisement, but it does not store the advertisement.
So I don't understand why if I shutdown Node B I still get responses?
And, should it be possible to get that only Node B answer to that requests?

Thanks in advanced
Pablo

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mcumings
Offline
Joined: 2004-04-22
Points: 0

Hi Pablo,

I may not be entirely correct on the details, but I believe the following is taking place:

First, when the DiscoveryService is initialized, it publishes your peer advertisement using publish(adv, INFINITE_LIFETIME, DEFAULT_EXPIRATION). If any peer discovers your peer advertisement it is allowed to cache the advertisement for up to DEFAULT_EXPIRATION milliseconds (currently set to 7200000L). What you are likely discovering after Node B is shut down is one of these cached advertisements.

Regarding the second question you ask relating to whether or not it is possible to get the advertisement to reliably not be discovered if Node B is no longer present; Not entirely, no. First off, since the platform makes use of the PeerAdvertisements, you won't have direct control of the lifetime and expiration. Second, even if you used your own custom advertisements you will probably find that using the discovery mechanism on it's own to provide "presence" information in an accurate and scalable manner is actually non-trivial. If that sort of functionality is what you're interested in, you may want to take a look and/or join the effort at: https://jxse-presence.dev.java.net/

Hope this helps,

Mike