• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

FBN - Multithreaded server problem

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI
I implemented my server using RMI. The instruction says that server should be able to serve multiple client, so you need to make your server multi threaded. However with RMI even a single instance of DataClient is able to serve multiple Users. So is it still necessary to make the server multi threaded?
I tried deploying DataServer as multi-threaded where every connection to dataserver will first get copy of DataClient, then this copy of dataClient will serve user's request. However I have to transport the entire DataClient to the user, which does not serve the purpose of RMI (wherein only stub is transported, and not the whole object). I think I am doing something horrible wrong, I just can't think of a good design to implement multi-threaded server in RMI. Any help in this respect will be greatly appreciated
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jignesh,
Your RMI server should expose the same methods as the Data class. The server holds a single instance of the Data object and delegates calls down to the Data instance. Your stub is for the RMI server which is sent to the clients, the Data class stays put and must be thread safe.
Only one server object gets registered. All clients issue a lookup and get a reference to the same RMI server instance.
I created an interface which my Data class implements. Then I made a DataFactory class which returns the interface type. Have the RMI Server implement the same interface. Now the factory can return either an instance of a local Data class or the remote class. Your code references the interface and doesn't know the difference. The factory must determine which type to create based on the aguments passed (i.e., file, host, port).
 
It's a tiny ad. At least, that's what she said.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic