My server just create an instance of a RemoteData object (which extends UnicastRemoteObject and redirects every mehtod call to a single Data instance),Then bind it to the RMI-registry.
and I don't use "snchronized" keyword in the RemoteData object.because methods in the Data class is already snchronized.
You guessed it, he doesOriginally posted by Jawad Kakar:
[... LockManager is a Singleton] because we need only one lock manager instance. I hope Peter does not have any problem with LockManager as a singleton [...]
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
It�s important for some classes to have exactly one instance. Although there can be many printers in a system, there should be only one printer spooler. There should be only one file system and one window manager. A digital filter will have one A/D converter. An accounting System will be dedicated to serving one company.
the fact that you'd never want to replace the lockedRecordes map can be made explicit by making it final
Your getLockManagerInstance() method is not threadsafe
In lock(), you are creating lots of new Integer(-1) objects; move this into a private static final field
The unlock() method does not work correctly if a client owns more than one lock; like the Singleton, this is another arbitrary restriction that happens to be okay for Fly By Night but otherwise severely restricts the reusability of the class without making your life any easier
Database locks aren't really handled;
Aruna A. Raghavan<br />SCJP, SCJD, SCWCD
Ah, but is that true?Originally posted by Jawad Kakar:
From GOF [...] I could conclude from above, there should be only one LockManager for FBN application. One and only one central place where all clients can lock their records.
Your unlock() method tests that the map contains the given record lock, and it tests that the lock map contains some lock owned by the client. It does not, however, test that the given record lock is actually owned by that client. This is a bug that would allow a client to unlock a record lock held by another client, thereby violating the unlock() javadoc.Test [the unlock() method] with one client holding 23 recordes, worked fine, Could you explain this in more detail please.
All your code does is ensure that no new locks are granted while a database lock is held. A lock(-1) call will actually return successfully even if there are still record locks held by other clients; surely that is wrong. Beware of potential deadlock issues when implementing this. Depending on your interpretation of the database lock requirement you may also want to implement unlock() functionality.guess I did handle Database lock in lock() method by doing [...]
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Which one is better, passing a RemotedataServer for clientId or passing an Object. As far as reusability is concern passing Object is a better idea, am I correct or there is some other reason for it too.
Eugene is right, of course. A LockManager that takes Objects for identification can be re-used in completely different contexts. If it stipulates RemoteDataServer, it is only reusable in the cut-paste-modify sense (i.e. NOT REUSABLE).Originally posted by Eugene Kononov:
Yes, refering to the interface or a superclass is always better than refering to a concrete implementation class.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Sure. But what did you gain, except greater complexity?Originally posted by walid aly:
1-about lock manager singlton
if we make class data singelton and lockmanager a class vatiable in it , i think i will always have a single instance of singelton
The one without client id is the signature exposed by Data and RemoteData/Connection/WhateverYouCallIt. The one with client id is the internal one exposed by the lock manager.2-i saw 2 signatires for lock and unlock in ur code , one which does not take a client id and a one that takes client id ...
No, you're not correct. This is one of the more interesting puzzles in the assignment. I'm sure that if you search this forum for the word "connection" you'll get plenty of hints.i think when using rmi we have to change the signature of the lock method in class data to take clientid ,am i correct?
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Everybody's invited. Even this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|