Re: RMI cleanup
Carl Cook <[email protected]> Thu, 30 Apr 2009 17:21:49 +1000
| Newsgroups | gmane.comp.java.sun.rmi |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I am not sure what RMI is doing (or not doing)... or for what matter the
Java GC is up to, but your approach will probably benefit by refactoring the
threading code slightly.
At present, for each client, you have a thread in a busy wait loop.
Regardless of the number of processors available, this is going to be
problematic from a scalability aspect.
Have you considered instead of sleeping to wait on a signalled object?
You could, for example, try this:
private object waitObject = new Object();
catch (Exception ex)
{
synchronized(waitObject)
{
waitObject.wait(1000);
}
}
A good primer is here:
http://tutorials.jenkov.com/java-concurrency/thread-signaling.html
The java concurrency/threading tutorials are also very good.
As for having thread handling code in an exception handler, this is quite
interesting as well, and perhaps could be avoided.
It would be interesting to refactor your code and then see if you even run
into these problems again.
I hope this helps!
--
Carl
2009/4/30 mvanr <[email protected]>
> I recently had a problem where a dual quad-core xeon was brought to its
> knees
> and this was traced back to RMI clients experiencing an io exception, and
> repeatedly retrying the operation every second. Here's the code:
>
> while (true) try
> {
> if (remote == null) try {
> remote = (T)Naming.lookup(serviceName);
> }
> catch (Exception ex) {
> throw new RemoteException(ex.getClass().getName() + ": " +
> ex.getMessage());
> }
> op.exec(remote);
> return;
> }
> catch (IOException ex) {
> remote = null;
> Thread.sleep(1000);
> }
>
> The call to naming lookup was succeeding. The call to op.exec just
> translates to a call of a method on the remote object, and that was
> throwing
> a host not found exception due to a misconfiguration on the server.
>
> I would have expected the discarded remote objects to be cleaned up shortly
> after the exception, but it seems that they are not. What's worse is that
> they continue to consume CPU. Half a dozen of these java programs caused
> the load on the server to get close to 1000.
>
> Does anyone know how best to avoid this? I would prefer an in-code
> solution
> to a command line argument to java, since the latter could always be
> forgotten.
>
> Thanks.
> --
> View this message in context:
> http://www.nabble.com/RMI-cleanup-tp23310928p23310928.html
> Sent from the Java - RMI mailing list archive at Nabble.com.
>
> ===========================================================================
> To unsubscribe, send email to [email protected] and include in the
> body
> of the message "signoff RMI-USERS". For general help, send email to
> [email protected] and include in the body of the message "help".
>
> For a list of frequently asked RMI questions please refer to:
> http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html
>
> To view past RMI-USERS postings, please see:
> http://archives.java.sun.com/archives/rmi-users.html
>
===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS". For general help, send email to
[email protected] and include in the body of the message "help".
For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html
To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html