This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Testing client crashes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Testing client crashes" Watch "Testing client crashes" New topic
Author

Testing client crashes

Ricardo Estafan
Ranch Hand

Joined: Mar 29, 2004
Posts: 84
Hello all,

this is not supposed to be a discussion on what to do with client crashes.
I have implemented a LockManager and in it i remove dead clients on certain occassions. Her is a piece of my code that shows how i do this :



I use eclipse to build debug etc. When i start multiple clients and kil one they have the same Thread, which means the thread is still alive. So i cannot test the removal of dead clients. Can someone help me with this one?!!

Thanks!!
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
hi Ricardo:
You need to start each client in different VM. For example, from the command prompet you can launch the server. Then, open a new command prompet window for each client, launch the client then test.
I used this technique to test my server and locking.


SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Ricardo Estafan
Ranch Hand

Joined: Mar 29, 2004
Posts: 84
Does anyone know hot to accomplish this in Eclipse? I tried to start Eclipse two times, this isnn't possible. Or else how can i debug when i start the application from the command line?

Thanks!!
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Hi Ricardo,

I assume you are using RMI (since if you were using sockets, you would be creating the threads yourself, and this issue wouldn't even arise).

However you cannot use the thread number within RMI as a client identifier. According to the Sun RMI Specification:


A method dispatched by the RMI runtime to a remote object implementation may or may not execute in a separate thread. The RMI runtime makes no guarantees with respect to mapping remote object invocations to threads. Since remote method invocation on the same remote object may execute concurrently, a remote object implementation needs to make sure its implementation is thread-safe.


The behaviour you described is allowable under the specification, even if each of your clients was working on a separate computer (so 3 computers / 3 JVMs).

It is also quite possible that with only one client connected, it's call to lock() could be handled by one thread, it's call to update() could be handled by a different thread, and it's call to unlock() could be handled by a third thread!

This is why we generally recommend using a connection factory on your server if you want to handle client death scenarios. It is one of the simpler ways to handle this.

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Testing client crashes
 
Similar Threads
How to run multiple Threads in Eclipse?
B&S logical record locking
FBNS: Final locking architecture, comment please...
NX:Client crashed cause deadlock in LockManager
consumes no CPU cycles solutions...