• Post Reply Bookmark Topic Watch Topic
  • New Topic

Two or more JVM in a single machine  RSS feed

 
Monoj Roy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to some background ,I want to invoke RMI call to a server ,and I have written the following client code ,that access a getCounter()to show the incremented static variables value ,each time calling the getCounter() will increment the static variable by 1.That code is deployed in the server.

PDOS_Remote_Interface service1 =(PDOS_Remote_Interface)Naming.lookup("rmi://x.xxx.xxx.xxx/REMOTE_SERVICE");
String s1= service1.sayHello();
int cont1 = service1.getCounter();
System.out.println(">>>>>> "+s1);
System.out.println(">>>>>> cont1 "+cont1);

PDOS_Remote_Interface service2 =(PDOS_Remote_Interface)Naming.lookup("rmi://y.yyy.yyy.yyy/REMOTE_SERVICE");
String s2= service2.sayHello();
int cont2 = service2.getCounter();
System.out.println(">>>>>> "+s2);
System.out.println(">>>>>> cont2 "+cont2);

This is working fine with even two different server (I mean in two physically different machine(x ip and y ip) ,there ip are different )

with following output :

>>>>>> Server Says Hai!
>>>>>> cont1 0
>>>>>> Server Says Hai!
>>>>>> cont2 0

that is static variable is not shareing as they are in two different server


Now My problem:

I want to hit the one and only server ,In this case Service1 and Service2 are getting the remote instance from only one machine .And when I am doing that I am getting the static variable incremented ,That is following output
>>>>>> Server Says Hai!
>>>>>> cont1 0
>>>>>> Server Says Hai!
>>>>>> cont2 1

Is this possible to create two JVM instance in a particular machine ..??
I mean I want the first output (both static variable shows 0)in second implementetion (using only one machine )???
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monoj:
Is this possible to create two JVM instance in a particular machine

Yeah you can start 2 JVMs on a single machine.
There is no restriction as to how many JVMs you can start in a single machine as long as you have enough memory to give them.

Monoj:I mean I want the first output (both static variable shows 0)in second implementetion (using only one machine )

I see that the name of the remote service is the same for Service1 and Service2. If you are looking up Service1 and Service2 from a single machine(this implies that the RMI registry you are referring to is the same since you are just changing the machine IP i assume) what makes them different?
Either you have to start two Rmi registry instances(using different ports) or use different names for different services(Service1 and 2) to get through your problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!