• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Providing multiple Data instances on RMI

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Initially I started my project providing just one Data object to all clients. But I started to have problems with multiple clients accessing the same RandomAccessFile object(through a Services fa�ade). The problems are caused by file pointer changes leading to unexpected results. To solve this problem the first idea I came up with was syncronizing on the RAF, but I consider this approach a little bit dangerous as I'm already syncronizing on a map object which holds the locks. My project could easily end up on a dead lock. Therefore I gave up the syncronizing on RAF solution and now I'm starting to think in providing a Data instance to each client. This will certainly solve the multiple RAF accesses problem as each client will have its own Data instance and so a file pointer. But here comes the problem. How can I provide multiple Data objects, one per client, on my RMI solution?

I have an interface exposing my business methods to be accessed by remote clients:

The realization of this interface is the remote object implementation:


This class performs its task delegating the calls to a local ServicesImpl object reference which is an attribute of RemoteServicesImpl. The ServicesImpl class is the class which holds a reference to a Data object. So, by using the RMI infrastructure, multiple client requests are handled automatically, each client request has its own thread, but the remote object is always the same and so is the Data object. Is it possible to provide a new remote object (RemoteServicesImpl ) to each client? Or all clients are handled by the same object? How can I provide one Data object to each Client?

Thank you in advance

Best Regards
Cleverson
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Cleverson-

Therefore I gave up the syncronizing on RAF solution and now I'm starting to think in providing a Data instance to each client. This will certainly solve the multiple RAF accesses problem as each client will have its own Data instance and so a file pointer.


This might not be a feasible solution for large number of clients (leading to large number of RAF instances) because of the OS limits on file descriptors and which has been mentioned atleast a few times in this forum.

Is it possible to provide a new remote object (RemoteServicesImpl ) to each client? Or all clients are handled by the same object? How can I provide one Data object to each Client?


You might want to use an RMIFactory that you register w/ the RMI registry and which in turn hands off the RemoteObject (and the DataAccessObject) on a per client basis. The following link which has been passed around quite a bit gives a nice description of the Factory Pattern as it would apply to RMI.
RMI Factory Pattern

Thanks,
Arun.
 
This one time, at bandcamp, I had relations with a tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic