ghanshyam sharma

Greenhorn
+ Follow
since Jan 05, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by ghanshyam sharma

Thanks all you guy...
Salman, sorry for late reply, I am working to join a business school, so busy with GMAT, too bad javaranch doesn't have a GMAT thread....
-Sharma
20 years ago
Just wanted to thank everyone in the forum.
Also I lost allthe marks in Network Server and General Consideration. I had used Max's book to design the server. Probably should have done some more work on it.
I am a bit uncertain about what general considerations means. Anyway, with a very busy schedule around I am just thankful that I could get a pass on this.
Again I highly appreciate everyone in the forum for bringing forward so many important issues. It was of immense help in designing my assignment.
Best of luck to everyone else there.
-Sharma
20 years ago
Hi
Can some one point me to a thread discussing what sort of questions are asked in the written exam for SCJD ? I have cleared the SCEA and there the questions were totally about the project, no theoratical questions. I believe the same should apply to SCJD too.
Any information will be appreciated.
-Sharma
I use the following code to start the registry.
java.rmi.registry.LocateRegistry.createRegistry(port);
surprisingly if I use any other port except 1099 I get an exception. The message says Connection refused to host <my ip address>. [java.net.ConnectException]
Thanks for your help already.
-sharma
Hi Guys
Somehow I can't make my server use any other port then 1099, the default RMI port. Any clues as to what I am doing wrong ???
Thanks.
-Sharma
Hmm, I would say you convinced me into using combo boxes for the search fields... Thanks a lot dude...
Too bad I cant put a tool tip saying "Dedicated to Andrew" when the customer crosses over my combos Just kidding... I appreciate your detailed responses very much.
-Sharma
Hmm tell me if I have trudged into some unknown area here but here it goes
In my implementation, and somewhat required by the Requirement Specification, [as i understand] My server does not keep track of the clients directly. (Whatever that means). When the client acquires a lock, he gets a UUID type of a cookie in return, which he requires to use to modify/unlock that particular record, as long as some clients comes up with the right record number and the identification cookie, he is a valid [should I say not dead/Alive !!!] client....
So I have no way but to build a server centric, timestamp based lock expiration strategy. I also keep timeout setting in a prioerties file so the Customer can adjust lock timeouts as per his requirements. A value of say 30 seconds is not going to hurt the clients who have something like a power breakdown I guess...Offcourse lost connections are different beasts and I dont think I should think so much about them....
Frankly I am trying to have some fun here while I finish this assignment
Thanks guys.
-sharma
Hmm, good question.
Like lets say I am synchronizing on a hashtable X and inside the synchronized block I check the presence of a key/value pair in the hashtable using if statement, now since I have already acquired a lock on the hashtable using synchronized statement, even if I get sliced out inside this if statement, my code is 100 % right about my if statement condition. I mean I cant possibly have this particular statement changing the condition value on thread slice.
like
Synchronized (X) {
if ( X.containsValue("HAHA") ) {
//Do Something
}
}

what do you say ?
-sharma
Hi guys.
Even though I am 100 % sure that my if conditions wont get effected due to thread slicing, still is it a bad programming practise to use if statements in synchronized blocks ???
If my dumb mind still remembers correctly Max's book didnt like it at all
-Sharma
Hmm, is there a way to controll the time intervals for lock expiration using WeakHashMaps ??? Unreferences Interfaces wont be usable for some of the requirement specifications out there ...I dont think there are though...
-Sharma
Thanks a Lot Andrew. I very much appreciate your detailed response. Guys like you make this forum real productive.

