>>>Are you saying you basically made two Data classes, like you copied and pasted and made slight modifications to both versions?
If yes. Don't change the data class, unless you can defend your choice to. In my case I did change the Data class, but only by implementing lock, unlock, and criteriaFind only, and at a minimum.
Instead try making an interface that has all the methods of the Data class. and make those two classes you have implement that interface.>>
I've done the same thing what u have written. I mean I made an Interface (DataBase) which has all the methods of DataClass. Now I've two classes NetworkData(Implements RemoteDataBase interface and this interface extends DataBase and Remote) and LocalData( Implements DataBase). Since these two classes implements DataBase interface, Both of them have methods of Data Class and I've modified lock, unlock, criteriaFind method. My understanding is that u have done the same thing. right???
Now copy/paste i'm confused. Can u elaborate on it plz?
>>>Really, is it easier for you? How do you get the ID, what distinctly points to your client? >>>>
I'm using a private int valriable on the server side for unique client Id. Whenever a new client connects to the server, the server increments the variable and return its value to the client. On client side this is a final variable where client store its id.
So every time client call bookSeat method it also passes the clientId which i use in locking/Unlocking.
I've understand ur logic of Connection class ( As i remember there was a discussion on the same issue by u, peter and denise)
But Is my method is wrong I mean its very simple and clear. Can this simplicity be acceptable justification for modifying the lock / unlock signature???
>>otherwise even if client crashes unlock will get executed >>since client is booking seats thru bookSeats method which is >>on server side.
>>>>I think bookSeats needs to be on the client side. less network traffic? maybe, maybe not, but in that case you will then need to use the Unreferenced interface to clean up for a crashed client, but that is really easy.>>>
I need to read and think about this unreferenced interface. I'm a beginner in case of RMI. Can u tell me what happen if I don't use Unreferenced. Since even if client crashes, Unlock method is called and lock held by the crashed client will be removed? Is it like some garbage collection needs to be done. And since I'm not using "Connection" class, Is Unreferenced still req??
>>Is there a need for me to keep a timer and than chk for old >>locks
>>>>A lot of people have used timers and it is a good idea. I mean if you are locking modifying then unlocking in one bookSeats method, then the whole process should be fast, so if say in 30 seconds it doesn't unlock, then something had to have happened, and it is a good idea to remove the old lock. I actually did not do this, but I guess I was lazy.
>>>>>
I've given a
alot of thought to this.. Now my point is that suppose Client A calls lock. After excution of lock it successfully reads the record (say 20). And now just before calling the modify method , the cpu switches the context. Now this client which is still alive did not get the CPU for say (60 sec which we set for timer) and we remove the lock from record 20. And in the mean time some other client B, calls the book seat method for same record 20 and gets the lock. reads the record and again context swtich and at this point, first client gets the cpu and modifies the records. Now client B gets the cpu and modifies the same record. Won't this lead to data corruption.
plz comment...
Hope this helps, and I hope I understood your design, so that my comments are accurate. If not, just ignore me
Ur comments are accurate and more comments are welcomed...
Mike