Search This Blog

Friday, August 16, 2013

Byteman Oracle JDBC Tracing

 

Extract byteman to a directory say , javac -cp lib/byteman.jar HelperSub.java 

First compile the helper class

javac -cp lib/byteman.jar HelperSub.java 

Make a jar file of this helper class

jar cvf HelperSub.jar HelperSub.class

Find the pid of the process 

jps -l
10065 org.apache.derby.drda.NetworkServerControl
14085
19782 weblogic.Server
20846 sun.tools.jps.Jps

Install the byteman agent to running jvm 

bin/bminstall.sh 19782

Load the heloper jar file

bmsubmit.sh -s /home/oracle/byteman-download-2.1.3/HelperSub.jar 

Load the rules

bmsubmit.sh  -l ../OracleJDBCTracing.btm 

run bmsubmit.sh with out any arguments to see whether it got loaded or not

to unload the rules use 

./bmsubmit.sh -u

Rules to trace Oracle JDBC Statements

OracleJDBCTracing.btm
## EXECUTION TIME #############
RULE OracleStatement Code StartTimer
CLASS  oracle.jdbc.driver.OracleStatement
METHOD  doExecuteWithTimeout()
HELPER HelperSub
AT ENTRY
BIND app1 = $0;
m2 = app1.sqlObject.getOriginalSql()
IF true
DO createTimer($0);
ENDRULE
RULE OracleStatement Code Insert AT EXIT StopTimer
CLASS  oracle.jdbc.driver.OracleStatement
METHOD  doExecuteWithTimeout()
HELPER HelperSub
AT EXIT
IF true
DO tracelnplain("Execution Time ("   + Integer.toHexString($0.hashCode()).toUpperCase() + ") : "+ getElapsedTimeFromTimer($0) +" ms");
deleteTimer($0);
ENDRULE
##+  $this.getOriginalSql()
RULE OracleStatement Code Insert
CLASS  oracle.jdbc.driver.OracleStatement
METHOD  doExecuteWithTimeout()
HELPER HelperSub
AT ENTRY
BIND app1 = $0;
m2 = app1.sqlObject.getOriginalSql()
IF true
DO tracelnwithdate(  " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") " +  " SQL : "+ m2  ) ;
ENDRULE
RULE OracleStatement Code Insert AT EXIT
CLASS  oracle.jdbc.driver.OracleStatement
METHOD  doExecuteWithTimeout()
HELPER HelperSub
AT EXIT
IF true
DO tracelnplain("-------------------------------------------------------------------------------- ");
ENDRULE
############# Get the Parameters from OraclePreparedStatement
HELPER HelperSub
RULE OraclePreparedStatement Code Insert setArray
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setArray(int,java.sql.Array)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (Array) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OraclePreparedStatement Code Insert setAsciiStream
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setAsciiStream(int,java.io.InputStream)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (AsciiStream) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OraclePreparedStatement Code Insert setAsciiStream 3 params
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setAsciiStream(int,java.io.InputStream,long length)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (AsciiStreamWithLength) P"  + $1 + " ==> " +$2 + " ==> " +$3  )
ENDRULE
RULE OraclePreparedStatement Code Insert setBigDecimal
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setBigDecimal(int,java.math.BigDecimal)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (BigDecimal) P"  + $1 + " ==> " +$2  )
ENDRULE
RULE OraclePreparedStatement Code Insert setBoolean
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setBoolean(int,boolean)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (bool) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OraclePreparedStatement Code Insert setByte
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setByte(int,byte)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Byte) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OraclePreparedStatement Code Insert setBytes
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setBytes(int,byte[])
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Bytes) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OraclePreparedStatement Code Insert      setCharacterStream
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD setCharacterStream(int,java.io.Reader)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (CharacterStream) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OraclePreparedStatement Code Insert      setCharacterStream 3
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD setCharacterStream(int,java.io.Reader,int)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (CharacterStream-With-length) P"  + $1 + " ==> " +$2 + " ==> " +$3)
ENDRULE
RULE OraclePreparedStatement Code Insert      setCharacterStream 3 long
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD setCharacterStream(int,java.io.Reader,long)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (CharacterStream-With-length) P"  + $1 + " ==> " +$2 + " ==> " +$3)
ENDRULE
RULE OraclePreparedStatement Code Insert setClob
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setClob(int,java.sql.Clob)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Clob) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OraclePreparedStatement Code Insert setClob Reader
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setClob(int,java.io.Reader)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Reader) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OraclePreparedStatement Code Insert setClob Reader 3
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setClob(int,java.io.Reader,long)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Reader-With-Length) P"  + $1 + " ==> " +$2 + " ==> " +$3)
ENDRULE
RULE OraclePreparedStatement Code Insert setDate
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setDate(int,java.sql.Date)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Date) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OraclePreparedStatement Code Insert setDate Calendar
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setDate(int,java.sql.Date,java.util.Calendar)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Calendar) P"  + $1 + " ==> " +$2 + " ==> " +$3)
ENDRULE
RULE OraclePreparedStatement Code Insert setDouble
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setDouble(int,double)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (double) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OraclePreparedStatement Code Insert setFloat
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setDouble(int,float)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Float) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OraclePreparedStatement Code Insert setInt
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setInt(int,int)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (int) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OraclePreparedStatement Code Insert setLong
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setLong(int,long)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (long) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OraclePreparedStatement Code Insert      setNCharacterStream
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setNCharacterStream(int,java.io.Reader)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (NCharacterStream) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OraclePreparedStatement Code Insert setNCharacterStream long
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setNCharacterStream(int,java.io.Reader,long)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (NCharacterStream-With-Length) P"  + $1 + " ==> " +$2 + " ==> " +$3)
ENDRULE
RULE OraclePreparedStatement Code Insert setNClob
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setNClob(int,java.sql.NClob)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (NClo) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OraclePreparedStatement Code Insert setNString
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setNClob(int,java.lang.String)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (NString) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OraclePreparedStatement Code Insert setNull
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setNull(int,int)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (Null) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OraclePreparedStatement Code Insert setObject
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setObject(int,java.lang.Object)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Object) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OraclePreparedStatement Code Insert setObject(int,java.lang.Object,int )
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setObject(int,java.lang.Object,int )
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Object-SqlType) P"  + $1 + " ==> " +$2 + " ==> " +$3)
ENDRULE
RULE OraclePreparedStatement Code Insert setObject(int,java.lang.Object,int,int )
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setObject(int,java.lang.Object,int,int )
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Object-SqlType-With-Length) P"  + $1 + " ==> " +$2 + " ==> " +$3 +" ==> " +$3)
ENDRULE
RULE OraclePreparedStatement Code Insert setRowId
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setRowId(int,java.sql.RowId)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (RowId) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OraclePreparedStatement Code Insert setShort
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setShort(int,short)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (Short) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OraclePreparedStatement Code Insert setSQLXML
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setSQLXML(int,java.sql.SQLXML)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (SQLXML) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OraclePreparedStatement Code Insert setString
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setString(int,java.lang.String)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (String) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OraclePreparedStatement Code Insert setTime
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setTime(int,java.sql.Time)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (Time) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OraclePreparedStatement Code Insert setTime Calendar
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setTime(int,java.sql.Time,java.util.Calendar)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (Time-Calendar) P"  + $1 + " ==> " +$2  + " ==> " +$3 )
ENDRULE
RULE OraclePreparedStatement Code Insert setTimestamp
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setTimestamp(int,java.sql.Timestamp)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (Timestamp) P"  + $1 + " ==> " +$2   )
ENDRULE
RULE OraclePreparedStatement Code Insert setTimestamp Calendar
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setTimestamp(int,java.sql.Timestamp,java.util.Calendar)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (Timestamp-Calendar) P"  + $1 + " ==> " +$2  + " ==> " +$3 )
ENDRULE
RULE OraclePreparedStatement Code Insert setURL
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setURL(int,java.net.URL)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (URL) P"  + $1 + " ==> " +$2   )
ENDRULE
RULE OraclePreparedStatement Code Insert setStringForClob
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setStringForClob(int,java.lang.String)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (StringForClob) P"  + $1 + " ==> " +$2   )
ENDRULE
RULE OraclePreparedStatement Code Insert setBinaryFloat
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setBinaryFloat(int,oracle.sql.BINARY_FLOAT)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (BinaryFloat) P"  + $1 + " ==> " +$2   )
ENDRULE
RULE OraclePreparedStatement Code Insert setBinaryDouble
CLASS  oracle.jdbc.driver.OraclePreparedStatement
METHOD  setBinaryDouble(int,oracle.sql.BINARY_DOUBLE)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (BinaryDouble) P"  + $1 + " ==> " +$2   )
ENDRULE
############# Get the Parameters from OracleCallableStatement ###########
RULE OracleCallableStatement Code Insert setArray
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setArray(int,java.sql.Array)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (Array) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OracleCallableStatement Code Insert setAsciiStream
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setAsciiStream(int,java.io.InputStream)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (AsciiStream) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OracleCallableStatement Code Insert setAsciiStream 3 params
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setAsciiStream(int,java.io.InputStream,long length)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (AsciiStreamWithLength) P"  + $1 + " ==> " +$2 + " ==> " +$3  )
ENDRULE
RULE OracleCallableStatement Code Insert setBigDecimal
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setBigDecimal(int,java.math.BigDecimal)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (BigDecimal) P"  + $1 + " ==> " +$2  )
ENDRULE
RULE OracleCallableStatement Code Insert setBoolean
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setBoolean(int,boolean)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (bool) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OracleCallableStatement Code Insert setByte
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setByte(int,byte)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Byte) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OracleCallableStatement Code Insert setBytes
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setBytes(int,byte[])
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Bytes) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OracleCallableStatement Code Insert      setCharacterStream
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD setCharacterStream(int,java.io.Reader)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (CharacterStream) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OracleCallableStatement Code Insert      setCharacterStream 3
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD setCharacterStream(int,java.io.Reader,int)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (CharacterStream-With-length) P"  + $1 + " ==> " +$2 + " ==> " +$3)
ENDRULE
RULE OracleCallableStatement Code Insert      setCharacterStream 3 long
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD setCharacterStream(int,java.io.Reader,long)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (CharacterStream-With-length) P"  + $1 + " ==> " +$2 + " ==> " +$3)
ENDRULE
RULE OracleCallableStatement Code Insert setClob
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setClob(int,java.sql.Clob)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Clob) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OracleCallableStatement Code Insert setClob Reader
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setClob(int,java.io.Reader)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Reader) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OracleCallableStatement Code Insert setClob Reader 3
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setClob(int,java.io.Reader,long)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Reader-With-Length) P"  + $1 + " ==> " +$2 + " ==> " +$3)
ENDRULE
RULE OracleCallableStatement Code Insert setDate
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setDate(int,java.sql.Date)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Date) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OracleCallableStatement Code Insert setDate Calendar
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setDate(int,java.sql.Date,java.util.Calendar)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Calendar) P"  + $1 + " ==> " +$2 + " ==> " +$3)
ENDRULE
RULE OracleCallableStatement Code Insert setDouble
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setDouble(int,double)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (double) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OracleCallableStatement Code Insert setFloat
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setDouble(int,float)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Float) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OracleCallableStatement Code Insert setInt
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setInt(int,int)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (int) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OracleCallableStatement Code Insert setLong
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setLong(int,long)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (long) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OracleCallableStatement Code Insert      setNCharacterStream
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setNCharacterStream(int,java.io.Reader)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (NCharacterStream) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OracleCallableStatement Code Insert setNCharacterStream long
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setNCharacterStream(int,java.io.Reader,long)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (NCharacterStream-With-Length) P"  + $1 + " ==> " +$2 + " ==> " +$3)
ENDRULE
RULE OracleCallableStatement Code Insert setNClob
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setNClob(int,java.sql.NClob)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (NClo) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OracleCallableStatement Code Insert setNString
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setNClob(int,java.lang.String)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (NString) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OracleCallableStatement Code Insert setNull
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setNull(int,int)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (Null) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OracleCallableStatement Code Insert setObject
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setObject(int,java.lang.Object)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Object) P"  + $1 + " ==> " +$2)
ENDRULE
RULE OracleCallableStatement Code Insert setObject(int,java.lang.Object,int )
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setObject(int,java.lang.Object,int )
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Object-SqlType) P"  + $1 + " ==> " +$2 + " ==> " +$3)
ENDRULE
RULE OracleCallableStatement Code Insert setObject(int,java.lang.Object,int,int )
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setObject(int,java.lang.Object,int,int )
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain(" (" + Integer.toHexString(app1.hashCode()).toUpperCase() +") (Object-SqlType-With-Length) P"  + $1 + " ==> " +$2 + " ==> " +$3 +" ==> " +$3)
ENDRULE
RULE OracleCallableStatement Code Insert setRowId
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setRowId(int,java.sql.RowId)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (RowId) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OracleCallableStatement Code Insert setShort
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setShort(int,short)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (Short) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OracleCallableStatement Code Insert setSQLXML
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setSQLXML(int,java.sql.SQLXML)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (SQLXML) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OracleCallableStatement Code Insert setString
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setString(int,java.lang.String)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (String) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OracleCallableStatement Code Insert setTime
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setTime(int,java.sql.Time)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (Time) P"  + $1 + " ==> " +$2 )
ENDRULE
RULE OracleCallableStatement Code Insert setTime Calendar
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setTime(int,java.sql.Time,java.util.Calendar)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (Time-Calendar) P"  + $1 + " ==> " +$2  + " ==> " +$3 )
ENDRULE
RULE OracleCallableStatement Code Insert setTimestamp
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setTimestamp(int,java.sql.Timestamp)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (Timestamp) P"  + $1 + " ==> " +$2   )
ENDRULE
RULE OracleCallableStatement Code Insert setTimestamp Calendar
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setTimestamp(int,java.sql.Timestamp,java.util.Calendar)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (Timestamp-Calendar) P"  + $1 + " ==> " +$2  + " ==> " +$3 )
ENDRULE
RULE OracleCallableStatement Code Insert setURL
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setURL(int,java.net.URL)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (URL) P"  + $1 + " ==> " +$2   )
ENDRULE
RULE OracleCallableStatement Code Insert setStringForClob
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setStringForClob(int,java.lang.String)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (StringForClob) P"  + $1 + " ==> " +$2   )
ENDRULE
RULE OracleCallableStatement Code Insert setBinaryFloat
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setBinaryFloat(int,oracle.sql.BINARY_FLOAT)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (BinaryFloat) P"  + $1 + " ==> " +$2   )
ENDRULE
RULE OracleCallableStatement Code Insert setBinaryDouble
CLASS  oracle.jdbc.driver.OracleCallableStatement
METHOD  setBinaryDouble(int,oracle.sql.BINARY_DOUBLE)
AT ENTRY
BIND app1 = $0;
IF true
DO tracelnplain( " (" + Integer.toHexString(app1.hashCode()).toUpperCase() +")  (BinaryDouble) P"  + $1 + " ==> " +$2   )
ENDRULE