Well I agree on your coments on using locks in local mode too. Infact thats how I have already build and justified my implementation.
The timestamp is not a key. The timestamp is just a way to keep track of the locks creation or AGE. I have a seperate utility class which generate unique long numbers (Required as cookies in my assignment ) which keep track of the clients. So that part is not a concern. I wanted to clearely define the expiration interval using a default value of maybe 30 seconds which can be overriden using a value from a properties file. Using lazy removal of expired locks from the hash table is a rather very simple process and I have already implemented and tested it successfully. The only concern left is throwing the right message to the client whoes lock is expired but who still want to do something with that lock. Right now he just gets a illegal access exception, but If I wan to give him a very accurate error message including his lock expiration, I will have to add some more code. [This goes towards an overkill I guess !!!]
It is not required by my assignment but I dont know how can you implement a locking solution without a lock expiration strategy, and I am just going for the best that I can think of.
Another thing I am not very comfortable about is using Combo Boxes for search fields. In commercial solutions search fields seldom use combo boxes [or am i a morone ???] If the JTable is already displaying all records when the applications starts, why do we need to use combo boxes for search.
-Sharma
Also I am planning to build a lock expiration mechanism but am unsure as to how ??? Using WeakHashMap doesn't sound like a simple idea. I am trying to build a lazy expiration where a lock expires if not used for a given time interval + now the record is required by another client . I guess my decision to delegate locking to a seperate LockManager is going to help me here since It would avoid the Data class code getting too complex ??? Dont know if I am missing something here :roll:
-Sharma
Very interesting discussion guys thanks for stimulating my brain.
I would like to make a few comments about my implementation, may be it beings up new ideas or maybe it exposes some holes in my implementation.
I have fully implemented add() [createRecord() in my assignment], I have introduced a new method called lockNewRecord() which is internally used by the implementation class to generate the next available record number and lock it for record creation. This way no other creation can interfere with a particular record creation. Although the GUI doesnot use this method but SUN SPEC says we have to implement it so I did.
I have not implemented the file level code in the Data class itself. I have a DataHelper class which has the low level code for everything, and then the Data class calls the methods from this class. Also all Record Locking code lies in the LockManager class and the Data class delegates locking to LockManager class. The reason for this design is that I do not want the Data class to have too much code, whic will create difficulty in maintenance, and also OOAD techniques support seperation of functionality into cohesive units [I got a 97 is SCEA , but am unsure of my approach here since sun instructions are rather vague ].
Although I am a bit doubtfull about not using lock unlock functionality in the local mode !!! If you think from a futuristic point of view, any functionality addition on the server side will have a big problem if we do not use locking. In the future we may need to henhance our design for various reasons [after all we all implementing a database syste !!!] we may need parallel implementation of things which may screw up due to lack of locking ??? Does my reasoning sound overkill.
In locks I define a lock with a record number and a timestamp and is stored in the hashtable with a key = a very unique cookie generated from a helper class. I can always enhance lock class to include table names to provide acces to multiple tables, so my design is okay as far as future enhancement is concerned ...Any comments here ???
I will write more as more issues cross my mind.
-Sharma
Hi guys.
How do you guys manage lock expiration. If a client goes down after locking a record, the record should expire after a given time period I guess ?
I am planning to store a timestamp in the lock and whenever a given lock is old enough clean it up. Do you guys have a silent thread working in the back ground, cleaning locks or something like that ???
I would appreciate if you guys can throw in some ideas here.
Thanks Already.
-Sharma
Does anyone have an idea regarding this.
The assignment mentions a set of methods as the interface that one MUST implement. Is it possible to add some exceptions to the throw clause of the interface methods without loosing any marks ???
Here is the reason. Using I am trying to have the RMI server s well as the local server return the server class with the same interface which the client can use invisibely. which means I am trying to use the same interface to build my Remote Server as well the local database class. The problem is that using RMI, the remote server implementation needs to throw RemoteException for every interface method that it implements.
Now if I am using the same base interface, the base interface should also throw RemoteException.
If I do not go this way I will have to return different type of objects in case of remote server implementation as compared to teh local server implementation which doesn't sound very good to me ...
Only way is to change the interface and add something like java.io.IOException to every method. Now since RemoteException is a subclass of IOException, I will be able to use the same interface for both local implementation and the remote implementation. My only doubt is does this voilate the MUST condition in the requirement spec ???
Thanks in advance...
-Sharma