Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!

Kim Barret

+ Follow
since Jul 21, 2003
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kim Barret

Hi George,
Nope, didn't send any emails to Sun. I simply waited patiently checking the CertManager daily
Though I should have. If its over 4 weeks for you, go ahead and email Sun. Don't see any harm in reminding them, they might prod the assessor to take some action sooner...
16 years ago
Hi Phil,
I didn't call notify or notifyAll in my lock method. I simply put this in the InterruptedException catch block in the lock method:

I did use notifyAll in my unlock method after unlocking a record.
16 years ago
Thanks Max, Ken and Philippe Am very happy with the score After the long wait for results! I submitted my assignment and took the exam in the first week of December!
Have a question: What all comes under general consideration? I am simply curious as to what I left out that they took off 10 points for general consideration...
Raj, here is my lock-unlock design:
For performance issues across a network, I decided to have a dedicated Data object per connection rather than using a singleton Data object to handle all requests to the database.
I implemented the lock and unlock methods in RemoteData class. For clarity and simplicity it made sense to implement these methods where they are actually used and RemoteData takes care of all database related remote calls. After all we need locking only when there are multiple remote clients trying to modify DB. In a local connection every connection has a devoted database of its own and there is no need to lock-unlock the DB.
My lock method first checks that database shouldn't be locked, if it is not locked then lock method calls lockRecord method for locking individual records. lockRecord method checks whether the specified record is already locked. If the specified lock is already locked then this thread waits until its unlocked. When the thread finds the record unlocked, it locks the record.
The unlock method, in a synchronized block, checks first whether this record is already locked. If it finds the record locked, the method checks if this thread is the owner of the lock. If yes then it unlocks the record otherwise it simply returns without unlocking the record.
When the lock method is called with -1 as the record number, the method checks first whether the database is already locked. If the database is already locked then a RemoteException is thrown telling the client that DB is already locked. If DB is not already locked then it is locked and no more client requests are accepted for booking, though the existing locked records are allowed to complete their booking.
Unlocking Entire Database: I did not provide this functionality.
16 years ago
I know this post doesn't belong here but I would like to thank everyone in this forum for all the help from everyone here especially Mark Spritzler, Andrew Monkhouse, Max H. and Philippe Maquet. This forum was my main reference for SCJD project. This is a great forum! Keep it up guys!!
Here are the details of my scores:
The maximum number of points is 400, to pass you need a score of 320.
General Con: 100 90
Documentation: 70 61
OOD: 30 30
GUI: 40 40
Locking: 80 80
Data Store: 40 40
Network Server: 40 40
Total: 400 381
16 years ago
Thanks Vanessa! Didn't see that one!! No harm in trying. Here goes my submission
I was able to log in with my old username and password. Everything seemed in order except that the system is a little slow to respond. My certification history was correct. But no option for SCJD assignment upload.
I sent an email, for step-by-step instructions on how-to upload assignment in the new CertManager system, to:
Do post their response on hearing from them. I will do the same.
I am ready to upload my assignment but on logging into the new CertManager system, I found no option for uploading it. Anyone else faced a similar problem? Any suggestions?
Developed my project on Windows XP platform using SDK 1.4
While testing the client on Unix machine (running SDK 1.4) I get the following warning:
Warning: Cannot convert string "-monotype-aerial-regular-r-normal--*-140-*-*-p-*-iso8859-1" to type FontStruct
Amazing thing is that nowhere in my client (or for that matter on server) am I specifying any font! Any suggestions on how to deal with this warning?
Thanks for your suggestions.
16 years ago

How are you proposing to handle the recordCount issue? A question I asked on my thread was whether or not changing the recordCount to a static member variable would violate Sun's instructions but I think that the class has to change regardless of whichever locking mechanism is deployed and was probably deliberately done that way to make the assignee make the decision and to record why. What do you think?

I thought since the add method is synchronized, there would be no problem there. Why do we need additional handling here?

In my DBAccess interface lock methods are included. Not the case in your assignment ?

