mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-24 12:16:33 +10:00
[강운덕] [LUCYSUS-1744] HIPPO 의 로거를 JDK 로거로 변경함. maven에 junit포함.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@475 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -4,19 +4,20 @@ import java.lang.instrument.ClassFileTransformer;
|
||||
import java.lang.instrument.IllegalClassFormatException;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.profiler.modifier.DefaultModifierRegistry;
|
||||
import com.profiler.modifier.Modifier;
|
||||
import com.profiler.modifier.ModifierRegistry;
|
||||
import javassist.ClassPool;
|
||||
import javassist.NotFoundException;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConfig;
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.DefaultModifierRegistry;
|
||||
import com.profiler.modifier.Modifier;
|
||||
import com.profiler.modifier.ModifierRegistry;
|
||||
|
||||
public class TomcatProfiler implements ClassFileTransformer {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(TomcatProfiler.class);
|
||||
private static final Logger logger = Logger.getLogger(TomcatProfiler.class.getName());
|
||||
|
||||
private String agentArgString = "";
|
||||
private Instrumentation instrumentation;
|
||||
@@ -54,7 +55,10 @@ public class TomcatProfiler implements ClassFileTransformer {
|
||||
|
||||
String catalinaHome = System.getProperty("catalina.home");
|
||||
if (catalinaHome != null) {
|
||||
logger.info("CATALINA_HOME=%s", catalinaHome);
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("CATALINA_HOME=" + catalinaHome);
|
||||
}
|
||||
|
||||
appendClassPath(classPool, catalinaHome + "/lib/servlet-api.jar");
|
||||
appendClassPath(classPool, catalinaHome + "/lib/catalina.jar");
|
||||
}
|
||||
@@ -65,7 +69,10 @@ public class TomcatProfiler implements ClassFileTransformer {
|
||||
try {
|
||||
classPool.appendClassPath(pathName);
|
||||
} catch (NotFoundException e) {
|
||||
logger.error("lib not found. " + e.getMessage());
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.warning("lib not found. " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.profiler.TomcatProfiler;
|
||||
import com.profiler.logging.LogLevel;
|
||||
import com.profiler.logging.Logger;
|
||||
|
||||
public class TomcatProfilerConfig {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(TomcatProfilerConfig.class);
|
||||
|
||||
private static final Logger logger = Logger.getLogger(TomcatProfilerConfig.class.getName());
|
||||
|
||||
public static String SERVER_IP = "127.0.0.1";
|
||||
|
||||
@@ -24,7 +24,7 @@ public class TomcatProfilerConfig {
|
||||
public static long JVM_STAT_GAP = 5000L;
|
||||
public static long SERVER_CONNECT_RETRY_GAP = 1000L;
|
||||
|
||||
public static LogLevel LOG_LEVEL = LogLevel.INFO;
|
||||
public static Level LOG_LEVEL = Level.INFO;
|
||||
|
||||
/**
|
||||
* If sql query count is over 10000 it consumes Memory. So sqlHashSet uses
|
||||
@@ -40,7 +40,7 @@ public class TomcatProfilerConfig {
|
||||
|
||||
String hippoConfigFileName = System.getProperty("hippo.config");
|
||||
if (hippoConfigFileName == null) {
|
||||
logger.warn("hippo.config property is not set. Using default values");
|
||||
logger.info("hippo.config property is not set. Using default values");
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -49,9 +49,13 @@ public class TomcatProfilerConfig {
|
||||
setPropertyValues(config, properties);
|
||||
return config;
|
||||
} catch (FileNotFoundException fnfe) {
|
||||
logger.error("%s file is not exists. Please check configuration.", hippoConfigFileName);
|
||||
} catch (Exception e) {
|
||||
logger.fatal(e.getMessage());
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.warning(hippoConfigFileName + " file is not exists. Please check configuration.");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
}
|
||||
return config;
|
||||
}
|
||||
@@ -84,47 +88,69 @@ public class TomcatProfilerConfig {
|
||||
|
||||
if ((temp = prop.get("SERVER_IP")) != null) {
|
||||
config.SERVER_IP = temp.toString();
|
||||
logger.info("SERVER_IP=%s", SERVER_IP);
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("SERVER_IP=" + SERVER_IP);
|
||||
}
|
||||
}
|
||||
if ((temp = prop.get("AGENT_TCP_LISTEN_PORT")) != null) {
|
||||
config.AGENT_TCP_LISTEN_PORT = Integer.parseInt(temp.toString());
|
||||
logger.info("AGENT_TCP_LISTEN_PORT=%d", AGENT_TCP_LISTEN_PORT);
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("AGENT_TCP_LISTEN_PORT=" + AGENT_TCP_LISTEN_PORT);
|
||||
}
|
||||
}
|
||||
if ((temp = prop.get("SERVER_TCP_LISTEN_PORT")) != null) {
|
||||
config.SERVER_TCP_LISTEN_PORT = Integer.parseInt(temp.toString());
|
||||
logger.info("SERVER_TCP_LISTEN_PORT=%d", SERVER_TCP_LISTEN_PORT);
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("SERVER_TCP_LISTEN_PORT=" + SERVER_TCP_LISTEN_PORT);
|
||||
}
|
||||
}
|
||||
if ((temp = prop.get("REQUEST_TRANSACTION_DATA_LISTEN_PORT")) != null) {
|
||||
config.REQUEST_TRANSACTION_DATA_LISTEN_PORT = Integer.parseInt(temp.toString());
|
||||
logger.info("REQUEST_TRANSACTION_DATA_LISTEN_PORT=%d", REQUEST_TRANSACTION_DATA_LISTEN_PORT);
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("REQUEST_TRANSACTION_DATA_LISTEN_PORT=" + REQUEST_TRANSACTION_DATA_LISTEN_PORT);
|
||||
}
|
||||
}
|
||||
if ((temp = prop.get("REQUEST_DATA_LISTEN_PORT")) != null) {
|
||||
config.REQUEST_DATA_LISTEN_PORT = Integer.parseInt(temp.toString());
|
||||
logger.info("REQUEST_DATA_LISTEN_PORT=%d", REQUEST_DATA_LISTEN_PORT);
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("REQUEST_DATA_LISTEN_PORT=" + REQUEST_DATA_LISTEN_PORT);
|
||||
}
|
||||
}
|
||||
if ((temp = prop.get("JVM_DATA_LISTEN_PORT")) != null) {
|
||||
config.JVM_DATA_LISTEN_PORT = Integer.parseInt(temp.toString());
|
||||
logger.info("JVM_DATA_LISTEN_PORT=%d", JVM_DATA_LISTEN_PORT);
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("JVM_DATA_LISTEN_PORT=" + JVM_DATA_LISTEN_PORT);
|
||||
}
|
||||
}
|
||||
if ((temp = prop.get("JVM_STAT_GAP")) != null) {
|
||||
config.JVM_STAT_GAP = Long.parseLong(temp.toString());
|
||||
logger.info("JVM_STAT_GAP=%d", JVM_STAT_GAP);
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("JVM_STAT_GAP=" + JVM_STAT_GAP);
|
||||
}
|
||||
}
|
||||
if ((temp = prop.get("SERVER_CONNECT_RETRY_GAP")) != null) {
|
||||
config.SERVER_CONNECT_RETRY_GAP = Long.parseLong(temp.toString());
|
||||
logger.info("SERVER_CONNECT_RETRY_GAP=%d", SERVER_CONNECT_RETRY_GAP);
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("SERVER_CONNECT_RETRY_GAP=" + SERVER_CONNECT_RETRY_GAP);
|
||||
}
|
||||
}
|
||||
if ((temp = prop.get("QUERY_COUNT_OVER_10000")) != null) {
|
||||
config.QUERY_COUNT_OVER_10000 = Boolean.parseBoolean(temp.toString());
|
||||
logger.info("QUERY_COUNT_OVER_10000=%s", QUERY_COUNT_OVER_10000);
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("QUERY_COUNT_OVER_10000=" + QUERY_COUNT_OVER_10000);
|
||||
}
|
||||
}
|
||||
if ((temp = prop.get("JDBC_PROFILE")) != null) {
|
||||
config.JDBC_PROFILE = Boolean.parseBoolean(temp.toString());
|
||||
logger.info("JDBC_PROFILE=%s", config.JDBC_PROFILE);
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("JDBC_PROFILE=" + config.JDBC_PROFILE);
|
||||
}
|
||||
}
|
||||
if ((temp = prop.get("LOG_LEVEL")) != null) {
|
||||
config.LOG_LEVEL = LogLevel.valueOf(temp.toString());
|
||||
logger.info("LOG_LEVEL=%s", LOG_LEVEL);
|
||||
config.LOG_LEVEL = Level.parse(temp.toString());
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("LOG_LEVEL=" + LOG_LEVEL);
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("configuration loaded successfully.");
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.profiler.logging;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConfig;
|
||||
|
||||
public class DefaultLogger extends Logger {
|
||||
|
||||
public DefaultLogger(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String message, Object... args) {
|
||||
if (TomcatProfilerConfig.LOG_LEVEL.priority >= LogLevel.INFO.priority) {
|
||||
System.out.printf("[HIPPO] %s [INFO] [%s] %s \n", df.format(new Date()), name, String.format(message, args));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message, Object... args) {
|
||||
if (TomcatProfilerConfig.LOG_LEVEL.priority >= LogLevel.DEBUG.priority) {
|
||||
System.out.printf("[HIPPO] %s [DEBUG] [%s] %s \n", df.format(new Date()), name, String.format(message, args));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String message, Object... args) {
|
||||
if (TomcatProfilerConfig.LOG_LEVEL.priority >= LogLevel.WARN.priority) {
|
||||
System.out.printf("[HIPPO] %s [WARN] [%s] %s \n", df.format(new Date()), name, String.format(message, args));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message, Object... args) {
|
||||
if (TomcatProfilerConfig.LOG_LEVEL.priority >= LogLevel.ERROR.priority) {
|
||||
System.out.printf("[HIPPO] %s [ERROR] [%s] %s \n", df.format(new Date()), name, String.format(message, args));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(String message, Object... args) {
|
||||
if (TomcatProfilerConfig.LOG_LEVEL.priority >= LogLevel.FATAL.priority) {
|
||||
System.out.printf("[HIPPO] %s [FATAL] [%s] %s \n", df.format(new Date()), name, String.format(message, args));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugEnabled() {
|
||||
return TomcatProfilerConfig.LOG_LEVEL.priority >= LogLevel.DEBUG.priority;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.profiler.logging;
|
||||
|
||||
public enum LogLevel {
|
||||
INFO(0), DEBUG(1), WARN(2), ERROR(3), FATAL(4);
|
||||
|
||||
int priority;
|
||||
|
||||
LogLevel(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.profiler.logging;
|
||||
|
||||
public abstract class Logger {
|
||||
|
||||
protected final String name;
|
||||
|
||||
protected final ThreadSafeSimpleDateFormat df = new ThreadSafeSimpleDateFormat();
|
||||
|
||||
public Logger(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static Logger getLogger(Class<?> clazz) {
|
||||
return new DefaultLogger(clazz.getName());
|
||||
}
|
||||
|
||||
public abstract void info(String message, Object... args);
|
||||
|
||||
public abstract void debug(String message, Object... args);
|
||||
|
||||
public abstract void warn(String message, Object... args);
|
||||
|
||||
public abstract void error(String message, Object... args);
|
||||
|
||||
public abstract void fatal(String message, Object... args);
|
||||
|
||||
public abstract boolean isDebugEnabled();
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.profiler.logging;
|
||||
|
||||
import com.profiler.util.NamedThreadLocal;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class ThreadSafeSimpleDateFormat {
|
||||
|
||||
private ThreadLocal<SimpleDateFormat> CACHE = new NamedThreadLocal<SimpleDateFormat>("SimpleDateFormatCache") {
|
||||
@Override
|
||||
protected SimpleDateFormat initialValue() {
|
||||
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
}
|
||||
};
|
||||
|
||||
public String format(Date date) {
|
||||
return CACHE.get().format(date);
|
||||
}
|
||||
}
|
||||
@@ -6,19 +6,23 @@ import javassist.CtConstructor;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class CubridPreparedStatementModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CubridPreparedStatementModifier.class);
|
||||
private final Logger logger = Logger.getLogger(CubridPreparedStatementModifier.class.getName());
|
||||
|
||||
public CubridPreparedStatementModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -34,8 +38,9 @@ public class CubridPreparedStatementModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if(logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,19 +5,23 @@ import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class CubridResultSetModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CubridResultSetModifier.class);
|
||||
private final Logger logger = Logger.getLogger(CubridResultSetModifier.class.getName());
|
||||
|
||||
public CubridResultSetModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -33,8 +37,9 @@ public class CubridResultSetModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if(logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,19 +5,23 @@ import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class CubridStatementModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CubridStatementModifier.class);
|
||||
private final Logger logger = Logger.getLogger(CubridStatementModifier.class.getName());
|
||||
|
||||
public CubridStatementModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -32,8 +36,9 @@ public class CubridStatementModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if(logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,19 +5,23 @@ import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class CubridUStatementModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CubridUStatementModifier.class);
|
||||
private final Logger logger = Logger.getLogger(CubridUStatementModifier.class.getName());
|
||||
|
||||
public CubridUStatementModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -32,8 +36,9 @@ public class CubridUStatementModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,19 +5,23 @@ import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class DBCPBasicDataSourceModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(DBCPBasicDataSourceModifier.class);
|
||||
private final Logger logger = Logger.getLogger(DBCPBasicDataSourceModifier.class.getName());
|
||||
|
||||
public DBCPBasicDataSourceModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -32,8 +36,9 @@ public class DBCPBasicDataSourceModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,19 +5,23 @@ import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class DBCPPoolModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(DBCPPoolModifier.class);
|
||||
private final Logger logger = Logger.getLogger(DBCPPoolModifier.class.getName());
|
||||
|
||||
public DBCPPoolModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -32,8 +36,9 @@ public class DBCPPoolModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,19 +5,23 @@ import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class MSSQLConnectionModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MSSQLConnectionModifier.class);
|
||||
private final Logger logger = Logger.getLogger(MSSQLConnectionModifier.class.getName());
|
||||
|
||||
public MSSQLConnectionModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethods(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -33,8 +37,9 @@ public class MSSQLConnectionModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -6,19 +6,23 @@ import javassist.CtConstructor;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class MSSQLPreparedStatementModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MSSQLPreparedStatementModifier.class);
|
||||
private final Logger logger = Logger.getLogger(MSSQLPreparedStatementModifier.class.getName());
|
||||
|
||||
public MSSQLPreparedStatementModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -35,8 +39,9 @@ public class MSSQLPreparedStatementModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -55,7 +60,7 @@ public class MSSQLPreparedStatementModifier extends AbstractModifier {
|
||||
|
||||
private void updateConstructor(CtClass cc) throws Exception {
|
||||
CtConstructor[] constructorList = cc.getConstructors();
|
||||
|
||||
|
||||
if (constructorList.length == 1) {
|
||||
CtConstructor constructor = constructorList[0];
|
||||
constructor.insertAfter("{" + TomcatProfilerConstant.CLASS_NAME_REQUEST_DATA_TRACER + ".putSqlQuery(" + TomcatProfilerConstant.REQ_DATA_TYPE_DB_QUERY + ",$2); }");
|
||||
|
||||
@@ -5,19 +5,24 @@ import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class MSSQLResultSetModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MSSQLResultSetModifier.class);
|
||||
private final Logger logger = Logger.getLogger(MSSQLResultSetModifier.class.getName());
|
||||
|
||||
public MSSQLResultSetModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -33,8 +38,9 @@ public class MSSQLResultSetModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,19 +5,22 @@ import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
public class MSSQLStatementModifier extends AbstractModifier {
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MSSQLStatementModifier.class);
|
||||
public class MSSQLStatementModifier extends AbstractModifier {
|
||||
private static final Logger logger = Logger.getLogger(MSSQLStatementModifier.class.getName());
|
||||
|
||||
public MSSQLStatementModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -32,8 +35,9 @@ public class MSSQLStatementModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,19 +5,23 @@ import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class MySQLConnectionImplModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MySQLConnectionImplModifier.class);
|
||||
private final Logger logger = Logger.getLogger(MySQLConnectionImplModifier.class.getName());
|
||||
|
||||
public MySQLConnectionImplModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethods(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -34,8 +38,9 @@ public class MySQLConnectionImplModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -6,19 +6,22 @@ import javassist.CtConstructor;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
public class MySQLPreparedStatementModifier extends AbstractModifier {
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MySQLPreparedStatementModifier.class);
|
||||
public class MySQLPreparedStatementModifier extends AbstractModifier {
|
||||
private final Logger logger = Logger.getLogger(MySQLPreparedStatementModifier.class.getName());
|
||||
|
||||
public MySQLPreparedStatementModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -35,8 +38,9 @@ public class MySQLPreparedStatementModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,19 +5,23 @@ import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class MySQLResultSetModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MySQLResultSetModifier.class);
|
||||
private final Logger logger = Logger.getLogger(MySQLResultSetModifier.class.getName());
|
||||
|
||||
public MySQLResultSetModifier(ClassPool classPool) {
|
||||
public MySQLResultSetModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -33,8 +37,9 @@ public class MySQLResultSetModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,19 +5,23 @@ import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class MySQLStatementModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MySQLStatementModifier.class);
|
||||
private final Logger logger = Logger.getLogger(MySQLStatementModifier.class.getName());
|
||||
|
||||
public MySQLStatementModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -32,8 +36,9 @@ public class MySQLStatementModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -6,19 +6,24 @@ import javassist.CtConstructor;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class OraclePreparedStatementModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(OraclePreparedStatementModifier.class);
|
||||
private final Logger logger = Logger.getLogger(OraclePreparedStatementModifier.class.getName());
|
||||
|
||||
public OraclePreparedStatementModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -35,8 +40,9 @@ public class OraclePreparedStatementModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,19 +5,23 @@ import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class OracleResultSetModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(OracleResultSetModifier.class);
|
||||
private final Logger logger = Logger.getLogger(OracleResultSetModifier.class.getName());
|
||||
|
||||
public OracleResultSetModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -33,8 +37,9 @@ public class OracleResultSetModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,18 +5,22 @@ import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConstant;
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class OracleStatementModifier extends AbstractModifier {
|
||||
private static final Logger logger = Logger.getLogger(OracleStatementModifier.class);
|
||||
private final Logger logger = Logger.getLogger(OracleStatementModifier.class.getName());
|
||||
|
||||
public OracleStatementModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
checkLibrary(classLoader, javassistClassName);
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
@@ -31,7 +35,9 @@ public class OracleStatementModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+20
-14
@@ -7,9 +7,11 @@ import javassist.ClassPool;
|
||||
import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Modify org.apache.catalina.core.StandardHostValve class
|
||||
*
|
||||
@@ -18,14 +20,16 @@ import com.profiler.modifier.AbstractModifier;
|
||||
*/
|
||||
public class EntryPointStandardHostValveModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(EntryPointStandardHostValveModifier.class);
|
||||
private final Logger logger = Logger.getLogger(EntryPointStandardHostValveModifier.class.getName());
|
||||
|
||||
public EntryPointStandardHostValveModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
return changeServiceMethod(classLoader, javassistClassName, classFileBuffer);
|
||||
}
|
||||
|
||||
@@ -51,8 +55,9 @@ public class EntryPointStandardHostValveModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -68,7 +73,7 @@ public class EntryPointStandardHostValveModifier extends AbstractModifier {
|
||||
insertCode.append(getParameterValues());
|
||||
insertCode.append(CLASS_NAME_REQUEST_TRACER).append(".startTransaction(requestURL,clientIP,requestTime,params);");
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
insertCode.append("System.out.println(\"--- ApplicationFilterChain.doFilter() is started.\");");
|
||||
}
|
||||
|
||||
@@ -83,7 +88,7 @@ public class EntryPointStandardHostValveModifier extends AbstractModifier {
|
||||
insertCode.append("while(attrs.hasMoreElements()) {");
|
||||
insertCode.append("String keyString=attrs.nextElement().toString();");
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
insertCode.append("System.out.println(keyString+\"=\"+tempRequest.getParameter(keyString));");
|
||||
}
|
||||
|
||||
@@ -94,7 +99,7 @@ public class EntryPointStandardHostValveModifier extends AbstractModifier {
|
||||
insertCode.append("if(valueStringLength>0 && valueStringLength<100) params.append(keyString).append(\"=\").append(valueString).append(\",\");");
|
||||
insertCode.append("}}");
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
insertCode.append("System.out.println(params);");
|
||||
}
|
||||
|
||||
@@ -106,7 +111,7 @@ public class EntryPointStandardHostValveModifier extends AbstractModifier {
|
||||
insertCode.append("{");
|
||||
insertCode.append(CLASS_NAME_REQUEST_TRACER).append(".endTransaction();");
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
insertCode.append("System.out.println(\"--- ApplicationFilterChain.doFilter() is ended.\");");
|
||||
}
|
||||
|
||||
@@ -118,7 +123,7 @@ public class EntryPointStandardHostValveModifier extends AbstractModifier {
|
||||
private String getInvokeMethodCatchInsertCode() {
|
||||
StringBuilder insertCode = new StringBuilder();
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
insertCode.append("{");
|
||||
insertCode.append("System.out.println(\"------------------------------------------------\");");
|
||||
insertCode.append("System.out.println(\"--- \"+$e.getMessage()+\" is occured !!!\");");
|
||||
@@ -126,13 +131,13 @@ public class EntryPointStandardHostValveModifier extends AbstractModifier {
|
||||
|
||||
insertCode.append(CLASS_NAME_REQUEST_TRACER).append(".exceptionTransaction($e);");
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
insertCode.append("System.out.println(\"------------------------------------------------\");");
|
||||
}
|
||||
|
||||
insertCode.append("throw $e;");
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
insertCode.append("}");
|
||||
}
|
||||
|
||||
@@ -145,8 +150,9 @@ public class EntryPointStandardHostValveModifier extends AbstractModifier {
|
||||
classLoader.loadClass(CLASS_NAME_REQUEST_THRIFT_DTO);
|
||||
classLoader.loadClass("org.apache.thrift.TBase");
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if(logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,11 @@ import javassist.ClassPool;
|
||||
import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* When org.apache.catalina.core.StandardService class is loaded in ClassLoader,
|
||||
* this class modifies methods.
|
||||
@@ -16,14 +18,16 @@ import com.profiler.modifier.AbstractModifier;
|
||||
*/
|
||||
public class TomcatConnectorModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(TomcatConnectorModifier.class);
|
||||
private final Logger logger = Logger.getLogger(TomcatConnectorModifier.class.getName());
|
||||
|
||||
public TomcatConnectorModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
|
||||
@@ -40,8 +44,9 @@ public class TomcatConnectorModifier extends AbstractModifier {
|
||||
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
// TODO 변환 실패에 의한 예가 아니면 원본을 반환 해줘야 할까?
|
||||
return null;
|
||||
|
||||
@@ -5,9 +5,11 @@ import javassist.ClassPool;
|
||||
import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import com.profiler.logging.Logger;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* When org.apache.catalina.core.StandardService class is loaded in ClassLoader,
|
||||
* this class modifies methods.
|
||||
@@ -17,14 +19,16 @@ import com.profiler.modifier.AbstractModifier;
|
||||
*/
|
||||
public class TomcatStandardServiceModifier extends AbstractModifier {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(TomcatStandardServiceModifier.class);
|
||||
private final Logger logger = Logger.getLogger(TomcatStandardServiceModifier.class.getName());
|
||||
|
||||
public TomcatStandardServiceModifier(ClassPool classPool) {
|
||||
super(classPool);
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, byte[] classFileBuffer) {
|
||||
logger.info("Modifing. %s", javassistClassName);
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Modifing. " + javassistClassName);
|
||||
}
|
||||
return changeMethod(javassistClassName, classFileBuffer);
|
||||
}
|
||||
|
||||
@@ -41,8 +45,9 @@ public class TomcatStandardServiceModifier extends AbstractModifier {
|
||||
printClassConvertComplete(javassistClassName);
|
||||
return cc.toBytecode();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2,14 +2,15 @@ package com.profiler.sender;
|
||||
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.net.Socket;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.profiler.config.TomcatProfilerConfig;
|
||||
import com.profiler.dto.AgentInfoDTO;
|
||||
import com.profiler.logging.Logger;
|
||||
|
||||
public class AgentInfoSender extends Thread {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(AgentInfoSender.class);
|
||||
private final Logger logger = Logger.getLogger(AgentInfoSender.class.getName());
|
||||
|
||||
boolean isAgentStart;
|
||||
|
||||
@@ -34,15 +35,21 @@ public class AgentInfoSender extends Thread {
|
||||
ObjectOutputStream stream = new ObjectOutputStream(requestSocket.getOutputStream());
|
||||
AgentInfoDTO dto = new AgentInfoDTO();
|
||||
dto.setIsDead();
|
||||
|
||||
logger.info("send agent stop info. %s", dto.toString());
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("send agent stop info. " + dto.toString());
|
||||
}
|
||||
|
||||
stream.writeObject(dto);
|
||||
stream.close();
|
||||
|
||||
logger.info("Agent Stopped message is sent. %s", dto.toString());
|
||||
if (logger.isLoggable(Level.INFO)){
|
||||
logger.info("Agent Stopped message is sent. " + dto.toString());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("AgentInfoSender Exception occured : %s", e.getMessage());
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, "AgentInfoSender Exception occured:" + e.getMessage(), e);
|
||||
}
|
||||
} finally {
|
||||
closeSocket();
|
||||
}
|
||||
@@ -66,9 +73,12 @@ public class AgentInfoSender extends Thread {
|
||||
|
||||
AgentInfoDTO dto = new AgentInfoDTO();
|
||||
|
||||
logger.info("send agent startup info. %s", dto.toString());
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("send agent startup info. " + dto.toString());
|
||||
}
|
||||
|
||||
stream.writeObject(dto);
|
||||
|
||||
stream.writeObject(dto);
|
||||
stream.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -80,17 +90,27 @@ public class AgentInfoSender extends Thread {
|
||||
|
||||
private boolean connectToServer() {
|
||||
try {
|
||||
logger.info("Trying to connect server. %s:%s", TomcatProfilerConfig.SERVER_IP, TomcatProfilerConfig.SERVER_TCP_LISTEN_PORT);
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("Trying to connect server. " + TomcatProfilerConfig.SERVER_IP + ":" + TomcatProfilerConfig.SERVER_TCP_LISTEN_PORT);
|
||||
}
|
||||
requestSocket = new Socket(TomcatProfilerConfig.SERVER_IP, TomcatProfilerConfig.SERVER_TCP_LISTEN_PORT);
|
||||
// TODO timeout 처리가 없음. api를 변경해야 될듯.
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("Connected to server. " + TomcatProfilerConfig.SERVER_IP + ":" + TomcatProfilerConfig.SERVER_TCP_LISTEN_PORT);
|
||||
}
|
||||
|
||||
requestSocket = new Socket(TomcatProfilerConfig.SERVER_IP, TomcatProfilerConfig.SERVER_TCP_LISTEN_PORT);
|
||||
|
||||
logger.info("Connected to server. %s:%s", TomcatProfilerConfig.SERVER_IP, TomcatProfilerConfig.SERVER_TCP_LISTEN_PORT);
|
||||
return false;
|
||||
return false;
|
||||
} catch (java.net.ConnectException ce) {
|
||||
logger.fatal("Connect to TomcatProfiler server is failed. %s:%s", TomcatProfilerConfig.SERVER_IP, TomcatProfilerConfig.SERVER_TCP_LISTEN_PORT);
|
||||
return true;
|
||||
|
||||
if (logger.isLoggable(Level.SEVERE)) {
|
||||
logger.log(Level.SEVERE, "Connect to TomcatProfiler server is failed. " + TomcatProfilerConfig.SERVER_IP + ":" + TomcatProfilerConfig.SERVER_TCP_LISTEN_PORT, ce);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.SEVERE)) {
|
||||
logger.log(Level.SEVERE, "Connect to TomcatProfiler server is failed. " + TomcatProfilerConfig.SERVER_IP + ":" + TomcatProfilerConfig.SERVER_TCP_LISTEN_PORT, e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -100,7 +120,9 @@ public class AgentInfoSender extends Thread {
|
||||
requestSocket.close();
|
||||
logger.info("TCP RequestSocket is closed");
|
||||
} catch (Exception e) {
|
||||
logger.error("closeSocket(). %s", e.getMessage());
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, "closeSocket(). " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,171 +17,185 @@ import com.profiler.dto.RequestDataThriftDTO;
|
||||
import com.profiler.util.QueryStringUtil;
|
||||
|
||||
public class RequestDataTracer {
|
||||
private static Set<Integer> sqlSet=null;
|
||||
private static Hashtable<Integer,String> dbConnectionURL=new Hashtable<Integer,String>();
|
||||
static {
|
||||
if(TomcatProfilerConfig.QUERY_COUNT_OVER_10000) {
|
||||
sqlSet=new CopyOnWriteArraySet<Integer>();
|
||||
} else {
|
||||
sqlSet=new HashSet<Integer>(1024);
|
||||
}
|
||||
}
|
||||
private static final ThreadLocal<RequestDataListThriftDTO> requestDataThreadLocal=new ThreadLocal<RequestDataListThriftDTO>();
|
||||
private static final ThreadLocal<HashMap<Integer,String>> sqlParamMapThreadLocal=new ThreadLocal<HashMap<Integer,String>>();
|
||||
|
||||
/**
|
||||
* These two variables are used counting "ResultSet.next()" times.
|
||||
*/
|
||||
private static final ThreadLocal<Integer> fetchCountThreadLocal=new ThreadLocal<Integer>();
|
||||
private static final ThreadLocal<Integer> totalFetchCountThreadLocal=new ThreadLocal<Integer>();
|
||||
public static RequestDataListThriftDTO getRequestDataList() {
|
||||
return requestDataThreadLocal.get();
|
||||
}
|
||||
public static void removeRequestDataList() {
|
||||
requestDataThreadLocal.remove();
|
||||
}
|
||||
private static boolean isRequestData() {
|
||||
Integer reqHashCode=RequestTransactionTracer.getRequestHashCode();
|
||||
if(reqHashCode==null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
private static Set<Integer> sqlSet = null;
|
||||
private static Hashtable<Integer, String> dbConnectionURL = new Hashtable<Integer, String>();
|
||||
|
||||
/**
|
||||
* Put data to requestDataThreadLocal.
|
||||
* @param dataType
|
||||
*/
|
||||
public static void put(int dataType) {
|
||||
static {
|
||||
if (TomcatProfilerConfig.QUERY_COUNT_OVER_10000) {
|
||||
sqlSet = new CopyOnWriteArraySet<Integer>();
|
||||
} else {
|
||||
sqlSet = new HashSet<Integer>(1024);
|
||||
}
|
||||
}
|
||||
|
||||
private static final ThreadLocal<RequestDataListThriftDTO> requestDataThreadLocal = new ThreadLocal<RequestDataListThriftDTO>();
|
||||
private static final ThreadLocal<HashMap<Integer, String>> sqlParamMapThreadLocal = new ThreadLocal<HashMap<Integer, String>>();
|
||||
|
||||
/**
|
||||
* These two variables are used counting "ResultSet.next()" times.
|
||||
*/
|
||||
private static final ThreadLocal<Integer> fetchCountThreadLocal = new ThreadLocal<Integer>();
|
||||
private static final ThreadLocal<Integer> totalFetchCountThreadLocal = new ThreadLocal<Integer>();
|
||||
|
||||
public static RequestDataListThriftDTO getRequestDataList() {
|
||||
return requestDataThreadLocal.get();
|
||||
}
|
||||
|
||||
public static void removeRequestDataList() {
|
||||
requestDataThreadLocal.remove();
|
||||
}
|
||||
|
||||
private static boolean isRequestData() {
|
||||
Integer reqHashCode = RequestTransactionTracer.getRequestHashCode();
|
||||
if (reqHashCode == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put data to requestDataThreadLocal.
|
||||
*
|
||||
* @param dataType
|
||||
*/
|
||||
public static void put(int dataType) {
|
||||
// System.out.println(dataType+"-----RequestHashCode="+RequestTransactionTracer.getRequestHashCode());
|
||||
if(isRequestData()) {
|
||||
RequestDataListThriftDTO dto=requestDataThreadLocal.get();
|
||||
dto=checkDTO(dto);
|
||||
List<RequestDataThriftDTO> list=dto.getRequestDataList();
|
||||
// System.out.println("-----RequestDataListThriftDTO list size="+list.size());
|
||||
|
||||
checkSqlParamMap(list);
|
||||
|
||||
RequestDataThriftDTO dataDto=new RequestDataThriftDTO(dataType,System.currentTimeMillis());
|
||||
list.add(dataDto);
|
||||
requestDataThreadLocal.set(dto);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put Connection data to requestDataThreadLocal.
|
||||
* @param dataType
|
||||
*/
|
||||
public static void putConnection(int dataType,String url) {
|
||||
if (isRequestData()) {
|
||||
RequestDataListThriftDTO dto = requestDataThreadLocal.get();
|
||||
dto = checkDTO(dto);
|
||||
List<RequestDataThriftDTO> list = dto.getRequestDataList();
|
||||
// System.out.println("-----RequestDataListThriftDTO list size="+list.size());
|
||||
|
||||
checkSqlParamMap(list);
|
||||
|
||||
RequestDataThriftDTO dataDto = new RequestDataThriftDTO(dataType, System.currentTimeMillis());
|
||||
list.add(dataDto);
|
||||
requestDataThreadLocal.set(dto);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put Connection data to requestDataThreadLocal.
|
||||
*
|
||||
* @param dataType
|
||||
*/
|
||||
public static void putConnection(int dataType, String url) {
|
||||
// System.out.println(dataType+"-----RequestHashCode="+RequestTransactionTracer.getRequestHashCode());
|
||||
if(isRequestData()) {
|
||||
RequestDataListThriftDTO dto=requestDataThreadLocal.get();
|
||||
dto=checkDTO(dto);
|
||||
List<RequestDataThriftDTO> list=dto.getRequestDataList();
|
||||
// System.out.println("-----RequestDataListThriftDTO list size="+list.size());
|
||||
|
||||
checkSqlParamMap(list);
|
||||
|
||||
RequestDataThriftDTO dataDto=new RequestDataThriftDTO(dataType,System.currentTimeMillis());
|
||||
if(url!=null) {
|
||||
int hashCode=url.hashCode();
|
||||
if(!dbConnectionURL.containsKey(hashCode)) {
|
||||
dbConnectionURL.put(hashCode, url);
|
||||
dataDto.setDataString(url);
|
||||
if (isRequestData()) {
|
||||
RequestDataListThriftDTO dto = requestDataThreadLocal.get();
|
||||
dto = checkDTO(dto);
|
||||
List<RequestDataThriftDTO> list = dto.getRequestDataList();
|
||||
// System.out.println("-----RequestDataListThriftDTO list size="+list.size());
|
||||
|
||||
checkSqlParamMap(list);
|
||||
|
||||
RequestDataThriftDTO dataDto = new RequestDataThriftDTO(dataType, System.currentTimeMillis());
|
||||
if (url != null) {
|
||||
int hashCode = url.hashCode();
|
||||
if (!dbConnectionURL.containsKey(hashCode)) {
|
||||
dbConnectionURL.put(hashCode, url);
|
||||
dataDto.setDataString(url);
|
||||
// System.out.println(url);
|
||||
}
|
||||
dataDto.setDataHashCode(hashCode);
|
||||
}
|
||||
list.add(dataDto);
|
||||
requestDataThreadLocal.set(dto);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Put SQL Query data into requestDataThreadLocal.
|
||||
* @param dataType
|
||||
*/
|
||||
public static void putSqlQuery(int dataType,String data) {
|
||||
if(isRequestData()) {
|
||||
RequestDataListThriftDTO dto=requestDataThreadLocal.get();
|
||||
dto=checkDTO(dto);
|
||||
List<RequestDataThriftDTO> list=dto.getRequestDataList();
|
||||
// System.out.println("-----RequestDataListThriftDTO list size="+list.size());
|
||||
|
||||
checkSqlParamMap(list);
|
||||
|
||||
RequestDataThriftDTO dataDto=new RequestDataThriftDTO(dataType,System.currentTimeMillis());
|
||||
int dataHashCode=data.hashCode();
|
||||
dataDto.setDataHashCode(dataHashCode);
|
||||
boolean isAlreadySent=checkHashCode(dataHashCode);
|
||||
if(!isAlreadySent) {
|
||||
if(data!=null) {
|
||||
dataDto.setDataString(QueryStringUtil.removeAllMultiSpace(data));
|
||||
}
|
||||
}
|
||||
list.add(dataDto);
|
||||
requestDataThreadLocal.set(dto);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check SQL Query HashCode set.
|
||||
* If Query count is over 10000, it can make memory problem.
|
||||
* So this method removes 100 hashCode.
|
||||
*
|
||||
* If you use HashSet this remove code will not run.
|
||||
*
|
||||
* @param dataHashCode
|
||||
* @return
|
||||
*/
|
||||
private static boolean checkHashCode(int dataHashCode) {
|
||||
if(TomcatProfilerConfig.QUERY_COUNT_OVER_10000) {
|
||||
//If sqlSet is CopyOnWriteArraySet, it removes data.
|
||||
if(sqlSet.size()>10000) {
|
||||
Iterator<Integer> iterator=sqlSet.iterator();
|
||||
for(int loop=0;loop<100;loop++) {
|
||||
sqlSet.remove(iterator.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(sqlSet.contains(dataHashCode)) {
|
||||
return true;
|
||||
} else {
|
||||
sqlSet.add(dataHashCode);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Manage sql param list
|
||||
* @param list
|
||||
*/
|
||||
private static void checkSqlParamMap(List<RequestDataThriftDTO> list) {
|
||||
if(isRequestData()) {
|
||||
HashMap<Integer,String> map=sqlParamMapThreadLocal.get();
|
||||
if(map!=null) {
|
||||
int mapSize=map.size();
|
||||
StringBuilder params=new StringBuilder();
|
||||
for(int loop=1;loop<=mapSize;loop++) {
|
||||
params.append(map.get(loop)).append(",");
|
||||
}
|
||||
|
||||
RequestDataThriftDTO dataDto=new RequestDataThriftDTO(TomcatProfilerConstant.REQ_DATA_TYPE_DB_PREPARED_STATEMENT_PARAM,System.currentTimeMillis());
|
||||
dataDto.setDataString(params.toString());
|
||||
list.add(dataDto);
|
||||
}
|
||||
sqlParamMapThreadLocal.remove();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Add sql parameter
|
||||
* @param sequence
|
||||
* @param data
|
||||
*/
|
||||
public static void putSqlParam(int sequence,String data) {
|
||||
if(isRequestData()) {
|
||||
HashMap<Integer,String> map=sqlParamMapThreadLocal.get();
|
||||
if(map==null) {
|
||||
map=new HashMap<Integer,String>();
|
||||
}
|
||||
}
|
||||
dataDto.setDataHashCode(hashCode);
|
||||
}
|
||||
list.add(dataDto);
|
||||
requestDataThreadLocal.set(dto);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put SQL Query data into requestDataThreadLocal.
|
||||
*
|
||||
* @param dataType
|
||||
*/
|
||||
public static void putSqlQuery(int dataType, String data) {
|
||||
if (isRequestData()) {
|
||||
RequestDataListThriftDTO dto = requestDataThreadLocal.get();
|
||||
dto = checkDTO(dto);
|
||||
List<RequestDataThriftDTO> list = dto.getRequestDataList();
|
||||
// System.out.println("-----RequestDataListThriftDTO list size="+list.size());
|
||||
|
||||
checkSqlParamMap(list);
|
||||
|
||||
RequestDataThriftDTO dataDto = new RequestDataThriftDTO(dataType, System.currentTimeMillis());
|
||||
int dataHashCode = data.hashCode();
|
||||
dataDto.setDataHashCode(dataHashCode);
|
||||
boolean isAlreadySent = checkHashCode(dataHashCode);
|
||||
if (!isAlreadySent) {
|
||||
if (data != null) {
|
||||
dataDto.setDataString(QueryStringUtil.removeAllMultiSpace(data));
|
||||
}
|
||||
}
|
||||
list.add(dataDto);
|
||||
requestDataThreadLocal.set(dto);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check SQL Query HashCode set.
|
||||
* If Query count is over 10000, it can make memory problem.
|
||||
* So this method removes 100 hashCode.
|
||||
* <p/>
|
||||
* If you use HashSet this remove code will not run.
|
||||
*
|
||||
* @param dataHashCode
|
||||
* @return
|
||||
*/
|
||||
private static boolean checkHashCode(int dataHashCode) {
|
||||
if (TomcatProfilerConfig.QUERY_COUNT_OVER_10000) {
|
||||
//If sqlSet is CopyOnWriteArraySet, it removes data.
|
||||
if (sqlSet.size() > 10000) {
|
||||
Iterator<Integer> iterator = sqlSet.iterator();
|
||||
for (int loop = 0; loop < 100; loop++) {
|
||||
sqlSet.remove(iterator.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sqlSet.contains(dataHashCode)) {
|
||||
return true;
|
||||
} else {
|
||||
sqlSet.add(dataHashCode);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage sql param list
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
private static void checkSqlParamMap(List<RequestDataThriftDTO> list) {
|
||||
if (isRequestData()) {
|
||||
HashMap<Integer, String> map = sqlParamMapThreadLocal.get();
|
||||
if (map != null) {
|
||||
int mapSize = map.size();
|
||||
StringBuilder params = new StringBuilder();
|
||||
for (int loop = 1; loop <= mapSize; loop++) {
|
||||
params.append(map.get(loop)).append(",");
|
||||
}
|
||||
|
||||
RequestDataThriftDTO dataDto = new RequestDataThriftDTO(TomcatProfilerConstant.REQ_DATA_TYPE_DB_PREPARED_STATEMENT_PARAM, System.currentTimeMillis());
|
||||
dataDto.setDataString(params.toString());
|
||||
list.add(dataDto);
|
||||
}
|
||||
sqlParamMapThreadLocal.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add sql parameter
|
||||
*
|
||||
* @param sequence
|
||||
* @param data
|
||||
*/
|
||||
public static void putSqlParam(int sequence, String data) {
|
||||
if (isRequestData()) {
|
||||
HashMap<Integer, String> map = sqlParamMapThreadLocal.get();
|
||||
if (map == null) {
|
||||
map = new HashMap<Integer, String>();
|
||||
}
|
||||
// if(data!=null) {
|
||||
// try {
|
||||
// System.out.print("Before="+data);
|
||||
@@ -209,86 +223,92 @@ public class RequestDataTracer {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
map.put(sequence,data);
|
||||
sqlParamMapThreadLocal.set(map);
|
||||
}
|
||||
}
|
||||
public static void putSqlParam(int sequence,byte[] data) {
|
||||
putSqlParam(sequence,new String(data));
|
||||
}
|
||||
public static void putSqlParam(int sequence,Object data) {
|
||||
if(data!=null) {
|
||||
putSqlParam(sequence,data.toString());
|
||||
} else {
|
||||
putSqlParam(sequence,"null");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check RequestDataListThriftDTO is null.
|
||||
* If this object is null, current request called this Class first time.
|
||||
* So it make RequestDataListThriftDTO object.
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
private static RequestDataListThriftDTO checkDTO(RequestDataListThriftDTO dto) {
|
||||
if(dto==null) {
|
||||
// System.out.println("dto=null");
|
||||
dto=new RequestDataListThriftDTO(AgentInfoDTO.staticHostHashCode,RequestTransactionTracer.getRequestHashCode(),new ArrayList<RequestDataThriftDTO>());
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
/**
|
||||
* add ResultSet.next() method call count.
|
||||
*/
|
||||
public static void updateFetchCount() {
|
||||
Integer totalFetchCount=totalFetchCountThreadLocal.get();
|
||||
Integer fetchCount=fetchCountThreadLocal.get();
|
||||
if(totalFetchCount==null) {
|
||||
totalFetchCountThreadLocal.set(0);
|
||||
}
|
||||
if(fetchCount==null) {
|
||||
fetchCountThreadLocal.set(0);
|
||||
}
|
||||
totalFetchCountThreadLocal.set(totalFetchCountThreadLocal.get()+1);
|
||||
fetchCountThreadLocal.set(fetchCountThreadLocal.get()+1);
|
||||
}
|
||||
map.put(sequence, data);
|
||||
sqlParamMapThreadLocal.set(map);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Before transaction end, removes current thread's fetch count data.
|
||||
*/
|
||||
public static void removeFetchCount() {
|
||||
totalFetchCountThreadLocal.remove();
|
||||
fetchCountThreadLocal.remove();
|
||||
}
|
||||
/**
|
||||
* If ResultSet.close() method is called,
|
||||
* this method is called.
|
||||
*/
|
||||
public static void addResultSetData() {
|
||||
if(isRequestData()) {
|
||||
//set data fetch count
|
||||
Integer fetchCount=fetchCountThreadLocal.get();
|
||||
if(fetchCount!=null) {
|
||||
Integer totalFetchCount=totalFetchCountThreadLocal.get();
|
||||
fetchCountThreadLocal.remove();
|
||||
|
||||
RequestDataListThriftDTO dto=requestDataThreadLocal.get();
|
||||
dto=checkDTO(dto);
|
||||
List<RequestDataThriftDTO> list=dto.getRequestDataList();
|
||||
int listSize=list.size();
|
||||
RequestDataThriftDTO previousDTO=list.get(listSize-1);
|
||||
if(previousDTO.getDataType()!=TomcatProfilerConstant.REQ_DATA_TYPE_DB_FETCH) {
|
||||
RequestDataThriftDTO dataDto=new RequestDataThriftDTO(TomcatProfilerConstant.REQ_DATA_TYPE_DB_FETCH,System.currentTimeMillis());
|
||||
dataDto.setExtraInt1(fetchCount);
|
||||
dataDto.setExtraInt2(totalFetchCount);
|
||||
list.add(dataDto);
|
||||
} else {
|
||||
//Because of MS SQL.
|
||||
int previousTotalFetchCount=previousDTO.getExtraInt2();
|
||||
totalFetchCountThreadLocal.set(previousTotalFetchCount);
|
||||
}
|
||||
requestDataThreadLocal.set(dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void putSqlParam(int sequence, byte[] data) {
|
||||
putSqlParam(sequence, new String(data));
|
||||
}
|
||||
|
||||
public static void putSqlParam(int sequence, Object data) {
|
||||
if (data != null) {
|
||||
putSqlParam(sequence, data.toString());
|
||||
} else {
|
||||
putSqlParam(sequence, "null");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check RequestDataListThriftDTO is null.
|
||||
* If this object is null, current request called this Class first time.
|
||||
* So it make RequestDataListThriftDTO object.
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
private static RequestDataListThriftDTO checkDTO(RequestDataListThriftDTO dto) {
|
||||
if (dto == null) {
|
||||
// System.out.println("dto=null");
|
||||
dto = new RequestDataListThriftDTO(AgentInfoDTO.staticHostHashCode, RequestTransactionTracer.getRequestHashCode(), new ArrayList<RequestDataThriftDTO>());
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
/**
|
||||
* add ResultSet.next() method call count.
|
||||
*/
|
||||
public static void updateFetchCount() {
|
||||
Integer totalFetchCount = totalFetchCountThreadLocal.get();
|
||||
Integer fetchCount = fetchCountThreadLocal.get();
|
||||
if (totalFetchCount == null) {
|
||||
totalFetchCountThreadLocal.set(0);
|
||||
}
|
||||
if (fetchCount == null) {
|
||||
fetchCountThreadLocal.set(0);
|
||||
}
|
||||
totalFetchCountThreadLocal.set(totalFetchCountThreadLocal.get() + 1);
|
||||
fetchCountThreadLocal.set(fetchCountThreadLocal.get() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Before transaction end, removes current thread's fetch count data.
|
||||
*/
|
||||
public static void removeFetchCount() {
|
||||
totalFetchCountThreadLocal.remove();
|
||||
fetchCountThreadLocal.remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* If ResultSet.close() method is called,
|
||||
* this method is called.
|
||||
*/
|
||||
public static void addResultSetData() {
|
||||
if (isRequestData()) {
|
||||
//set data fetch count
|
||||
Integer fetchCount = fetchCountThreadLocal.get();
|
||||
if (fetchCount != null) {
|
||||
Integer totalFetchCount = totalFetchCountThreadLocal.get();
|
||||
fetchCountThreadLocal.remove();
|
||||
|
||||
RequestDataListThriftDTO dto = requestDataThreadLocal.get();
|
||||
dto = checkDTO(dto);
|
||||
List<RequestDataThriftDTO> list = dto.getRequestDataList();
|
||||
int listSize = list.size();
|
||||
RequestDataThriftDTO previousDTO = list.get(listSize - 1);
|
||||
if (previousDTO.getDataType() != TomcatProfilerConstant.REQ_DATA_TYPE_DB_FETCH) {
|
||||
RequestDataThriftDTO dataDto = new RequestDataThriftDTO(TomcatProfilerConstant.REQ_DATA_TYPE_DB_FETCH, System.currentTimeMillis());
|
||||
dataDto.setExtraInt1(fetchCount);
|
||||
dataDto.setExtraInt2(totalFetchCount);
|
||||
list.add(dataDto);
|
||||
} else {
|
||||
//Because of MS SQL.
|
||||
int previousTotalFetchCount = previousDTO.getExtraInt2();
|
||||
totalFetchCountThreadLocal.set(previousTotalFetchCount);
|
||||
}
|
||||
requestDataThreadLocal.set(dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,99 +12,109 @@ import com.profiler.sender.RequestDataSender;
|
||||
import com.profiler.sender.RequestTransactionDataSender;
|
||||
|
||||
public class RequestTransactionTracer extends AbstractTracer {
|
||||
// private static Hashtable<String,RequestThriftDTO> requestTable=new Hashtable<String,RequestThriftDTO>();
|
||||
private static Set<String> requestSet=null;
|
||||
static{
|
||||
requestSet=Collections.synchronizedSet(new HashSet<String>());
|
||||
}
|
||||
// private static Hashtable<String,RequestThriftDTO> requestTable=new Hashtable<String,RequestThriftDTO>();
|
||||
private static Set<String> requestSet = null;
|
||||
|
||||
public RequestTransactionTracer() {
|
||||
}
|
||||
private static final ThreadLocal<String> requestID=new ThreadLocal<String>();
|
||||
private static final ThreadLocal<Integer> requestHashCode=new ThreadLocal<Integer>();
|
||||
public static Integer getRequestHashCode() {
|
||||
return requestHashCode.get();
|
||||
}
|
||||
public static void startTransaction(String requestURL,String clientIP,long requestTime,StringBuilder params) {
|
||||
static {
|
||||
|
||||
requestSet = Collections.synchronizedSet(new HashSet<String>());
|
||||
}
|
||||
|
||||
public RequestTransactionTracer() {
|
||||
}
|
||||
|
||||
private static final ThreadLocal<String> requestID = new ThreadLocal<String>();
|
||||
private static final ThreadLocal<Integer> requestHashCode = new ThreadLocal<Integer>();
|
||||
|
||||
public static Integer getRequestHashCode() {
|
||||
return requestHashCode.get();
|
||||
}
|
||||
|
||||
public static void startTransaction(String requestURL, String clientIP, long requestTime, StringBuilder params) {
|
||||
// printStackTrace();
|
||||
// long cpuUserTime[]=getThreadTime();
|
||||
long cpuUserTime[]=new long[2];
|
||||
|
||||
String currentThreadName=Thread.currentThread().getName();
|
||||
//### set Thread id with thread local
|
||||
String tempRequestID=currentThreadName+"_"+System.nanoTime();
|
||||
requestID.set(tempRequestID);
|
||||
int tempRequestHashCode=tempRequestID.hashCode();
|
||||
requestHashCode.set(tempRequestHashCode);
|
||||
RequestThriftDTO dto=new RequestThriftDTO(AgentInfoDTO.staticHostHashCode,tempRequestHashCode,TomcatProfilerConstant.DATA_TYPE_REQUEST,requestTime,cpuUserTime[0],cpuUserTime[1]);
|
||||
dto.setClientIP(clientIP);
|
||||
dto.setRequestURL(requestURL);
|
||||
int paramsLength=params.length();
|
||||
if(paramsLength>0) {
|
||||
params.deleteCharAt(paramsLength-1);
|
||||
dto.setExtraData1(params.toString());
|
||||
}
|
||||
requestSet.add(requestID.get());
|
||||
RequestTransactionDataSender sender=new RequestTransactionDataSender(dto);
|
||||
sender.send();
|
||||
}
|
||||
/**
|
||||
* Transaction is successfully ended.
|
||||
*/
|
||||
public static void endTransaction() {
|
||||
long cpuUserTime[] = new long[2];
|
||||
|
||||
String currentThreadName = Thread.currentThread().getName();
|
||||
//### set Thread id with thread local
|
||||
String tempRequestID = currentThreadName + "_" + System.nanoTime();
|
||||
requestID.set(tempRequestID);
|
||||
int tempRequestHashCode = tempRequestID.hashCode();
|
||||
requestHashCode.set(tempRequestHashCode);
|
||||
RequestThriftDTO dto = new RequestThriftDTO(AgentInfoDTO.staticHostHashCode, tempRequestHashCode, TomcatProfilerConstant.DATA_TYPE_REQUEST, requestTime, cpuUserTime[0], cpuUserTime[1]);
|
||||
dto.setClientIP(clientIP);
|
||||
dto.setRequestURL(requestURL);
|
||||
int paramsLength = params.length();
|
||||
if (paramsLength > 0) {
|
||||
params.deleteCharAt(paramsLength - 1);
|
||||
dto.setExtraData1(params.toString());
|
||||
}
|
||||
requestSet.add(requestID.get());
|
||||
RequestTransactionDataSender sender = new RequestTransactionDataSender(dto);
|
||||
sender.send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Transaction is successfully ended.
|
||||
*/
|
||||
public static void endTransaction() {
|
||||
// long cpuUserTime[]=getThreadTime();
|
||||
long cpuUserTime[]=new long[2];
|
||||
RequestThriftDTO dto=new RequestThriftDTO(AgentInfoDTO.staticHostHashCode,requestHashCode.get(),TomcatProfilerConstant.DATA_TYPE_RESPONSE,System.currentTimeMillis(),cpuUserTime[0],cpuUserTime[1]);
|
||||
|
||||
finishTransaction(dto);
|
||||
}
|
||||
/**
|
||||
* There was an Exception processing transaction.
|
||||
* @param throwable
|
||||
*/
|
||||
public static void exceptionTransaction(Throwable throwable) {
|
||||
long cpuUserTime[] = new long[2];
|
||||
RequestThriftDTO dto = new RequestThriftDTO(AgentInfoDTO.staticHostHashCode, requestHashCode.get(), TomcatProfilerConstant.DATA_TYPE_RESPONSE, System.currentTimeMillis(), cpuUserTime[0], cpuUserTime[1]);
|
||||
|
||||
finishTransaction(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* There was an Exception processing transaction.
|
||||
*
|
||||
* @param throwable
|
||||
*/
|
||||
public static void exceptionTransaction(Throwable throwable) {
|
||||
// long cpuUserTime[]=getThreadTime();
|
||||
long cpuUserTime[]=new long[2];
|
||||
RequestThriftDTO dto=new RequestThriftDTO(AgentInfoDTO.staticHostHashCode,requestHashCode.get(),TomcatProfilerConstant.DATA_TYPE_UNCAUGHT_EXCEPTION,System.currentTimeMillis(),cpuUserTime[0],cpuUserTime[1]);
|
||||
dto.setExtraData1(throwable.getMessage());
|
||||
StackTraceElement[] tempElement=throwable.getStackTrace();
|
||||
dto.setExtraData2(tempElement[0].toString());
|
||||
|
||||
finishTransaction(dto);
|
||||
}
|
||||
/**
|
||||
* Transaction is ended and send request end data
|
||||
* @param dto
|
||||
*/
|
||||
public static void finishTransaction(RequestThriftDTO dto) {
|
||||
RequestDataListThriftDTO dataListDto=RequestDataTracer.getRequestDataList();
|
||||
if(dataListDto!=null) {
|
||||
RequestDataSender dSender=new RequestDataSender(dataListDto);
|
||||
dSender.send();
|
||||
}
|
||||
RequestTransactionDataSender tSender=new RequestTransactionDataSender(dto);
|
||||
tSender.send();
|
||||
|
||||
requestSet.remove(requestID.get());
|
||||
RequestDataTracer.removeRequestDataList();
|
||||
|
||||
RequestDataTracer.removeFetchCount();
|
||||
}
|
||||
|
||||
public static int getActiveThreadCount() {
|
||||
return requestSet.size();
|
||||
}
|
||||
/* If every time call Thread's CPU time
|
||||
* it affect to TPS and CPU usage.
|
||||
* It is one of bottle neck.
|
||||
public static long[] getThreadTime() {
|
||||
long result[]=new long[2];
|
||||
|
||||
ThreadMXBean bean=ManagementFactory.getThreadMXBean();
|
||||
// System.out.println(Thread.currentThread().getName()+" CPU:"+bean.getCurrentThreadCpuTime()+" User:"+bean.getCurrentThreadUserTime());
|
||||
result[0]=bean.getCurrentThreadCpuTime();
|
||||
result[1]=bean.getCurrentThreadUserTime();
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
long cpuUserTime[] = new long[2];
|
||||
RequestThriftDTO dto = new RequestThriftDTO(AgentInfoDTO.staticHostHashCode, requestHashCode.get(), TomcatProfilerConstant.DATA_TYPE_UNCAUGHT_EXCEPTION, System.currentTimeMillis(), cpuUserTime[0], cpuUserTime[1]);
|
||||
dto.setExtraData1(throwable.getMessage());
|
||||
StackTraceElement[] tempElement = throwable.getStackTrace();
|
||||
dto.setExtraData2(tempElement[0].toString());
|
||||
|
||||
finishTransaction(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transaction is ended and send request end data
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
public static void finishTransaction(RequestThriftDTO dto) {
|
||||
RequestDataListThriftDTO dataListDto = RequestDataTracer.getRequestDataList();
|
||||
if (dataListDto != null) {
|
||||
RequestDataSender dSender = new RequestDataSender(dataListDto);
|
||||
dSender.send();
|
||||
}
|
||||
RequestTransactionDataSender tSender = new RequestTransactionDataSender(dto);
|
||||
tSender.send();
|
||||
|
||||
requestSet.remove(requestID.get());
|
||||
RequestDataTracer.removeRequestDataList();
|
||||
|
||||
RequestDataTracer.removeFetchCount();
|
||||
}
|
||||
|
||||
public static int getActiveThreadCount() {
|
||||
return requestSet.size();
|
||||
}
|
||||
/* If every time call Thread's CPU time
|
||||
* it affect to TPS and CPU usage.
|
||||
* It is one of bottle neck.
|
||||
public static long[] getThreadTime() {
|
||||
long result[]=new long[2];
|
||||
|
||||
ThreadMXBean bean=ManagementFactory.getThreadMXBean();
|
||||
// System.out.println(Thread.currentThread().getName()+" CPU:"+bean.getCurrentThreadCpuTime()+" User:"+bean.getCurrentThreadUserTime());
|
||||
result[0]=bean.getCurrentThreadCpuTime();
|
||||
result[1]=bean.getCurrentThreadUserTime();
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1,32 +1,41 @@
|
||||
package com.profiler.util;
|
||||
|
||||
import com.profiler.logging.Logger;
|
||||
import javassist.ClassPool;
|
||||
import javassist.CtClass;
|
||||
import javassist.CtConstructor;
|
||||
import javassist.CtMethod;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ByteCodeUtil {
|
||||
// TODO logger 를 별도로 써야 되는지 않는지 검토.
|
||||
private static final Logger logger = Logger.getLogger(ByteCodeUtil.class);
|
||||
private static final Logger logger = Logger.getLogger(ByteCodeUtil.class.getName());
|
||||
|
||||
public static void printClassInfo(ClassPool classPool, String className) {
|
||||
logger.debug("Printing Class Info of [" + className + "]");
|
||||
try {
|
||||
logger.debug("try");
|
||||
String javaassistClassName = className.replace('/', '.');
|
||||
logger.debug("replace");
|
||||
CtClass cc = classPool.get(javaassistClassName);
|
||||
logger.debug("ClassName:" + javaassistClassName);
|
||||
CtConstructor[] constructorList = cc.getConstructors();
|
||||
if (!logger.isLoggable(Level.FINE)) {
|
||||
return;
|
||||
}
|
||||
logger.fine("Printing Class Info of [" + className + "]");
|
||||
try {
|
||||
logger.fine("try");
|
||||
|
||||
String javaassistClassName = className.replace('/', '.');
|
||||
logger.fine("replace");
|
||||
|
||||
CtClass cc = classPool.get(javaassistClassName);
|
||||
logger.fine("ClassName:" + javaassistClassName);
|
||||
|
||||
CtConstructor[] constructorList = cc.getConstructors();
|
||||
|
||||
for (CtConstructor cons : constructorList) {
|
||||
try {
|
||||
String signature = cons.getSignature();
|
||||
logger.info("Constructor signature:%s", signature);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
logger.info("Constructor signature:" + signature);
|
||||
} catch (Exception e) {
|
||||
if(logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,27 +45,27 @@ public class ByteCodeUtil {
|
||||
try {
|
||||
String methodName = tempMethod.getLongName();
|
||||
|
||||
logger.debug("MethodName:" + methodName);
|
||||
logger.fine("MethodName:" + methodName);
|
||||
|
||||
CtClass[] params = tempMethod.getParameterTypes();
|
||||
|
||||
if (params.length != 0) {
|
||||
int paramsLength = params.length;
|
||||
for (int loop = paramsLength - 1; loop > 0; loop--) {
|
||||
logger.debug("Param" + loop + ":" + params[loop].getName());
|
||||
logger.fine("Param" + loop + ":" + params[loop].getName());
|
||||
}
|
||||
} else {
|
||||
logger.debug(" No params");
|
||||
}
|
||||
|
||||
logger.debug("ReturnType=" + tempMethod.getReturnType().getName());
|
||||
logger.fine(" No params");
|
||||
}
|
||||
logger.fine("ReturnType=" + tempMethod.getReturnType().getName());
|
||||
} catch (Exception methodException) {
|
||||
logger.error("Exception : " + methodException.getMessage());
|
||||
logger.log(Level.WARNING, "Exception :" + methodException.getMessage(), methodException);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user