HelperSub.java 

==========

import java.io.FileWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.jboss.byteman.rule.Rule;
import org.jboss.byteman.rule.helper.Helper;
public class HelperSub extends Helper
{
  public static PrintWriter  fw = null ;
  public HelperSub(Rule paramRule)
  {
    super(paramRule);
  }
  public static void activated()
    {
        System.out.println("=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ in the activated");
      SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat("dd-MMM-yy HH:mm:ss.SSS");
      try {
        fw = new PrintWriter("jdbclogs.txt");
      fw.println(" JDBC Logs  on " +localSimpleDateFormat.format(new Date()) +"\n");
      }
      catch (Exception e1) {
        e1.printStackTrace();
      }
    }
    public static void deactivated()
    {
        System.out.println("=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ in the  deactivated");
      try {
       fw.close();
      }
      catch (Exception e1) {
        e1.printStackTrace();
      }
    }
  public boolean tracelnwithdate(String paramString)
  {
    SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat("dd-MMM-yy HH:mm:ss.SSS");
  // System.out.println(localSimpleDateFormat.format(new Date()) + paramString);
  try {
    fw.println(localSimpleDateFormat.format(new Date()) + paramString );
    fw.flush();
  }
  catch (Exception e1) {
    e1.printStackTrace();
  }
    return true;
  }
  public boolean tracelnplain(String paramString)
  {
    try {
      fw.println( paramString );
      fw.flush();
    }
    catch (Exception e1) {
      e1.printStackTrace();
    }
    return true;
  }
}

