Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

Yu Sun

Greenhorn
+ Follow
since Nov 06, 2006
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 Yu Sun

Hi everyone,

I just got email from Sun this morning that I passed the SCJD.

I finished everything on 5/21/2010, and around 7/21/2010, I sent them email to ask the result. However, I got the same request to resend the Jar file, which was disappointing. After sending the file again, on 8/9/2010, they informed me the result.

However, it seems that they do not provide the numeric score right now:


Congratulations! You have passed the Sun Certified Developer for the Java 2 Platform certification. You are among the elite 1% of certified Java professionals who have gone on to achieve the Sun Certified Developer for the Java 2 Platform certification.

You have received a passing score. Passing grades do not receive a score, just the pass. A failing grade will receive section level scoring so that a candidate may isolate the area of failure and resubmit their assignment. Numeric scores are only provided on failures.



I am wondering are there anybody passed the exam recently who also got their scores?

BTW, how do you understand the "1% of certified Java ...."? Is this a generic template letter, or does it really mean the percentage?

Anyway, it is good news, although I have to wait for two and a half months.

I want to thank you all you help.

Good luck to everyone.

Yu
10 years ago
Thanks a lot, guys.

I also have that "must" requirement for my assignment, so I just generated it.

Yu
Thanks Carlos. I guess I am ready to submit

Yu
Hi guys,

I tested my project a lot and it works well. However, I just found that in Andrew's book, it also mentioned using rmic tool to generate the stub.

What is the purpose? Do we need to use this?

I made the RemoteServiceImpl extending UnicastRemoteObject, and register the RMI using the regular approach.

Thanks.

Yu
Thank you, Carlos. That is so clear. And I like the idea of how you handle exceptions.

Thanks again.

Yu
Hi guys,

I am almost done with my project and doing the final check. I would like to ask some questions to make sure it is correct:

1. There is a Magic Cookie Value in the beginning of the file, I use it to check if the file selected is a valid database file for this application. I think this is a fixed value for my application, right? For example, I read the file Sun provided, and this value is 513, then I just use 513 to decide if a certain file is valid or not.

2. There are two Exceptions required to implement - RecordNotFoundException, and DuplicateKeyException. I only put two constructors in this two classes as mentioned in the instruction - one without argument, the other with a String argument. Is this OK? Is there anything else we need to do in the Exception class?

3. When handling the Exceptions in the project, I just throw the Exceptions from one class to another, and catch them in the end out side. And, in the catch block, I just simply printStackTrace(), is this OK?

4. I have a configuration window for Network-mode Client to setup the host address and port before the main GUI. I also have a different configuration window for Standalone application to setup the location of the database file before starting the main GUI. Is this OK? Do we need to merge these two windows? Because in the instruction, it says

Non-networked Model
... Architecturally, this mode must use the database and GUI from the networked form, but must not use the network server code at all.
...
Network Approaches
...the program must allow the user to specify the location of the database, and it must also accept an indication that a local database is to be used, in which case, the networking must be bypassed entirely.



5. When I test my program now, I need to run "start rmiregistry" first. Do we need to somehow make this also in program?

Thanks a lot.

Yu
That confusing expression was my bad.

Thanks again for you patience, Roel.

Yu
Hi Roel,

I did three separated synchronized blocks as you did, so trust me that I understand your design correctly this time.

I printed out the lock table when running Robert's test program, and you can see that in the middle, multiple locks are in the table; you can also find that some other thread will start locking another record before one thread trying to update or unlock a certain record; another proof is that if we do not check the rec validity twice, we might incorrect try to lock an deleted record.

So you mean this (using synchronized atomic block) will be ok for Sun's test, right? And for the standalone version, we can just use the same version of Data and provide an Id, or we do not even use lock / unlock in the standalone version?

Thanks.

Yu

Hi Roel,

Thanks a lot for your direction. I spent another day working on my locking. And finally I got my code passed the Robert's testing program. I was actually writing last post to confirm some of my understanding. I had some thoughts in mind, but just not 100% sure, so I tried to take advantage of you to confirm my understanding, which is not very good as you mentioned

Later, I checked some more references and tested the code a lot, and I confirmed my understanding by experiments. I applied your approach of considering setting client Id and lock / unlcok / update as an atomic operation, which works well.

Here is one more issue I want to confirm with you:
- when using the Robert's test program, I replaced the lock() / update() / unlock() with synchronized { setId(); lock() / update() / update() } blocks, and got the correct results, I think this change is reasonable according to our design, right?
- however, I am just concerned that whether this will pass Sun's automatic test. What if they don't use synchronized { } block with setting Id to test the lock() / update() / unlock(), although it will still work with a singal default clientId.

Thanks again.

Yu
Sorry Roel. My description is a little bit unclear. Maybe there are too many things to consider about locking and I got confused.

I just checked more posts, and getting a little bit better. However, let me ask a question directly on this code from here



Now I understand both synchronized(data) parts in the beginning and the end. But what about the // Do work part?

I think it should be:



correct?

If this is correct, in the update() method, we should also check in a way something like this:


My question is: we execute data.setClientId(null) after the locking, how could Data read the clientId again when it execute the update() method? Should I do something like this in // Do work part: ?



Thanks again.

Yu
Thanks Roel. The code sample you gave makes sense. However, the lock() in my Data interface does not return any value. And obviously the update() method does not have the third parameter in the interface. How should we handle this?

Yu
Thanks Roel and Raf. Now I understand what kind value can be used.

Now, I just want to confirm that after we generate the value in the lock method, we need to store it not only in the lock hashtable or map, but also in the client, right? If so, the client, the lock manager and the update() / delete() methods would probably need to communicate with each other, what is the common design on this?

Specifically
- after we generate the value in lock(), how and where to store it in the client, GUIController?
- if we want to check whether the record is being locked by a certain client in update() / delete(), how to access the current client's value?

I checked a lot of post, but did not find what I want. Thanks a lot.

Yu
Hi guys,

I have been reading the posts about locking for a while, and I have got the basic idea. I just want to clarify one thing and ask one question:

In lock() / unlock(), we need to generate a cookie value and put it together with the recNo in the lock map; In Update() / Delete(), we need to check if the current record is being locked, as well as if this current record is being lock by the same client thread. Correct?

If this is correct, then Question:

Why do we usually use System.currentTimeMillis(), or nanoTime()? In other words, how such a timing value can be used to identify a client thread? If we use Thread.getId(), I can understand. But if we use System.currentTimeMillis(), that means that we will store this value in the client class as an attribute after generating it, right?

Thanks.

Yu
Thanks Roel. Those are very good and helpful comments.

Yu