ms<br />SCJP, SCJD
Originally posted by Mike Southgate:
[QB]Max;
as I've said before, I'm using the approach you suggest with respect to doing the locking within the Data class and using a HashMap within Data to track the locks. I'd like to trap the clients crashing while holding a lock so I've implemented Unreferenced in my server. Trouble is, even after there are no clients connected any more but there is a lock outstanding, unreferenced isn't being called.
One last question, I've implemented a sorting algorithm in the table model. I think that would be very useful to any users but it does go beyond the requirements of the assignment. It obviously makes the table model more complex. Would it be better to take it out, do you think?
ms
ms<br />SCJP, SCJD
ms<br />SCJP, SCJD
ms<br />SCJP, SCJD
So, As I understand it, two gui clients will each have an instance of Data? That is, they will not be sharing the same instance of Data? If that's so, then you're almost done, with two minor modifications.
ms<br />SCJP, SCJD
ms<br />SCJP, SCJD
Originally posted by Mike Southgate:
No, Data is only used to actually do the reading and writing from the database file. The DbServer class wraps Data to make it accessible remotely. The client asks for the locks itself talking to the server.
ms
ms<br />SCJP, SCJD
I just had an idea. Change my DataSourceXfc to use a Long for the lock instead of a long. Have the server store these locks in a WeakHashMap.
So, when a client dies the reference will be automatically removed from it.
Also have the server implement Unreferenced. When Unref is called the server gets the locks from Data (as longs, of course) and compares them to it's own Longs.
Help me walk though this. GUI client #1 wants to lock record rec#1. So the DbServer stores a Long(recnNo) in a weakhashmap, then locks recNo in the Data.hashmap? Are you going to change the signature of the Data.lock method to take a Long, or just extract the Long from the dbServer and pass it along?
ms<br />SCJP, SCJD
Originally posted by Mike Southgate:
[QB]
No, the way this would work is the server calls Data's lock method. It stores a long in a HashMap and returns the long to the server. Now, the server converts the long to a Long, saves it in the WeakHashMap and returns the Long to the client. Now, when the client dies, the only reference to the Long outside of the WHM is removed
so the server's Unreferenced method should be called.
ms<br />SCJP, SCJD
Originally posted by Mike Southgate:
I don't need to trust you. Eventually I figure things out even if it does take 3x as long as it should. You're right unreferenced won't get called. I think I'll take your advice and leave well enough alone. But if I fail over this I'll be some (but not at you).
ms
Blood pressure normal? What do I change to get "magnificent"? Maybe this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|