This discussion is archived
8 Replies Latest reply: Mar 29, 2013 11:48 PM by EJP RSS

Parallelism with JAVA RMI

1000075 Newbie
Currently Being Moderated
Hi,

I am a student. I am working on a project : trying to distribute heavy matrix calculus on many machines to reduce the execution time(Parallelism on many "slave" machines). I thought Java RMI would help me do this.(master/slaves application)
The problem is that i didn't know how to enable a client to create a connexion simultaneously with multiple server (each server on a different physical machine, that means each server has its own ip address)
i tried this, but didn't work.
*InterfaceRMI esclaves[]= new InterfaceRMI[ns]; (interfaceRMI c'est le nom de l'interface)*

for(int i=0;i<ns;i++) (ns is the number of ''slaves'')
*{*
*slaves=(InterfaceRMI) Naming.lookup("rmi://10.0.0."+(i+1)+"/Slaves"+(i+1));* (slaves has ip addresses from 10.0.0.1-->10.0.0.6 for example)
*}*
It seems that a client can contact only one rmiregistry at once.??
how can i resolve this problem? is there any solution to do my project with JAVA RMI?

thanks in advance.
  • 1. Re: Parallelism with JAVA RMI
    EJP Guru
    Currently Being Moderated
    It's not clear what you're asking here. A thread can only do one thing at a time. If you want to lookup multiple RMI Registries, or call multiple remote methods on multiple remote servers, or even add a to b, all at the same time, you have to use threads. It has nothing to do with RMI at all.
  • 2. Re: Parallelism with JAVA RMI
    1000075 Newbie
    Currently Being Moderated
    I am trying to create many connections simultaneously with many servers that have different ip addresses.

    that's what i am trying to do. contacting different 'rmiregistry' 's at the same time.

    it is not about threads.
    is this possible?

    Do you mean that each thread should contain its own Naming.lookup ?

    Does this mean that the different Naming.lookup requests cannot be done in the main thread, before creating the other different threads?
  • 3. Re: Parallelism with JAVA RMI
    EJP Guru
    Currently Being Moderated
    You can do all the Naming.lookups first in the main thread.

    In which case I have no idea what you were asking in the first place.
  • 4. Re: Parallelism with JAVA RMI
    1000075 Newbie
    Currently Being Moderated
    Well, i tried the different Naming.lookup in the main thread, but that didn't work. that was a nobound., the first connexion with 10.0.0.1 was created, but the second connexion to 10.0.0.2 didn't work.
    Nobound.Exception, it didn't recognize the name of the second server. i think that this is because it was looking for the name of the second server in the rmiregistry of the 1st machine (10.0.0.1).

    Are you sure that this is possible?? it didn't work for me...

    ?
  • 5. Re: Parallelism with JAVA RMI
    EJP Guru
    Currently Being Moderated
    NotBoundException means that there was nothing in that registry by that name. It does not mean that it looked in the wrong registry. Nothing to do with threading or parallelism whatsoever.

    And there are no connections in RMI.
  • 6. Re: Parallelism with JAVA RMI
    1000075 Newbie
    Currently Being Moderated
    so, if i conclude:

    "connecting" to multiple registries in the same time is possible for a single Rmi client. i'll retry, may be another thing was wrong.
    This is the code i used, i post it another time:

    InterfaceRMI slaves[]= new InterfaceRMI[5]; (interfaceRMI is the name of the interface)
         for(int i=0;i<5;i++)
         {

              slaves=(InterfaceRMI) Naming.lookup("rmi://10.0.0."+*(i+1)*+"/slaves"+*(i+1)*);

    **          }**

    Does this code, theoretically, enable "talking" to the RMIregistries in the PC's with the IP addresses going from 10.0.0.1 to 10.0.0.5. ??
  • 7. Re: Parallelism with JAVA RMI
    EJP Guru
    Currently Being Moderated
    So, if I conclude
    "connecting" to multiple registries in the same time
    You can't conclude that without completely ignoring what I have just told you, that there are no connections in RMI, and no 'in the same time' in anything without using threads.
    in the same time is possible for a single Rmi client. i'll retry, may be another thing was wrong.
    Does this code, theoretically, enable "talking" to the RMIregistries in the PC's with the IP addresses going from 10.0.0.1 to 10.0.0.5. ?
    Yes.
  • 8. Re: Parallelism with JAVA RMI
    1000075 Newbie
    Currently Being Moderated
    thanks you. I'll retry to run this code to find out what caused the NoBound Exception. I hope i 'll find the problem..

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points