Monday, August 12, 2013

Coherence Logging in SOA

 

C:\temp\tangosol_coherence_override_1.xml

<coherence>
<cluster-config>
<unicast-listener>
<address system-property="tangosol.coherence.localhost">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.localport">8088</port>
<port-auto-adjust system-property="tangosol.coherence.localport.adjust">true</port-auto-adjust>
<well-known-addresses>
<socket-address id="1">
<address system-property="tangosol.coherence.wka1">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.wka1.port">8088</port>
</socket-address>
<socket-address id="2">
<address system-property="tangosol.coherence.wka2">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.wka2.port">8089</port>
</socket-address>
<socket-address id="3">
<address system-property="tangosol.coherence.wka2">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.wka2.port">8090</port>
</socket-address>
<socket-address id="4">
<address system-property="tangosol.coherence.wka2">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.wka2.port">8091</port>
</socket-address>
</well-known-addresses>
</unicast-listener>
</cluster-config>
</coherence>

C:\temp\tangosol_coherence_override_2.xml

<coherence>
<cluster-config>
<unicast-listener>
<address system-property="tangosol.coherence.localhost">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.localport">8089</port>
<port-auto-adjust system-property="tangosol.coherence.localport.adjust">true</port-auto-adjust>
<well-known-addresses>
<socket-address id="1">
<address system-property="tangosol.coherence.wka1">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.wka1.port">8088</port>
</socket-address>
<socket-address id="2">
<address system-property="tangosol.coherence.wka2">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.wka2.port">8089</port>
</socket-address>
<socket-address id="3">
<address system-property="tangosol.coherence.wka2">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.wka2.port">8090</port>
</socket-address>
<socket-address id="4">
<address system-property="tangosol.coherence.wka2">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.wka2.port">8091</port>
</socket-address>
</well-known-addresses>
</unicast-listener>
</cluster-config>
</coherence>

