Skip to main content

Question about JXTA peers

3 replies [Last post]
krycek_a
Offline
Joined: 2007-05-23

Hi,

I posted this question earlier in the forums of Java Sun but someone told me it was better to ask it over here. So here goes:

At the moment I created a client/server application. If a server is started than the client can connect to this server and a console will appear. With this console, the client can send commands to the server to do some actions (the actions aren't relevant for the question). All peers (server and client) are connected to a RendezVous peer. This all work well. But the main problem is, the JxtaServerSocket uses a PipeAdvertisement that is stored on the harddrive as a file. So you can only connect to the server if you have that file. But what happens if another client has that same file ? An exception will occur. Now I was thinking of rebuilding my application in a way that every peer actually can be a server and a client at the same time. So there is no need for a central server. If I start the Console, I should dynamicly discover peers and add them to a list. I then need to be able to select a peer which I want to connect to.
I was wondering how I can manage all this.

I hope someone can give me feedback on how to begin.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
asghar
Offline
Joined: 2005-07-26

Hi

An advertisement is a “network resource” and a Rdv is there to make them accessible to it’s (peer) clients. Therefore it must be possible that the Rdv contains the „pipe advertisement“ for use by the peers.

„Making each peer to a server too“ is not a good method to solve the problem in yourApp.
You have to take care of network – traffic, when developing network apps.
Maybe a simpler solution is to put the XML - file, describing the pipe advertisement on each client’s persistent storage, accessible to yourApp.

A more professional solution is to implement the service as a „peer group service“ . If (because of SOME reasons) the server says goodbye to the JXTA network, another peer (previously pre-selected) guarantees the uninterrupted delivery of the actual service to the peers.

I know, that in a „peer group“ several peers can simultaneously deliver the same service (BUT for purposes like load balancing, avoidness of single point of failure, …) but I’m not sure, if it’s possible, the peer, acting as the SINGLE server can seamless delegate it’s job and role to another (pre-selected) peer, before saying goodbye to the peer group (JXTA network)?

I hope These all are correct & can help you to go on with yourApp.

Asghar

In addtion:
When more than one peer uses the XML-file (describing the pipe advertisement), you get an exception!
I’m sure, that exception must have some other reason.

A pipe advertisement (also in form of XML file) doesn’t have such critical data (except “pipe id”, which is used by peers to get the necessary resource from the platform, needed for communication like PipeInut / PipeOutput or in yourCase JxtaSocket / JxtaServerSocket), causing problem, when used by several peers.

asghar
Offline
Joined: 2005-07-26

Sorry!

An advertisement relates to a “network resource” and a Rdv is there to make them (network resources) accessible to it’s (peer) clients.

How can somebody modify his / her already posted messages?
And if it’s actually possible ?

krycek_a
Offline
Joined: 2007-05-23

Hi,

Thanks for the nice explanation. I know you said it wasn't a good solution, but for the moment I let every peer implement a JxtaServerSocket to allow connections and a JxtaSocket to connect hisself to other peers in the network.
You were right about the networktraffic, If one peers go offline I need to make sure that all the other connected peers are notified in the process.
That's the only thing I need to figure out how to do that in a proper way.