Re: Running Multiple Nodes inside a single JVM

"John D. Blair" <[email protected]> Tue, 20 Sep 2005 15:47:17 -0700
Newsgroups gmane.comp.java.jxta.user
Message-ID <[email protected]>
On Sep 20, 2005, at 11:40 AM, Azubuko Obele wrote:

>
>  I have a "simple" problem but I'm finding it impossible to make it  
> work. For testing purposes, I want to be able to run several JXTA  
> nodes in the same JVM. (How on earth do other people solve this  
> problem by the way? Does everybody have arrays of machines they use  
> for testing? Ant scripts? I'd think it would be a very common  
> problem.) Ideally, I'd need to support 2-20 nodes inside a single JVM  
> that I can easily start and stop.

i run multiple nodes on the same machine for testing.  i don't run them  
inside the same JVM, however... i give each one its own JVM.

>  After speaking with bondolo, it seems I need to do the following:
>
>  1) Change the JXTA_HOME system property before I start each node.

or you can just copy your class files to different locations before you  
start... cheesy, but it works for testing.

>  2) Run each node inside its own ClassLoader. For example use a class  
> like  
> http://bench.jxta.org/source/browse/bench/performance/src/net/java/ 
> bench/load/PeerClassLoader.java this ... but it's not clear HOW JXTA  
> gets it's classloader. Do I just have to change the thread context  
> classloader before calling newNetPeerGroup() ?

not necessary if you just give each one its own JVM.  at any rate, i  
don't know how  this works anyway.

>  3) Change the ports used by each Node in it's Profile -- how? It's  
> not clear at all how to do this.

when it starts up the first time the GUI configuration tool will start.  
  click on the "advanced" button (or tab) and change the TCP and HTTP  
settings.  for example, the default incoming TCP port is 9701.  I  
change the 10's digit for each of my peers-- 9711, 9721, etc., and  
number my peers to match so i can keep track of them.

once i figure out how to configure the peer at runtime i'll set these  
values automatically, which will make it easier to run lots of peers  
for testing.

>  A little help please? Once I figure this out I'll gladly throw  
> something on the wiki so others can set up their own jxta unit testing  
> environment.