C:\temp\tangosol_coherence_override_3.xml

<coherence>
<cluster-config>
<unicast-listener>
<address system-property="tangosol.coherence.localhost">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.localport">8090</port>
<port-auto-adjust system-property="tangosol.coherence.localport.adjust">true</port-auto-adjust>
<well-known-addresses>
<socket-address id="1">
<address system-property="tangosol.coherence.wka1">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.wka1.port">8088</port>
</socket-address>
<socket-address id="2">
<address system-property="tangosol.coherence.wka2">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.wka2.port">8089</port>
</socket-address>
<socket-address id="3">
<address system-property="tangosol.coherence.wka2">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.wka2.port">8090</port>
</socket-address>
<socket-address id="4">
<address system-property="tangosol.coherence.wka2">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.wka2.port">8091</port>
</socket-address>
</well-known-addresses>
</unicast-listener>
</cluster-config>
</coherence>

C:\temp\tangosol_coherence_override_4.xml

<coherence>
<cluster-config>
<unicast-listener>
<address system-property="tangosol.coherence.localhost">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.localport">8091</port>
<port-auto-adjust system-property="tangosol.coherence.localport.adjust">true</port-auto-adjust>
<well-known-addresses>
<socket-address id="1">
<address system-property="tangosol.coherence.wka1">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.wka1.port">8088</port>
</socket-address>
<socket-address id="2">
<address system-property="tangosol.coherence.wka2">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.wka2.port">8089</port>
</socket-address>
<socket-address id="3">
<address system-property="tangosol.coherence.wka2">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.wka2.port">8090</port>
</socket-address>
<socket-address id="4">
<address system-property="tangosol.coherence.wka2">xx.xx.xx.xx</address>
<port system-property="tangosol.coherence.wka2.port">8091</port>
</socket-address>
</well-known-addresses>
</unicast-listener>
</cluster-config>
</coherence>

