• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Providing multiple Data instances on RMI

 
Cleverson Schmidt
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • 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
 
Arun Subramanian
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic