Monday, November 15, 2010

Ad4j (JVM Diagnostics) vs OCAMM (ADP)


Both AD4J (JVM Diagnostics) and OCAMM (ADP) are application performance mgmt solutions. Both of these focus on java-j2ee applications diagnostics.  Often we come across this question, how does one know which solution should be used where? What is the underlying technology? Though there is some common functionality overlap between these solutions. But in general, functionally and technically, both the tools are very different.

Similarities:
  1. Both of these solutions focus on java-j2ee applications diagnostics.  
  2. Both the solutions have their respective agents that need to be deployed on the target app server that one wants to monitor.
  3. Both have similar architecture like manager, agent and UI. Where agent is deployed on target app server (JVM), monitors its activities, gathers data and sends it to respective manager. Manager in turn processed data and collect it in repository. UI displays the entire data.

Let me list some of the differences:
  1.  Ad4j focuses primarily on exact response time and invocation count(cost/sample) metrics for service-layer constructs (methods/requests), but is limited in its ability to view arbitrary method metrics. However it does not have any higher level(application) context in relation to metadata constructs such as BPEL, WLI, or Portal. While CAMM focuses primarily on these higher-level constructs, but is limited in its ability to view arbitrary method metrics. Therefore, the two solutions actually compliment to each other .
  2. Ad4j focuses on JVM level diagnostics. It shows top methods, top requests, top DB states and Top SQLs for a set of JVM(s). It has limitation in terms that it cannot relate these methods/requests to application at high level. While CAMM knows application components and models(like  WebCenter, Spring Beans, Composites, OSB, Web Services etc.) and can relate data with it.
  3. On deploying ad4j agent, it starts showing real time data for a particular JVM like its real time thread system and memory system of a JVM.   When ADP is deployed to a Oracle WebLogic domain, IBM WebSphere cell, or an Oracle SOA Suite cluster, it automatically discovers information about this particular domain including all deployed applications, configuration, resources, and others. ADP displays this information in the Monitoring tab under Oracle Enterprise Manager.
  4. Ad4j is a sampling tool. It samples the JVM metrics and monitors the JVM, gathers data and then predicts trends and analyzes data. ad4j does runtime Objects analysis. It uses two techniques for monitoring JVM, a. native diagnostic technique and  b. JVMTI calls within JVM. While CAMM is a BCI(Byte Code based instrumentation) based tool. CAMM utilizes model-driven service management, a unique model-driven approach to application service management that automatically discovers and models the structure of J2EE and composite applications. 
  5. When deployed in production, ad4j claims less than 1% overhead while CAMM claims around 5% overhead. CAMM is also very useful in development environment.

In 11g, both the solutions have been integrated and in future plan is to integrate them with other products in Oracle middleware stack

Tuesday, November 09, 2010

ad4j/jam agent implementation methods for app server /standalone JVMs


ad4j agent can used to monitor any JVM. Be it an application server or a standalone JVM(Java applications).
This article explains the method to monitor standalone Java programs which do not have away of loading a servlet or another class. jamagent has "jamagent.jamrun" class that can be used for this purpose.

 For an application server, 11g jamagent.war can be deployed using one of the following two modes:
1. manual deployment of war file
2. automated deployment of war file on Target Weblogic Server

For an application server, 10g jamagent can be deployed using following mode:
1. manual deployment of war/ear file

For standalone JVM, 10g/11g, follow given steps:
1. Include the file jamagent.zip(jamagent.war in 11g) in the CLASSPATH
2. Change the java command line parameters to call the wrapper jamagent.jamrun as mentioned below.

Original command looks like:
%java $JVM_OPTIONS $TARGET_CLASS $TARGET_CLASS_PARAMS
Here JVM_OPTIONS are the JVM properties and options e.g. Xmx512M -Dweblogic.name
TARGET_CLASS is the program which being examined
TARGET_CLASS_PARAMS are parameters passed to the class

Modified command would be:
%java $JVM_OPTIONS jamagent.jamrun [$JAMAGENT_PARAMS_LIST] $TARGET_CLASS $TARGET_CLASS_PARAMS

ad4j/jam agent will use default parameters. If you want to change any of them, you can specify them as
name=value pairs. To specify a different manager/console and port you will specify
jamconshost=<hostname where manager/console is running>, jamconsport=<listen port of manager/console>

e.g. For Weblogic server,
Original command is:
% $JAVA_HOME/bin/java ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS} \
-Dweblogic.Name=${SERVER_NAME} \
-Dweblogic.ProductionModeEnabled=${PRODUCTION_MODE} \
-Djava.security.policy="${WL_HOME}/server/lib/weblogic.policy" \
weblogic.Server
The class being called is weblogic.Server. There are no parameters.

Modified command would be:
We are going to insert out class and parameters before that, so it will look like :
%$JAVA_HOME/bin/java ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS} \
-Dweblogic.Name=${SERVER_NAME} \
-Dweblogic.ProductionModeEnabled=${PRODUCTION_MODE} \
-Djava.security.policy="${WL_HOME}/server/lib/weblogic.policy" \
jamagent.jamrun weblogic.Server

If you want to change some JAM parameters you can specify them as
%$JAVA_HOME/bin/java ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS} \
-Dweblogic.Name=${SERVER_NAME} \
-Dweblogic.ProductionModeEnabled=${PRODUCTION_MODE} \
-Djava.security.policy="${WL_HOME}/server/lib/weblogic.policy" \
jamagent.jamrun jamconshost=abc jam_jvm_id=5001 weblogic.Server

Ensure that JAM Agent Libraries/Classes is added to the Classpath
Also ensure that jam/jamagent/WEB-INF/classes directory is added to the CLASSPATH.
It is best to do this just before the call to java.
Here we find a couple of lines above the call to Java.
# Start WebLogic server
CLASSPATH="${WEBLOGIC_CLASSPATH}${CLASSPATHSEP}${CLASSPATH}"
We change it to
# Start WebLogic server
CLASSPATH="${WEBLOGIC_CLASSPATH}${CLASSPATHSEP}${CLASSPATH}${CLASSPATHS
EP}/u01/app/em/jamagent/deploy/jamagent.zip"


Target Parameters
What about the -Dweblogic and other properties : You need to insert jamagent.jamrun just before
the calling program and it's parameters. This should happen after all the JVM options and
properties have been specified.

JAM Agent Input Parameters Description
jamconshost - em_console_host The host where JAM manager/console is running
jamconsport - 3600 The port ad4j manager/console is listening on
jamconsretr - 300 Seconds to wait before retrying broken console connection
jamtimeout - 900 Seconds to timeout for long operations
jamloglevel - 3 Level of logging. Valid values are 1-5.
jamjvmid - Server Port Unique Identifier for JVM, Default of 5555 for unrecognized
Servers
jammaxbackoff - 10 Amount of time to wait for long operations
jamdelaystartup - 0 Number of seconds to delay target program
jamisdaemon - false jamisdaemon=true will prevent the agent from exiting
Note: this parameter jamisdaemon=true should be set to true for jamagent to not to exit.