Start the Coherence Cache on all the four servers using ,

java -cp coherence.jar -Dtangosol.coherence.management.remote=true -Dtangosol.coherence.session.localstorage=true -Dtangosol.coherence.override=c:\temp\tangosol_coherence_override_1.xml com.tangosol.net.DefaultCacheServer
 
java -cp coherence.jar -Dtangosol.coherence.management.remote=true -Dtangosol.coherence.session.localstorage=true -Dtangosol.coherence.override=c:\temp\tangosol_coherence_override_2.xml com.tangosol.net.DefaultCacheServer

java -cp coherence.jar -Dtangosol.coherence.management.remote=true -Dtangosol.coherence.session.localstorage=true -Dtangosol.coherence.override=c:\temp\tangosol_coherence_override_3.xml com.tangosol.net.DefaultCacheServer
 
java -cp coherence.jar -Dtangosol.coherence.management.remote=true -Dtangosol.coherence.session.localstorage=true -Dtangosol.coherence.override=c:\temp\tangosol_coherence_override_4.xml com.tangosol.net.DefaultCacheServer

For Coherence logging ,

Remove the entries , (especially ,  -Dtangosol.coherence.log=jdk)

-Dtangosol.coherence.clusteraddress=xx.x.x.x -Dtangosol.coherence.clusterport=9778 -Dtangosol.coherence.log=jdk
And set the following options , -Dtangosol.coherence.log.level=9 -Dtangosol.coherence.log=/tmp/coherence.log

export JAVA_OPTIONS="-Dtangosol.coherence.log.level=9 -Dtangosol.coherence.log=/tmp/coherence.log"

and start the SOA Server , you will find entries like this ,


WellKnownAddressList(Size=2,
  WKA{Address=xx.xx.x.x, Port=8088}
  WKA{Address=xx.x.x.x.x, Port=8088}
  )

For the ODL logging set the Coherence=TRACE:32 and also log level , oracle.integration.platform = TRACE:32
you will find entries like ,
[2013-08-12T15:35:00.316+05:30] [soa_server2] [NOTIFICATION] [] [Coherence] [tid: Logger@9750876 3.7.1.1] [userId: <anonymous>] [ecid: 0000K1lyeYmESOJpMkS4ye1I2BBN000002,0] [APP: soa-infra] 2013-08-12 15:34:58.482/125.893 Oracle Coherence 3.7.1.1 <Info> (thread=[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)', member=n/a): Loaded operational configuration from "jar:file:/fmw11g/fmw1116/Middleware/oracle_common/modules/oracle.coherence/coherence.jar!/tangosol-coherence.xml"