• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Locking Mechanism. Please help Max, Peter, Eugene,Mark

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Couple of days ago I had posted my design and got good feedback. However the way things are working I do not think my clients are getting unique remote objects.
The flow of things are as follows.
(*) My Clients looks up the registry to find a RemoteDataFactory object.
(*) That stub is retrieved from the registry. This is my RemoteDataFactory. RemoteDataFactory inherits from UnicastRemoteObjects.
(*) From this factory my clients pass the location of the db.db file. The factory has a mapOfRemoteObjects. It checks if a remote object was created for this location if it had then return the same object otherwise create a new RemoteObject and put it in the map.
(*) The remoteObject also inherits from UnicastRemoteObject it contains LockManager and Data object.
(*) My client calls remoteObject.lock(rowID). This method in turn calls lockManager.lock(rowID, this);
(*) LockManager has a Map, LockManager's lock method does the following before putting it in the map

In my second condition !(mapOfLocks.get(aRow) == remoteData) this always yields false and so no clients have to wait.
So Now it is making me think that remoteData is not unique. When I do a toString on the stub for both clients it returns the following

I do not know what is going on. Is my design wrong. Why am I not getting unique remote objects? Do I have to do something special?
I do not want to put my whole design and I apologize if it is confusing. Please let me know if you need more info on a particular aspects.
I really appreciate all y'alls help!!
-Amish
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

(*) From this factory my clients pass the location of the db.db file. The factory has a mapOfRemoteObjects. It checks if a remote object was created for this location if it had then return the same object otherwise create a new RemoteObject and put it in the map.
Why am I not getting unique remote objects?

You have a faulty logic. You should always return a new remote object, it's just that it would wrap the same Data instance and the same corresponding instance of the lock manager if that particular database has already been requested.
Eugene.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eugene
You are right. I should not have done it this way. I do not know how I overlooked this. So now I will have two maps one for all the Data instances that I have already instantiated and the other map for all the LockManager. Is this a good idea? Or is there a better way?
Thanks
-Amish
Originally posted by Eugene Kononov:

You have a faulty logic. You should always return a new remote object, it's just that it would wrap the same Data instance and the same corresponding instance of the lock manager if that particular database has already been requested.
Eugene.
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

So now I will have two maps one for all the Data instances that I have already instantiated and the other map for all the LockManager. Is this a good idea? Or is there a better way?

Perhaps a cleaner approach is to have one map where the database is the key and the array list of two items is the value:
database name --> (Data instance, lockmanager instance)
Eugene.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You very much Eugene!!!
-Amish

Originally posted by Eugene Kononov:

Perhaps a cleaner approach is to have one map where the database is the key and the array list of two items is the value:
database name --> (Data instance, lockmanager instance)
Eugene.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic