Arjan Broer

Greenhorn
+ Follow
since Dec 20, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Arjan Broer

I was mainly concerned about the use of Thread.currentThread(). The RMI specifcation does not garantee that a client will always use the same server thread.
So is currentThread a proper identification of the client holding the lock?

Originally posted by Vlad Rabkin:
What assignement do you prepare FBN or URLyBird? (I am interested in it to understand better your locking concept).


URLyBird

Originally posted by Vlad Rabkin:

Your connection class is not actially obliged to implement DBMain interface.
Only your Data class must implement DBMain interface.


Correct. My connection class acts as a proxy. So each client will have its own connection. Now the lockmanager stores the clientID (Object) as being the connection class. The connection class does NOT implement the DBMain interface.
My Data class implements the DBMain interface. And thus has an implementation of the (un)lock methods. The only reasonable functionality for these methods would be to set a flag on a record as being locked. (not actualy a flag, but an entery in the lock List)
So i solved the restrictive lock method of DBMain. Still this method has to be implemented on the Data class.

Originally posted by Andrew Monkhouse:
There are many different versions of the three different assignments.


Oeps, didn't think of that.
Basicly because my Data class implements DBMain and DBMain contains lock(recno) and unlock(recno).
Now my connection Class contains lock(recno). This function calls the LockManager with lock(recno, this) where this is ofcource the clientID of type Object.
The DBMain (un)lock function is just to restrictive . Personaly i would prefer to leave out the lock and unlock in DBMain.
A concideration was to let the Connection class implement DBMain, but then i'm stuck with the String arrays for records .
Do you see any other solution?

Originally posted by biang lin:
I don't have a "LockManager" class,I just use a HashMap to store cookies.


But how do you pass the cookies? The DBMain interface passes the recno parameter only. This means you would violate the DBMain interface and thereby violate the assignment requirements. Or did i miss something?
The locks in the data class are basicly flags on records and holds no owner data. I also have a LockManager that keeps track of the lock owners. A Connection class will call the lockmanager to create a lock on a record for a certain client. The lock manager then notifies the Data class of this lock.
The data class uses the lock to validate if an update can be done on the record. The lockmanager autorizes the operation for a client. So there is a slight difference in semantics of the Data lock and the LockManager lock.
Main reason for this is the DBMain interface. Data must implement this interface.
Vlad,
Thanks for your review.
The lock vector stores the recordID as an Integer. I implementated this as a Vector just because it is the first thing that came to mind. The conciderations for choosing Vector or ArrayList are not clear to me . Can you help me on that.
Personaly i think caching would be very good for a database, but the assingment does not require caching.
If you implement caching, you also need to implement a change log. All update statements are written to the change log so you will not loose any changes. An other thread would then write all changes from the change log to the database file in a timely batch or something. This is probebly the only way to asure the ACID properties of your database.
When your JVM crashed (power interrupt) the first thing to do on startup is to commit the changelog to the database. Thats ACID.
When implementing a changelog a lot of complexity is added to the database that was not required in the assignment. So i doubt if this is rewarded by the sun judges.

Originally posted by Akash Singh:
Can any one write how to find out whether RMI server is running or not on a machine with a particular port; without looking for a bound object ?


If you just want to find out if the rmi server has started you could telnet to the server with the specified port.

If the connection is refused than no service was running on this port.
Ofcourse this is not usable in Java code, but it could solve some debugging problems.
For the URLyBird assignment i've come up with the following design. I was just wondering if i'm not over-complicating things.
I have a Data class implementing DBMain. This class handles all IO and is able to (un)lock records by a simple lock flag implementated in a Vector.
Because the String arrays are to close to the file structure, i implementated the column, schema, field and record classes.
I have a GenericColumn interface and a ColumnInfo class implementing the interface. The interface exposes getFieldName and getWidth.
The RecordSchema exposes getColumnCount and getColumnSchema. The column schema is an array of GenericColumn. SchemaInfo implements this interface and holds the array of columns.
The Field interface extends GenericColumn and adds getFieldValue and setFieldValue methods. The FieldInfo class implements this interface.
The Record class implements GenericRecord. This interface exposes functions to query the schema and field values. It also adds a unique id to the record.
The connection classes (remote and local) expose methods for retrieving records and update records (and all other functions that compare to DBMain) The difference with DBMain is that the connection class works with the Record schema i described above in stead of the string arrays. A huge advantage is that the schema validation is handeld by the record schema before the data is provided to the Data class. Also for building a client it is more intuitive to work with records in stead of string arrays.
Please tell me what you think of this design.
This sure sounds familiar. I've been strugling with the same problem for a few days and i came to a point to consult my doctor for my blood presure.
The some newbie junior developer asked me if i started the correct rmiregistry.
Explicit start of %JAVA_HOME%\bin\rmiregistry solved the problem. Somehow my %path% variable got screwed up.
Don't know if you have the same problem, but the sympthoms are alike. Give it a go. If this doesn't solve your problem .... good luck
Lets get this on at the top again.
In my design i have implemented the lock(int) and unlock(int) in Data. This implements simple straight forward locking of records.
I've also implemented a lockManager. The lockManager implements lock(int record, Object client) and unlock(int, Object). The LockManager simply administers the locks by keeping track of the lock owners in a Map.
So when a client requests a lock it calls the LockManager. Then the LockManager locks the record in Data on behalf of the client.
Regards,

Originally posted by Peter den Haan:
I figured I couldn't count on other developers to be totally disciplined acquiring locks.


I fully agree that other developers can not be trusted to use your server as you itended. But does that mean your server has to do the work they forgot to implement, or should you throw an exception for misusing your server.
When the stupid programmer, i mentioned above, implements update-lock-unlock. He could think this is correct due to the implicit lock.
If you implement an implicite lock, shouldn't we also check if the client had the most up to date record?
I personaly don't think so, because of the scope of this assignment. This would mean that an exception should be thrown when misusing the locking model.
Did i just make a design decision???
please critisize.
[ January 16, 2003: Message edited by: Arjan Broer ]
Hi all,
When i analyse the locking model of other database systems i must conclude that the server is responsable for aquiring locks on records on behalf of the client. With a SQL update statement the client implicitly requests a record lock, but the server is responsable to handle the lock-update-unlock sequence.
This sounds fair when you take into consideration that a client programmer makes a stupid mistake by implementing the sequence update-lock-unlock.
My question here is if we should expose lock and unlock to the client and if we should implement an implicite lock.
(excuse me for my spelling)
Regards