Skip to main content

How to discover all peers through a RendezVous Peer?

7 replies [Last post]
pietro78
Offline
Joined: 2007-01-31
Points: 0

Hello, i have this question: how can i discover all peers in a Peer Group using a RendezVous Peer?
My network is configured in this way:
- several peers behind a NAT are connected to a specified Rdv Peer (visible from outside)
- an external Peer is connected to the same Rdv Peer and performs the getRemoteAdvertisements() previously described.
- All peers (NAT, external and Rdv) are in the same Peer Group, called myPeerGroup.

Using this method
myDiscoSvc.getRemoteAdvertisements(null, DiscoveryService.PEER, null, null, 10); i discover ONLY the PeerAdvertisement of the Rdv Peer which i am connected to.

while this method
myDiscoSvc.getRemoteAdvertisements(null, DiscoveryService.PEER, "Name", "pc*", 10); returns all the peers whose name start with 'pc'. So this way the method works fine.

Is there some kind of 'block' by the Rdv for queries that are too generic? And if so, where can i find some documents that explain this issue?

Thanks in advance.

ciao

pietro

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tra
Offline
Joined: 2003-06-16
Points: 0

>
> Using this method
> [code] myDiscoSvc.getRemoteAdvertisements(null,
> DiscoveryService.PEER, null, null, 10); [/code] i
> discover ONLY the PeerAdvertisement of the Rdv Peer
> which i am connected to.
In fact you may discover also peers that are connected
to other rendezvous.

> Is there some kind of 'block' by the Rdv for queries
> that are too generic? And if so, where can i find
> some documents that explain this issue?
Yes, such queries are not repropagated to avoid massive
network storming.

B.
>
> Thanks in advance.
>
> ciao
>
> pietro

pietro78
Offline
Joined: 2007-01-31
Points: 0

> > Using this method
> > [code] myDiscoSvc.getRemoteAdvertisements(null,
> > DiscoveryService.PEER, null, null, 10); [/code] i
> > discover ONLY the PeerAdvertisement of the Rdv Peer
> > which i am connected to.
> In fact you may discover also peers that are
> connected
> to other rendezvous.
I don't understand: i don't have other Rdvs, i have only one, and with that method i get only the Rdv's Advertisement, not the advertisements of the other edge peers connected to that Rdv.
As you have written below, the Rdv blocks generic queries, so how can a edge peer discover ALL other edge peers which are in a different subnet? Can i ask the Rdv Peer "give me the list of all the peers you are connected to"?

> > Is there some kind of 'block' by the Rdv for
> queries
> > that are too generic? And if so, where can i find
> > some documents that explain this issue?
> Yes, such queries are not repropagated to avoid
> massive
> network storming.

Thanks a lot

pietro

tra
Offline
Joined: 2003-06-16
Points: 0

> I don't understand: i don't have other Rdvs,
I was just taking the general case.

> i have
> only one, and with that method i get only the Rdv's
> Advertisement, not the advertisements of the other
> edge peers connected to that Rdv.
Are you waiting for the RDV connection to your
edge before issueing the discovery request. Check
the jxta.org discovery tutorial

> As you have written below, the Rdv blocks generic
> queries, so how can a edge peer discover ALL other
> edge peers which are in a different subnet?
Yes

>Can i ask
> the Rdv Peer "give me the list of all the peers you
> are connected to"?
You can get the info from the RDV service but there is
no API to get the info from an edge peer.

B.

>
>
> > > Is there some kind of 'block' by the Rdv for
> > queries
> > > that are too generic? And if so, where can i
> find
> > > some documents that explain this issue?
> > Yes, such queries are not repropagated to avoid
> > massive
> > network storming.
>
> Thanks a lot
>
> pietro

papelito
Offline
Joined: 2007-01-11
Points: 0

I'd like to creat a PeerGroup in which every Peer is aware of the others Peer conneeted in the group. I'm working in my home Lan. It should be simple to do, but i'm xperiencing som problems. One of the Peers elects itself as RendzVous Peer for the group and the other peers connects to it. Every Peer publishes its PeerAdvertisment calling discovery.remotePublish(myAdv, 60*1000)
and periodically calls discovery.getRemoteAdvertisements(null, DiscoveryService.PEER, null, null, 5)
After that, calling Enumeration en = Discovery.getLocalAdvertisements(DiscoveryService.PEER,null,null)
the local cache seems filled with all the Advs of the Peers connected to the RendezVous (And this behaviour seeems to be the opposite to that experienced by pietro78!!!!). The problem is that when I shut down one of the EdgePeers, its PeerAdvertisment doesn't disappear from the other Peers' cache...Why?? Do you have another solution to reach my objective?

