• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Please help me feel confident with my design ...

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
First let me sketch you the basics of my design, then I will have some questions.
I have a DataInterface that defines the methods to be implemented by the Data class (original from the assignment) and RemoteData class (the RemoteObject, extends UnicastRemoteObject, implements RemoteDataInterface, which in turn extends Remote and DataInterface).
My 'server' is the main method of RemoteData with the following code :

The instance of RemoteData bound to the RMI registry has an instance variable which is a Data object and also a LockManager instance.
My LockManager is a class that basically contains a HashMap for tracking associations between (client - record locked). As client ID in the LockManager, the RemoteData object uses itself (read 'this'). Is this correct ? (I feel not ...)
Now for the client : it acquires its DataInterface object like this :

which returns in db a DataInterface object. If operatingMode is local, then a simple Data object is created, if operatingMode is remote, then the factory does a lookup on RMI if no RemoteObject is already associated to the requesting client.
I hope everything is clear, because this is really difficult to put on paper. Don't hesitate to ask for clarifications if needed to answer my questions .... which are coming just now :

1. Do you see any major design problem ?
2. Is my locking mechanism correct ? In particular, will the client id chosen be a good choice ? (I didn't test it on several machines yet)
3. If I want to track client losses, I read in many posts that a different instance of RemoteData should be returned to each client, which is not the case in here. Would you recommend changing my whole design, or just forget about the client loss problem ?
Thanks in advance for any help or comment on my design, as I am in a phase now where I wonder about each one of my choices

Stephane
 
Stephane Weber
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I decided to change a bit my design, to answer all of these questions at one time.
So my 'server' is now a DataServer object. This DataServer object has only one method 'getConnection' which returns a RemoteDataInterface object to the client. So each client received its own Remote object, that it can reuse. This simplifies locking management as well.
Do you see still see remarks or comments on my design ?
Thanks,
Stephane
 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe you should ask one question at a time...
I think your locking approach is basically correct. I'd have preferred to have used the locking signature given in Data (I know people have done just fine by doing so), except for the bothersome language to the effect that someone shouldn't be able to unlock a record whose lock he doesn't own (a correctly implemented client wouldn't even try).
I just created a single interface that's implemented (you seem to mix "extends" and "implements" as if they were the same thing) both by the Data class, and by my RMI server, so that my client subsequently accesses the database methods polymorphically (that is, without caring whether the "database object" is local or remote).
The only time my client cares whether it's dealing with the database locally-versus-remotely is when the choice is actually made, and an instance of one or the other is constructed.
 
Stephane Weber
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Thomas, and sorry for lack of clarity. I should indeed have split my post in pieces ;-)
Anyway, I found in your answer the kind of hints I was waiting for. (Like that my locking mechanism seems good, and indeed I tested it yesterday with several clients, and it works fine).
So, thanks again,
Stephane
 
Ranch Hand
Posts: 2379
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Stephane,
Here is my plan for client interaction with the server using RMI.
The programs starts ---> user is asked for the mode --> if(net node as a client), specify server/host name or ip address else stand alone (not shown now) --> if (the server is running) connect and send request --> client wait for the response in a que maintained by server --> the server connects to db, checks the locking staff through lock manager --> the server gives respone --> client receives and updates its gui --> the server processes the next client's request in the que
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic