Originally posted by Vishal Sinha:
Come on I meant that the command on windows to start RMI Registry is
What is the equivalent command on mac and unix.
These command lines are supposed to invoked from the installation directory where the submission jar file is un-jarred. Now do i have to tell the examiners/accessors that they have to change over to the installation folder and then type out the above command lines, or simply should i tell them that the command lines to activate the server and client are the ones just mentioned in codes above.
Do you think that I should switch over to a simple command line parameter.
Any suggetions ?
In my server implementation if the user commits any mistake the server terminates after printing an error message and a proper usage message like:
Invalid parameter string
USAGE: java suncertify.server.DatServer xx yyy zzz
Moreover when I package my server into a jar file what should be the proper usage message. Should i modify my DataServer class to print the following:
java -jar Server.jar xx yyy zzz
System.exit(1); System.exit(20) etc...
What is the purpose & reason of doing so ?
I have implemented my DataServer on the basis of Singleton pattern. I allow only one instance of data/remote data class for a single file. All clients will have the same instance of Data class.
My data class contains a single instance of LockManager class that handles locking and unlocking.
I have modified the Data class's lock and unlock method signatures to include client id. These methods do nothing but simply call the corresponding methods with same signature in the LockManager class.
Client ID is generated at the client side by concatenating java.rmi.server.UID() + ":" + InetAddress.getHost(). This client id is used by the client while requesting locks on records.
The LockManager class contains a HashMap that maps record numbers with clients.
In addition to this I have implemented a unlockAll() method in the DataClass, that instructs the lock manager to release all locks. This method signature has not been included in the DataInterface. So a calling class can access this method only when it directly instantiates the Data class by using ...
The unlock all method is called by DataServer class, whenever the DataServer is unreferenced.
Another thing, when the user tries to shut down server, i start a timer of 60 seconds before I finally shut down server. In the mean time I try to attempt a database lock (-1) on the database, if the database lock is successful the server shuts down immediately, otherwise a server shuts down forcefully after 60 seconds and unbinds the Data class instance from the rmiregistry.
I really think that candidates are skating on thin ice when they start changing signatures on the provided methods. This is why I said you may consider keeping LockManager independant of Data. You can just leave Data's lock() and unlock() as empty methods and keep a reference to the LockManager in your remote implementation class. Then instead of calling data.lock(), you call lockManager.lock() instead. Of course that means that the remote implementation class will have to play nice by verifying that it has the lock on record before modifying it instead of letting Data verify it.
Michael, can you give me some leads in this regard as to how to implement the locking architecture without modifying the lock and unlock signature ?
Is there any other better way of achieving the purpose ?
In the above code i am having a single Data and LockManager instance for the whole connection factory but a different but unique RemoteData instance for each clients. Is there any other better way of achieving the purpose ?
No that is the best and a very elegant solution.
That looks fine. Of course you know that your getConnection() method will have to return the Remote interface.
My ConnectionFactory did not keep a reference to Data and LockManager, instead I built a composite.
I used lazy instantiation for each, ie the Data and/or LockManager was not created until the first call to get them.
Why not simpy create them in the composite constructor itself ?