pietro78
Offline
Joined: 2007-01-31
Points: 0

> (And this behaviour
> seeems to be the opposite to that experienced by
> pietro78!!!!).
I'm working in a different scenario, since my Discoverer peer is NOT in the same LAN of RdvPeer and Edge Peer; besides i have disabled multicast in Edge Peers's configuration in order to avoid "strange bahaviours" due to the multicast.
I have also experienced that the [code] discovery.remotePublish(myAdv, 60*1000)[/code] has the effect of copying myAdv in RdvPeer's cache ONLY ONCE, so the RdvPeer responds only with that myAdv to a matching query, and "hides" other Edge Peer's Advertisements that has been published with a [code]discovery.publish(myAdv, lifetime, 60*100)[/code] This behaviour terminates the Expiration Time ends.

> The problem is that when I shut
> down one of the EdgePeers, its PeerAdvertisment
> doesn't disappear from the other Peers' cache...Why??

I think it happens bacause when you create your Peer Advertisement from the Peer Group, the platform automatically stores it in the local cache with default Lifetime (1 year) an default Expiration Time (2 hours). Doing this, and using multicast, other peers continue to discover the edge Peer for the remaining 2 hours, because they have the Advertisement in their local cache.
Up to now i have solved this problem cleaning the local cache of each Edge Peer just before the publish().

I don't know if there are some better solution, but this one works!

ciao

pietro

papelito
Offline
Joined: 2007-01-11
Points: 0

I still use a multicast enabled lan, otherwise client peers can't connect to th rndezVous peer...but I've changed myAppl, now I use the discovery.publish(myAdv,60*1000,60*1000) method; in this way I think that it should works because I'm setting also the Adv's lifetime, but it's still not working.
The adv is still the others peers' caches!

I should empty the cache? I' think this can be usefull for me at the start up of the application, but not during the operations, otherwise I clear also the working-peers' Advs. So I think that I haven't understood your advice...
And how to empty the cache?I know the DiscoveryService.flushAdvertisement() but it takes as parameters a specific Advertisement, instead I want to clear them at all.

Thanks lots, and excuse me for my persisting questions, but its important for me!

Message was edited by: papelito

pietro78
Offline
Joined: 2007-01-31
Points: 0

> I should empty the cache? I' think this can be
> usefull for me at the start up of the application,
> but not during the operations, otherwise I clear also
> the working-peers' Advs.

I clean the cache on startup and then i perform a publish() only once. Obviously I set the default Lifetime (1 year), so the Peer can be discovered for 1 year from the time it performed the publish(). When the Expiration time ends (for an adv in another peer's cache), the adv is "renewed" by contacting the Peer which published that adv. (at least it's the way i have understood it)

I use this method to empty the cache of each Peer:
[code]
private void cleanLocalCache(DiscoveryService ds){

try {
if (ds != null) {
PeerAdvertisement adv = null;
Enumeration en = ds.getLocalAdvertisements(ds.PEER, null, null);
if (en != null) {
while (en.hasMoreElements()) {
adv = (PeerAdvertisement) en.nextElement();
ds.flushAdvertisement(adv);
}
}
PeerGroupAdvertisement pgAdv = null;
en = ds.getLocalAdvertisements(ds.GROUP, null, null);
if (en != null) {
while (en.hasMoreElements()) {
pgAdv = (PeerGroupAdvertisement) en.nextElement();
ds.flushAdvertisement(pgAdv);
}
}
Advertisement genericAdv = null;
en = ds.getLocalAdvertisements(ds.ADV, null, null);
if (en != null) {
while (en.hasMoreElements()) {
genericAdv = (Advertisement) en.nextElement();
ds.flushAdvertisement(genericAdv);
}
}
System.out.println("Cache is now empty.");
}
else {
System.out.println("The Discovery Service is null!");
}
} catch (Exception e) {
System.out.println("Exception in Cleaning the Local Cache: " + e.getMessage());
e.printStackTrace();
}
}
[/code]

> The adv is still the others peers' caches!

I think that is due to the fact that you have CREATED the advertisement with default Lifetime and Expiration Time, but i don't know how to solve this problem, I'm quite a newbie in JXTA :-)