The way I thought about it was: lock/unlock are functionalities not required in the local access hence my DataAccess interface had all public methods of Data class with the exception of lock/unlock public methods. I have a RemoteDataAccess interface which has lock/unlock public method signatures and my RemoteData class implements this interface and implements these methods.
But the more I think of it, the more I like your suggestion Phil. I think I should implement the lock/unlock methods in Data class and use them from RemoteData class and not use them for LocalAccess, since anyways I am using object composition and Adapter pattern rather than extending the data class to use its methods for Local and Remote access. Would appreciate it if you could point out issues I am overlooking here, in this approach. Thanks.
What does everyone think of this approach?
Thanks for your responses Max, Svetlana, Mark, Andrew and Phil.
I am discussing these ideas as I implement the logic and this discussion here brought to light many issues I wasn't even aware of.
Thanks Phil for the code example. I was planning a similar approach regarding the record number being stored in the HashMap as an object so that multiple databases are possible with my assignment implementation. Just to clear up a doubt though, when you talk about "multiple tables" - I am assuming you are talking about multiple databases. Am I right?
Phil, the reason I am implementing my lock/unlock functionality via a static HashMap is because its fairly simple to understand. There is no need for a separate LockManager, there is no need to make or use Data as a singleton to ensure that all remote clients use the same Database. Is this not reason enough to take this approach? I am asking this because apparently in your documentation you used weak references and reference ques as additional justification along with the simplicity of this approach.
Phil, when you say "I had to play with WeakReferences stored in a regular HashMap, with a ReferenceQueue", you mean in your implementation you wrapped the Data and Record objects as WeakReference objects and used WeakReference queues? Why would you do that? In addition to added complexity to code, isn't using WeakReference for our case a little risky?
From my understanding of WeakReference (correct me if I am wrong - don't know much abt this) - "a WeakReference object can be collected by the garbage collector if no OTHER part of the program is using that object, since we could always retrieve that object from permanent storage" - doesn't this mean that while our WeakReference object is in the HashMap if no OTHER part of our program is using that object, the object would be garbage collected (even if JVM is NOT running low on memory). This requires us to add additional code to first check if the WeakReference object has been garbage collected and if it has, than retrieve it from database file. Now what if both the key and the value are garbage collected? Maybe my understanding of this package is faulty. Would appreciate it if you could throw some light on it. Thanks.
Max: "True, it doesn't scale as easily as the LockManager, but I don't think that what Kim's concerned with here, and the SCJD doesn't grade on scalabilty: only clearity and simplicity."
Max, how is this approach not scalable? You are right I had not thought about the scalability issues here.
Max: "Absolutely. However, Mark's LockManager, as I understand it, sits outside of the Data class. It's not delegation at all. In the designs that Mark has advocated in the past, the lock/unlock methods are left un implemented."
Max, I leave the lock/unlock methods provided in the Data class provided by Sun M. unimplemented too! For my remote data access, I have RemoteDataAccess interface that has the lock and unlock method signatures and it extends both Remote and DataAccess interfaces (where DataAccess interface has all the public methods of Data class except the lock unlock methods). There is a RemoteData class that extends UnicastRemoteObject and implements RemoteDataAccess and Unreferenced interfaces. It is in this RemoteData class that I am implementing the lock/unlock methods! Am I correct in understanding from your statement Max that the lock/unlock methods should be implemented in the Data class and in my RemoteData class simply use these methods where as in my LocalData class NOT use them?
Andrew, yes I am doing the FBN assignment.
Andrew: "Now since each connected client has it's own instance of the Data class, this means you will have to consider changing the add() method. If you leave it unchanged from what Sun provided, it will not work correctly in multi user mode."
Andrew, I guess what you are saying is I would have to either synchronize or lock the database and let only one client add records to the database at a time? In that you are right, I would have to take into consideration that multiple people might want to add records to the database concurrently.
Thanks all very much.
Thanks for your response Max and Svetlana.
What I have done so far in my RemoteData class: I have a Data object in the RemoteData class which implements DataAccess interface (which has all the public method signatures of Data class). In my implementation of RemoteData class's public methods (inherited from DataAccess interface), I call respective public methods of Data class on the data object. I plan to implement the lock/unlock functionality in the RemoteData class.
I plan to use object composition for Local access also. I intend to have a LocalData class which shall have a Data object. Only this class won't have any need to implement the lock/unlock functionality and would be very straight forward. I could use the Data class directly but I prefer to have a separate class to implement the criteriaFind method because I don't think this method belongs in Data class.
I have modified Data class ONLY to get rid of the deprecated method calls.
I read your responses in other topics on lock/unlock functionality and have decided against a separate LockManager class. I plan to implement the lock/unlock functionality in the RemoteData class, itself. I have a static HashMap object to keep track of the Data object and the record number required to lock. Now each remote client gets a copy of their own RemoteData hence indirectly a copy of Data object. When the client requests to lock a record, I add the record number as key and client's data object as value to the static HashMap variable. This makes sure that when unlocking, only the client who locked the record should unlock it.
I am still working on the lock/unlock code. Would appreciate if you can point out any holes you see in the design or lock/unlock logic. Thanks.
I have all the public methods of Data class in a DataAccess interface. My data class implements this interface. I have a LocalData class that has a data object (trying object composition here) to get local access.
For my remote data access, I have RemoteDataAccess interface that has the lock and unlock method signatures and it extends both Remote and DataAccess interfaces. There is a RemoteData class that extends UnicastRemoteObject and implements RemoteDataAccess and Unreferenced interfaces.
Now I have two options (from what I see): I could either copy and paste the code of public functions of RemoteData class (inherited from DataAccess interface) from Data class, since (correct me if I am wrong) the code for public functions doesn't change except for the Lock/unlock methods (that need to be implemented only for remote access). But this option is NOT good since we are replicating a lot of code which already exists.
The other option I have is data composition, I could have a Data object in my RemoteData class and call all the public methods of Data class from the respective public methods of RemoteData class (inherited from DataAccess interface). This doesn't require data replication of any existing data. I like this option but is this a good design? What are my other options? I am a newbie where design is concerned. Would appreciate some feedback and comments from ALL.
Please reassure me.....
I am planing to give the exam in 1'st week of sept. Is there
anychance of any change in the exam objectives /pattern??
- Thanks