Using JDB for Fault recovery

Hi,

I am analyzing the possiblity of using the JDB in our J2SE based application server for status monitoring and fault tolerance (MFT in short). Here are a few queries I have before I can dig deep into using JDB.

1. Is it best to use the JDI for application monitoring. Else, which is the best option. I think JVMPI would be very heavy.

2. The MFT will be enabled by default. Hence, it is important that it does not affect ny application's performance much.

3. The MFT must have options to enable and disable it completly at run time.

4. If JDB satisfies the above mentioned criteria, is it possible to start the JDB in the same JVM as that of my server instead of launching my server from JDB.

Looking forward for your help or pointers in these areas.

Regards,

CyberTeT.

[828 byte] By [CyberTeTa] at [2007-9-29 20:09:26]
# 1

> 1. Is it best to use the JDI for application

> monitoring. Else, which is the best option. I think

> JVMPI would be very heavy.

JVMPI was an experimental interface that will not be around

in the long term. The replacement interface for Profiling,

Debugging, and Monitoring & Management is called JVMTI

(JVM Tool Interface). The design and development work was

done under JSRs 163 (Profiling Architecture) and 174 (Monitoring

and Management). For more information, take a look at :

http://www.jcp.org/en/jsr/detail?id=174

http://www.jcp.org/en/jsr/detail?id=163

For an overview of JDI, you may want to study the diagram

in this Architecture Overview document:

http://java.sun.com/j2se/1.4.2/docs/guide/jpda/architecture.html

> 2. The MFT will be enabled by default. Hence, it is

> important that it does not affect ny application's

> performance much.

You will have to test your application and measure whether

the impact will be acceptable. It should be. Take a look at

this white paper:

http://java.sun.com/products/hotspot/docs/whitepaper/Java_HSpot_WP_v1.4_802_3.html

> 3. The MFT must have options to enable and disable it

> completly at run time.

The current Java Debugger Interface (JDI) is enabled or disabled

at VM start up time. Refer to "Connection and Invocation Details"

http://java.sun.com/j2se/1.4.2/docs/guide/jpda/conninv.html

This restriction will be removed in the future, via JSR 163.

> 4. If JDB satisfies the above mentioned criteria

JDB is a simple command-line debugging tool that demonstrates

use of the JDI (Java Debug Interface) API. It would be a good idea

for you to study all of the examples listed on the "Example JDI Applications"

page:

http://java.sun.com/products/jpda/examples.html

The demo code is available in your SDK installation, under

$JAVA_HOME/demo/jpda. Just unpack examples.jar to look

at the demos, compile them, and run them.

>Is it possible to start the JDB in the same JVM as that

> of my server instead of launching my server from JDB.

This is not recommended because it will usually lead

to deadlocks and hangs. Refer to this question in the FAQ:

"Why do debugger applications run in a separate VM from the debuggee?"

http://java.sun.com/products/jpda/faq.html#IA3

If you run your monitoring agent in a separate, standalone VM, other

advantages would be:

1) It could run on a separate machine

2) It could be designed to monitor multiple VMs running your application(s).

3) A fatal bug in the agent will be less likely to take down your application

debugging_teama at 2007-7-16 0:22:47 > top of Java-index,Archived Forums,Debugging Tools and Techniques...
# 2

Hi Debugging team,

Sorry for my late reply and Thanks a lot for your comments. I am currently doing a small POC and would like to get more informations.

1. Is is possible to get all the reference of an object. For instance, assume I have a class A that is created and used in many other classes. Now, I would like to get the reference of all the instance of A (all private and protected instances also) so that I can invoke a few methods on them. Is it possible in JPDA and any code snippet for the same is appreciated.

2. For the performance related query, I tested it by enabling JPDA and running my server (using -Xrunjdwp). The performace impact was about 7% even without monitoring (its a huge than I expected). On monitoring the method entry request of a single class (say B), the performace hit was multifolds and the CPU usage of my server was very high. Any suggestions to minimize the performance impact?

BTW, is JVMTI available only in JDK 1.5. If it is so, it may not be possible for me to wait for JDK 1.5 release. Any way, I will keep a note of it and it may be useful for my next version.

Thanks for your help.

CyberTeT.

CyberTeTa at 2007-7-16 0:22:47 > top of Java-index,Archived Forums,Debugging Tools and Techniques...
# 3

I only have answers for 1.5. With JVMTI, you can Tag a jclass object, then traverse the Heap and find all objects that are instances of that class. Pre 1.5, you would need to look at JVMPI, which is a dead end feature, or look at JVMDI and RedefineClasses().

Monitoring by way of method entry will be expensive unless you do something like BCI on the class of interest. You would inject a call to some static method into the bytecodes of the method of interest, then you can do whatever you want in that static method to track time etc.

You should also look into:

http://java.sun.com/j2se/1.5.0/docs/guide/management/index.html

kellyohaira at 2007-7-16 0:22:47 > top of Java-index,Archived Forums,Debugging Tools and Techniques...