This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Micro Frontends in Action and have Michael Geers on-line!
See this thread for details.
Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Two or more JVM in a single machine

 
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 )???
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • 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.
 
That's a very big dog. I think I want to go home now and hug this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic