File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Is it ok to NOT taking care of client crash? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Is it ok to NOT taking care of client crash?" Watch "Is it ok to NOT taking care of client crash?" New topic
Author

Is it ok to NOT taking care of client crash?

Jin Zhang
Greenhorn

Joined: Jan 15, 2004
Posts: 28
Hi Ranchers,

I do not want to take of client crash in my code, because it is not required in the docs and the chance for one client to crash with a locked record is pretty low.

Is it ok? Anybody passed the exam without taking care of it?

Thanks.

Cheers,
Zhang Jin
Serkan Yazici
Ranch Hand

Joined: Apr 24, 2004
Posts: 33
Hi Jin,

I didn't implement any checks for client-crashing in my server code and didn't lose any marks for that. However I have mentioned this in my design choices document.

-- Serkan


-- SCJP 1.4 (98%), SCJD (98%), SCWCD (96%), OCA Dev (97% avg.), SCBCD (97%), SCJP 1.5 BETA (90%)<br />-- OCP Dev (maybe), MCDBA (probably) SCEA (eventually)<br />-- Haven't tried Firefox yet? Free, open, secure, fast, tabified, and slick!<br />-- <a href="http://www.mozilla.org/products/firefox/" target="_blank" rel="nofollow">http://www.mozilla.org/products/firefox/</a>
Denis Spirin
Ranch Hand

Joined: Mar 22, 2004
Posts: 72
If you mean "dead cliens", ie when client crashes while record is locked, then it is better to handle such situation. In my design I handled it and get 80 / 80 on locking mechanism.
[ June 04, 2004: Message edited by: Denis Spirin ]

Regards<br /> <br />Ph.D.<br />SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD 2
Jin Zhang
Greenhorn

Joined: Jan 15, 2004
Posts: 28
Hi,

Thanks both of you!

80/80, wow! Pass is enough to me I think. Do not want to spend too much time on it. So... Serkan, may I know your score for the locking portion?

Cheers,
Zhang Jin
Stephen Galbraith
Ranch Hand

Joined: Oct 27, 2003
Posts: 90
I think that to max out in the locking area you MUST have a mechanism that will prevent the locking of a record if the client crashes out. I did this by using a thin client design with the unlock on the server in a finally block.

Also document your descision.

Steve.
(I too got 80/80 locking)


SCJP 1.4, SCJD, SCWCD 1.4
James Turner
Ranch Hand

Joined: May 10, 2004
Posts: 194
Can anyone tell me how it is best to implement this client crash issue? I'm pretty stuck.

Thanx for any help.

Jarvis


James<br />SCJP 1.4 - 92%<br />SCJD - 93%<br />SCWCD 1.4 - 95%<br />SCBCD 1.3 - 100%<br />SCEA - 92%
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11460
    
  94

Hi Jarvis,

If you implement a thin client (so the client calls a "book" method on the server which does the whole "lock - verify - update - unlock" process, then you should never need to deal with dead clients.

However if, like me, you think the client should be handling the booking process, then there is the potential for a client to die before disconnecting. (For more on the whole fat client / thin client issue, see the long thread "Should lock methods be callable by the client").

The easiest ways to handle this involve setting up a connection factory on the server. This way, each client will have a unique instance of the remote class which provides all the functionality. You then have two ways of handling client death:
  • Implement the Unreferenced interface, so that the instance of your remote class will eventually be notified if the client dies - you can then perform any clean up operations.
  • Use the instance of the remote object as the key in a WeakHashMap (with the object in the map being the lock), so that when the client dies, the lock will automagically be removed from the map (you may want to have an extra thread monitoring the status of the map).



  • I have deliberately not gone into detail on any of these - have a think about them, and see if you can work out how to move forward with them.

    Regards, Andrew


    The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
    Serkan Yazici
    Ranch Hand

    Joined: Apr 24, 2004
    Posts: 33
    Originally posted by Jin Zhang:
    Hi,

    Thanks both of you!

    80/80, wow! Pass is enough to me I think. Do not want to spend too much time on it. So... Serkan, may I know your score for the locking portion?

    Cheers,
    Zhang Jin


    I've got 80/80 as well (without crashed client detection).
    [ June 11, 2004: Message edited by: Serkan Yazici ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Is it ok to NOT taking care of client crash?