mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-18 01:06:03 +10:00
[#103] Removed private projects
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
/.settings/
|
||||
/.project
|
||||
@@ -1,5 +0,0 @@
|
||||
/target/
|
||||
/*.iml
|
||||
/.settings/
|
||||
/.classpath
|
||||
/.project
|
||||
@@ -1,116 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.nhn.pinpoint</groupId>
|
||||
<artifactId>pinpoint-naver</artifactId>
|
||||
<version>1.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pinpoint-naver-agent</artifactId>
|
||||
<name>Pinpoint agent distribution for Naver</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<distribution.directory>${project.build.directory}/pinpoint-agent</distribution.directory>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.nhn.pinpoint</groupId>
|
||||
<artifactId>pinpoint-agent</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nhn.pinpoint</groupId>
|
||||
<artifactId>pinpoint-naver-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.nhncorp</groupId>
|
||||
<artifactId>triples-redis-client</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>${basedir}/src/test/java</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</testResource>
|
||||
<testResource>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/test/resources</directory>
|
||||
</testResource>
|
||||
</testResources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<inherited>true</inherited>
|
||||
<configuration>
|
||||
<debug>true</debug>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<includeScope>runtime</includeScope>
|
||||
<!-- pinpoint-bootstrap will be placed in the root of distribution directory. pinpoint-commons is included in pinpoint-bootstrap. -->
|
||||
<excludeArtifactIds>pinpoint-bootstrap,pinpoint-commons</excludeArtifactIds>
|
||||
<outputDirectory>${distribution.directory}/lib</outputDirectory>
|
||||
<overWriteReleases>true</overWriteReleases>
|
||||
<overWriteSnapshots>true</overWriteSnapshots>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-bootstrap-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<includeArtifactIds>pinpoint-bootstrap</includeArtifactIds>
|
||||
<outputDirectory>${distribution.directory}</outputDirectory>
|
||||
<overWriteReleases>true</overWriteReleases>
|
||||
<overWriteSnapshots>true</overWriteSnapshots>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-pinpoint-resources</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${distribution.directory}</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/src/main/resources-${env}</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
|
||||
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<layout class="org.apache.log4j.EnhancedPatternLayout">
|
||||
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-35c{1.}) %m%n" />
|
||||
<!-- %L 옵션은 라인넘버가 출력되나 속도저하가 심하다. -->
|
||||
<!--<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-30c{1}) %m%n" />-->
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="dailyRollingFile" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="file" value="${pinpoint.log}/${pinpoint.agentId}-pinpoint.log" />
|
||||
<param name="Append" value="true" />
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
|
||||
|
||||
<layout class="org.apache.log4j.EnhancedPatternLayout">
|
||||
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-35c{1.}) %m%n" />
|
||||
<!-- %L 옵션은 라인넘버가 출력되나 속도저하가 심하다. -->
|
||||
<!--<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-30c{1}) %m%n" />-->
|
||||
</layout>
|
||||
|
||||
</appender>
|
||||
|
||||
|
||||
<logger name="com.nhn.pinpoint" additivity="false">
|
||||
<level value="INFO" />
|
||||
<!--<appender-ref ref="console" />-->
|
||||
<appender-ref ref="dailyRollingFile" />
|
||||
</logger>
|
||||
|
||||
|
||||
<root>
|
||||
<level value="INFO" />
|
||||
<!--<appender-ref ref="console" />-->
|
||||
<appender-ref ref="dailyRollingFile" />
|
||||
</root>
|
||||
</log4j:configuration>
|
||||
@@ -1,212 +0,0 @@
|
||||
#
|
||||
# Pinpoint agent configuration
|
||||
# (Phase : dev)
|
||||
#
|
||||
|
||||
###########################################################
|
||||
# Collector server #
|
||||
###########################################################
|
||||
# placeHolder
|
||||
profiler.collector.ip=dev.collector.pinpoint.navercorp.com
|
||||
|
||||
# placeHolder support "${key}"
|
||||
profiler.collector.span.ip=${profiler.collector.ip}
|
||||
profiler.collector.span.port=9996
|
||||
|
||||
# placeHolder support "${key}"
|
||||
profiler.collector.stat.ip=${profiler.collector.ip}
|
||||
profiler.collector.stat.port=9995
|
||||
|
||||
# placeHolder support "${key}"
|
||||
profiler.collector.tcp.ip=${profiler.collector.ip}
|
||||
profiler.collector.tcp.port=9994
|
||||
|
||||
|
||||
###########################################################
|
||||
# Profiler Global Configuration #
|
||||
###########################################################
|
||||
profiler.enable=true
|
||||
|
||||
profiler.jvm.collect.interval=1000
|
||||
|
||||
profiler.sampling.enable=true
|
||||
|
||||
# 아래 지정한 값중 한 개의 트랜잭션을 수집합니다. (예를들어 1로 지정하면 100%수집, 2로 지정하면 50%수집 셈)
|
||||
profiler.sampling.rate=1
|
||||
|
||||
# span을 Io에 flush할 경우 buffering 여부
|
||||
profiler.io.buffering.enable=true
|
||||
|
||||
# buffering 시 몇개 까지 저장할지 여부
|
||||
profiler.io.buffering.buffersize=20
|
||||
|
||||
profiler.spandatasender.write.queue.size=5120
|
||||
#profiler.spandatasender.socket.sendbuffersize=1048576
|
||||
#profiler.spandatasender.socket.timeout=3000
|
||||
profiler.spandatasender.chunk.size=16384
|
||||
|
||||
profiler.statdatasender.write.queue.size=5120
|
||||
#profiler.statdatasender.socket.sendbuffersize=1048576
|
||||
#profiler.statdatasender.socket.timeout=3000
|
||||
profiler.statdatasender.chunk.size=16384
|
||||
|
||||
profiler.agentInfo.send.retry.interval=300000
|
||||
|
||||
# Tcp Data Command 허용 여부
|
||||
profiler.tcpdatasender.command.accept.enable=true
|
||||
|
||||
###########################################################
|
||||
# application type #
|
||||
###########################################################
|
||||
#profiler.applicationservertype=TOMCAT
|
||||
#profiler.applicationservertype=BLOC
|
||||
|
||||
|
||||
###########################################################
|
||||
# user defined classes #
|
||||
###########################################################
|
||||
profiler.include=com.nhn.pinpoint.testweb.controller.*,com.nhn.pinpoint.testweb.MyClass
|
||||
|
||||
###########################################################
|
||||
# TOMCAT #
|
||||
###########################################################
|
||||
profiler.tomcat.hidepinpointheader=true
|
||||
#naver standard l7 check
|
||||
profiler.tomcat.excludeurl=/monitor/l7check.html
|
||||
#profiler.tomcat.excludeurl=/aa/test.html, /bb/exclude.html
|
||||
|
||||
###########################################################
|
||||
# JDBC #
|
||||
###########################################################
|
||||
profiler.jdbc=true
|
||||
profiler.jdbc.sqlcachesize=1024
|
||||
profiler.jdbc.maxsqlbindvaluesize=1024
|
||||
|
||||
#
|
||||
# MYSQL
|
||||
#
|
||||
profiler.jdbc.mysql=true
|
||||
profiler.jdbc.mysql.setautocommit=true
|
||||
profiler.jdbc.mysql.commit=true
|
||||
profiler.jdbc.mysql.rollback=true
|
||||
|
||||
#
|
||||
# MSSQL Jtds
|
||||
#
|
||||
profiler.jdbc.jtds=true
|
||||
profiler.jdbc.jtds.setautocommit=true
|
||||
profiler.jdbc.jtds.commit=true
|
||||
profiler.jdbc.jtds.rollback=true
|
||||
|
||||
#
|
||||
# Oracle
|
||||
#
|
||||
profiler.jdbc.oracle=true
|
||||
profiler.jdbc.oracle.setautocommit=true
|
||||
profiler.jdbc.oracle.commit=true
|
||||
profiler.jdbc.oracle.rollback=true
|
||||
|
||||
#
|
||||
# CUBRID
|
||||
#
|
||||
profiler.jdbc.cubrid=true
|
||||
profiler.jdbc.cubrid.setautocommit=true
|
||||
profiler.jdbc.cubrid.commit=true
|
||||
profiler.jdbc.cubrid.rollback=true
|
||||
|
||||
#
|
||||
# DBCP
|
||||
#
|
||||
profiler.jdbc.dbcp=true
|
||||
profiler.jdbc.dbcp.connectionclose=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# Apache HTTP Client 4.x #
|
||||
###########################################################
|
||||
profiler.apache.httpclient4=true
|
||||
profiler.apache.httpclient4.cookie=true
|
||||
|
||||
# cookie를 언제 덤프할지 결정. ALWAYS or EXCEPTION 2가지
|
||||
profiler.apache.httpclient4.cookie.dumptype=ALWAYS
|
||||
profiler.apache.httpclient4.cookie.sampling.rate=1
|
||||
|
||||
# post, put의 entity를 덤프한다. 단 HttpEtity.isRepeatable()=true 인 Entity에 한정된다.
|
||||
profiler.apache.httpclient4.entity=true
|
||||
|
||||
# entity를 언제 덤프할지 결정. ALWAYS or EXCEPTION 2가지
|
||||
profiler.apache.httpclient4.entity.dumptype=ALWAYS
|
||||
profiler.apache.httpclient4.entity.sampling.rate=1
|
||||
|
||||
profiler.apache.nio.httpclient4=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# Ning Async HTTP Client #
|
||||
###########################################################
|
||||
profiler.ning.asynchttpclient=true
|
||||
profiler.ning.asynchttpclient.cookie=true
|
||||
profiler.ning.asynchttpclient.cookie.dumptype=ALWAYS
|
||||
profiler.ning.asynchttpclient.cookie.dumpsize=1024
|
||||
profiler.ning.asynchttpclient.cookie.sampling.rate=1
|
||||
profiler.ning.asynchttpclient.entity=true
|
||||
profiler.ning.asynchttpclient.entity.dumptype=ALWAYS
|
||||
profiler.ning.asynchttpclient.entity.dumpsize=1024
|
||||
profiler.ning.asynchttpclient.entity.sampling.rate=1
|
||||
profiler.ning.asynchttpclient.param=true
|
||||
profiler.ning.asynchttpclient.param.dumptype=ALWAYS
|
||||
profiler.ning.asynchttpclient.param.dumpsize=1024
|
||||
profiler.ning.asynchttpclient.param.sampling.rate=1
|
||||
|
||||
|
||||
###########################################################
|
||||
# LINE+ baseframework #
|
||||
###########################################################
|
||||
profiler.line.game.netty.param.dumpsize=512
|
||||
profiler.line.game.netty.entity.dumpsize=512
|
||||
|
||||
|
||||
###########################################################
|
||||
# Arcus #
|
||||
###########################################################
|
||||
profiler.arcus=true
|
||||
profiler.arcus.keytrace=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# Memcached #
|
||||
###########################################################
|
||||
profiler.memcached=true
|
||||
profiler.memcached.keytrace=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# ibatis #
|
||||
###########################################################
|
||||
profiler.orm.ibatis=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# mybatis #
|
||||
###########################################################
|
||||
profiler.orm.mybatis=true
|
||||
|
||||
###########################################################
|
||||
# redis #
|
||||
###########################################################
|
||||
profiler.redis=true
|
||||
profiler.redis.pipeline=true
|
||||
|
||||
###########################################################
|
||||
# nBase-ARC #
|
||||
###########################################################
|
||||
profiler.nbase_arc=true
|
||||
profiler.nbase_arc.pipeline=true
|
||||
|
||||
###########################################################
|
||||
# spring-beans
|
||||
###########################################################
|
||||
profiler.spring.beans=false
|
||||
profiler.spring.beans.name.pattern=
|
||||
profiler.spring.beans.class.pattern=
|
||||
profiler.spring.beans.annotation=org.springframework.stereotype.Controller,org.springframework.stereotype.Service,org.springframework.stereotype.Repository
|
||||
@@ -1,40 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
|
||||
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<layout class="org.apache.log4j.EnhancedPatternLayout">
|
||||
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-35c{1.}:%-3L) %m%n" />
|
||||
<!-- %L 옵션은 라인넘버가 출력되나 속도저하가 심하다. -->
|
||||
<!--<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-30c{1}) %m%n" />-->
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="dailyRollingFile" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="file" value="${pinpoint.log}/${pinpoint.agentId}-pinpoint.log" />
|
||||
<param name="Append" value="true" />
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
|
||||
|
||||
<layout class="org.apache.log4j.EnhancedPatternLayout">
|
||||
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-35c{1.}) %m%n" />
|
||||
<!-- %L 옵션은 라인넘버가 출력되나 속도저하가 심하다. -->
|
||||
<!--<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-30c{1}) %m%n" />-->
|
||||
</layout>
|
||||
|
||||
</appender>
|
||||
|
||||
|
||||
<logger name="com.nhn.pinpoint" additivity="false">
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="console" />
|
||||
<appender-ref ref="dailyRollingFile" />
|
||||
</logger>
|
||||
|
||||
|
||||
|
||||
<root>
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="console" />
|
||||
<appender-ref ref="dailyRollingFile" />
|
||||
</root>
|
||||
</log4j:configuration>
|
||||
@@ -1,217 +0,0 @@
|
||||
#
|
||||
# Pinpoint agent configuration
|
||||
# (Phase : local)
|
||||
#
|
||||
|
||||
###########################################################
|
||||
# Collector server #
|
||||
###########################################################
|
||||
# local
|
||||
profiler.collector.ip=127.0.0.1
|
||||
# dev
|
||||
#profiler.collector.ip=dev.collector.pinpoint.navercorp.com
|
||||
# real
|
||||
#profiler.collector.ip=collector.pinpoint.navercorp.com
|
||||
|
||||
# placeHolder support "${key}"
|
||||
profiler.collector.span.ip=${profiler.collector.ip}
|
||||
profiler.collector.span.port=9996
|
||||
|
||||
# placeHolder support "${key}"
|
||||
profiler.collector.stat.ip=${profiler.collector.ip}
|
||||
profiler.collector.stat.port=9995
|
||||
|
||||
# placeHolder support "${key}"
|
||||
profiler.collector.tcp.ip=${profiler.collector.ip}
|
||||
profiler.collector.tcp.port=9994
|
||||
|
||||
|
||||
###########################################################
|
||||
# Profiler Global Configuration #
|
||||
###########################################################
|
||||
profiler.enable=true
|
||||
|
||||
profiler.jvm.collect.interval=1000
|
||||
|
||||
profiler.sampling.enable=true
|
||||
|
||||
# 아래 지정한 값중 한 개의 트랜잭션을 수집합니다. (예를들어 1로 지정하면 100%수집, 2로 지정하면 50%수집 셈)
|
||||
profiler.sampling.rate=1
|
||||
|
||||
# span을 Io에 flush할 경우 buffering 여부
|
||||
profiler.io.buffering.enable=true
|
||||
|
||||
# buffering 시 몇개 까지 저장할지 여부
|
||||
profiler.io.buffering.buffersize=20
|
||||
|
||||
|
||||
|
||||
profiler.spandatasender.write.queue.size=5120
|
||||
#profiler.spandatasender.socket.sendbuffersize=1048576
|
||||
#profiler.spandatasender.socket.timeout=3000
|
||||
profiler.spandatasender.chunk.size=16384
|
||||
|
||||
profiler.statdatasender.write.queue.size=5120
|
||||
#profiler.statdatasender.socket.sendbuffersize=1048576
|
||||
#profiler.statdatasender.socket.timeout=3000
|
||||
profiler.statdatasender.chunk.size=16384
|
||||
|
||||
profiler.agentInfo.send.retry.interval=300000
|
||||
|
||||
# Tcp Data Command 허용 여부
|
||||
profiler.tcpdatasender.command.accept.enable=true
|
||||
|
||||
###########################################################
|
||||
# application type #
|
||||
###########################################################
|
||||
#profiler.applicationservertype=TOMCAT
|
||||
#profiler.applicationservertype=BLOC
|
||||
|
||||
|
||||
###########################################################
|
||||
# user defined classes #
|
||||
###########################################################
|
||||
profiler.include=com.nhn.pinpoint.testweb.controller.*,com.nhn.pinpoint.testweb.MyClass
|
||||
|
||||
###########################################################
|
||||
# TOMCAT #
|
||||
###########################################################
|
||||
profiler.tomcat.hidepinpointheader=true
|
||||
#naver standard l7 check
|
||||
profiler.tomcat.excludeurl=/monitor/l7check.html
|
||||
#profiler.tomcat.excludeurl=/aa/test.html, /bb/exclude.html
|
||||
|
||||
###########################################################
|
||||
# JDBC #
|
||||
###########################################################
|
||||
profiler.jdbc=true
|
||||
profiler.jdbc.sqlcachesize=1024
|
||||
profiler.jdbc.maxsqlbindvaluesize=1024
|
||||
|
||||
#
|
||||
# MYSQL
|
||||
#
|
||||
profiler.jdbc.mysql=true
|
||||
profiler.jdbc.mysql.setautocommit=true
|
||||
profiler.jdbc.mysql.commit=true
|
||||
profiler.jdbc.mysql.rollback=true
|
||||
|
||||
#
|
||||
# MSSQL Jtds
|
||||
#
|
||||
profiler.jdbc.jtds=true
|
||||
profiler.jdbc.jtds.setautocommit=true
|
||||
profiler.jdbc.jtds.commit=true
|
||||
profiler.jdbc.jtds.rollback=true
|
||||
|
||||
#
|
||||
# Oracle
|
||||
#
|
||||
profiler.jdbc.oracle=true
|
||||
profiler.jdbc.oracle.setautocommit=true
|
||||
profiler.jdbc.oracle.commit=true
|
||||
profiler.jdbc.oracle.rollback=true
|
||||
|
||||
#
|
||||
# CUBRID
|
||||
#
|
||||
profiler.jdbc.cubrid=true
|
||||
profiler.jdbc.cubrid.setautocommit=true
|
||||
profiler.jdbc.cubrid.commit=true
|
||||
profiler.jdbc.cubrid.rollback=true
|
||||
|
||||
#
|
||||
# DBCP
|
||||
#
|
||||
profiler.jdbc.dbcp=true
|
||||
profiler.jdbc.dbcp.connectionclose=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# Apache HTTP Client 4.x #
|
||||
###########################################################
|
||||
profiler.apache.httpclient4=true
|
||||
profiler.apache.httpclient4.cookie=true
|
||||
|
||||
# cookie를 언제 덤프할지 결정. ALWAYS or EXCEPTION 2가지
|
||||
profiler.apache.httpclient4.cookie.dumptype=ALWAYS
|
||||
profiler.apache.httpclient4.cookie.sampling.rate=1
|
||||
|
||||
# post, put의 entity를 덤프한다. 단 HttpEtity.isRepeatable()=true 인 Entity에 한정된다.
|
||||
profiler.apache.httpclient4.entity=true
|
||||
|
||||
# entity를 언제 덤프할지 결정. ALWAYS or EXCEPTION 2가지
|
||||
profiler.apache.httpclient4.entity.dumptype=ALWAYS
|
||||
profiler.apache.httpclient4.entity.sampling.rate=1
|
||||
|
||||
profiler.apache.nio.httpclient4=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# Ning Async HTTP Client #
|
||||
###########################################################
|
||||
profiler.ning.asynchttpclient=true
|
||||
profiler.ning.asynchttpclient.cookie=true
|
||||
profiler.ning.asynchttpclient.cookie.dumptype=ALWAYS
|
||||
profiler.ning.asynchttpclient.cookie.dumpsize=1024
|
||||
profiler.ning.asynchttpclient.cookie.sampling.rate=1
|
||||
profiler.ning.asynchttpclient.entity=true
|
||||
profiler.ning.asynchttpclient.entity.dumptype=ALWAYS
|
||||
profiler.ning.asynchttpclient.entity.dumpsize=1024
|
||||
profiler.ning.asynchttpclient.entity.sampling.rate=1
|
||||
profiler.ning.asynchttpclient.param=true
|
||||
profiler.ning.asynchttpclient.param.dumptype=ALWAYS
|
||||
profiler.ning.asynchttpclient.param.dumpsize=1024
|
||||
profiler.ning.asynchttpclient.param.sampling.rate=1
|
||||
|
||||
|
||||
###########################################################
|
||||
# LINE+ baseframework #
|
||||
###########################################################
|
||||
profiler.line.game.netty.param.dumpsize=512
|
||||
profiler.line.game.netty.entity.dumpsize=512
|
||||
|
||||
|
||||
###########################################################
|
||||
# Arcus #
|
||||
###########################################################
|
||||
profiler.arcus=true
|
||||
profiler.arcus.keytrace=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# Memcached #
|
||||
###########################################################
|
||||
profiler.memcached=true
|
||||
profiler.memcached.keytrace=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# ibatis #
|
||||
###########################################################
|
||||
profiler.orm.ibatis=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# mybatis #
|
||||
###########################################################
|
||||
profiler.orm.mybatis=true
|
||||
|
||||
###########################################################
|
||||
# redis #
|
||||
###########################################################
|
||||
profiler.redis=true
|
||||
profiler.redis.pipeline=true
|
||||
|
||||
###########################################################
|
||||
# nBase-ARC #
|
||||
###########################################################
|
||||
profiler.nbase_arc=true
|
||||
profiler.nbase_arc.pipeline=true
|
||||
###########################################################
|
||||
# spring-beans
|
||||
###########################################################
|
||||
profiler.spring.beans=false
|
||||
profiler.spring.beans.name.pattern=
|
||||
profiler.spring.beans.class.pattern=
|
||||
profiler.spring.beans.annotation=org.springframework.stereotype.Controller,org.springframework.stereotype.Service,org.springframework.stereotype.Repository
|
||||
@@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
|
||||
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<layout class="org.apache.log4j.EnhancedPatternLayout">
|
||||
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-35c{1.}) %m%n" />
|
||||
<!-- %L 옵션은 라인넘버가 출력되나 속도저하가 심하다. -->
|
||||
<!--<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-30c{1}) %m%n" />-->
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="dailyRollingFile" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="file" value="${pinpoint.log}/${pinpoint.agentId}-pinpoint.log" />
|
||||
|
||||
<param name="Append" value="true" />
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
|
||||
|
||||
<layout class="org.apache.log4j.EnhancedPatternLayout">
|
||||
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-35c{1.}) %m%n" />
|
||||
</layout>
|
||||
|
||||
</appender>
|
||||
|
||||
|
||||
<logger name="com.nhn.pinpoint" additivity="false">
|
||||
<level value="INFO" />
|
||||
<!--<appender-ref ref="console" />-->
|
||||
<appender-ref ref="dailyRollingFile" />
|
||||
</logger>
|
||||
|
||||
|
||||
<root>
|
||||
<level value="INFO" />
|
||||
<!--<appender-ref ref="console" />-->
|
||||
<appender-ref ref="dailyRollingFile" />
|
||||
</root>
|
||||
</log4j:configuration>
|
||||
@@ -1,215 +0,0 @@
|
||||
#
|
||||
# Pinpoint agent configuration
|
||||
# (Phase : release)
|
||||
#
|
||||
|
||||
###########################################################
|
||||
# Collector server #
|
||||
###########################################################
|
||||
# placeHolder
|
||||
profiler.collector.ip=collector.pinpoint.navercorp.com
|
||||
|
||||
# placeHolder support "${key}"
|
||||
profiler.collector.span.ip=${profiler.collector.ip}
|
||||
profiler.collector.span.port=9996
|
||||
|
||||
# placeHolder support "${key}"
|
||||
profiler.collector.stat.ip=${profiler.collector.ip}
|
||||
profiler.collector.stat.port=9995
|
||||
|
||||
# placeHolder support "${key}"
|
||||
profiler.collector.tcp.ip=${profiler.collector.ip}
|
||||
profiler.collector.tcp.port=9994
|
||||
|
||||
|
||||
###########################################################
|
||||
# Profiler Global Configuration #
|
||||
###########################################################
|
||||
profiler.enable=true
|
||||
|
||||
profiler.jvm.collect.interval=1000
|
||||
|
||||
profiler.sampling.enable=true
|
||||
|
||||
# 아래 지정한 값중 한 개의 트랜잭션을 수집합니다. (예를들어 1로 지정하면 100%수집, 2로 지정하면 50%수집 셈)
|
||||
profiler.sampling.rate=20
|
||||
|
||||
# span을 Io에 flush할 경우 buffering 여부
|
||||
profiler.io.buffering.enable=true
|
||||
|
||||
# buffering 시 몇개 까지 저장할지 여부
|
||||
profiler.io.buffering.buffersize=20
|
||||
|
||||
|
||||
profiler.spandatasender.write.queue.size=5120
|
||||
#profiler.spandatasender.socket.sendbuffersize=1048576
|
||||
#profiler.spandatasender.socket.timeout=3000
|
||||
profiler.spandatasender.chunk.size=16384
|
||||
|
||||
profiler.statdatasender.write.queue.size=5120
|
||||
#profiler.statdatasender.socket.sendbuffersize=1048576
|
||||
#profiler.statdatasender.socket.timeout=3000
|
||||
profiler.statdatasender.chunk.size=16384
|
||||
|
||||
profiler.agentInfo.send.retry.interval=60000
|
||||
|
||||
# Tcp Data Command 허용 여부
|
||||
profiler.tcpdatasender.command.accept.enable=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# application type #
|
||||
###########################################################
|
||||
#profiler.applicationservertype=TOMCAT
|
||||
#profiler.applicationservertype=BLOC
|
||||
|
||||
|
||||
###########################################################
|
||||
# user defined classes #
|
||||
###########################################################
|
||||
profiler.include=com.nhn.pinpoint.testweb.controller.*,com.nhn.pinpoint.testweb.MyClass
|
||||
|
||||
###########################################################
|
||||
# TOMCAT #
|
||||
###########################################################
|
||||
profiler.tomcat.hidepinpointheader=true
|
||||
#naver standard l7 check
|
||||
profiler.tomcat.excludeurl=/monitor/l7check.html
|
||||
#profiler.tomcat.excludeurl=/aa/test.html, /bb/exclude.html
|
||||
|
||||
###########################################################
|
||||
# JDBC #
|
||||
###########################################################
|
||||
profiler.jdbc=true
|
||||
profiler.jdbc.sqlcachesize=1024
|
||||
profiler.jdbc.maxsqlbindvaluesize=1024
|
||||
|
||||
#
|
||||
# MYSQL
|
||||
#
|
||||
profiler.jdbc.mysql=true
|
||||
profiler.jdbc.mysql.setautocommit=false
|
||||
profiler.jdbc.mysql.commit=false
|
||||
profiler.jdbc.mysql.rollback=false
|
||||
|
||||
#
|
||||
# MSSQL Jtds
|
||||
#
|
||||
profiler.jdbc.jtds=true
|
||||
profiler.jdbc.jtds.setautocommit=false
|
||||
profiler.jdbc.jtds.commit=false
|
||||
profiler.jdbc.jtds.rollback=false
|
||||
|
||||
#
|
||||
# Oracle
|
||||
#
|
||||
profiler.jdbc.oracle=true
|
||||
profiler.jdbc.oracle.setautocommit=false
|
||||
profiler.jdbc.oracle.commit=false
|
||||
profiler.jdbc.oracle.rollback=false
|
||||
|
||||
#
|
||||
# CUBRID
|
||||
#
|
||||
profiler.jdbc.cubrid=true
|
||||
profiler.jdbc.cubrid.setautocommit=false
|
||||
profiler.jdbc.cubrid.commit=false
|
||||
profiler.jdbc.cubrid.rollback=false
|
||||
|
||||
#
|
||||
# DBCP
|
||||
#
|
||||
profiler.jdbc.dbcp=true
|
||||
profiler.jdbc.dbcp.connectionclose=false
|
||||
|
||||
|
||||
###########################################################
|
||||
# Apache HTTP Client 4.x #
|
||||
###########################################################
|
||||
profiler.apache.httpclient4=true
|
||||
profiler.apache.httpclient4.cookie=true
|
||||
|
||||
# cookie를 언제 덤프할지 결정. ALWAYS or EXCEPTION 2가지
|
||||
profiler.apache.httpclient4.cookie.dumptype=EXCEPTION
|
||||
profiler.apache.httpclient4.cookie.sampling.rate=10
|
||||
|
||||
# post, put의 entity를 덤프한다. 단 HttpEtity.isRepeatable()=true 인 Entity에 한정된다.
|
||||
profiler.apache.httpclient4.entity=false
|
||||
|
||||
# entity를 언제 덤프할지 결정. ALWAYS or EXCEPTION 2가지
|
||||
profiler.apache.httpclient4.entity.dumptype=EXCEPTION
|
||||
profiler.apache.httpclient4.entity.sampling.rate=10
|
||||
|
||||
profiler.apache.nio.httpclient4=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# Ning Async HTTP Client #
|
||||
###########################################################
|
||||
profiler.ning.asynchttpclient=true
|
||||
profiler.ning.asynchttpclient.cookie=true
|
||||
profiler.ning.asynchttpclient.cookie.dumptype=EXCEPTION
|
||||
profiler.ning.asynchttpclient.cookie.dumpsize=1024
|
||||
profiler.ning.asynchttpclient.cookie.sampling.rate=10
|
||||
profiler.ning.asynchttpclient.entity=false
|
||||
profiler.ning.asynchttpclient.entity.dumptype=EXCEPTION
|
||||
profiler.ning.asynchttpclient.entity.dumpsize=1024
|
||||
profiler.ning.asynchttpclient.entity.sampling.rate=10
|
||||
profiler.ning.asynchttpclient.param=false
|
||||
profiler.ning.asynchttpclient.param.dumptype=EXCEPTION
|
||||
profiler.ning.asynchttpclient.param.dumpsize=1024
|
||||
profiler.ning.asynchttpclient.param.sampling.rate=10
|
||||
|
||||
|
||||
###########################################################
|
||||
# LINE+ baseframework #
|
||||
###########################################################
|
||||
profiler.line.game.netty.param.dumpsize=512
|
||||
profiler.line.game.netty.entity.dumpsize=512
|
||||
|
||||
|
||||
###########################################################
|
||||
# Arcus #
|
||||
###########################################################
|
||||
profiler.arcus=true
|
||||
profiler.arcus.keytrace=false
|
||||
|
||||
|
||||
###########################################################
|
||||
# Memcached #
|
||||
###########################################################
|
||||
profiler.memcached=true
|
||||
profiler.memcached.keytrace=false
|
||||
|
||||
|
||||
###########################################################
|
||||
# ibatis #
|
||||
###########################################################
|
||||
profiler.orm.ibatis=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# mybatis #
|
||||
###########################################################
|
||||
profiler.orm.mybatis=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# redis #
|
||||
###########################################################
|
||||
profiler.redis=true
|
||||
profiler.redis.pipeline=true
|
||||
|
||||
###########################################################
|
||||
# nBase-ARC #
|
||||
###########################################################
|
||||
profiler.nbase_arc=true
|
||||
profiler.nbase_arc.pipeline=true
|
||||
|
||||
###########################################################
|
||||
# spring-beans
|
||||
###########################################################
|
||||
profiler.spring.beans=false
|
||||
profiler.spring.beans.name.pattern=
|
||||
profiler.spring.beans.class.pattern=
|
||||
profiler.spring.beans.annotation=org.springframework.stereotype.Controller,org.springframework.stereotype.Service,org.springframework.stereotype.Repository
|
||||
-85
@@ -1,85 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.exceptions.JedisDataException;
|
||||
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import com.nhn.pinpoint.common.bo.SpanEventBo;
|
||||
import com.nhn.pinpoint.test.junit4.BasePinpointTest;
|
||||
|
||||
public class JedisModifierTest extends BasePinpointTest {
|
||||
private static final String HOST = "10.99.116.91";
|
||||
private static final int PORT = 6390;
|
||||
|
||||
private Jedis jedis;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
// 생성자 인터셉터도 함께 테스트 해야 하는데 mock으로는 어려워서 실제 jedis를 사용한다.
|
||||
// jedis 주소는 nBase-ARC 개발환경의 redis 주소를 사용한다.
|
||||
jedis = new Jedis(HOST, PORT);
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
if (jedis != null) {
|
||||
jedis.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void traceMethod() {
|
||||
// get 명령을 실행하고 event 결과를 확인한다.
|
||||
jedis.get("foo");
|
||||
|
||||
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
|
||||
assertEquals(1, spanEvents.size());
|
||||
SpanEventBo event = spanEvents.get(0);
|
||||
|
||||
assertEquals(HOST + ":" + PORT, event.getEndPoint());
|
||||
assertEquals("REDIS", event.getDestinationId());
|
||||
assertEquals(ServiceType.REDIS, event.getServiceType());
|
||||
assertNull(event.getExceptionMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void traceBinaryMethod() {
|
||||
// get 명령을 실행하고 event 결과를 확인한다.
|
||||
jedis.get("foo".getBytes());
|
||||
|
||||
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
|
||||
assertEquals(1, spanEvents.size());
|
||||
SpanEventBo event = spanEvents.get(0);
|
||||
|
||||
assertEquals(HOST + ":" + PORT, event.getEndPoint());
|
||||
assertEquals("REDIS", event.getDestinationId());
|
||||
assertEquals(ServiceType.REDIS, event.getServiceType());
|
||||
assertNull(event.getExceptionMessage());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void traceMethodThrowException() {
|
||||
// 에러가 발생한 경우에 대한 event 결과를 확인한다.
|
||||
String key = null;
|
||||
try {
|
||||
jedis.get(key);
|
||||
} catch (JedisDataException e) {
|
||||
// 값이 null인 것에 대한 에러를 던진다.
|
||||
}
|
||||
|
||||
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
|
||||
assertEquals(1, spanEvents.size());
|
||||
SpanEventBo event = spanEvents.get(0);
|
||||
|
||||
assertNotNull(event.getExceptionMessage());
|
||||
}
|
||||
}
|
||||
-92
@@ -1,92 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.Pipeline;
|
||||
import redis.clients.jedis.exceptions.JedisDataException;
|
||||
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import com.nhn.pinpoint.common.bo.SpanEventBo;
|
||||
import com.nhn.pinpoint.test.junit4.BasePinpointTest;
|
||||
|
||||
public class JedisPipelineModifierTest extends BasePinpointTest {
|
||||
private static final String HOST = "10.99.116.91";
|
||||
private static final int PORT = 6390;
|
||||
|
||||
private Jedis jedis;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
// 생성자 인터셉터도 함께 테스트 해야 하는데 mock으로는 어려워서 실제 jedis를 사용한다.
|
||||
// jedis 주소는 nBase-ARC 개발환경의 redis 주소를 사용한다.
|
||||
jedis = new Jedis(HOST, PORT);
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
if (jedis != null) {
|
||||
jedis.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void traceMultikeyMethod() {
|
||||
// get 명령을 실행하고 event 결과를 확인한다.
|
||||
Pipeline pipeline = jedis.pipelined();
|
||||
pipeline.mget("foo");
|
||||
pipeline.syncAndReturnAll();
|
||||
|
||||
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
|
||||
assertEquals(2, spanEvents.size());
|
||||
SpanEventBo event = spanEvents.get(0);
|
||||
|
||||
System.out.println(event);
|
||||
assertEquals(HOST + ":" + PORT, event.getEndPoint());
|
||||
assertEquals("REDIS", event.getDestinationId());
|
||||
assertEquals(ServiceType.REDIS, event.getServiceType());
|
||||
assertNull(event.getExceptionMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void traceBaseMethod() {
|
||||
// get 명령을 실행하고 event 결과를 확인한다.
|
||||
Pipeline pipeline = jedis.pipelined();
|
||||
pipeline.get("foo");
|
||||
pipeline.syncAndReturnAll();
|
||||
|
||||
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
|
||||
assertEquals(2, spanEvents.size());
|
||||
SpanEventBo event = spanEvents.get(0);
|
||||
System.out.println(event);
|
||||
assertEquals(HOST + ":" + PORT, event.getEndPoint());
|
||||
assertEquals("REDIS", event.getDestinationId());
|
||||
assertEquals(ServiceType.REDIS, event.getServiceType());
|
||||
assertNull(event.getExceptionMessage());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void traceMethodThrowException() {
|
||||
// 에러가 발생한 경우에 대한 event 결과를 확인한다.
|
||||
String key = null;
|
||||
try {
|
||||
jedis.get(key);
|
||||
} catch (JedisDataException e) {
|
||||
// 값이 null인 것에 대한 에러를 던진다.
|
||||
}
|
||||
|
||||
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
|
||||
assertEquals(1, spanEvents.size());
|
||||
SpanEventBo event = spanEvents.get(0);
|
||||
|
||||
assertNotNull(event.getExceptionMessage());
|
||||
}
|
||||
|
||||
}
|
||||
-97
@@ -1,97 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.exceptions.JedisDataException;
|
||||
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import com.nhn.pinpoint.common.bo.SpanEventBo;
|
||||
import com.nhn.pinpoint.test.junit4.BasePinpointTest;
|
||||
import com.nhncorp.redis.cluster.RedisCluster;
|
||||
import com.nhncorp.redis.cluster.gateway.GatewayClient;
|
||||
import com.nhncorp.redis.cluster.gateway.GatewayConfig;
|
||||
|
||||
public class RedisClusterModifierTest extends BasePinpointTest {
|
||||
private static final String HOST = "10.99.116.91";
|
||||
private static final int PORT = 6390;
|
||||
private static final String ZK_ADDRESS = "dev.xnbasearc.navercorp.com:2181";
|
||||
private static final String CLUSTER_NAME = "java_client_test";
|
||||
|
||||
private RedisCluster redis;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
redis = new RedisCluster(HOST, PORT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void traceMethod() {
|
||||
redis.get("foo");
|
||||
|
||||
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
|
||||
assertEquals(1, spanEvents.size());
|
||||
SpanEventBo event = spanEvents.get(0);
|
||||
|
||||
assertEquals("NBASE_ARC", event.getDestinationId());
|
||||
assertEquals(HOST + ":" + PORT, event.getEndPoint());
|
||||
assertEquals(ServiceType.NBASE_ARC, event.getServiceType());
|
||||
assertNull(event.getExceptionMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void traceBinaryMethod() {
|
||||
redis.get("foo".getBytes());
|
||||
|
||||
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
|
||||
assertEquals(1, spanEvents.size());
|
||||
SpanEventBo event = spanEvents.get(0);
|
||||
|
||||
assertEquals("NBASE_ARC", event.getDestinationId());
|
||||
assertEquals(HOST + ":" + PORT, event.getEndPoint());
|
||||
assertEquals(ServiceType.NBASE_ARC, event.getServiceType());
|
||||
assertNull(event.getExceptionMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void traceDestinationId() {
|
||||
GatewayConfig config = new GatewayConfig();
|
||||
config.setZkAddress(ZK_ADDRESS);
|
||||
config.setClusterName(CLUSTER_NAME);
|
||||
|
||||
GatewayClient client = new GatewayClient(config);
|
||||
|
||||
client.get("foo");
|
||||
|
||||
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
|
||||
SpanEventBo event = spanEvents.get(spanEvents.size() - 1);
|
||||
|
||||
assertEquals(CLUSTER_NAME, event.getDestinationId());
|
||||
assertEquals(HOST + ":" + PORT, event.getEndPoint());
|
||||
assertEquals(ServiceType.NBASE_ARC, event.getServiceType());
|
||||
assertNull(event.getExceptionMessage());
|
||||
|
||||
client.destroy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void traceMethodThrowException() {
|
||||
// 에러가 발생한 경우에 대한 event 결과를 확인한다.
|
||||
String key = null;
|
||||
try {
|
||||
redis.get(key);
|
||||
} catch (JedisDataException e) {
|
||||
// 값이 null인 것에 대한 에러를 던진다.
|
||||
}
|
||||
|
||||
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
|
||||
assertEquals(1, spanEvents.size());
|
||||
SpanEventBo event = spanEvents.get(0);
|
||||
|
||||
assertNotNull(event.getExceptionMessage());
|
||||
}
|
||||
}
|
||||
-93
@@ -1,93 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import com.nhn.pinpoint.common.bo.SpanEventBo;
|
||||
import com.nhn.pinpoint.test.junit4.BasePinpointTest;
|
||||
import com.nhncorp.redis.cluster.gateway.GatewayAddress;
|
||||
import com.nhncorp.redis.cluster.gateway.GatewayClient;
|
||||
import com.nhncorp.redis.cluster.gateway.GatewayConfig;
|
||||
import com.nhncorp.redis.cluster.gateway.GatewayServer;
|
||||
import com.nhncorp.redis.cluster.pipeline.RedisClusterPipeline;
|
||||
|
||||
public class RedisClusterPipelineModifierTest extends BasePinpointTest {
|
||||
private static final String HOST = "10.99.116.91";
|
||||
private static final int PORT = 6390;
|
||||
private static final String ZK_ADDRESS = "dev.xnbasearc.navercorp.com:2181";
|
||||
private static final String CLUSTER_NAME = "java_client_test";
|
||||
|
||||
private RedisClusterPipeline pipeline;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
GatewayServer server = new GatewayServer(new GatewayAddress(HOST, PORT));
|
||||
pipeline = new RedisClusterPipeline(server);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void traceMethod() {
|
||||
pipeline.get("foo");
|
||||
pipeline.syncAndReturnAll();
|
||||
|
||||
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
|
||||
for (SpanEventBo bo : spanEvents) {
|
||||
System.out.println("### " + bo);
|
||||
}
|
||||
|
||||
assertEquals(2, spanEvents.size());
|
||||
SpanEventBo event = spanEvents.get(0);
|
||||
|
||||
assertEquals("NBASE_ARC", event.getDestinationId());
|
||||
assertEquals(HOST + ":" + PORT, event.getEndPoint());
|
||||
assertEquals(ServiceType.NBASE_ARC, event.getServiceType());
|
||||
assertNull(event.getExceptionMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void traceBinaryMethod() {
|
||||
pipeline.get("foo".getBytes());
|
||||
pipeline.syncAndReturnAll();
|
||||
|
||||
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
|
||||
for (SpanEventBo bo : spanEvents) {
|
||||
System.out.println("### " + bo);
|
||||
}
|
||||
|
||||
assertEquals(2, spanEvents.size());
|
||||
SpanEventBo event = spanEvents.get(0);
|
||||
|
||||
assertEquals("NBASE_ARC", event.getDestinationId());
|
||||
assertEquals(HOST + ":" + PORT, event.getEndPoint());
|
||||
assertEquals(ServiceType.NBASE_ARC, event.getServiceType());
|
||||
assertNull(event.getExceptionMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void traceDestinationId() {
|
||||
GatewayConfig config = new GatewayConfig();
|
||||
config.setZkAddress(ZK_ADDRESS);
|
||||
config.setClusterName(CLUSTER_NAME);
|
||||
|
||||
GatewayClient client = new GatewayClient(config);
|
||||
RedisClusterPipeline pipeline = client.pipeline();
|
||||
|
||||
pipeline.get("foo");
|
||||
pipeline.syncAndReturnAll();
|
||||
|
||||
final List<SpanEventBo> spanEvents = getCurrentSpanEvents();
|
||||
SpanEventBo event = spanEvents.get(spanEvents.size() - 1);
|
||||
|
||||
assertEquals(CLUSTER_NAME, event.getDestinationId());
|
||||
assertEquals(HOST + ":" + PORT, event.getEndPoint());
|
||||
assertEquals(ServiceType.NBASE_ARC, event.getServiceType());
|
||||
assertNull(event.getExceptionMessage());
|
||||
|
||||
client.destroy();
|
||||
}
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
#
|
||||
# Pinpoint agent configuration
|
||||
# (Phase : local)
|
||||
#
|
||||
|
||||
###########################################################
|
||||
# Collector server #
|
||||
###########################################################
|
||||
# local
|
||||
profiler.collector.ip=127.0.0.1
|
||||
# dev
|
||||
#profiler.collector.ip=dev.collector.pinpoint.navercorp.com
|
||||
# real
|
||||
#profiler.collector.ip=collector.pinpoint.navercorp.com
|
||||
|
||||
# placeHolder support "${key}"
|
||||
profiler.collector.span.ip=${profiler.collector.ip}
|
||||
profiler.collector.span.port=9996
|
||||
|
||||
# placeHolder support "${key}"
|
||||
profiler.collector.stat.ip=${profiler.collector.ip}
|
||||
profiler.collector.stat.port=9995
|
||||
|
||||
# placeHolder support "${key}"
|
||||
profiler.collector.tcp.ip=${profiler.collector.ip}
|
||||
profiler.collector.tcp.port=9994
|
||||
|
||||
|
||||
###########################################################
|
||||
# Profiler Global Configuration #
|
||||
###########################################################
|
||||
profiler.enable=true
|
||||
|
||||
profiler.jvm.collect.interval=1000
|
||||
|
||||
profiler.sampling.enable=true
|
||||
|
||||
# 아래 지정한 값중 한 개의 트랜잭션을 수집합니다. (예를들어 1로 지정하면 100%수집, 2로 지정하면 50%수집 셈)
|
||||
profiler.sampling.rate=1
|
||||
|
||||
# span을 Io에 flush할 경우 buffering 여부
|
||||
profiler.io.buffering.enable=true
|
||||
|
||||
# buffering 시 몇개 까지 저장할지 여부
|
||||
profiler.io.buffering.buffersize=20
|
||||
|
||||
|
||||
|
||||
profiler.spandatasender.write.queue.size=5120
|
||||
#profiler.spandatasender.socket.sendbuffersize=1048576
|
||||
#profiler.spandatasender.socket.timeout=3000
|
||||
profiler.spandatasender.chunk.size=16384
|
||||
|
||||
profiler.statdatasender.write.queue.size=5120
|
||||
#profiler.statdatasender.socket.sendbuffersize=1048576
|
||||
#profiler.statdatasender.socket.timeout=3000
|
||||
profiler.statdatasender.chunk.size=16384
|
||||
|
||||
profiler.agentInfo.send.retry.interval=300000
|
||||
|
||||
# Tcp Data Command 허용 여부
|
||||
profiler.tcpdatasender.command.accept.enable=true
|
||||
|
||||
###########################################################
|
||||
# application type #
|
||||
###########################################################
|
||||
#profiler.applicationservertype=TOMCAT
|
||||
#profiler.applicationservertype=BLOC
|
||||
|
||||
|
||||
###########################################################
|
||||
# user defined classes #
|
||||
###########################################################
|
||||
profiler.include=com.nhn.pinpoint.testweb.controller.*,com.nhn.pinpoint.testweb.MyClass
|
||||
|
||||
###########################################################
|
||||
# TOMCAT #
|
||||
###########################################################
|
||||
profiler.tomcat.hidepinpointheader=true
|
||||
#naver standard l7 check
|
||||
profiler.tomcat.excludeurl=/monitor/l7check.html
|
||||
#profiler.tomcat.excludeurl=/aa/test.html, /bb/exclude.html
|
||||
|
||||
###########################################################
|
||||
# JDBC #
|
||||
###########################################################
|
||||
profiler.jdbc=true
|
||||
profiler.jdbc.sqlcachesize=1024
|
||||
profiler.jdbc.maxsqlbindvaluesize=1024
|
||||
|
||||
#
|
||||
# MYSQL
|
||||
#
|
||||
profiler.jdbc.mysql=true
|
||||
profiler.jdbc.mysql.setautocommit=true
|
||||
profiler.jdbc.mysql.commit=true
|
||||
profiler.jdbc.mysql.rollback=true
|
||||
|
||||
#
|
||||
# MSSQL Jtds
|
||||
#
|
||||
profiler.jdbc.jtds=true
|
||||
profiler.jdbc.jtds.setautocommit=true
|
||||
profiler.jdbc.jtds.commit=true
|
||||
profiler.jdbc.jtds.rollback=true
|
||||
|
||||
#
|
||||
# Oracle
|
||||
#
|
||||
profiler.jdbc.oracle=true
|
||||
profiler.jdbc.oracle.setautocommit=true
|
||||
profiler.jdbc.oracle.commit=true
|
||||
profiler.jdbc.oracle.rollback=true
|
||||
|
||||
#
|
||||
# CUBRID
|
||||
#
|
||||
profiler.jdbc.cubrid=true
|
||||
profiler.jdbc.cubrid.setautocommit=true
|
||||
profiler.jdbc.cubrid.commit=true
|
||||
profiler.jdbc.cubrid.rollback=true
|
||||
|
||||
#
|
||||
# DBCP
|
||||
#
|
||||
profiler.jdbc.dbcp=true
|
||||
profiler.jdbc.dbcp.connectionclose=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# Apache HTTP Client 4.x #
|
||||
###########################################################
|
||||
profiler.apache.httpclient4=true
|
||||
profiler.apache.httpclient4.cookie=true
|
||||
|
||||
# cookie를 언제 덤프할지 결정. ALWAYS or EXCEPTION 2가지
|
||||
profiler.apache.httpclient4.cookie.dumptype=ALWAYS
|
||||
profiler.apache.httpclient4.cookie.sampling.rate=1
|
||||
|
||||
# post, put의 entity를 덤프한다. 단 HttpEtity.isRepeatable()=true 인 Entity에 한정된다.
|
||||
profiler.apache.httpclient4.entity=true
|
||||
|
||||
# entity를 언제 덤프할지 결정. ALWAYS or EXCEPTION 2가지
|
||||
profiler.apache.httpclient4.entity.dumptype=ALWAYS
|
||||
profiler.apache.httpclient4.entity.sampling.rate=1
|
||||
|
||||
profiler.apache.nio.httpclient4=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# Ning Async HTTP Client #
|
||||
###########################################################
|
||||
profiler.ning.asynchttpclient=true
|
||||
profiler.ning.asynchttpclient.cookie=true
|
||||
profiler.ning.asynchttpclient.cookie.dumptype=ALWAYS
|
||||
profiler.ning.asynchttpclient.cookie.dumpsize=1024
|
||||
profiler.ning.asynchttpclient.cookie.sampling.rate=1
|
||||
profiler.ning.asynchttpclient.entity=true
|
||||
profiler.ning.asynchttpclient.entity.dumptype=ALWAYS
|
||||
profiler.ning.asynchttpclient.entity.dumpsize=1024
|
||||
profiler.ning.asynchttpclient.entity.sampling.rate=1
|
||||
profiler.ning.asynchttpclient.param=true
|
||||
profiler.ning.asynchttpclient.param.dumptype=ALWAYS
|
||||
profiler.ning.asynchttpclient.param.dumpsize=1024
|
||||
profiler.ning.asynchttpclient.param.sampling.rate=1
|
||||
|
||||
|
||||
###########################################################
|
||||
# LINE+ baseframework #
|
||||
###########################################################
|
||||
profiler.line.game.netty.param.dumpsize=512
|
||||
profiler.line.game.netty.entity.dumpsize=512
|
||||
|
||||
|
||||
###########################################################
|
||||
# Arcus #
|
||||
###########################################################
|
||||
profiler.arcus=true
|
||||
profiler.arcus.keytrace=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# Memcached #
|
||||
###########################################################
|
||||
profiler.memcached=true
|
||||
profiler.memcached.keytrace=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# ibatis #
|
||||
###########################################################
|
||||
profiler.orm.ibatis=true
|
||||
|
||||
|
||||
###########################################################
|
||||
# mybatis #
|
||||
###########################################################
|
||||
profiler.orm.mybatis=true
|
||||
|
||||
###########################################################
|
||||
# redis #
|
||||
###########################################################
|
||||
profiler.redis=true
|
||||
profiler.redis.pipeline=true
|
||||
|
||||
###########################################################
|
||||
# nBase-ARC #
|
||||
###########################################################
|
||||
profiler.nbase_arc=true
|
||||
profiler.nbase_arc.pipeline=true
|
||||
###########################################################
|
||||
# spring-beans
|
||||
###########################################################
|
||||
profiler.spring.beans=false
|
||||
profiler.spring.beans.name.pattern=
|
||||
profiler.spring.beans.class.pattern=
|
||||
profiler.spring.beans.annotation=org.springframework.stereotype.Controller,org.springframework.stereotype.Service,org.springframework.stereotype.Repository
|
||||
@@ -1,5 +0,0 @@
|
||||
/target/
|
||||
/*.iml
|
||||
/.settings/
|
||||
/.classpath
|
||||
/.project
|
||||
@@ -1,100 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.nhn.pinpoint</groupId>
|
||||
<artifactId>pinpoint-naver</artifactId>
|
||||
<version>1.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pinpoint-naver-collector</artifactId>
|
||||
<name>Pinpoint Collector for Naver</name>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<properties>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.nhn.pinpoint</groupId>
|
||||
<artifactId>pinpoint-collector</artifactId>
|
||||
<type>war</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.nhn.pinpoint</groupId>
|
||||
<artifactId>pinpoint-collector</artifactId>
|
||||
<classifier>classes</classifier>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- for zookeeper test -->
|
||||
<dependency>
|
||||
<groupId>org.apache.curator</groupId>
|
||||
<artifactId>curator-test</artifactId>
|
||||
<version>2.6.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nhncorp.nelo2</groupId>
|
||||
<artifactId>nelo2-java-sdk-log4j</artifactId>
|
||||
<version>1.3.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/src/main/java</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${basedir}/src/main/resources-${env}</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>${basedir}/src/test/java</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</testResource>
|
||||
<testResource>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/test/resources</directory>
|
||||
</testResource>
|
||||
</testResources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<configuration>
|
||||
<overlays>
|
||||
<overlay>
|
||||
<groupId>com.nhn.pinpoint</groupId>
|
||||
<artifactId>pinpoint-collector</artifactId>
|
||||
</overlay>
|
||||
</overlays>
|
||||
<webappDirectory>target/deploy</webappDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,3 +0,0 @@
|
||||
hbase.client.host=dev.zk.pinpoint.navercorp.com
|
||||
hbase.client.port=2181
|
||||
hbase.htable.threads.max=4
|
||||
@@ -1,75 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
|
||||
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<layout class="org.apache.log4j.EnhancedPatternLayout">
|
||||
<!--<param name="ConversionPattern" value="%d{MM-dd HH:mm:ss} [%-5p](%-35c{1.}:%L) %m%n"/>-->
|
||||
<!-- %L 옵션은 라인넘버가 출력되나 속도저하가 심하다. -->
|
||||
|
||||
<!-- 아래가 운영용에 접합한 옵션이다.-->
|
||||
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-35c{1.}) %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="stat-appender" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="file" value="${catalina.home}/logs/stat.log"/>
|
||||
<param name="Append" value="true"/>
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
|
||||
<layout class="org.apache.log4j.EnhancedPatternLayout">
|
||||
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-35c{1.}) %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="nelo" class="com.nhncorp.nelo2.log4j.NeloAppender">
|
||||
<param name="Threshold" value="WARN"/>
|
||||
<param name="projectName" value="PINPOINT"/>
|
||||
<param name="collectorUrl" value="nelo2-col.nhncorp.com"/>
|
||||
<param name="port" value="10006"/>
|
||||
<param name="encoding" value="utf-8"/>
|
||||
<param name="timeout" value="1200"/>
|
||||
<param name="enable" value="true"/>
|
||||
<param name="logType" value="dev"/>
|
||||
<param name="logSource" value="collector"/>
|
||||
<param name="errorCodeTYpe" value="default"/>
|
||||
<param name="debug" value="false"/>
|
||||
</appender>
|
||||
|
||||
<appender name="nelo-async" class="com.nhncorp.nelo2.log4j.Nelo2AsyncAppender">
|
||||
<param name="Threshold" value="WARN"/>
|
||||
<param name="blocking" value="false"/>
|
||||
<param name="locationInfo" value="false"/>
|
||||
<param name="bufferSize" value="1024"/>
|
||||
<appender-ref ref="nelo"/>
|
||||
</appender>
|
||||
|
||||
<logger name="com.nhn.pinpoint" additivity="false">
|
||||
<level value="DEBUG"/>
|
||||
<appender-ref ref="console"/>
|
||||
</logger>
|
||||
|
||||
|
||||
<logger name="org.apache.zookeeper" additivity="false">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="console"/>
|
||||
</logger>
|
||||
|
||||
<logger name="org.apache.hadoop.hbase" additivity="false">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="console"/>
|
||||
</logger>
|
||||
|
||||
<!--
|
||||
state 모니터링용 로거. 만약 개발시 로그 출력으로 불편하다면 log level을 WARN이상으로 할것
|
||||
-->
|
||||
<logger name="com.nhn.pinpoint.collector.StateReport" additivity="false">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="stat-appender"/>
|
||||
</logger>
|
||||
|
||||
<root>
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="console"/>
|
||||
<!--<appender-ref ref="nelo-async"/>-->
|
||||
</root>
|
||||
</log4j:configuration>
|
||||
@@ -1,48 +0,0 @@
|
||||
#HBaseTemplate에서 사용하는 HtablePool사이즈
|
||||
hbase.hTablePoolSize=1024
|
||||
|
||||
# tcp listen ip
|
||||
collector.tcpListenIp=0.0.0.0
|
||||
collector.tcpListenPort=9994
|
||||
|
||||
# udp listen ip
|
||||
collector.udpStatListenIp=0.0.0.0
|
||||
collector.udpStatListenPort=9995
|
||||
|
||||
# L4 tcp 채널 close 무시를 위한 설정.
|
||||
collector.l4.ip=
|
||||
|
||||
# udp메시지를 처리할 thread 수, hbase.hTablePoolSize사이즈와 같이 조절해야 한다.
|
||||
collector.udpStatWorkerThread=256
|
||||
# udp메시지를 처리할 thread가 모두 동작중일때 요청을 몇개까지 큐잉할지?
|
||||
collector.udpStatWorkerQueueSize=5120
|
||||
|
||||
#udp socket의 receiveBufferSize설정. 만약 udp 손실율이 심할 경우 아래 사항을 체크해볼것.
|
||||
collector.udpStatSocketReceiveBufferSize=4194304
|
||||
|
||||
|
||||
# span listen port ---------------------------------------------------------------------
|
||||
collector.udpSpanListenIp=0.0.0.0
|
||||
collector.udpSpanListenPort=9996
|
||||
|
||||
# udp메시지를 처리할 thread 수, hbase.hTablePoolSize사이즈와 같이 조절해야 한다.
|
||||
collector.udpSpanWorkerThread=256
|
||||
# udp메시지를 처리할 thread가 모두 동작중일때 요청을 몇개까지 큐잉할지?
|
||||
collector.udpSpanWorkerQueueSize=5120
|
||||
|
||||
#udp socket의 receiveBufferSize설정. 만약 udp 손실율이 심할 경우 아래 사항을 체크해볼것.
|
||||
collector.udpSpanSocketReceiveBufferSize=4194304
|
||||
#$ /sbin/sysctl -a | grep -e rmem -e wmem
|
||||
#net.core.wmem_max = 524288
|
||||
#net.core.rmem_max = 524288
|
||||
#net.core.wmem_default = 229376
|
||||
#net.core.rmem_default = 229376
|
||||
#위 설정을 다음과 같이 수정합니다.
|
||||
#irteamsu$ sudo sysctl -w net.core.rmem_max=4194304
|
||||
|
||||
# 통계값 flush 주기
|
||||
statistics.flushPeriod=1000
|
||||
|
||||
cluster.enable=true
|
||||
cluster.zookeeper.address=dev.zk.pinpoint.navercorp.com
|
||||
cluster.zookeeper.sessiontimeout=3000
|
||||
@@ -1,10 +0,0 @@
|
||||
# local
|
||||
#hbase.client.host=localhost
|
||||
# dev
|
||||
#hbase.client.host=dev.zk.pinpoint.navercorp.com
|
||||
# local-dev
|
||||
hbase.client.host=10.101.17.108
|
||||
# ??
|
||||
#hbase.client.host=10.25.141.69
|
||||
hbase.client.port=2181
|
||||
hbase.htable.threads.max=4
|
||||
@@ -1,82 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
|
||||
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<layout class="org.apache.log4j.EnhancedPatternLayout">
|
||||
<param name="ConversionPattern" value="%d{MM-dd HH:mm:ss} [%-5p](%-35c{1.}:%L) %m%n"/>
|
||||
<!-- %L 옵션은 라인넘버가 출력되나 속도저하가 심하다. -->
|
||||
|
||||
<!-- 아래가 운영용에 접합한 옵션이다.-->
|
||||
<!--<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-35c{1.}) %m%n" />-->
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="stat-appender" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="file" value="${catalina.home}/logs/stat.log"/>
|
||||
<param name="Append" value="true"/>
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
|
||||
<layout class="org.apache.log4j.EnhancedPatternLayout">
|
||||
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-35c{1.}) %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
|
||||
<appender name="nelo" class="com.nhncorp.nelo2.log4j.NeloAppender">
|
||||
<param name="Threshold" value="WARN"/>
|
||||
<param name="projectName" value="PINPOINT"/>
|
||||
<param name="collectorUrl" value="nelo2-col.nhncorp.com"/>
|
||||
<param name="port" value="10006"/>
|
||||
<param name="encoding" value="utf-8"/>
|
||||
<param name="timeout" value="1200"/>
|
||||
<param name="enable" value="true"/>
|
||||
<param name="logType" value="local"/>
|
||||
<param name="logSource" value="collector"/>
|
||||
<param name="errorCodeTYpe" value="default"/>
|
||||
<param name="debug" value="false"/>
|
||||
</appender>
|
||||
|
||||
<appender name="nelo-async" class="com.nhncorp.nelo2.log4j.Nelo2AsyncAppender">
|
||||
<param name="Threshold" value="WARN"/>
|
||||
<param name="blocking" value="false"/>
|
||||
<param name="locationInfo" value="false"/>
|
||||
<param name="bufferSize" value="1024"/>
|
||||
<appender-ref ref="nelo"/>
|
||||
</appender>
|
||||
|
||||
|
||||
<logger name="com.nhn.pinpoint" additivity="false">
|
||||
<level value="DEBUG"/>
|
||||
<appender-ref ref="console"/>
|
||||
</logger>
|
||||
|
||||
<logger name="com.nhn.pinpoint.collector.dao" additivity="false">
|
||||
<level value="TRACE"/>
|
||||
<appender-ref ref="console"/>
|
||||
</logger>
|
||||
|
||||
|
||||
<logger name="org.apache.zookeeper" additivity="false">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="console"/>
|
||||
</logger>
|
||||
|
||||
<logger name="org.apache.hadoop.hbase" additivity="false">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="console"/>
|
||||
</logger>
|
||||
|
||||
<!--
|
||||
state 모니터링용 로거. 만약 개발시 로그 출력으로 불편하다면 log level을 WARN이상으로 할것
|
||||
-->
|
||||
<logger name="com.nhn.pinpoint.collector.StateReport" additivity="false">
|
||||
<level value="WARN"/>
|
||||
<appender-ref ref="stat-appender"/>
|
||||
</logger>
|
||||
|
||||
<root>
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="console"/>
|
||||
<!--<appender-ref ref="nelo-async"/>-->
|
||||
</root>
|
||||
</log4j:configuration>
|
||||
@@ -1,48 +0,0 @@
|
||||
#HBaseTemplate에서 사용하는 HtablePool사이즈
|
||||
hbase.hTablePoolSize=1024
|
||||
|
||||
# tcp listen ip
|
||||
collector.tcpListenIp=0.0.0.0
|
||||
collector.tcpListenPort=9994
|
||||
|
||||
# udp listen ip
|
||||
collector.udpStatListenIp=0.0.0.0
|
||||
collector.udpStatListenPort=9995
|
||||
|
||||
# L4 tcp 채널 close 무시를 위한 설정.
|
||||
collector.l4.ip=
|
||||
|
||||
# udp메시지를 처리할 thread 수, hbase.hTablePoolSize사이즈와 같이 조절해야 한다.
|
||||
collector.udpStatWorkerThread=16
|
||||
# udp메시지를 처리할 thread가 모두 동작중일때 요청을 몇개까지 큐잉할지?
|
||||
collector.udpStatWorkerQueueSize=512
|
||||
|
||||
#udp socket의 receiveBufferSize설정. 만약 udp 손실율이 심할 경우 아래 사항을 체크해볼것.
|
||||
collector.udpStatSocketReceiveBufferSize=4194304
|
||||
|
||||
|
||||
# span listen port ---------------------------------------------------------------------
|
||||
collector.udpSpanListenIp=0.0.0.0
|
||||
collector.udpSpanListenPort=9996
|
||||
|
||||
# udp메시지를 처리할 thread 수, hbase.hTablePoolSize사이즈와 같이 조절해야 한다.
|
||||
collector.udpSpanWorkerThread=32
|
||||
# udp메시지를 처리할 thread가 모두 동작중일때 요청을 몇개까지 큐잉할지?
|
||||
collector.udpSpanWorkerQueueSize=1024
|
||||
|
||||
#udp socket의 receiveBufferSize설정. 만약 udp 손실율이 심할 경우 아래 사항을 체크해볼것.
|
||||
collector.udpSpanSocketReceiveBufferSize=4194304
|
||||
#$ /sbin/sysctl -a | grep -e rmem -e wmem
|
||||
#net.core.wmem_max = 524288
|
||||
#net.core.rmem_max = 524288
|
||||
#net.core.wmem_default = 229376
|
||||
#net.core.rmem_default = 229376
|
||||
#위 설정을 다음과 같이 수정합니다.
|
||||
#irteamsu$ sudo sysctl -w net.core.rmem_max=4194304
|
||||
|
||||
# 통계값 flush 주기
|
||||
statistics.flushPeriod=1000
|
||||
|
||||
cluster.enable=false
|
||||
cluster.zookeeper.address=
|
||||
cluster.zookeeper.sessiontimeout=
|
||||
@@ -1,3 +0,0 @@
|
||||
hbase.client.host=zk.pinpoint.nhncorp.com
|
||||
hbase.client.port=2181
|
||||
hbase.htable.threads.max=4
|
||||
@@ -1,75 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
|
||||
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<layout class="org.apache.log4j.EnhancedPatternLayout">
|
||||
<!--<param name="ConversionPattern" value="%d{MM-dd HH:mm:ss} [%-5p](%-35c{3}:%L) %m%n"/>-->
|
||||
<!-- %L 옵션은 라인넘버가 출력되나 속도저하가 심하다. -->
|
||||
|
||||
<!-- 아래가 운영용에 접합한 옵션이다.-->
|
||||
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-35c{1.}) %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="stat-appender" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="file" value="${catalina.home}/logs/stat.log"/>
|
||||
<param name="Append" value="true"/>
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
|
||||
<layout class="org.apache.log4j.EnhancedPatternLayout">
|
||||
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-35c{1.}) %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="nelo" class="com.nhncorp.nelo2.log4j.NeloAppender">
|
||||
<param name="Threshold" value="WARN"/>
|
||||
<param name="projectName" value="PINPOINT"/>
|
||||
<param name="collectorUrl" value="nelo2-col.nhncorp.com"/>
|
||||
<param name="port" value="10006"/>
|
||||
<param name="encoding" value="utf-8"/>
|
||||
<param name="timeout" value="1200"/>
|
||||
<param name="enable" value="true"/>
|
||||
<param name="logType" value="real"/>
|
||||
<param name="logSource" value="collector"/>
|
||||
<param name="errorCodeTYpe" value="default"/>
|
||||
<param name="debug" value="false"/>
|
||||
</appender>
|
||||
|
||||
<appender name="nelo-async" class="com.nhncorp.nelo2.log4j.Nelo2AsyncAppender">
|
||||
<param name="Threshold" value="WARN"/>
|
||||
<param name="blocking" value="false"/>
|
||||
<param name="locationInfo" value="false"/>
|
||||
<param name="bufferSize" value="1024"/>
|
||||
<appender-ref ref="nelo"/>
|
||||
</appender>
|
||||
|
||||
|
||||
<logger name="com.nhn.pinpoint" additivity="false">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="console"/>
|
||||
</logger>
|
||||
|
||||
|
||||
<logger name="org.apache.zookeeper" additivity="false">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="console"/>
|
||||
</logger>
|
||||
|
||||
<logger name="org.apache.hadoop.hbase" additivity="false">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="console"/>
|
||||
</logger>
|
||||
|
||||
<!--
|
||||
state 모니터링용 로거. 만약 개발시 로그 출력으로 불편하다면 log level을 WARN이상으로 할것
|
||||
-->
|
||||
<logger name="com.nhn.pinpoint.collector.StateReport" additivity="false">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="stat-appender"/>
|
||||
</logger>
|
||||
<root>
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="console"/>
|
||||
<appender-ref ref="nelo-async"/>
|
||||
</root>
|
||||
</log4j:configuration>
|
||||
@@ -1,48 +0,0 @@
|
||||
#HBaseTemplate에서 사용하는 HtablePool사이즈
|
||||
hbase.hTablePoolSize=1024
|
||||
|
||||
# tcp listen ip
|
||||
collector.tcpListenIp=0.0.0.0
|
||||
collector.tcpListenPort=9994
|
||||
|
||||
# udp listen ip
|
||||
collector.udpStatListenIp=0.0.0.0
|
||||
collector.udpStatListenPort=9995
|
||||
|
||||
# L4 tcp 채널 close 무시를 위한 설정.
|
||||
collector.l4.ip=10.118.36.61,10.118.36.62
|
||||
|
||||
# udp메시지를 처리할 thread 수, hbase.hTablePoolSize사이즈와 같이 조절해야 한다.
|
||||
collector.udpStatWorkerThread=64
|
||||
# udp메시지를 처리할 thread가 모두 동작중일때 요청을 몇개까지 큐잉할지?
|
||||
collector.udpStatWorkerQueueSize=5120
|
||||
|
||||
#udp socket의 receiveBufferSize설정. 만약 udp 손실율이 심할 경우 아래 사항을 체크해볼것.
|
||||
collector.udpStatSocketReceiveBufferSize=4194304
|
||||
|
||||
|
||||
# span listen port ---------------------------------------------------------------------
|
||||
collector.udpSpanListenIp=0.0.0.0
|
||||
collector.udpSpanListenPort=9996
|
||||
|
||||
# udp메시지를 처리할 thread 수, hbase.hTablePoolSize사이즈와 같이 조절해야 한다.
|
||||
collector.udpSpanWorkerThread=512
|
||||
# udp메시지를 처리할 thread가 모두 동작중일때 요청을 몇개까지 큐잉할지?
|
||||
collector.udpSpanWorkerQueueSize=20000
|
||||
|
||||
#udp socket의 receiveBufferSize설정. 만약 udp 손실율이 심할 경우 아래 사항을 체크해볼것.
|
||||
collector.udpSpanSocketReceiveBufferSize=4194304
|
||||
#$ /sbin/sysctl -a | grep -e rmem -e wmem
|
||||
#net.core.wmem_max = 524288
|
||||
#net.core.rmem_max = 524288
|
||||
#net.core.wmem_default = 229376
|
||||
#net.core.rmem_default = 229376
|
||||
#위 설정을 다음과 같이 수정합니다.
|
||||
#irteamsu$ sudo sysctl -w net.core.rmem_max=4194304
|
||||
|
||||
# 통계값 flush 주기
|
||||
statistics.flushPeriod=1000
|
||||
|
||||
cluster.enable=true
|
||||
cluster.zookeeper.address=zk.pinpoint.nhncorp.com
|
||||
cluster.zookeeper.sessiontimeout=3000
|
||||
@@ -1,4 +0,0 @@
|
||||
#hbase.client.host=test.zk.pinpoint.navercorp.com
|
||||
hbase.client.host=10.101.17.108
|
||||
hbase.client.port=2181
|
||||
hbase.htable.threads.max=4
|
||||
@@ -1,79 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
|
||||
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<layout class="org.apache.log4j.EnhancedPatternLayout">
|
||||
<param name="ConversionPattern" value="%d{MM-dd HH:mm:ss} [%-5p](%-35c{1.}:%L) %m%n"/>
|
||||
<!-- %L 옵션은 라인넘버가 출력되나 속도저하가 심하다. -->
|
||||
|
||||
<!-- 아래가 운영용에 접합한 옵션이다.-->
|
||||
<!--<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-35c{1.}) %m%n" />-->
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="stat-appender" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="file" value="${catalina.home}/logs/stat.log"/>
|
||||
<param name="Append" value="true"/>
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
|
||||
<layout class="org.apache.log4j.EnhancedPatternLayout">
|
||||
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p](%-35c{1.}) %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="nelo" class="com.nhncorp.nelo2.log4j.NeloAppender">
|
||||
<param name="Threshold" value="WARN"/>
|
||||
<param name="projectName" value="PINPOINT"/>
|
||||
<param name="collectorUrl" value="nelo2-col.nhncorp.com"/>
|
||||
<param name="port" value="10006"/>
|
||||
<param name="encoding" value="utf-8"/>
|
||||
<param name="timeout" value="1200"/>
|
||||
<param name="enable" value="true"/>
|
||||
<param name="logType" value="test"/>
|
||||
<param name="logSource" value="collector"/>
|
||||
<param name="errorCodeTYpe" value="default"/>
|
||||
<param name="debug" value="false"/>
|
||||
</appender>
|
||||
|
||||
<appender name="nelo-async" class="com.nhncorp.nelo2.log4j.Nelo2AsyncAppender">
|
||||
<param name="Threshold" value="WARN"/>
|
||||
<param name="blocking" value="false"/>
|
||||
<param name="locationInfo" value="false"/>
|
||||
<param name="bufferSize" value="1024"/>
|
||||
<appender-ref ref="nelo"/>
|
||||
</appender>
|
||||
|
||||
<logger name="com.nhn.pinpoint" additivity="false">
|
||||
<level value="DEBUG"/>
|
||||
<appender-ref ref="console"/>
|
||||
</logger>
|
||||
|
||||
<logger name="com.nhn.pinpoint.collector.dao" additivity="false">
|
||||
<level value="TRACE"/>
|
||||
<appender-ref ref="console"/>
|
||||
</logger>
|
||||
|
||||
<logger name="org.apache.zookeeper" additivity="false">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="console"/>
|
||||
</logger>
|
||||
|
||||
<logger name="org.apache.hadoop.hbase" additivity="false">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="console"/>
|
||||
</logger>
|
||||
|
||||
<!--
|
||||
state 모니터링용 로거. 만약 개발시 로그 출력으로 불편하다면 log level을 WARN이상으로 할것
|
||||
-->
|
||||
<logger name="com.nhn.pinpoint.collector.StateReport" additivity="false">
|
||||
<level value="stat-appender"/>
|
||||
<appender-ref ref="console"/>
|
||||
</logger>
|
||||
|
||||
<root>
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="console"/>
|
||||
<!--<appender-ref ref="nelo-async"/>-->
|
||||
</root>
|
||||
</log4j:configuration>
|
||||
@@ -1,48 +0,0 @@
|
||||
#HBaseTemplate에서 사용하는 HtablePool사이즈
|
||||
hbase.hTablePoolSize=1024
|
||||
|
||||
# tcp listen ip
|
||||
collector.tcpListenIp=0.0.0.0
|
||||
collector.tcpListenPort=9994
|
||||
|
||||
# udp listen ip
|
||||
collector.udpStatListenIp=0.0.0.0
|
||||
collector.udpStatListenPort=9995
|
||||
|
||||
# L4 tcp 채널 close 무시를 위한 설정.
|
||||
collector.l4.ip=
|
||||
|
||||
# udp메시지를 처리할 thread 수, hbase.hTablePoolSize사이즈와 같이 조절해야 한다.
|
||||
collector.udpStatWorkerThread=16
|
||||
# udp메시지를 처리할 thread가 모두 동작중일때 요청을 몇개까지 큐잉할지?
|
||||
collector.udpStatWorkerQueueSize=512
|
||||
|
||||
#udp socket의 receiveBufferSize설정. 만약 udp 손실율이 심할 경우 아래 사항을 체크해볼것.
|
||||
collector.udpStatSocketReceiveBufferSize=4194304
|
||||
|
||||
|
||||
# span listen port ---------------------------------------------------------------------
|
||||
collector.udpSpanListenIp=0.0.0.0
|
||||
collector.udpSpanListenPort=9996
|
||||
|
||||
# udp메시지를 처리할 thread 수, hbase.hTablePoolSize사이즈와 같이 조절해야 한다.
|
||||
collector.udpSpanWorkerThread=32
|
||||
# udp메시지를 처리할 thread가 모두 동작중일때 요청을 몇개까지 큐잉할지?
|
||||
collector.udpSpanWorkerQueueSize=1024
|
||||
|
||||
#udp socket의 receiveBufferSize설정. 만약 udp 손실율이 심할 경우 아래 사항을 체크해볼것.
|
||||
collector.udpSpanSocketReceiveBufferSize=4194304
|
||||
#$ /sbin/sysctl -a | grep -e rmem -e wmem
|
||||
#net.core.wmem_max = 524288
|
||||
#net.core.rmem_max = 524288
|
||||
#net.core.wmem_default = 229376
|
||||
#net.core.rmem_default = 229376
|
||||
#위 설정을 다음과 같이 수정합니다.
|
||||
#irteamsu$ sudo sysctl -w net.core.rmem_max=4194304
|
||||
|
||||
# 통계값 flush 주기
|
||||
statistics.flushPeriod=1000
|
||||
|
||||
cluster.enable=false
|
||||
cluster.zookeeper.address=
|
||||
cluster.zookeeper.sessiontimeout=
|
||||
-165
@@ -1,165 +0,0 @@
|
||||
package com.nhn.pinpoint.collector.cluster;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.nhn.pinpoint.collector.receiver.tcp.AgentHandshakePropertyType;
|
||||
import com.nhn.pinpoint.collector.util.CollectorUtils;
|
||||
import com.nhn.pinpoint.rpc.packet.HandshakeResponseCode;
|
||||
import com.nhn.pinpoint.rpc.packet.HandshakeResponseType;
|
||||
import com.nhn.pinpoint.rpc.packet.RequestPacket;
|
||||
import com.nhn.pinpoint.rpc.packet.SendPacket;
|
||||
import com.nhn.pinpoint.rpc.server.ChannelContext;
|
||||
import com.nhn.pinpoint.rpc.server.PinpointServerSocket;
|
||||
import com.nhn.pinpoint.rpc.server.ServerMessageListener;
|
||||
import com.nhn.pinpoint.rpc.server.SocketChannel;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:applicationContext-test.xml")
|
||||
public class ClusterPointRouterTest {
|
||||
|
||||
private static final int DEFAULT_ACCEPTOR_SOCKET_PORT = 22215;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final long currentTime = System.currentTimeMillis();
|
||||
|
||||
@Autowired
|
||||
ClusterPointRouter clusterPointRouter;
|
||||
|
||||
@Test
|
||||
public void webClusterPointtest() {
|
||||
WebCluster webClusterPoint = new WebCluster(CollectorUtils.getServerIdentifier(), clusterPointRouter);
|
||||
|
||||
try {
|
||||
PinpointServerSocket pinpointServerSocket = new PinpointServerSocket();
|
||||
pinpointServerSocket.setMessageListener(new PinpointSocketManagerHandler());
|
||||
pinpointServerSocket.bind("127.0.0.1", DEFAULT_ACCEPTOR_SOCKET_PORT);
|
||||
|
||||
InetSocketAddress address = new InetSocketAddress("127.0.0.1", DEFAULT_ACCEPTOR_SOCKET_PORT);
|
||||
|
||||
Assert.assertEquals(0, webClusterPoint.getWebClusterList().size());
|
||||
webClusterPoint.connectPointIfAbsent(address);
|
||||
Assert.assertEquals(1, webClusterPoint.getWebClusterList().size());
|
||||
webClusterPoint.connectPointIfAbsent(address);
|
||||
Assert.assertEquals(1, webClusterPoint.getWebClusterList().size());
|
||||
|
||||
webClusterPoint.disconnectPoint(address);
|
||||
Assert.assertEquals(0, webClusterPoint.getWebClusterList().size());
|
||||
webClusterPoint.disconnectPoint(address);
|
||||
Assert.assertEquals(0, webClusterPoint.getWebClusterList().size());
|
||||
} finally {
|
||||
webClusterPoint.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void profilerClusterPointtest() {
|
||||
ClusterPointRepository clusterPointRepository = clusterPointRouter.getTargetClusterPointRepository();
|
||||
|
||||
SocketChannel socketChannel = mock(SocketChannel.class);
|
||||
|
||||
ChannelContext channelContext = new ChannelContext(socketChannel, null);
|
||||
channelContext.setChannelProperties(getParams());
|
||||
|
||||
ClusterPoint clusterPoint = new ChannelContextClusterPoint(channelContext);
|
||||
|
||||
clusterPointRepository.addClusterPoint(clusterPoint);
|
||||
List<TargetClusterPoint> clusterPointList = clusterPointRepository.getClusterPointList();
|
||||
|
||||
Assert.assertEquals(1, clusterPointList.size());
|
||||
Assert.assertNull(findClusterPoint("a", "a", -1L, clusterPointList));
|
||||
Assert.assertNull(findClusterPoint("application", "a", -1L, clusterPointList));
|
||||
Assert.assertEquals(clusterPoint, findClusterPoint("application", "agent", currentTime, clusterPointList));
|
||||
|
||||
boolean isAdd = clusterPointRepository.addClusterPoint(new ChannelContextClusterPoint(channelContext));
|
||||
Assert.assertFalse(isAdd);
|
||||
|
||||
clusterPointRepository.removeClusterPoint(new ChannelContextClusterPoint(channelContext));
|
||||
clusterPointList = clusterPointRepository.getClusterPointList();
|
||||
|
||||
Assert.assertEquals(0, clusterPointList.size());
|
||||
Assert.assertNull(findClusterPoint("application", "agent", currentTime, clusterPointList));
|
||||
}
|
||||
|
||||
private class PinpointSocketManagerHandler implements ServerMessageListener {
|
||||
@Override
|
||||
public void handleSend(SendPacket sendPacket, SocketChannel channel) {
|
||||
logger.warn("Unsupport send received {} {}", sendPacket, channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRequest(RequestPacket requestPacket, SocketChannel channel) {
|
||||
logger.warn("Unsupport request received {} {}", requestPacket, channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandshakeResponseCode handleHandshake(Map properties) {
|
||||
logger.warn("do Handshake {}", properties);
|
||||
return HandshakeResponseType.Success.DUPLEX_COMMUNICATION;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<Object, Object> getParams() {
|
||||
Map<Object, Object> properties = new HashMap<Object, Object>();
|
||||
|
||||
properties.put(AgentHandshakePropertyType.AGENT_ID.getName(), "agent");
|
||||
properties.put(AgentHandshakePropertyType.APPLICATION_NAME.getName(), "application");
|
||||
properties.put(AgentHandshakePropertyType.HOSTNAME.getName(), "hostname");
|
||||
properties.put(AgentHandshakePropertyType.IP.getName(), "ip");
|
||||
properties.put(AgentHandshakePropertyType.PID.getName(), 1111);
|
||||
properties.put(AgentHandshakePropertyType.SERVICE_TYPE.getName(), 10);
|
||||
properties.put(AgentHandshakePropertyType.START_TIMESTAMP.getName(), currentTime);
|
||||
properties.put(AgentHandshakePropertyType.VERSION.getName(), "1.0.3-SNAPSHOT");
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
private TargetClusterPoint findClusterPoint(String applicationName, String agentId, long startTimeStamp, List<TargetClusterPoint> targetClusterPointList) {
|
||||
|
||||
List<TargetClusterPoint> result = new ArrayList<TargetClusterPoint>();
|
||||
|
||||
for (TargetClusterPoint targetClusterPoint : targetClusterPointList) {
|
||||
if (!targetClusterPoint.getApplicationName().equals(applicationName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!targetClusterPoint.getAgentId().equals(agentId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(targetClusterPoint.getStartTimeStamp() == startTimeStamp)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result.add(targetClusterPoint);
|
||||
}
|
||||
|
||||
if (result.size() == 1) {
|
||||
return result.get(0);
|
||||
}
|
||||
|
||||
if (result.size() > 1) {
|
||||
logger.warn("Ambiguous ClusterPoint {}, {}, {} (Valid Agent list={}).", applicationName, agentId, startTimeStamp, result);
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
-208
@@ -1,208 +0,0 @@
|
||||
package com.nhn.pinpoint.collector.cluster;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.apache.thrift.TException;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.nhn.pinpoint.collector.receiver.tcp.AgentHandshakePropertyType;
|
||||
import com.nhn.pinpoint.collector.util.CollectorUtils;
|
||||
import com.nhn.pinpoint.rpc.DefaultFuture;
|
||||
import com.nhn.pinpoint.rpc.Future;
|
||||
import com.nhn.pinpoint.rpc.ResponseMessage;
|
||||
import com.nhn.pinpoint.rpc.packet.HandshakeResponseCode;
|
||||
import com.nhn.pinpoint.rpc.packet.HandshakeResponseType;
|
||||
import com.nhn.pinpoint.rpc.packet.RequestPacket;
|
||||
import com.nhn.pinpoint.rpc.packet.SendPacket;
|
||||
import com.nhn.pinpoint.rpc.server.ChannelContext;
|
||||
import com.nhn.pinpoint.rpc.server.PinpointServerSocket;
|
||||
import com.nhn.pinpoint.rpc.server.ServerMessageListener;
|
||||
import com.nhn.pinpoint.rpc.server.SocketChannel;
|
||||
import com.nhn.pinpoint.thrift.dto.command.TCommandEcho;
|
||||
import com.nhn.pinpoint.thrift.dto.command.TCommandTransfer;
|
||||
import com.nhn.pinpoint.thrift.io.DeserializerFactory;
|
||||
import com.nhn.pinpoint.thrift.io.SerializerFactory;
|
||||
import com.nhn.pinpoint.thrift.util.SerializationUtils;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:applicationContext-test.xml")
|
||||
public class ClusterPointRouterTest2 {
|
||||
|
||||
private static final int DEFAULT_ACCEPTOR_SOCKET_PORT = 22215;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final long currentTime = System.currentTimeMillis();
|
||||
|
||||
@Autowired
|
||||
ClusterPointRouter clusterPointRouter;
|
||||
|
||||
@Autowired
|
||||
private SerializerFactory commandSerializerFactory;
|
||||
|
||||
@Autowired
|
||||
private DeserializerFactory commandDeserializerFactory;
|
||||
|
||||
@Test
|
||||
public void profilerClusterPointtest() throws TException, InterruptedException {
|
||||
WebCluster webCluster = null;
|
||||
try {
|
||||
webCluster = new WebCluster(CollectorUtils.getServerIdentifier(), clusterPointRouter);
|
||||
|
||||
PinpointServerSocket pinpointServerSocket = createServerSocket("127.0.0.1", DEFAULT_ACCEPTOR_SOCKET_PORT);
|
||||
|
||||
InetSocketAddress address = new InetSocketAddress("127.0.0.1", DEFAULT_ACCEPTOR_SOCKET_PORT);
|
||||
webCluster.connectPointIfAbsent(address);
|
||||
|
||||
// profiler쪽 clusterPoint 생성
|
||||
SocketChannel socketChannel = mock(SocketChannel.class);
|
||||
ClusterPoint clusterPoint = new ChannelContextClusterPoint(createChannelContext(socketChannel));
|
||||
|
||||
ClusterPointRepository clusterPointRepository = clusterPointRouter.getTargetClusterPointRepository();
|
||||
clusterPointRepository.addClusterPoint(clusterPoint);
|
||||
|
||||
byte[] echoPayload = createEchoPayload("hello");
|
||||
when(socketChannel.sendRequestMessage(echoPayload)).thenReturn(createExpectedFuture(echoPayload));
|
||||
|
||||
byte[] commandDeliveryPayload = createDeliveryCommandPayload("application", "agent", currentTime, echoPayload);
|
||||
|
||||
List<ChannelContext> contextList = pinpointServerSocket.getDuplexCommunicationChannelContext();
|
||||
ChannelContext context = contextList.get(0);
|
||||
Future<ResponseMessage> future = context.getSocketChannel().sendRequestMessage(commandDeliveryPayload);
|
||||
future.await();
|
||||
|
||||
TCommandEcho base = (TCommandEcho) SerializationUtils.deserialize(future.getResult().getMessage(), commandDeserializerFactory);
|
||||
|
||||
Assert.assertEquals(base.getMessage(), "hello");
|
||||
} finally {
|
||||
if (webCluster != null) {
|
||||
webCluster.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private PinpointServerSocket createServerSocket(String host, int port) {
|
||||
PinpointServerSocket pinpointServerSocket = new PinpointServerSocket();
|
||||
pinpointServerSocket.setMessageListener(new PinpointSocketManagerHandler());
|
||||
pinpointServerSocket.bind(host, port);
|
||||
|
||||
|
||||
return pinpointServerSocket;
|
||||
}
|
||||
|
||||
private ChannelContext createChannelContext(SocketChannel socketChannel) {
|
||||
ChannelContext channelContext = new ChannelContext(socketChannel, null);
|
||||
channelContext.setChannelProperties(getParams());
|
||||
|
||||
return channelContext;
|
||||
}
|
||||
|
||||
private DefaultFuture createExpectedFuture(byte[] payload) {
|
||||
ResponseMessage responseMessage = new ResponseMessage();
|
||||
responseMessage.setMessage(payload);
|
||||
|
||||
DefaultFuture future = new DefaultFuture();
|
||||
future.setResult(responseMessage);
|
||||
|
||||
return future;
|
||||
}
|
||||
|
||||
private byte[] createEchoPayload(String message) throws TException {
|
||||
TCommandEcho echo = new TCommandEcho();
|
||||
echo.setMessage("hello");
|
||||
|
||||
byte[] payload = SerializationUtils.serialize(echo, commandSerializerFactory);
|
||||
return payload;
|
||||
}
|
||||
|
||||
private byte[] createDeliveryCommandPayload(String application, String agent, long currentTime, byte[] echoPayload) throws TException {
|
||||
TCommandTransfer commandTransfer = new TCommandTransfer();
|
||||
commandTransfer.setApplicationName("application");
|
||||
commandTransfer.setAgentId("agent");
|
||||
commandTransfer.setStartTime(currentTime);
|
||||
commandTransfer.setPayload(echoPayload);
|
||||
|
||||
byte[] payload = SerializationUtils.serialize(commandTransfer, commandSerializerFactory);
|
||||
return payload;
|
||||
}
|
||||
|
||||
private class PinpointSocketManagerHandler implements ServerMessageListener {
|
||||
@Override
|
||||
public void handleSend(SendPacket sendPacket, SocketChannel channel) {
|
||||
logger.warn("Unsupport send received {} {}", sendPacket, channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRequest(RequestPacket requestPacket, SocketChannel channel) {
|
||||
logger.warn("Unsupport request received {} {}", requestPacket, channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandshakeResponseCode handleHandshake(Map properties) {
|
||||
logger.warn("do handleEnableWorker {}", properties);
|
||||
return HandshakeResponseType.Success.DUPLEX_COMMUNICATION;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<Object, Object> getParams() {
|
||||
Map<Object, Object> properties = new HashMap<Object, Object>();
|
||||
|
||||
properties.put(AgentHandshakePropertyType.AGENT_ID.getName(), "agent");
|
||||
properties.put(AgentHandshakePropertyType.APPLICATION_NAME.getName(), "application");
|
||||
properties.put(AgentHandshakePropertyType.HOSTNAME.getName(), "hostname");
|
||||
properties.put(AgentHandshakePropertyType.IP.getName(), "ip");
|
||||
properties.put(AgentHandshakePropertyType.PID.getName(), 1111);
|
||||
properties.put(AgentHandshakePropertyType.SERVICE_TYPE.getName(), 10);
|
||||
properties.put(AgentHandshakePropertyType.START_TIMESTAMP.getName(), currentTime);
|
||||
properties.put(AgentHandshakePropertyType.VERSION.getName(), "1.0.3-SNAPSHOT");
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
private TargetClusterPoint findClusterPoint(String applicationName, String agentId, long startTimeStamp, List<TargetClusterPoint> targetClusterPointList) {
|
||||
|
||||
List<TargetClusterPoint> result = new ArrayList<TargetClusterPoint>();
|
||||
|
||||
for (TargetClusterPoint targetClusterPoint : targetClusterPointList) {
|
||||
if (!targetClusterPoint.getApplicationName().equals(applicationName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!targetClusterPoint.getAgentId().equals(agentId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(targetClusterPoint.getStartTimeStamp() == startTimeStamp)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result.add(targetClusterPoint);
|
||||
}
|
||||
|
||||
if (result.size() == 1) {
|
||||
return result.get(0);
|
||||
}
|
||||
|
||||
if (result.size() > 1) {
|
||||
logger.warn("Ambiguous ClusterPoint {}, {}, {} (Valid Agent list={}).", applicationName, agentId, startTimeStamp, result);
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
-262
@@ -1,262 +0,0 @@
|
||||
package com.nhn.pinpoint.collector.cluster.zookeeper;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.apache.curator.test.InstanceSpec;
|
||||
import org.apache.curator.test.TestingCluster;
|
||||
import org.apache.curator.test.TestingZooKeeperServer;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.nhn.pinpoint.collector.cluster.ClusterPointRouter;
|
||||
import com.nhn.pinpoint.collector.config.CollectorConfiguration;
|
||||
import com.nhn.pinpoint.collector.receiver.tcp.AgentHandshakePropertyType;
|
||||
import com.nhn.pinpoint.rpc.server.ChannelContext;
|
||||
import com.nhn.pinpoint.rpc.server.SocketChannel;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:applicationContext-test.xml")
|
||||
public class ZookeeperEnsembleProfilerClusterServiceTest {
|
||||
|
||||
@Autowired
|
||||
ClusterPointRouter clusterPointRouter;
|
||||
|
||||
@Test
|
||||
public void simpleTest1() throws Exception {
|
||||
TestingCluster tcluster = null;
|
||||
try {
|
||||
tcluster = createZookeeperCluster(3);
|
||||
|
||||
String connectString = getConnectString(tcluster);
|
||||
|
||||
CollectorConfiguration collectorConfig = createConfig(connectString);
|
||||
|
||||
|
||||
ZookeeperClusterService service = new ZookeeperClusterService(collectorConfig, clusterPointRouter);
|
||||
service.setUp();
|
||||
|
||||
ChannelContext channelContext = new ChannelContext(mock(SocketChannel.class), null, service.getChannelStateChangeEventListener());
|
||||
channelContext.setChannelProperties(getParams());
|
||||
|
||||
ZookeeperProfilerClusterManager profilerClusterManager = service.getProfilerClusterManager();
|
||||
|
||||
channelContext.changeStateRun();
|
||||
Thread.sleep(1000);
|
||||
|
||||
List<String> result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
channelContext.changeStateRunDuplexCommunication();
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(1, result.size());
|
||||
|
||||
channelContext.changeStateShutdown();
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
service.tearDown();
|
||||
} finally {
|
||||
closeZookeeperCluster(tcluster);
|
||||
}
|
||||
}
|
||||
|
||||
// 연결되어 있는 쥬키퍼 클러스터가 끊어졌을때 해당 이벤트가 유지되는지
|
||||
// 테스트 코드만으로는 정확한 확인은 힘들다. 로그를 봐야함
|
||||
@Test
|
||||
public void simpleTest2() throws Exception {
|
||||
TestingCluster tcluster = null;
|
||||
try {
|
||||
tcluster = createZookeeperCluster(3);
|
||||
|
||||
String connectString = getConnectString(tcluster);
|
||||
|
||||
CollectorConfiguration collectorConfig = createConfig(connectString);
|
||||
|
||||
ZookeeperClusterService service = new ZookeeperClusterService(collectorConfig, clusterPointRouter);
|
||||
service.setUp();
|
||||
|
||||
ChannelContext channelContext = new ChannelContext(mock(SocketChannel.class), null, service.getChannelStateChangeEventListener());
|
||||
channelContext.setChannelProperties(getParams());
|
||||
|
||||
ZookeeperProfilerClusterManager profilerClusterManager = service.getProfilerClusterManager();
|
||||
|
||||
channelContext.changeStateRun();
|
||||
Thread.sleep(1000);
|
||||
List<String> result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
channelContext.changeStateRunDuplexCommunication();
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(1, result.size());
|
||||
|
||||
restart(tcluster);
|
||||
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(1, result.size());
|
||||
|
||||
channelContext.changeStateShutdown();
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
service.tearDown();
|
||||
} finally {
|
||||
closeZookeeperCluster(tcluster);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 연결되어 있는 쥬키퍼 클러스터가 모두 죽었을 경우
|
||||
// 그 이후 해당 이벤트가 유지되는지
|
||||
// 테스트 코드만으로는 정확한 확인은 힘들다. 로그를 봐야함
|
||||
@Test
|
||||
public void simpleTest3() throws Exception {
|
||||
TestingCluster tcluster = null;
|
||||
try {
|
||||
tcluster = createZookeeperCluster(3);
|
||||
|
||||
String connectString = getConnectString(tcluster);
|
||||
|
||||
CollectorConfiguration collectorConfig = createConfig(connectString);
|
||||
|
||||
ZookeeperClusterService service = new ZookeeperClusterService(collectorConfig, clusterPointRouter);
|
||||
service.setUp();
|
||||
|
||||
ChannelContext channelContext = new ChannelContext(mock(SocketChannel.class), null, service.getChannelStateChangeEventListener());
|
||||
channelContext.setChannelProperties(getParams());
|
||||
|
||||
ZookeeperProfilerClusterManager profilerClusterManager = service.getProfilerClusterManager();
|
||||
|
||||
channelContext.changeStateRun();
|
||||
Thread.sleep(1000);
|
||||
List<String> result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
channelContext.changeStateRunDuplexCommunication();
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(1, result.size());
|
||||
|
||||
stop(tcluster);
|
||||
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
restart(tcluster);
|
||||
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(1, result.size());
|
||||
|
||||
channelContext.changeStateShutdown();
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
service.tearDown();
|
||||
} finally {
|
||||
closeZookeeperCluster(tcluster);
|
||||
}
|
||||
}
|
||||
|
||||
private TestingCluster createZookeeperCluster(int size) throws Exception {
|
||||
return createZookeeperCluster(size, true);
|
||||
}
|
||||
|
||||
private TestingCluster createZookeeperCluster(int size, boolean start) throws Exception {
|
||||
TestingCluster zookeeperCluster = new TestingCluster(size);
|
||||
|
||||
// 주의 cluster 초기화에 시간이 좀 걸림 그래서 테스트에 sleep을 좀 길게 둠
|
||||
// 다 된걸 받는 이벤트도 없음
|
||||
if (start) {
|
||||
zookeeperCluster.start();
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
|
||||
return zookeeperCluster;
|
||||
}
|
||||
|
||||
private void startZookeeperCluster(TestingCluster zookeeperCluster) throws Exception {
|
||||
zookeeperCluster.start();
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
|
||||
private void restart(TestingCluster zookeeperCluster) throws Exception {
|
||||
for (TestingZooKeeperServer zookeeperServer : zookeeperCluster.getServers()) {
|
||||
zookeeperServer.restart();
|
||||
}
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
|
||||
private void stop(TestingCluster zookeeperCluster) throws Exception {
|
||||
zookeeperCluster.stop();
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
|
||||
private void closeZookeeperCluster(TestingCluster zookeeperCluster) throws Exception {
|
||||
try {
|
||||
if (zookeeperCluster != null) {
|
||||
zookeeperCluster.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
private String getConnectString(TestingZooKeeperServer testingZooKeeperServer) {
|
||||
return testingZooKeeperServer.getInstanceSpec().getConnectString();
|
||||
}
|
||||
|
||||
private String getConnectString(TestingCluster zookeeperCluster) {
|
||||
StringBuilder connectString = new StringBuilder();
|
||||
|
||||
Iterator<InstanceSpec> instanceSpecIterator = zookeeperCluster.getInstances().iterator();
|
||||
while (instanceSpecIterator.hasNext()) {
|
||||
InstanceSpec instanceSpec = instanceSpecIterator.next();
|
||||
connectString.append(instanceSpec.getConnectString());
|
||||
|
||||
if (instanceSpecIterator.hasNext()) {
|
||||
connectString.append(",");
|
||||
}
|
||||
}
|
||||
|
||||
return connectString.toString();
|
||||
}
|
||||
|
||||
private Map<Object, Object> getParams() {
|
||||
Map<Object, Object> properties = new HashMap<Object, Object>();
|
||||
|
||||
properties.put(AgentHandshakePropertyType.AGENT_ID.getName(), "agent");
|
||||
properties.put(AgentHandshakePropertyType.APPLICATION_NAME.getName(), "application");
|
||||
properties.put(AgentHandshakePropertyType.HOSTNAME.getName(), "hostname");
|
||||
properties.put(AgentHandshakePropertyType.IP.getName(), "ip");
|
||||
properties.put(AgentHandshakePropertyType.PID.getName(), 1111);
|
||||
properties.put(AgentHandshakePropertyType.SERVICE_TYPE.getName(), 10);
|
||||
properties.put(AgentHandshakePropertyType.START_TIMESTAMP.getName(), System.currentTimeMillis());
|
||||
properties.put(AgentHandshakePropertyType.VERSION.getName(), "1.0");
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
private CollectorConfiguration createConfig(String connectString) {
|
||||
CollectorConfiguration collectorConfig = new CollectorConfiguration();
|
||||
|
||||
collectorConfig.setClusterEnable(true);
|
||||
collectorConfig.setClusterAddress(connectString);
|
||||
collectorConfig.setClusterSessionTimeout(3000);
|
||||
|
||||
return collectorConfig;
|
||||
}
|
||||
|
||||
}
|
||||
-279
@@ -1,279 +0,0 @@
|
||||
package com.nhn.pinpoint.collector.cluster.zookeeper;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.curator.test.TestingServer;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.nhn.pinpoint.collector.cluster.ClusterPointRouter;
|
||||
import com.nhn.pinpoint.collector.config.CollectorConfiguration;
|
||||
import com.nhn.pinpoint.collector.receiver.tcp.AgentHandshakePropertyType;
|
||||
import com.nhn.pinpoint.rpc.server.ChannelContext;
|
||||
import com.nhn.pinpoint.rpc.server.SocketChannel;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:applicationContext-test.xml")
|
||||
public class ZookeeperProfilerClusterServiceTest {
|
||||
|
||||
private static final int DEFAULT_ACCEPTOR_PORT = 22213;
|
||||
|
||||
private static CollectorConfiguration collectorConfig = null;
|
||||
|
||||
@Autowired
|
||||
ClusterPointRouter clusterPointRouter;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
collectorConfig = new CollectorConfiguration();
|
||||
|
||||
collectorConfig.setClusterEnable(true);
|
||||
collectorConfig.setClusterAddress("127.0.0.1:" + DEFAULT_ACCEPTOR_PORT);
|
||||
collectorConfig.setClusterSessionTimeout(3000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleTest1() throws Exception {
|
||||
TestingServer ts = null;
|
||||
try {
|
||||
ts = ZookeeperTestUtils.createZookeeperServer(DEFAULT_ACCEPTOR_PORT);
|
||||
|
||||
ZookeeperClusterService service = new ZookeeperClusterService(collectorConfig, clusterPointRouter);
|
||||
service.setUp();
|
||||
|
||||
ChannelContext channelContext = new ChannelContext(mock(SocketChannel.class), null, service.getChannelStateChangeEventListener());
|
||||
channelContext.setChannelProperties(getParams());
|
||||
|
||||
ZookeeperProfilerClusterManager profilerClusterManager = service.getProfilerClusterManager();
|
||||
|
||||
channelContext.changeStateRun();
|
||||
Thread.sleep(1000);
|
||||
|
||||
List<String> result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
channelContext.changeStateRunDuplexCommunication();
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(1, result.size());
|
||||
|
||||
|
||||
|
||||
channelContext.changeStateShutdown();
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
service.tearDown();
|
||||
} finally {
|
||||
closeZookeeperServer(ts);
|
||||
}
|
||||
}
|
||||
|
||||
// 심플 쥬키퍼 테스트
|
||||
// 쥬키퍼와 연결이 끊어져 있는경우 이벤트가 발생했을때 쥬키퍼와 연결이 될 경우 해당 이벤트가 처리되어 있는지
|
||||
@Test
|
||||
public void simpleTest2() throws Exception {
|
||||
TestingServer ts = null;
|
||||
try {
|
||||
ZookeeperClusterService service = new ZookeeperClusterService(collectorConfig, clusterPointRouter);
|
||||
service.setUp();
|
||||
|
||||
ChannelContext channelContext = new ChannelContext(mock(SocketChannel.class), null, service.getChannelStateChangeEventListener());
|
||||
channelContext.setChannelProperties(getParams());
|
||||
|
||||
ZookeeperProfilerClusterManager profilerClusterManager = service.getProfilerClusterManager();
|
||||
|
||||
channelContext.changeStateRun();
|
||||
Thread.sleep(1000);
|
||||
List<String> result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
channelContext.changeStateRunDuplexCommunication();
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
ts = ZookeeperTestUtils.createZookeeperServer(DEFAULT_ACCEPTOR_PORT);
|
||||
Thread.sleep(10000);
|
||||
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(1, result.size());
|
||||
|
||||
channelContext.changeStateShutdown();
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
service.tearDown();
|
||||
} finally {
|
||||
closeZookeeperServer(ts);
|
||||
}
|
||||
}
|
||||
|
||||
// 심플 쥬키퍼 테스트
|
||||
// 쥬키퍼와 연결되었을때 이벤트가 등록되었는데
|
||||
// 쥬키퍼가 종료 되고 다시 연결될때 해당 이벤트가 상태를 유지 되는지
|
||||
@Test
|
||||
public void simpleTest3() throws Exception {
|
||||
TestingServer ts = null;
|
||||
try {
|
||||
ts = ZookeeperTestUtils.createZookeeperServer(DEFAULT_ACCEPTOR_PORT);
|
||||
|
||||
ZookeeperClusterService service = new ZookeeperClusterService(collectorConfig, clusterPointRouter);
|
||||
service.setUp();
|
||||
|
||||
ChannelContext channelContext = new ChannelContext(mock(SocketChannel.class), null, service.getChannelStateChangeEventListener());
|
||||
channelContext.setChannelProperties(getParams());
|
||||
|
||||
ZookeeperProfilerClusterManager profilerClusterManager = service.getProfilerClusterManager();
|
||||
|
||||
channelContext.changeStateRun();
|
||||
Thread.sleep(1000);
|
||||
List<String> result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
channelContext.changeStateRunDuplexCommunication();
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(1, result.size());
|
||||
|
||||
ts.stop();
|
||||
Thread.sleep(1000);
|
||||
ts.restart();
|
||||
Thread.sleep(1000);
|
||||
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(1, result.size());
|
||||
|
||||
channelContext.changeStateShutdown();
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
service.tearDown();
|
||||
} finally {
|
||||
closeZookeeperServer(ts);
|
||||
}
|
||||
}
|
||||
|
||||
// 심플 쥬키퍼 테스트
|
||||
// 쥬키퍼와 연결이 끊어져 있는경우 이벤트가 발생했을때 쥬키퍼와 연결이 될 경우 해당 이벤트가 처리되어 있는지
|
||||
@Test
|
||||
public void simpleTest4() throws Exception {
|
||||
TestingServer ts = null;
|
||||
try {
|
||||
ZookeeperClusterService service = new ZookeeperClusterService(collectorConfig, clusterPointRouter);
|
||||
service.setUp();
|
||||
|
||||
ChannelContext channelContext = new ChannelContext(mock(SocketChannel.class), null, service.getChannelStateChangeEventListener());
|
||||
channelContext.setChannelProperties(getParams());
|
||||
|
||||
ZookeeperProfilerClusterManager profilerClusterManager = service.getProfilerClusterManager();
|
||||
|
||||
channelContext.changeStateRun();
|
||||
Thread.sleep(1000);
|
||||
List<String> result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
channelContext.changeStateRunDuplexCommunication();
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
channelContext.changeStateShutdown();
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
ts = ZookeeperTestUtils.createZookeeperServer(DEFAULT_ACCEPTOR_PORT);
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
service.tearDown();
|
||||
} finally {
|
||||
closeZookeeperServer(ts);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 심플 쥬키퍼 테스트
|
||||
// 쥬키퍼와 연결되었을때 이벤트가 등록되었는데
|
||||
// 쥬키퍼가 종료 되고 다시 연결될때 해당 이벤트가 상태를 유지 되는지
|
||||
@Test
|
||||
public void simpleTest5() throws Exception {
|
||||
TestingServer ts = null;
|
||||
try {
|
||||
ts = ZookeeperTestUtils.createZookeeperServer(DEFAULT_ACCEPTOR_PORT);
|
||||
|
||||
ZookeeperClusterService service = new ZookeeperClusterService(collectorConfig, clusterPointRouter);
|
||||
service.setUp();
|
||||
|
||||
ChannelContext channelContext = new ChannelContext(mock(SocketChannel.class), null, service.getChannelStateChangeEventListener());
|
||||
channelContext.setChannelProperties(getParams());
|
||||
|
||||
ZookeeperProfilerClusterManager profilerClusterManager = service.getProfilerClusterManager();
|
||||
|
||||
channelContext.changeStateRun();
|
||||
Thread.sleep(1000);
|
||||
List<String> result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
channelContext.changeStateRunDuplexCommunication();
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(1, result.size());
|
||||
|
||||
channelContext.changeStateShutdown();
|
||||
Thread.sleep(1000);
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
ts.stop();
|
||||
Thread.sleep(1000);
|
||||
ts.restart();
|
||||
Thread.sleep(1000);
|
||||
|
||||
result = profilerClusterManager.getClusterData();
|
||||
Assert.assertEquals(0, result.size());
|
||||
|
||||
service.tearDown();
|
||||
} finally {
|
||||
closeZookeeperServer(ts);
|
||||
}
|
||||
}
|
||||
|
||||
private void closeZookeeperServer(TestingServer mockZookeeperServer) throws Exception {
|
||||
try {
|
||||
mockZookeeperServer.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Map<Object, Object> getParams() {
|
||||
Map<Object, Object> properties = new HashMap<Object, Object>();
|
||||
|
||||
properties.put(AgentHandshakePropertyType.AGENT_ID.getName(), "agent");
|
||||
properties.put(AgentHandshakePropertyType.APPLICATION_NAME.getName(), "application");
|
||||
properties.put(AgentHandshakePropertyType.HOSTNAME.getName(), "hostname");
|
||||
properties.put(AgentHandshakePropertyType.IP.getName(), "ip");
|
||||
properties.put(AgentHandshakePropertyType.PID.getName(), 1111);
|
||||
properties.put(AgentHandshakePropertyType.SERVICE_TYPE.getName(), 10);
|
||||
properties.put(AgentHandshakePropertyType.START_TIMESTAMP.getName(), System.currentTimeMillis());
|
||||
properties.put(AgentHandshakePropertyType.VERSION.getName(), "1.0");
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
}
|
||||
-320
@@ -1,320 +0,0 @@
|
||||
package com.nhn.pinpoint.collector.cluster.zookeeper;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.apache.curator.test.TestingServer;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.nhn.pinpoint.collector.cluster.ClusterPointRouter;
|
||||
import com.nhn.pinpoint.collector.config.CollectorConfiguration;
|
||||
import com.nhn.pinpoint.rpc.PinpointSocketException;
|
||||
import com.nhn.pinpoint.rpc.client.MessageListener;
|
||||
import com.nhn.pinpoint.rpc.client.PinpointSocket;
|
||||
import com.nhn.pinpoint.rpc.client.PinpointSocketFactory;
|
||||
import com.nhn.pinpoint.rpc.server.PinpointServerSocket;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:applicationContext-test.xml")
|
||||
public class ZookeeperProfilerClusterStressTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ZookeeperProfilerClusterStressTest.class);
|
||||
|
||||
private static final int DEFAULT_ACCEPTOR_PORT = 22313;
|
||||
private static final int DEFAULT_ACCEPTOR_SOCKET_PORT = 22315;
|
||||
|
||||
private static final MessageListener messageListener = ZookeeperTestUtils.getMessageListener();
|
||||
|
||||
private static CollectorConfiguration collectorConfig = null;
|
||||
|
||||
private final int doCount = 10;
|
||||
|
||||
@Autowired
|
||||
ClusterPointRouter clusterPointRouter;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
collectorConfig = new CollectorConfiguration();
|
||||
|
||||
collectorConfig.setClusterEnable(true);
|
||||
collectorConfig.setClusterAddress("127.0.0.1:" + DEFAULT_ACCEPTOR_PORT);
|
||||
collectorConfig.setClusterSessionTimeout(3000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleTest1() throws Exception {
|
||||
List<TestSocket> socketList = new ArrayList<ZookeeperProfilerClusterStressTest.TestSocket>();
|
||||
|
||||
PinpointServerSocket pinpointServerSocket = null;
|
||||
|
||||
TestingServer ts = null;
|
||||
try {
|
||||
ts = ZookeeperTestUtils.createZookeeperServer(DEFAULT_ACCEPTOR_PORT);
|
||||
|
||||
ZookeeperClusterService service = new ZookeeperClusterService(collectorConfig, clusterPointRouter);
|
||||
service.setUp();
|
||||
|
||||
ZookeeperProfilerClusterManager profiler = service.getProfilerClusterManager();
|
||||
|
||||
pinpointServerSocket = new PinpointServerSocket(service.getChannelStateChangeEventListener());
|
||||
pinpointServerSocket.setMessageListener(ZookeeperTestUtils.getServerMessageListener());
|
||||
pinpointServerSocket.bind("127.0.0.1", DEFAULT_ACCEPTOR_SOCKET_PORT);
|
||||
|
||||
InetSocketAddress address = new InetSocketAddress("127.0.0.1", DEFAULT_ACCEPTOR_SOCKET_PORT);
|
||||
|
||||
socketList = connectPoint(socketList, address, doCount);
|
||||
Thread.sleep(1000);
|
||||
Assert.assertEquals(socketList.size(), profiler.getClusterData().size());
|
||||
|
||||
for (int i=0; i < doCount; i++) {
|
||||
socketList = randomJob(socketList, address);
|
||||
Thread.sleep(1000);
|
||||
Assert.assertEquals(socketList.size(), profiler.getClusterData().size());
|
||||
}
|
||||
|
||||
disconnectPoint(socketList, socketList.size());
|
||||
Thread.sleep(1000);
|
||||
Assert.assertEquals(0, profiler.getClusterData().size());
|
||||
|
||||
service.tearDown();
|
||||
} finally {
|
||||
closeZookeeperServer(ts);
|
||||
pinpointServerSocket.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleTest2() throws Exception {
|
||||
|
||||
PinpointServerSocket pinpointServerSocket = null;
|
||||
|
||||
TestingServer ts = null;
|
||||
try {
|
||||
ts = ZookeeperTestUtils.createZookeeperServer(DEFAULT_ACCEPTOR_PORT);
|
||||
|
||||
ZookeeperClusterService service = new ZookeeperClusterService(collectorConfig, clusterPointRouter);
|
||||
service.setUp();
|
||||
|
||||
ZookeeperProfilerClusterManager profiler = service.getProfilerClusterManager();
|
||||
|
||||
pinpointServerSocket = new PinpointServerSocket(service.getChannelStateChangeEventListener());
|
||||
pinpointServerSocket.setMessageListener(ZookeeperTestUtils.getServerMessageListener());
|
||||
pinpointServerSocket.bind("127.0.0.1", DEFAULT_ACCEPTOR_SOCKET_PORT);
|
||||
|
||||
InetSocketAddress address = new InetSocketAddress("127.0.0.1", DEFAULT_ACCEPTOR_SOCKET_PORT);
|
||||
|
||||
CountDownLatch latch = new CountDownLatch(2);
|
||||
|
||||
|
||||
List<TestSocket> socketList1 = connectPoint(new ArrayList<TestSocket>(), address, doCount);
|
||||
List<TestSocket> socketList2 = connectPoint(new ArrayList<TestSocket>(), address, doCount);
|
||||
|
||||
|
||||
WorkerJob job1 = new WorkerJob(latch, socketList1, address, 5);
|
||||
WorkerJob job2 = new WorkerJob(latch, socketList2, address, 5);
|
||||
|
||||
Thread worker1 = new Thread(job1);
|
||||
worker1.setDaemon(false);
|
||||
worker1.start();
|
||||
|
||||
Thread worker2 = new Thread(job2);
|
||||
worker2.setDaemon(false);
|
||||
worker2.start();
|
||||
|
||||
|
||||
latch.await();
|
||||
|
||||
List<TestSocket> socketList = new ArrayList<ZookeeperProfilerClusterStressTest.TestSocket>();
|
||||
socketList.addAll(job1.getSocketList());
|
||||
socketList.addAll(job2.getSocketList());
|
||||
|
||||
|
||||
logger.info(profiler.getClusterData().toString());
|
||||
Assert.assertEquals(socketList.size(), profiler.getClusterData().size());
|
||||
|
||||
|
||||
disconnectPoint(socketList, socketList.size());
|
||||
Thread.sleep(1000);
|
||||
|
||||
service.tearDown();
|
||||
} finally {
|
||||
closeZookeeperServer(ts);
|
||||
pinpointServerSocket.close();
|
||||
}
|
||||
}
|
||||
|
||||
class WorkerJob implements Runnable {
|
||||
|
||||
private final CountDownLatch latch;
|
||||
|
||||
private final InetSocketAddress address;
|
||||
|
||||
private List<TestSocket> socketList;
|
||||
private int workCount;
|
||||
|
||||
public WorkerJob(CountDownLatch latch, List<TestSocket> socketList, InetSocketAddress address ,int workCount) {
|
||||
this.latch = latch;
|
||||
this.address = address;
|
||||
|
||||
this.socketList = socketList;
|
||||
this.workCount = workCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for (int i=0; i < workCount; i++) {
|
||||
socketList = randomJob(socketList, address);
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
latch.countDown();
|
||||
}
|
||||
}
|
||||
|
||||
public List<TestSocket> getSocketList() {
|
||||
return socketList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void closeZookeeperServer(TestingServer mockZookeeperServer) throws Exception {
|
||||
try {
|
||||
mockZookeeperServer.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private class TestSocket {
|
||||
|
||||
private final PinpointSocketFactory factory;
|
||||
private final Map<String, Object> properties;
|
||||
|
||||
private PinpointSocket socket;
|
||||
|
||||
|
||||
public TestSocket() {
|
||||
this.properties = ZookeeperTestUtils.getParams(Thread.currentThread().getName(), "agent", System.currentTimeMillis());
|
||||
|
||||
this.factory = new PinpointSocketFactory();
|
||||
this.factory.setProperties(properties);
|
||||
this.factory.setMessageListener(messageListener);
|
||||
}
|
||||
|
||||
private void connect(InetSocketAddress address) {
|
||||
if (socket == null) {
|
||||
socket = createPinpointSocket(factory, address);
|
||||
}
|
||||
}
|
||||
|
||||
private void stop() {
|
||||
if (socket != null) {
|
||||
socket.close();
|
||||
socket = null;
|
||||
}
|
||||
|
||||
if (factory != null) {
|
||||
factory.release();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getClass().getSimpleName() + "(" + properties + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private PinpointSocket createPinpointSocket(PinpointSocketFactory factory, InetSocketAddress address) {
|
||||
String host = address.getHostName();
|
||||
int port = address.getPort();
|
||||
|
||||
PinpointSocket socket = null;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
socket = factory.connect(host, port);
|
||||
logger.info("tcp connect success:{}/{}", host, port);
|
||||
return socket;
|
||||
} catch (PinpointSocketException e) {
|
||||
logger.warn("tcp connect fail:{}/{} try reconnect, retryCount:{}", host, port, i);
|
||||
}
|
||||
}
|
||||
logger.warn("change background tcp connect mode {}/{} ", host, port);
|
||||
socket = factory.scheduledConnect(host, port);
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
private List<TestSocket> randomJob(List<TestSocket> socketList, InetSocketAddress address) {
|
||||
Random random = new Random(System.currentTimeMillis());
|
||||
int randomNumber = Math.abs(random.nextInt());
|
||||
|
||||
if (randomNumber % 2 == 0) {
|
||||
return connectPoint(socketList, address, 1);
|
||||
} else {
|
||||
return disconnectPoint(socketList, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private List<TestSocket> connectPoint(List<TestSocket> socketList, InetSocketAddress address, int count) {
|
||||
// logger.info("connect list=({}), address={}, count={}.", socketList, address, count);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
||||
// startTimeStamp 혹시나 안겹치게
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
TestSocket socket = new TestSocket();
|
||||
logger.info("connect ({}), .", socket);
|
||||
socket.connect(address);
|
||||
|
||||
socketList.add(socket);
|
||||
}
|
||||
|
||||
return socketList;
|
||||
}
|
||||
|
||||
private List<TestSocket> disconnectPoint(List<TestSocket> socketList, int count) {
|
||||
// logger.info("disconnect list=({}), count={}.", socketList, count);
|
||||
|
||||
int index = 1;
|
||||
|
||||
Iterator<TestSocket> iterator = socketList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TestSocket socket = iterator.next();
|
||||
|
||||
logger.info("disconnect ({}), .", socket);
|
||||
socket.stop();
|
||||
|
||||
iterator.remove();
|
||||
|
||||
if (index++ >= count) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return socketList;
|
||||
}
|
||||
|
||||
}
|
||||
-95
@@ -1,95 +0,0 @@
|
||||
package com.nhn.pinpoint.collector.cluster.zookeeper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.curator.test.TestingServer;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.collector.receiver.tcp.AgentHandshakePropertyType;
|
||||
import com.nhn.pinpoint.rpc.client.MessageListener;
|
||||
import com.nhn.pinpoint.rpc.packet.HandshakeResponseCode;
|
||||
import com.nhn.pinpoint.rpc.packet.HandshakeResponseType;
|
||||
import com.nhn.pinpoint.rpc.packet.RequestPacket;
|
||||
import com.nhn.pinpoint.rpc.packet.SendPacket;
|
||||
import com.nhn.pinpoint.rpc.server.ServerMessageListener;
|
||||
import com.nhn.pinpoint.rpc.server.SocketChannel;
|
||||
|
||||
final class ZookeeperTestUtils {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ZookeeperTestUtils.class);
|
||||
|
||||
private ZookeeperTestUtils() {
|
||||
}
|
||||
|
||||
static MessageListener getMessageListener() {
|
||||
return new SimpleMessageListener();
|
||||
}
|
||||
|
||||
static ServerMessageListener getServerMessageListener() {
|
||||
return new SimpleServerMessageListner();
|
||||
}
|
||||
|
||||
static Map<String, Object> getParams() {
|
||||
return getParams("application", "agent", System.currentTimeMillis());
|
||||
}
|
||||
|
||||
static Map<String, Object> getParams(String applicationName, String agentId, long startTimeMillis) {
|
||||
Map<String, Object> properties = new HashMap<String, Object>();
|
||||
|
||||
properties.put(AgentHandshakePropertyType.AGENT_ID.getName(), agentId);
|
||||
properties.put(AgentHandshakePropertyType.APPLICATION_NAME.getName(), applicationName);
|
||||
properties.put(AgentHandshakePropertyType.HOSTNAME.getName(), "hostname");
|
||||
properties.put(AgentHandshakePropertyType.IP.getName(), "ip");
|
||||
properties.put(AgentHandshakePropertyType.PID.getName(), 1111);
|
||||
properties.put(AgentHandshakePropertyType.SERVICE_TYPE.getName(), 10);
|
||||
properties.put(AgentHandshakePropertyType.START_TIMESTAMP.getName(), startTimeMillis);
|
||||
properties.put(AgentHandshakePropertyType.VERSION.getName(), "1.0");
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
static TestingServer createZookeeperServer(int port) throws Exception {
|
||||
TestingServer mockZookeeperServer = new TestingServer(port);
|
||||
mockZookeeperServer.start();
|
||||
|
||||
return mockZookeeperServer;
|
||||
}
|
||||
|
||||
private static class SimpleMessageListener implements MessageListener {
|
||||
|
||||
public SimpleMessageListener() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSend(SendPacket sendPacket, Channel channel) {
|
||||
LOGGER.info("Received SendPacket{} {}", sendPacket, channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRequest(RequestPacket requestPacket, Channel channel) {
|
||||
LOGGER.info("Received RequestPacket{} {}", requestPacket, channel);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SimpleServerMessageListner implements ServerMessageListener {
|
||||
@Override
|
||||
public void handleSend(SendPacket sendPacket, SocketChannel channel) {
|
||||
LOGGER.warn("Unsupport send received {} {}", sendPacket, channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRequest(RequestPacket requestPacket, SocketChannel channel) {
|
||||
LOGGER.warn("Unsupport request received {} {}", requestPacket, channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandshakeResponseCode handleHandshake(Map properties) {
|
||||
LOGGER.warn("do handleEnableWorker {}", properties);
|
||||
return HandshakeResponseType.Success.DUPLEX_COMMUNICATION;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-102
@@ -1,102 +0,0 @@
|
||||
package com.nhn.pinpoint.collector.cluster.zookeeper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.apache.curator.test.TestingServer;
|
||||
import org.apache.zookeeper.WatchedEvent;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.nhn.pinpoint.collector.cluster.ClusterPointRouter;
|
||||
import com.nhn.pinpoint.collector.config.CollectorConfiguration;
|
||||
import com.nhn.pinpoint.rpc.server.ChannelContext;
|
||||
import com.nhn.pinpoint.rpc.server.PinpointServerSocket;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:applicationContext-test.xml")
|
||||
public class ZookeeperWebClusterServiceTest {
|
||||
|
||||
private static final String PINPOINT_CLUSTER_PATH = "/pinpoint-cluster";
|
||||
private static final String PINPOINT_WEB_CLUSTER_PATH = PINPOINT_CLUSTER_PATH + "/web";
|
||||
private static final String PINPOINT_PROFILER_CLUSTER_PATH = PINPOINT_CLUSTER_PATH + "/profiler";
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
private static final int DEFAULT_ZOOKEEPER_PORT = 22213;
|
||||
private static final int DEFAULT_ACCEPTOR_SOCKET_PORT = 22214;
|
||||
|
||||
private static CollectorConfiguration collectorConfig = null;
|
||||
|
||||
@Autowired
|
||||
ClusterPointRouter clusterPointRouter;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
collectorConfig = new CollectorConfiguration();
|
||||
|
||||
collectorConfig.setClusterEnable(true);
|
||||
collectorConfig.setClusterAddress("127.0.0.1:" + DEFAULT_ZOOKEEPER_PORT);
|
||||
collectorConfig.setClusterSessionTimeout(3000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleTest1() throws Exception {
|
||||
TestingServer ts = null;
|
||||
try {
|
||||
ts = ZookeeperTestUtils.createZookeeperServer(DEFAULT_ZOOKEEPER_PORT);
|
||||
|
||||
ZookeeperClusterService service = new ZookeeperClusterService(collectorConfig, clusterPointRouter);
|
||||
service.setUp();
|
||||
|
||||
PinpointServerSocket pinpointServerSocket = new PinpointServerSocket();
|
||||
pinpointServerSocket.setMessageListener(ZookeeperTestUtils.getServerMessageListener());
|
||||
pinpointServerSocket.bind("127.0.0.1", DEFAULT_ACCEPTOR_SOCKET_PORT);
|
||||
|
||||
ZookeeperClient client = new ZookeeperClient("127.0.0.1:" + DEFAULT_ZOOKEEPER_PORT, 3000, new ZookeeperEventWatcher() {
|
||||
|
||||
@Override
|
||||
public void process(WatchedEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
client.createPath(PINPOINT_WEB_CLUSTER_PATH, true);
|
||||
client.createNode(PINPOINT_WEB_CLUSTER_PATH + "/" + "127.0.0.1:" + DEFAULT_ACCEPTOR_SOCKET_PORT, "127.0.0.1".getBytes());
|
||||
|
||||
Thread.sleep(5000);
|
||||
|
||||
List<ChannelContext> channelContextList = pinpointServerSocket.getDuplexCommunicationChannelContext();
|
||||
Assert.assertEquals(1, channelContextList.size());
|
||||
|
||||
client.close();
|
||||
|
||||
Thread.sleep(5000);
|
||||
channelContextList = pinpointServerSocket.getDuplexCommunicationChannelContext();
|
||||
Assert.assertEquals(0, channelContextList.size());
|
||||
|
||||
service.tearDown();
|
||||
} finally {
|
||||
closeZookeeperServer(ts);
|
||||
}
|
||||
}
|
||||
|
||||
private void closeZookeeperServer(TestingServer mockZookeeperServer) throws Exception {
|
||||
try {
|
||||
mockZookeeperServer.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
package com.nhn.pinpoint.collector.dao.hbase;
|
||||
|
||||
import static org.mockito.Matchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.apache.hadoop.hbase.client.Put;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.Spy;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.nhn.pinpoint.collector.dao.AgentStatDao;
|
||||
import com.nhn.pinpoint.collector.mapper.thrift.ThriftBoMapper;
|
||||
import com.nhn.pinpoint.common.bo.AgentStatCpuLoadBo;
|
||||
import com.nhn.pinpoint.common.bo.AgentStatMemoryGcBo;
|
||||
import com.nhn.pinpoint.common.hbase.HBaseTables;
|
||||
import com.nhn.pinpoint.common.hbase.HbaseOperations2;
|
||||
import com.nhn.pinpoint.thrift.dto.TAgentStat;
|
||||
import com.nhn.pinpoint.thrift.dto.TCpuLoad;
|
||||
import com.nhn.pinpoint.thrift.dto.TJvmGc;
|
||||
import com.nhn.pinpoint.thrift.dto.TJvmGcType;
|
||||
import com.sematext.hbase.wd.AbstractRowKeyDistributor;
|
||||
|
||||
/**
|
||||
* @author hyungil.jeong
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:applicationContext-test.xml")
|
||||
public class HbaseAgentStatDaoTest {
|
||||
|
||||
@Mock
|
||||
private HbaseOperations2 hbaseTemplate;
|
||||
|
||||
@Spy
|
||||
@Autowired
|
||||
@Qualifier("agentStatMemoryGcBoMapper")
|
||||
private ThriftBoMapper<AgentStatMemoryGcBo, TAgentStat> agentStatMemoryGcBoMapper;
|
||||
|
||||
@Spy
|
||||
@Autowired
|
||||
@Qualifier("agentStatCpuLoadBoMapper")
|
||||
private ThriftBoMapper<AgentStatCpuLoadBo, TAgentStat> agentStatCpuLoadBoMapper;
|
||||
|
||||
@Spy
|
||||
@Autowired
|
||||
@Qualifier("agentStatRowKeyDistributor")
|
||||
private AbstractRowKeyDistributor rowKeyDistributor;
|
||||
|
||||
@InjectMocks
|
||||
private AgentStatDao agentStatDao = new HbaseAgentStatDao();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsert() {
|
||||
// Given
|
||||
final String agentId = "agentId";
|
||||
final long startTimestamp = Long.MAX_VALUE;
|
||||
final TAgentStat agentStat = createAgentStat(agentId, startTimestamp, createTJvmGc(agentId, startTimestamp), createTCpuLoad());
|
||||
// When
|
||||
agentStatDao.insert(agentStat);
|
||||
// Then
|
||||
verify(hbaseTemplate).put(eq(HBaseTables.AGENT_STAT), isA(Put.class));
|
||||
}
|
||||
|
||||
private TAgentStat createAgentStat(String agentId, long startTimestamp, TJvmGc gc, TCpuLoad cpuLoad) {
|
||||
final TAgentStat agentStat = new TAgentStat();
|
||||
agentStat.setAgentId(agentId);
|
||||
agentStat.setStartTimestamp(startTimestamp);
|
||||
agentStat.setGc(gc);
|
||||
agentStat.setCpuLoad(cpuLoad);
|
||||
return agentStat;
|
||||
}
|
||||
|
||||
private TJvmGc createTJvmGc(String agentId, long startTimestamp) {
|
||||
final TJvmGc jvmGc = new TJvmGc();
|
||||
jvmGc.setType(TJvmGcType.G1);
|
||||
jvmGc.setJvmMemoryHeapUsed(Long.MIN_VALUE);
|
||||
jvmGc.setJvmMemoryHeapMax(Long.MAX_VALUE);
|
||||
jvmGc.setJvmMemoryNonHeapUsed(Long.MIN_VALUE);
|
||||
jvmGc.setJvmMemoryNonHeapMax(Long.MAX_VALUE);
|
||||
jvmGc.setJvmGcOldCount(1L);
|
||||
jvmGc.setJvmGcOldTime(1L);
|
||||
return jvmGc;
|
||||
}
|
||||
|
||||
private TCpuLoad createTCpuLoad() {
|
||||
final TCpuLoad cpuLoad = new TCpuLoad();
|
||||
cpuLoad.setJvmCpuLoad(Double.MIN_VALUE);
|
||||
cpuLoad.setSystemCpuLoad(Double.MAX_VALUE);
|
||||
return cpuLoad;
|
||||
}
|
||||
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package com.nhn.pinpoint.collector.dao.hbase;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.sematext.hbase.wd.RowKeyDistributorByHashPrefix;
|
||||
|
||||
/**
|
||||
* @author emeroad
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:applicationContext-test.xml")
|
||||
public class HbaseApplicationTraceIndexDaoTest {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("applicationTraceIndexDistributor")
|
||||
private RowKeyDistributorByHashPrefix distributorByHashPrefix;
|
||||
|
||||
@Test
|
||||
public void testInsert() throws Exception {
|
||||
// distributorByHashPrefix.getOriginalKey(Bytes.read(1));
|
||||
}
|
||||
}
|
||||
-118
@@ -1,118 +0,0 @@
|
||||
package com.nhn.pinpoint.collector.mapper.thrift;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.nhn.pinpoint.common.bo.AgentStatCpuLoadBo;
|
||||
import com.nhn.pinpoint.thrift.dto.TAgentStat;
|
||||
import com.nhn.pinpoint.thrift.dto.TCpuLoad;
|
||||
|
||||
/**
|
||||
* @author hyungil.jeong
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:applicationContext-test.xml")
|
||||
public class AgentStatCpuLoadBoMapperTest {
|
||||
|
||||
// CPU 사용량 소수점 2자리 표시
|
||||
private static final double DELTA = 1e-4;
|
||||
|
||||
@Autowired
|
||||
private AgentStatCpuLoadBoMapper mapper;
|
||||
|
||||
@Test
|
||||
public void testValidMap() {
|
||||
// Given
|
||||
final TAgentStat thriftObj = new TAgentStat();
|
||||
thriftObj.setAgentId("agentId");
|
||||
thriftObj.setStartTimestamp(0L);
|
||||
thriftObj.setTimestamp(1L);
|
||||
final TCpuLoad cpuLoad = new TCpuLoad();
|
||||
cpuLoad.setJvmCpuLoad(99.0D);
|
||||
cpuLoad.setSystemCpuLoad(99.9D);
|
||||
thriftObj.setCpuLoad(cpuLoad);
|
||||
// When
|
||||
AgentStatCpuLoadBo mappedBo = mapper.map(thriftObj);
|
||||
// Then
|
||||
assertEquals(mappedBo.getAgentId(), thriftObj.getAgentId());
|
||||
assertEquals(mappedBo.getStartTimestamp(), thriftObj.getStartTimestamp());
|
||||
assertEquals(mappedBo.getTimestamp(), thriftObj.getTimestamp());
|
||||
assertEquals(mappedBo.getJvmCpuLoad(), cpuLoad.getJvmCpuLoad(), DELTA);
|
||||
assertEquals(mappedBo.getSystemCpuLoad(), cpuLoad.getSystemCpuLoad(), DELTA);
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void mapShouldThrowNpeForNullThriftObject() {
|
||||
// Given
|
||||
final TAgentStat thriftObj = null;
|
||||
// When
|
||||
mapper.map(thriftObj);
|
||||
// Then
|
||||
fail();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mapShouldNotThrowExceptionForNullCpuLoad() {
|
||||
// Given
|
||||
final TAgentStat thriftObj = new TAgentStat();
|
||||
thriftObj.setAgentId("agentId");
|
||||
thriftObj.setStartTimestamp(0L);
|
||||
thriftObj.setTimestamp(1L);
|
||||
thriftObj.setCpuLoad(null);
|
||||
// When
|
||||
AgentStatCpuLoadBo mappedBo = mapper.map(thriftObj);
|
||||
// Then
|
||||
assertEquals(mappedBo.getAgentId(), thriftObj.getAgentId());
|
||||
assertEquals(mappedBo.getStartTimestamp(), thriftObj.getStartTimestamp());
|
||||
assertEquals(mappedBo.getTimestamp(), thriftObj.getTimestamp());
|
||||
assertTrue(mappedBo.getJvmCpuLoad() < 0.0D);
|
||||
assertTrue(mappedBo.getSystemCpuLoad() < 0.0D);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mapShouldNotThrowExceptionForNullJvmCpuLoad() {
|
||||
// Given
|
||||
final TAgentStat thriftObj = new TAgentStat();
|
||||
thriftObj.setAgentId("agentId");
|
||||
thriftObj.setStartTimestamp(0L);
|
||||
thriftObj.setTimestamp(1L);
|
||||
final TCpuLoad cpuLoad = new TCpuLoad();
|
||||
cpuLoad.setJvmCpuLoadIsSet(false);
|
||||
cpuLoad.setSystemCpuLoad(99.0D);
|
||||
thriftObj.setCpuLoad(cpuLoad);
|
||||
// When
|
||||
AgentStatCpuLoadBo mappedBo = mapper.map(thriftObj);
|
||||
// Then
|
||||
assertEquals(mappedBo.getAgentId(), thriftObj.getAgentId());
|
||||
assertEquals(mappedBo.getStartTimestamp(), thriftObj.getStartTimestamp());
|
||||
assertEquals(mappedBo.getTimestamp(), thriftObj.getTimestamp());
|
||||
assertTrue(mappedBo.getJvmCpuLoad() < 0.0D);
|
||||
assertEquals(mappedBo.getSystemCpuLoad(), cpuLoad.getSystemCpuLoad(), DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mapShouldNotThrowExceptionForNullSystemCpuLoad() {
|
||||
// Given
|
||||
final TAgentStat thriftObj = new TAgentStat();
|
||||
thriftObj.setAgentId("agentId");
|
||||
thriftObj.setStartTimestamp(0L);
|
||||
thriftObj.setTimestamp(1L);
|
||||
final TCpuLoad cpuLoad = new TCpuLoad();
|
||||
cpuLoad.setJvmCpuLoad(99.0D);
|
||||
cpuLoad.setSystemCpuLoadIsSet(false);
|
||||
thriftObj.setCpuLoad(cpuLoad);
|
||||
// When
|
||||
AgentStatCpuLoadBo mappedBo = mapper.map(thriftObj);
|
||||
// Then
|
||||
assertEquals(mappedBo.getAgentId(), thriftObj.getAgentId());
|
||||
assertEquals(mappedBo.getStartTimestamp(), thriftObj.getStartTimestamp());
|
||||
assertEquals(mappedBo.getTimestamp(), thriftObj.getTimestamp());
|
||||
assertEquals(mappedBo.getJvmCpuLoad(), cpuLoad.getJvmCpuLoad(), DELTA);
|
||||
assertTrue(mappedBo.getSystemCpuLoad() < 0.0D);
|
||||
}
|
||||
}
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
package com.nhn.pinpoint.collector.mapper.thrift;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.nhn.pinpoint.common.bo.AgentStatMemoryGcBo;
|
||||
import com.nhn.pinpoint.thrift.dto.TAgentStat;
|
||||
import com.nhn.pinpoint.thrift.dto.TJvmGc;
|
||||
import com.nhn.pinpoint.thrift.dto.TJvmGcType;
|
||||
|
||||
/**
|
||||
* @author hyungil.jeong
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:applicationContext-test.xml")
|
||||
public class AgentStatMemoryGcBoMapperTest {
|
||||
|
||||
@Autowired
|
||||
private AgentStatMemoryGcBoMapper mapper;
|
||||
|
||||
@Test
|
||||
public void testValidMap() {
|
||||
// Given
|
||||
final TAgentStat thriftObj = new TAgentStat();
|
||||
thriftObj.setAgentId("agentId");
|
||||
thriftObj.setStartTimestamp(0L);
|
||||
thriftObj.setTimestamp(1L);
|
||||
final TJvmGc gc = new TJvmGc();
|
||||
gc.setType(TJvmGcType.UNKNOWN);
|
||||
gc.setJvmMemoryHeapUsed(999L);
|
||||
gc.setJvmMemoryHeapMax(1000L);
|
||||
gc.setJvmMemoryNonHeapUsed(1999L);
|
||||
gc.setJvmMemoryNonHeapMax(2000L);
|
||||
gc.setJvmGcOldCount(3L);
|
||||
gc.setJvmGcOldTime(10L);
|
||||
thriftObj.setGc(gc);
|
||||
// When
|
||||
AgentStatMemoryGcBo mappedBo = mapper.map(thriftObj);
|
||||
// Then
|
||||
assertEquals(mappedBo.getAgentId(), thriftObj.getAgentId());
|
||||
assertEquals(mappedBo.getStartTimestamp(), thriftObj.getStartTimestamp());
|
||||
assertEquals(mappedBo.getTimestamp(), thriftObj.getTimestamp());
|
||||
assertEquals(mappedBo.getGcType(), gc.getType().name());
|
||||
assertEquals(mappedBo.getJvmMemoryHeapUsed(), gc.getJvmMemoryHeapUsed());
|
||||
assertEquals(mappedBo.getJvmMemoryHeapMax(), gc.getJvmMemoryHeapMax());
|
||||
assertEquals(mappedBo.getJvmMemoryNonHeapUsed(), gc.getJvmMemoryNonHeapUsed());
|
||||
assertEquals(mappedBo.getJvmMemoryNonHeapMax(), gc.getJvmMemoryNonHeapMax());
|
||||
assertEquals(mappedBo.getJvmGcOldCount(), gc.getJvmGcOldCount());
|
||||
assertEquals(mappedBo.getJvmGcOldTime(), gc.getJvmGcOldTime());
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void mapShouldThrowNpeForNullThriftObject() {
|
||||
// Given
|
||||
final TAgentStat thriftObj = null;
|
||||
// When
|
||||
mapper.map(thriftObj);
|
||||
// Then
|
||||
fail();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mapShouldNotThrowExceptionForNullGc() {
|
||||
// Given
|
||||
final TAgentStat thriftObj = new TAgentStat();
|
||||
thriftObj.setAgentId("agentId");
|
||||
thriftObj.setStartTimestamp(0L);
|
||||
thriftObj.setTimestamp(1L);
|
||||
thriftObj.setGc(null);
|
||||
// When
|
||||
AgentStatMemoryGcBo mappedBo = mapper.map(thriftObj);
|
||||
// Then
|
||||
assertEquals(mappedBo.getAgentId(), thriftObj.getAgentId());
|
||||
assertEquals(mappedBo.getStartTimestamp(), thriftObj.getStartTimestamp());
|
||||
assertEquals(mappedBo.getTimestamp(), thriftObj.getTimestamp());
|
||||
assertEquals(mappedBo.getGcType(), TJvmGcType.UNKNOWN.name());
|
||||
assertEquals(mappedBo.getJvmMemoryHeapUsed(), 0L);
|
||||
assertEquals(mappedBo.getJvmMemoryHeapMax(), 0L);
|
||||
assertEquals(mappedBo.getJvmMemoryNonHeapUsed(), 0L);
|
||||
assertEquals(mappedBo.getJvmMemoryNonHeapMax(), 0L);
|
||||
assertEquals(mappedBo.getJvmGcOldCount(), 0L);
|
||||
assertEquals(mappedBo.getJvmGcOldTime(), 0L);
|
||||
}
|
||||
}
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
package com.nhn.pinpoint.collector.mapper.thrift;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.nhn.pinpoint.common.bo.ServerMetaDataBo;
|
||||
import com.nhn.pinpoint.common.bo.ServiceInfoBo;
|
||||
import com.nhn.pinpoint.thrift.dto.TServerMetaData;
|
||||
import com.nhn.pinpoint.thrift.dto.TServiceInfo;
|
||||
|
||||
/**
|
||||
* @author hyungil.jeong
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:applicationContext-test.xml")
|
||||
public class ServerMetaDataBoMapperTest {
|
||||
|
||||
@Autowired
|
||||
private ServerMetaDataBoMapper mapper;
|
||||
|
||||
@Test
|
||||
public void testValidMap() {
|
||||
// Given
|
||||
final TServerMetaData tServerMetaData = new TServerMetaData();
|
||||
tServerMetaData.setServerInfo("serverInfo");
|
||||
tServerMetaData.setVmArgs(Arrays.asList("arg1", "arg2"));
|
||||
|
||||
final TServiceInfo tServiceInfo = new TServiceInfo();
|
||||
tServiceInfo.setServiceName("serviceName");
|
||||
tServiceInfo.setServiceLibs(Arrays.asList("lib1", "lib2"));
|
||||
List<TServiceInfo> tServiceInfos = Arrays.asList(tServiceInfo);
|
||||
tServerMetaData.setServiceInfos(tServiceInfos);
|
||||
// When
|
||||
ServerMetaDataBo serverMetaData = mapper.map(tServerMetaData);
|
||||
List<ServiceInfoBo> serviceInfos = serverMetaData.getServiceInfos();
|
||||
// Then
|
||||
assertEquals(tServerMetaData.getServerInfo(), serverMetaData.getServerInfo());
|
||||
assertEquals(tServerMetaData.getVmArgs(), serverMetaData.getVmArgs());
|
||||
assertEquals(tServiceInfos.size(), serviceInfos.size());
|
||||
for (int i = 0; i < tServiceInfos.size(); ++i) {
|
||||
assertEquals(tServiceInfos.get(i).getServiceName(), serviceInfos.get(i).getServiceName());
|
||||
assertEquals(tServiceInfos.get(i).getServiceLibs(), serviceInfos.get(i).getServiceLibs());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mapShouldNotThrowExceptionForNullValues() {
|
||||
// Given
|
||||
final TServerMetaData tServerMetaData = new TServerMetaData();
|
||||
tServerMetaData.setServerInfo(null);
|
||||
tServerMetaData.setVmArgs(null);
|
||||
tServerMetaData.setServiceInfos(null);
|
||||
// When
|
||||
ServerMetaDataBo serverMetaData = mapper.map(tServerMetaData);
|
||||
// Then
|
||||
assertEquals("", serverMetaData.getServerInfo());
|
||||
assertEquals(Collections.emptyList(), serverMetaData.getVmArgs());
|
||||
assertEquals(Collections.emptyList(), serverMetaData.getServiceInfos());
|
||||
}
|
||||
|
||||
}
|
||||
-135
@@ -1,135 +0,0 @@
|
||||
package com.nhn.pinpoint.collector.receiver.tcp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
|
||||
import org.apache.thrift.TBase;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.nhn.pinpoint.collector.receiver.TcpDispatchHandler;
|
||||
import com.nhn.pinpoint.rpc.packet.Packet;
|
||||
import com.nhn.pinpoint.rpc.packet.RequestPacket;
|
||||
import com.nhn.pinpoint.rpc.packet.ResponsePacket;
|
||||
import com.nhn.pinpoint.rpc.packet.SendPacket;
|
||||
import com.nhn.pinpoint.thrift.dto.TAgentInfo;
|
||||
import com.nhn.pinpoint.thrift.dto.TResult;
|
||||
import com.nhn.pinpoint.thrift.io.HeaderTBaseDeserializer;
|
||||
import com.nhn.pinpoint.thrift.io.HeaderTBaseDeserializerFactory;
|
||||
import com.nhn.pinpoint.thrift.io.HeaderTBaseSerializer;
|
||||
import com.nhn.pinpoint.thrift.io.HeaderTBaseSerializerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* @author koo.taejin
|
||||
*/
|
||||
@ContextConfiguration("classpath:applicationContext-collector.xml")
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class TCPReceiverBOTest {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
TcpDispatchHandler handler;
|
||||
|
||||
@Autowired
|
||||
private TCPReceiver tcpReceiver;
|
||||
|
||||
|
||||
@Test
|
||||
public void agentInfoTest1() throws Exception {
|
||||
Socket socket = connectTcpReceiver();
|
||||
OutputStream os = socket.getOutputStream();
|
||||
InputStream is = socket.getInputStream();
|
||||
|
||||
TAgentInfo agentInfo = getAgentInfo();
|
||||
encodeAndWrite(os, agentInfo, false);
|
||||
ResponsePacket responsePacket = readAndDecode(is, 1000);
|
||||
Assert.assertNull(responsePacket);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void agentInfoTest2() throws Exception {
|
||||
Socket socket = connectTcpReceiver();
|
||||
OutputStream os = socket.getOutputStream();
|
||||
InputStream is = socket.getInputStream();
|
||||
|
||||
TAgentInfo agentInfo = getAgentInfo();
|
||||
encodeAndWrite(os, agentInfo, true);
|
||||
ResponsePacket responsePacket = readAndDecode(is, 1000);
|
||||
|
||||
HeaderTBaseDeserializer deserializer = new HeaderTBaseDeserializerFactory().createDeserializer();
|
||||
TResult result = (TResult) deserializer.deserialize(responsePacket.getPayload());
|
||||
|
||||
Assert.assertTrue(result.isSuccess());
|
||||
}
|
||||
|
||||
private Socket connectTcpReceiver() throws IOException {
|
||||
Socket socket = new Socket();
|
||||
socket.connect(new InetSocketAddress("127.0.0.1", 9994));
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
private void encodeAndWrite(OutputStream os, TBase tbase, boolean isReqRes) throws Exception {
|
||||
HeaderTBaseSerializer serializer = HeaderTBaseSerializerFactory.DEFAULT_FACTORY.createSerializer();
|
||||
byte[] payload = serializer.serialize(tbase);
|
||||
|
||||
Packet packet = null;
|
||||
if (isReqRes) {
|
||||
packet = new RequestPacket(payload);
|
||||
} else {
|
||||
packet = new SendPacket(payload);
|
||||
}
|
||||
|
||||
os.write(packet.toBuffer().toByteBuffer().array());
|
||||
os.flush();
|
||||
}
|
||||
|
||||
private ResponsePacket readAndDecode(InputStream is, long waitTimeMillis) throws Exception {
|
||||
long startTimeMillis = System.currentTimeMillis();
|
||||
|
||||
while (true) {
|
||||
int avaiableRead = is.available();
|
||||
|
||||
if (avaiableRead > 0) {
|
||||
byte[] payload = new byte[avaiableRead];
|
||||
is.read(payload);
|
||||
|
||||
for (byte b : payload) {
|
||||
logger.warn("!!!{}", b);
|
||||
}
|
||||
|
||||
ChannelBuffer cb = ChannelBuffers.wrappedBuffer(payload);
|
||||
cb.readByte();
|
||||
cb.readByte();
|
||||
|
||||
|
||||
ResponsePacket responsePacket = ResponsePacket.readBuffer((short) 6, cb);
|
||||
return responsePacket;
|
||||
}
|
||||
|
||||
Thread.sleep(20);
|
||||
if (waitTimeMillis < System.currentTimeMillis() - startTimeMillis) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TAgentInfo getAgentInfo() {
|
||||
TAgentInfo agentInfo = new TAgentInfo("hostname", "127.0.0.1", "8081", "agentId", "appName", (short) 2, 1111, "1", System.currentTimeMillis());
|
||||
return agentInfo;
|
||||
}
|
||||
|
||||
}
|
||||
-168
@@ -1,168 +0,0 @@
|
||||
package com.nhn.pinpoint.collector.regionsplit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.sematext.hbase.wd.AbstractRowKeyDistributor;
|
||||
import com.sematext.hbase.wd.RowKeyDistributorByHashPrefix.OneByteSimpleHash;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:applicationContext-test.xml")
|
||||
public class PreSplitRegionsTest {
|
||||
|
||||
int acceptApplictaion = 4;
|
||||
int metaDataNumber = 8;
|
||||
int traceRegionNumber = 64;
|
||||
int traceIndexRegionNumber = 32;
|
||||
int agentStatRegionNumber = 32;
|
||||
|
||||
String metadata = "%s";
|
||||
String tracesFormat = "create 'Traces', { NAME => 'S', TTL => 604800 }, { NAME => 'A', TTL => 604800 }, { NAME => 'T', TTL => 604800 }, %s";
|
||||
String traceIndexFormat = "create 'ApplicationTraceIndex', { NAME => 'I', TTL => 604800 }, %s";
|
||||
String agentStatFormat = "create 'AgentStat', { NAME => 'S', TTL => 604800 }, %s";
|
||||
|
||||
@Autowired
|
||||
@Qualifier("applicationTraceIndexDistributor")
|
||||
private AbstractRowKeyDistributor rowKeyDistributor;
|
||||
|
||||
|
||||
@Test
|
||||
public void acceptApplication4() {
|
||||
List<String> regions = new ArrayList<String>();
|
||||
|
||||
OneByteSimpleHash hash = new OneByteSimpleHash(acceptApplictaion);
|
||||
for (byte[] each : hash.getAllPossiblePrefixes()) {
|
||||
byte onebyte = each[0];
|
||||
if (onebyte == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String region = "\\x" + Integer.toString((onebyte & 0xff) + 0x100, 16).substring(1);
|
||||
for (int i = 0; i < 15; i++) {
|
||||
region += "\\x00";
|
||||
}
|
||||
regions.add(region);
|
||||
}
|
||||
|
||||
printCommand(metadata, regions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void metaData8() {
|
||||
List<String> regions = new ArrayList<String>();
|
||||
|
||||
OneByteSimpleHash hash = new OneByteSimpleHash(metaDataNumber);
|
||||
for (byte[] each : hash.getAllPossiblePrefixes()) {
|
||||
byte onebyte = each[0];
|
||||
if (onebyte == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String region = "\\x" + Integer.toString((onebyte & 0xff) + 0x100, 16).substring(1);
|
||||
for (int i = 0; i < 15; i++) {
|
||||
region += "\\x00";
|
||||
}
|
||||
regions.add(region);
|
||||
}
|
||||
|
||||
printCommand(metadata, regions);
|
||||
}
|
||||
@Test
|
||||
public void traceRegions64() {
|
||||
List<String> regions = new ArrayList<String>();
|
||||
|
||||
OneByteSimpleHash hash = new OneByteSimpleHash(traceRegionNumber);
|
||||
for (byte[] each : hash.getAllPossiblePrefixes()) {
|
||||
byte onebyte = each[0];
|
||||
if (onebyte == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String region = "\\x" + Integer.toString((onebyte & 0xff) + 0x100, 16).substring(1);
|
||||
for (int i = 0; i < 15; i++) {
|
||||
region += "\\x00";
|
||||
}
|
||||
regions.add(region);
|
||||
}
|
||||
|
||||
printCommand(tracesFormat, regions);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void range() {
|
||||
System.out.println("------------------------");
|
||||
for (int i =0 ; i< 255; i++) {
|
||||
byte[] bytes = new byte[1];
|
||||
bytes[0] = (byte) i;
|
||||
byte[] distributedKey = rowKeyDistributor.getDistributedKey(bytes);
|
||||
System.out.println("distributedKey:" + distributedKey[0]);
|
||||
}
|
||||
System.out.println("------------------------");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applicationTraceIndexRegions() {
|
||||
List<String> regions = new ArrayList<String>();
|
||||
|
||||
OneByteSimpleHash hash = new OneByteSimpleHash(traceIndexRegionNumber);
|
||||
int index = 1;
|
||||
for (byte[] each : hash.getAllPossiblePrefixes()) {
|
||||
byte onebyte = each[0];
|
||||
if (onebyte == 0) {
|
||||
continue;
|
||||
}
|
||||
String region = "\\x" + Integer.toString((onebyte & 0xff) + 0x100, 16).substring(1);
|
||||
for (int i = 0; i < 15; i++) {
|
||||
region += "\\x00";
|
||||
}
|
||||
if (index % 2 == 0) {
|
||||
regions.add(region);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
printCommand(traceIndexFormat, regions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void agentStatRegions() {
|
||||
List<String> regions = new ArrayList<String>();
|
||||
|
||||
OneByteSimpleHash hash = new OneByteSimpleHash(agentStatRegionNumber);
|
||||
for (byte[] each : hash.getAllPossiblePrefixes()) {
|
||||
byte onebyte = each[0];
|
||||
if (onebyte == 0) {
|
||||
continue;
|
||||
}
|
||||
String region = "\\x" + Integer.toString((onebyte & 0xff) + 0x100, 16).substring(1);
|
||||
for (int i = 0; i < 15; i++) {
|
||||
region += "\\x00";
|
||||
}
|
||||
regions.add(region);
|
||||
}
|
||||
|
||||
printCommand(agentStatFormat, regions);
|
||||
}
|
||||
|
||||
void printCommand(String format, List<String> regions) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("{SPLITS=>[");
|
||||
for (int i=0; i<regions.size(); i++) {
|
||||
if (i != 0) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append("\"").append(regions.get(i)).append("\"");
|
||||
}
|
||||
sb.append("]}");
|
||||
|
||||
System.out.println(String.format(format, sb.toString()));
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:util="http://www.springframework.org/schema/util" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xmlns:hdp="http://www.springframework.org/schema/hadoop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
|
||||
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd">
|
||||
|
||||
<context:annotation-config/>
|
||||
|
||||
<context:component-scan
|
||||
base-package="com.nhn.pinpoint.collector.dao.hbase,
|
||||
com.nhn.pinpoint.collector.handler,
|
||||
com.nhn.pinpoint.collector.mapper,
|
||||
com.nhn.pinpoint.collector.util
|
||||
com.nhn.pinpoint.collector.config" />
|
||||
|
||||
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="locations">
|
||||
<list>
|
||||
<value>hbase.properties</value>
|
||||
<value>pinpoint-collector.properties</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<import resource="classpath:applicationContext-hbase.xml"></import>
|
||||
|
||||
<bean id="hBaseAdminTemplate" class="com.nhn.pinpoint.common.hbase.HBaseAdminTemplate" destroy-method="close">
|
||||
<constructor-arg ref="hbaseConfiguration" index="0"></constructor-arg>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="metricRegistry" class="com.codahale.metrics.MetricRegistry">
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="metricsServlet" class="com.codahale.metrics.servlets.MetricsServlet">
|
||||
<constructor-arg ref="metricRegistry" />
|
||||
</bean>
|
||||
|
||||
<!-- Cluster 관련된 Bean들 -->
|
||||
<bean id="commandHeaderTBaseSerializerFactory" class="com.nhn.pinpoint.thrift.io.CommandHeaderTBaseSerializerFactory">
|
||||
<constructor-arg value="#{T(com.nhn.pinpoint.common.Version).VERSION}" />
|
||||
</bean>
|
||||
|
||||
<bean id="commandHeaderTBaseDeserializerFactory" class="com.nhn.pinpoint.thrift.io.CommandHeaderTBaseDeserializerFactory">
|
||||
<constructor-arg value="#{T(com.nhn.pinpoint.common.Version).VERSION}" />
|
||||
</bean>
|
||||
|
||||
<bean id="clusterPointRouter" class="com.nhn.pinpoint.collector.cluster.ClusterPointRouter">
|
||||
</bean>
|
||||
|
||||
<bean id="jsonObjectMapper" class="org.codehaus.jackson.map.ObjectMapper">
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="hTable" class="com.nhn.pinpoint.common.hbase.HBaseTables"></bean>
|
||||
|
||||
<bean id="callerMerge" class="com.nhn.pinpoint.collector.dao.hbase.statistics.RowKeyMerge">
|
||||
<constructor-arg value="#{hTable.MAP_STATISTICS_CALLER_CF_COUNTER}"/>
|
||||
</bean>
|
||||
|
||||
<bean id="calleeMerge" class="com.nhn.pinpoint.collector.dao.hbase.statistics.RowKeyMerge">
|
||||
<constructor-arg value="#{hTable.MAP_STATISTICS_CALLEE_CF_COUNTER}"/>
|
||||
</bean>
|
||||
|
||||
<bean id="selfMerge" class="com.nhn.pinpoint.collector.dao.hbase.statistics.RowKeyMerge">
|
||||
<constructor-arg value="#{hTable.MAP_STATISTICS_SELF_CF_COUNTER}"/>
|
||||
</bean>
|
||||
|
||||
<bean id="timeSlot" class="com.nhn.pinpoint.common.util.DefaultTimeSlot">
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
@@ -1,5 +0,0 @@
|
||||
/target/
|
||||
/*.iml
|
||||
/.settings/
|
||||
/.classpath
|
||||
/.project
|
||||
@@ -1,121 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.nhn.pinpoint</groupId>
|
||||
<artifactId>pinpoint-naver</artifactId>
|
||||
<version>1.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pinpoint-naver-plugin</artifactId>
|
||||
<name>Pinpoint profiler plugin for Naver</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.nhn.pinpoint</groupId>
|
||||
<artifactId>pinpoint-profiler</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.nhncorp.lucy</groupId>
|
||||
<artifactId>lucy-npc</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nhncorp.lucy</groupId>
|
||||
<artifactId>lucy-nimmconnector</artifactId>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>cglib-nodep</artifactId>
|
||||
<groupId>cglib</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jaxen</artifactId>
|
||||
<groupId>jaxen</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<groupId>dom4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>mina-core</artifactId>
|
||||
<groupId>external.org.apache.mina</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- Redis -->
|
||||
<!-- nBase-ARC -->
|
||||
<dependency>
|
||||
<groupId>com.nhncorp</groupId>
|
||||
<artifactId>triples-redis-client</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.nhncorp.lucy</groupId>
|
||||
<artifactId>bloc-core</artifactId>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Logging depedencies -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<!-- commons-logging-adapter -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/src/main/java</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>${basedir}/src/test/java</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</testResource>
|
||||
<testResource>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/test/resources</directory>
|
||||
</testResource>
|
||||
</testResources>
|
||||
</build>
|
||||
</project>
|
||||
-127
@@ -1,127 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.config.ProfilerConfig;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.profiler.modifier.bloc4.NettyInboundHandlerModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.bloc4.NpcHandlerModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.bloc4.RequestProcessorModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.connector.lucynet.CompositeInvocationFutureModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.connector.lucynet.DefaultInvocationFutureModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.connector.nimm.NimmInvokerModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.connector.npc.KeepAliveNpcHessianConnectorModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.connector.npc.LightWeightConnectorModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.connector.npc.NioNpcHessianConnectorModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.connector.npc.NpcHessianConnectorModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.linegame.HandlerInvokeTaskModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.linegame.HttpCustomServerHandlerModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.BinaryJedisModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.BinaryRedisClusterModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.BinaryTriplesRedisClusterModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.GatewayModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.GatewayServerModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.JedisClientModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.JedisModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.JedisMultiKeyPipelineBaseModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.JedisPipelineBaseModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.JedisPipelineModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.RedisClusterModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.RedisClusterPipelineModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.TriplesRedisClusterModifier;
|
||||
|
||||
public class NaverModifierProvider implements ModifierProvider {
|
||||
|
||||
@Override
|
||||
public List<Modifier> getModifiers(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
List<Modifier> modifiers = new ArrayList<Modifier>();
|
||||
|
||||
addBLOC4Modifier(modifiers, byteCodeInstrumentor, agent);
|
||||
addNpcModifier(modifiers, byteCodeInstrumentor, agent);
|
||||
addNimmModifier(modifiers, byteCodeInstrumentor, agent);
|
||||
addLucyNetModifier(modifiers, byteCodeInstrumentor, agent);
|
||||
addLineGameBaseFrameworkModifier(modifiers, byteCodeInstrumentor, agent);
|
||||
addNbaseArcSupport(modifiers, byteCodeInstrumentor, agent);
|
||||
addRedisSupport(modifiers, byteCodeInstrumentor, agent);
|
||||
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
/**
|
||||
* BLOC 4.x
|
||||
*/
|
||||
private void addBLOC4Modifier(List<Modifier> modifiers, ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
NettyInboundHandlerModifier nettyInboundHandlerModifier = new NettyInboundHandlerModifier(byteCodeInstrumentor, agent);
|
||||
modifiers.add(nettyInboundHandlerModifier);
|
||||
|
||||
NpcHandlerModifier npcHandlerModifier = new NpcHandlerModifier(byteCodeInstrumentor, agent);
|
||||
modifiers.add(npcHandlerModifier);
|
||||
|
||||
RequestProcessorModifier requestProcessorModifier = new RequestProcessorModifier(byteCodeInstrumentor, agent);
|
||||
modifiers.add(requestProcessorModifier);
|
||||
}
|
||||
|
||||
private void addNpcModifier(List<Modifier> modifiers, ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
modifiers.add(new KeepAliveNpcHessianConnectorModifier(byteCodeInstrumentor, agent));
|
||||
// modifiers.add(new LightWeightNbfpConnectorModifier(byteCodeInstrumentor, agent));
|
||||
// modifiers.add(new LightWeightNpcHessianConnectorModifier(byteCodeInstrumentor, agent));
|
||||
modifiers.add(new LightWeightConnectorModifier(byteCodeInstrumentor, agent));
|
||||
modifiers.add(new NioNpcHessianConnectorModifier(byteCodeInstrumentor, agent));
|
||||
modifiers.add(new NpcHessianConnectorModifier(byteCodeInstrumentor, agent));
|
||||
}
|
||||
|
||||
private void addNimmModifier(List<Modifier> modifiers, ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
modifiers.add(new NimmInvokerModifier(byteCodeInstrumentor, agent));
|
||||
}
|
||||
|
||||
private void addLucyNetModifier(List<Modifier> modifiers, ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
modifiers.add(new DefaultInvocationFutureModifier(byteCodeInstrumentor, agent));
|
||||
modifiers.add(new CompositeInvocationFutureModifier(byteCodeInstrumentor, agent));
|
||||
}
|
||||
|
||||
/**
|
||||
* line game에서 사용하는 baseframework의 http handler를 지원.
|
||||
*/
|
||||
private void addLineGameBaseFrameworkModifier(List<Modifier> modifiers, ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
modifiers.add(new HandlerInvokeTaskModifier(byteCodeInstrumentor, agent));
|
||||
modifiers.add(new HttpCustomServerHandlerModifier(byteCodeInstrumentor, agent));
|
||||
}
|
||||
|
||||
private void addRedisSupport(List<Modifier> modifiers, ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
ProfilerConfig profilerConfig = agent.getProfilerConfig();
|
||||
|
||||
if (profilerConfig.isRedisEnabled()) {
|
||||
modifiers.add(new BinaryJedisModifier(byteCodeInstrumentor, agent));
|
||||
modifiers.add(new JedisModifier(byteCodeInstrumentor, agent));
|
||||
}
|
||||
|
||||
if (profilerConfig.isRedisPipelineEnabled()) {
|
||||
modifiers.add(new JedisClientModifier(byteCodeInstrumentor, agent));
|
||||
modifiers.add(new JedisPipelineBaseModifier(byteCodeInstrumentor, agent));
|
||||
modifiers.add(new JedisMultiKeyPipelineBaseModifier(byteCodeInstrumentor, agent));
|
||||
modifiers.add(new JedisPipelineModifier(byteCodeInstrumentor, agent));
|
||||
}
|
||||
}
|
||||
|
||||
private void addNbaseArcSupport(List<Modifier> modifiers, ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
ProfilerConfig profilerConfig = agent.getProfilerConfig();
|
||||
|
||||
if (profilerConfig.isNbaseArcEnabled() || profilerConfig.isNbaseArcPipelineEnabled()) {
|
||||
modifiers.add(new GatewayModifier(byteCodeInstrumentor, agent));
|
||||
modifiers.add(new GatewayServerModifier(byteCodeInstrumentor, agent));
|
||||
|
||||
if (profilerConfig.isNbaseArcEnabled()) {
|
||||
modifiers.add(new RedisClusterModifier(byteCodeInstrumentor, agent));
|
||||
modifiers.add(new BinaryRedisClusterModifier(byteCodeInstrumentor, agent));
|
||||
modifiers.add(new TriplesRedisClusterModifier(byteCodeInstrumentor, agent));
|
||||
modifiers.add(new BinaryTriplesRedisClusterModifier(byteCodeInstrumentor, agent));
|
||||
}
|
||||
|
||||
if (profilerConfig.isNbaseArcPipelineEnabled()) {
|
||||
modifiers.add(new RedisClusterPipelineModifier(byteCodeInstrumentor, agent));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.bloc4;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author netspider
|
||||
*/
|
||||
public class NettyInboundHandlerModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public NettyInboundHandlerModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/lucy/bloc/http/NettyInboundHandler";
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", javassistClassName);
|
||||
}
|
||||
|
||||
try {
|
||||
InstrumentClass aClass = byteCodeInstrumentor.getClass(classLoader, javassistClassName, classFileBuffer);
|
||||
|
||||
aClass.addGetter("__getUriEncoding", "uriEncoding", "java.nio.charset.Charset");
|
||||
|
||||
Interceptor read0nterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.bloc4.interceptor.ChannelRead0Interceptor");
|
||||
aClass.addInterceptor("channelRead0", new String[] { "io.netty.channel.ChannelHandlerContext", "io.netty.handler.codec.http.FullHttpRequest" }, read0nterceptor);
|
||||
|
||||
return aClass.toBytecode();
|
||||
} catch (InstrumentException e) {
|
||||
logger.warn("NettyInboundHandlerModifier fail. Caused:", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.bloc4;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
|
||||
public class NpcHandlerModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public NpcHandlerModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", javassistClassName);
|
||||
}
|
||||
|
||||
try {
|
||||
InstrumentClass npcHandler = byteCodeInstrumentor.getClass(classLoader, javassistClassName, classFileBuffer);
|
||||
Interceptor messageReceivedInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.bloc4.interceptor.MessageReceivedInterceptor");
|
||||
npcHandler.addInterceptor("messageReceived", new String[] {"external.org.apache.mina.common.IoFilter$NextFilter", "external.org.apache.mina.common.IoSession", "java.lang.Object"}, messageReceivedInterceptor);
|
||||
|
||||
return npcHandler.toBytecode();
|
||||
} catch (InstrumentException e) {
|
||||
logger.warn("NpcHandlerModifier fail. Caused:", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/lucy/bloc/npc/handler/NpcHandler";
|
||||
}
|
||||
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.bloc4;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
|
||||
public class RequestProcessorModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public RequestProcessorModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", javassistClassName);
|
||||
}
|
||||
|
||||
try {
|
||||
InstrumentClass npcHandler = byteCodeInstrumentor.getClass(classLoader, javassistClassName, classFileBuffer);
|
||||
Interceptor messageReceivedInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.bloc4.interceptor.ProcessInterceptor");
|
||||
npcHandler.addInterceptor("process", new String[] {"com.nhncorp.lucy.bloc.core.processor.BlocRequest"}, messageReceivedInterceptor);
|
||||
|
||||
return npcHandler.toBytecode();
|
||||
} catch (InstrumentException e) {
|
||||
logger.warn("RequestProcessorModifier fail. Caused:", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/lucy/bloc/core/processor/RequestProcessor";
|
||||
}
|
||||
}
|
||||
-250
@@ -1,250 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.bloc4.interceptor;
|
||||
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
import io.netty.handler.codec.http.QueryStringDecoder;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.context.Header;
|
||||
import com.nhn.pinpoint.bootstrap.context.RecordableTrace;
|
||||
import com.nhn.pinpoint.bootstrap.context.Trace;
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceId;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SpanSimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
|
||||
import com.nhn.pinpoint.bootstrap.sampler.SamplingFlagUtils;
|
||||
import com.nhn.pinpoint.bootstrap.util.MetaObject;
|
||||
import com.nhn.pinpoint.bootstrap.util.NumberUtils;
|
||||
import com.nhn.pinpoint.bootstrap.util.StringUtils;
|
||||
import com.nhn.pinpoint.common.AnnotationKey;
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import com.nhn.pinpoint.profiler.context.SpanId;
|
||||
|
||||
/**
|
||||
* @author netspider
|
||||
*/
|
||||
public class ChannelRead0Interceptor extends SpanSimpleAroundInterceptor implements TargetClassLoader {
|
||||
|
||||
private MetaObject<java.nio.charset.Charset> getUriEncoding = new MetaObject<java.nio.charset.Charset>("__getUriEncoding");
|
||||
|
||||
public ChannelRead0Interceptor() {
|
||||
super(ChannelRead0Interceptor.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doInBeforeTrace(RecordableTrace trace, Object target, Object[] args) {
|
||||
io.netty.channel.ChannelHandlerContext ctx = (io.netty.channel.ChannelHandlerContext) args[0];
|
||||
io.netty.handler.codec.http.FullHttpRequest request = (io.netty.handler.codec.http.FullHttpRequest) args[1];
|
||||
|
||||
trace.markBeforeTime();
|
||||
if (trace.canSampled()) {
|
||||
trace.recordServiceType(ServiceType.BLOC);
|
||||
final String requestURL = request.getUri();
|
||||
trace.recordRpcName(requestURL);
|
||||
|
||||
String endPoint = getIpPort(ctx.channel().localAddress());
|
||||
String remoteAddress = getIp(ctx.channel().remoteAddress());
|
||||
|
||||
trace.recordEndPoint(endPoint);
|
||||
trace.recordRemoteAddress(remoteAddress);
|
||||
trace.recordAttribute(AnnotationKey.HTTP_URL, request.getUri());
|
||||
}
|
||||
|
||||
if (!trace.isRoot()) {
|
||||
recordParentInfo(trace, request, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Trace createTrace(Object target, Object[] args) {
|
||||
|
||||
final io.netty.handler.codec.http.FullHttpRequest request = (io.netty.handler.codec.http.FullHttpRequest) args[1];
|
||||
|
||||
final boolean sampling = samplingEnable(request);
|
||||
if (!sampling) {
|
||||
// 샘플링 대상이 아닐 경우도 TraceObject를 생성하여, sampling 대상이 아니라는것을 명시해야
|
||||
// 한다.
|
||||
// sampling 대상이 아닐경우 rpc 호출에서 sampling 대상이 아닌 것에 rpc호출 파라미터에
|
||||
// sampling disable 파라미터를 박을수 있다.
|
||||
final Trace trace = getTraceContext().disableSampling();
|
||||
if (isDebug) {
|
||||
logger.debug("mark disable sampling. skip trace");
|
||||
}
|
||||
return trace;
|
||||
}
|
||||
|
||||
final TraceId traceId = populateTraceIdFromRequest(request);
|
||||
if (traceId != null) {
|
||||
final Trace trace = getTraceContext().continueTraceObject(traceId);
|
||||
if (trace.canSampled()) {
|
||||
if (isDebug) {
|
||||
String requestURL = request.getUri();
|
||||
io.netty.channel.ChannelHandlerContext ctx = (io.netty.channel.ChannelHandlerContext) args[0];
|
||||
String remoteAddr = ((SocketChannel) ctx.channel()).remoteAddress().toString();
|
||||
logger.debug("TraceID exist. continue trace. traceId:{}, requestUrl:{}, remoteAddr:{}", new Object[] { traceId, requestURL, remoteAddr });
|
||||
}
|
||||
return trace;
|
||||
} else {
|
||||
if (isDebug) {
|
||||
String requestURL = request.getUri();
|
||||
io.netty.channel.ChannelHandlerContext ctx = (io.netty.channel.ChannelHandlerContext) args[0];
|
||||
String remoteAddr = ((SocketChannel) ctx.channel()).remoteAddress().toString();
|
||||
logger.debug("TraceID exist. camSampled is false. skip trace. traceId:{}, requestUrl:{}, remoteAddr:{}", new Object[] { traceId, requestURL, remoteAddr });
|
||||
}
|
||||
return trace;
|
||||
}
|
||||
} else {
|
||||
final Trace trace = getTraceContext().newTraceObject();
|
||||
if (trace.canSampled()) {
|
||||
if (isDebug) {
|
||||
String requestURL = request.getUri();
|
||||
io.netty.channel.ChannelHandlerContext ctx = (io.netty.channel.ChannelHandlerContext) args[0];
|
||||
String remoteAddr = ((SocketChannel) ctx.channel()).remoteAddress().toString();
|
||||
logger.debug("TraceID not exist. start new trace. requestUrl:{}, remoteAddr:{}", new Object[] { requestURL, remoteAddr });
|
||||
}
|
||||
return trace;
|
||||
} else {
|
||||
if (isDebug) {
|
||||
String requestURL = request.getUri();
|
||||
io.netty.channel.ChannelHandlerContext ctx = (io.netty.channel.ChannelHandlerContext) args[0];
|
||||
String remoteAddr = ((SocketChannel) ctx.channel()).remoteAddress().toString();
|
||||
logger.debug("TraceID not exist. camSampled is false. skip trace. requestUrl:{}, remoteAddr:{}", new Object[] { requestURL, remoteAddr });
|
||||
}
|
||||
return trace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doInAfterTrace(RecordableTrace trace, Object target, Object[] args, Object result, Throwable throwable) {
|
||||
if (trace.canSampled()) {
|
||||
io.netty.handler.codec.http.FullHttpRequest request = (io.netty.handler.codec.http.FullHttpRequest) args[1];
|
||||
|
||||
if (HttpMethod.POST.name().equals(request.getMethod().name()) || HttpMethod.PUT.name().equals(request.getMethod().name())) {
|
||||
// TODO record post body
|
||||
} else {
|
||||
java.nio.charset.Charset uriEncoding = getUriEncoding.invoke(target);
|
||||
String parameters = getRequestParameter(request, 64, 512, uriEncoding);
|
||||
if (parameters != null && parameters.length() > 0) {
|
||||
trace.recordAttribute(AnnotationKey.HTTP_PARAM, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
trace.recordApi(getMethodDescriptor());
|
||||
}
|
||||
trace.recordException(throwable);
|
||||
trace.markAfterTime();
|
||||
}
|
||||
|
||||
private boolean samplingEnable(io.netty.handler.codec.http.FullHttpRequest request) {
|
||||
// optional 값.
|
||||
String samplingFlag = request.headers().get(Header.HTTP_SAMPLED.toString());
|
||||
return SamplingFlagUtils.isSamplingFlag(samplingFlag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pupulate source trace from HTTP Header.
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
private TraceId populateTraceIdFromRequest(io.netty.handler.codec.http.FullHttpRequest request) {
|
||||
final HttpHeaders headers = request.headers();
|
||||
|
||||
String transactionId = headers.get(Header.HTTP_TRACE_ID.toString());
|
||||
if (transactionId != null) {
|
||||
long parentSpanId = NumberUtils.parseLong(headers.get(Header.HTTP_PARENT_SPAN_ID.toString()), SpanId.NULL);
|
||||
// TODO NULL이 되는게 맞는가?
|
||||
long spanId = NumberUtils.parseLong(headers.get(Header.HTTP_SPAN_ID.toString()), SpanId.NULL);
|
||||
short flags = NumberUtils.parseShort(headers.get(Header.HTTP_FLAGS.toString()), (short) 0);
|
||||
|
||||
final TraceId id = getTraceContext().createTraceId(transactionId, parentSpanId, spanId, flags);
|
||||
if (isDebug) {
|
||||
logger.debug("TraceID exist. continue trace. {}", id);
|
||||
}
|
||||
return id;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String getRequestParameter(io.netty.handler.codec.http.FullHttpRequest request, int eachLimit, int totalLimit, java.nio.charset.Charset uriEncoding) {
|
||||
String uri = request.getUri();
|
||||
QueryStringDecoder decoder = new QueryStringDecoder(uri, uriEncoding);
|
||||
Map<String, List<String>> parameters = decoder.parameters();
|
||||
|
||||
final StringBuilder params = new StringBuilder(64);
|
||||
|
||||
for (Entry<String, List<String>> entry : parameters.entrySet()) {
|
||||
if (params.length() != 0) {
|
||||
params.append('&');
|
||||
}
|
||||
|
||||
if (params.length() > totalLimit) {
|
||||
params.append("...");
|
||||
break;
|
||||
}
|
||||
|
||||
String key = entry.getKey();
|
||||
|
||||
params.append(StringUtils.drop(key, eachLimit));
|
||||
params.append("=");
|
||||
|
||||
Object value = entry.getValue().get(0);
|
||||
|
||||
if (value != null) {
|
||||
params.append(StringUtils.drop(StringUtils.toString(value), eachLimit));
|
||||
}
|
||||
}
|
||||
|
||||
return params.toString();
|
||||
}
|
||||
|
||||
private String getIp(SocketAddress socketAddress) {
|
||||
if (socketAddress instanceof InetSocketAddress) {
|
||||
InetSocketAddress addr = (InetSocketAddress) socketAddress;
|
||||
return addr.getAddress().getHostAddress();
|
||||
} else {
|
||||
return "NOT_SUPPORTED_ADDRESS";
|
||||
}
|
||||
}
|
||||
|
||||
private String getIpPort(SocketAddress socketAddress) {
|
||||
String address = socketAddress.toString();
|
||||
|
||||
if (socketAddress instanceof InetSocketAddress) {
|
||||
InetSocketAddress addr = (InetSocketAddress) socketAddress;
|
||||
return addr.getAddress().getHostAddress() + ":" + addr.getPort();
|
||||
}
|
||||
|
||||
if (address.startsWith("/")) {
|
||||
return address.substring(1);
|
||||
} else {
|
||||
if (address.contains("/")) {
|
||||
return address.substring(address.indexOf("/") + 1);
|
||||
} else {
|
||||
return address;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void recordParentInfo(RecordableTrace trace, io.netty.handler.codec.http.FullHttpRequest request, io.netty.channel.ChannelHandlerContext ctx) {
|
||||
HttpHeaders headers = request.headers();
|
||||
String parentApplicationName = headers.get(Header.HTTP_PARENT_APPLICATION_NAME.toString());
|
||||
|
||||
if (parentApplicationName != null) {
|
||||
// FIXME record Acceptor Host는 URL상의 host를 가져와야한다. 일단 가져올 수 있는 방법이 없어보여 IP라도 추가해둠.
|
||||
String acceptorHost = getIpPort(ctx.channel().localAddress());
|
||||
trace.recordAcceptorHost(acceptorHost);
|
||||
|
||||
final String type = headers.get(Header.HTTP_PARENT_APPLICATION_TYPE.toString());
|
||||
final short parentApplicationType = NumberUtils.parseShort(type, ServiceType.UNDEFINED.getCode());
|
||||
trace.recordParentApplication(parentApplicationName, parentApplicationType);
|
||||
}
|
||||
}
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.bloc4.interceptor;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.context.RecordableTrace;
|
||||
import com.nhn.pinpoint.bootstrap.context.Trace;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SpanSimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
|
||||
public class MessageReceivedInterceptor extends SpanSimpleAroundInterceptor implements TargetClassLoader {
|
||||
|
||||
public MessageReceivedInterceptor() {
|
||||
super(MessageReceivedInterceptor.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doInBeforeTrace(RecordableTrace trace, Object target, Object[] args) {
|
||||
trace.markBeforeTime();
|
||||
|
||||
if (trace.canSampled()) {
|
||||
trace.recordServiceType(ServiceType.BLOC);
|
||||
trace.recordRpcName("NPC Call");
|
||||
|
||||
final external.org.apache.mina.common.IoSession ioSession = (external.org.apache.mina.common.IoSession)args[1];
|
||||
trace.recordEndPoint(ioSession.getLocalAddress().toString());
|
||||
trace.recordRemoteAddress(ioSession.getRemoteAddress().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Trace createTrace(Object target, Object[] args) {
|
||||
final Trace trace = getTraceContext().newTraceObject();
|
||||
|
||||
if (isDebug) {
|
||||
final external.org.apache.mina.common.IoSession ioSession = (external.org.apache.mina.common.IoSession)args[1];
|
||||
|
||||
if (trace.canSampled()) {
|
||||
logger.debug("TraceID not exist. start new trace. requestUrl:{}, remoteAddr:{}", new Object[] {ioSession.getRemoteAddress().toString()});
|
||||
} else {
|
||||
logger.debug("TraceID not exist. camSampled is false. skip trace. requestUrl:{}, remoteAddr:{}", new Object[] {ioSession.getRemoteAddress().toString()});
|
||||
}
|
||||
}
|
||||
|
||||
return trace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doInAfterTrace(RecordableTrace trace, Object target, Object[] args, Object result, Throwable throwable) {
|
||||
trace.recordApi(getMethodDescriptor());
|
||||
trace.recordException(throwable);
|
||||
trace.markAfterTime();
|
||||
}
|
||||
}
|
||||
-83
@@ -1,83 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.bloc4.interceptor;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.context.Trace;
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceContext;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.ByteCodeMethodDescriptorSupport;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.MethodDescriptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TraceContextSupport;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
import com.nhn.pinpoint.common.AnnotationKey;
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import com.nhncorp.lucy.bloc.core.processor.BlocRequest;
|
||||
|
||||
public class ProcessInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport, TargetClassLoader {
|
||||
|
||||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
private MethodDescriptor descriptor;
|
||||
private TraceContext traceContext;
|
||||
private ServiceType serviceType = ServiceType.INTERNAL_METHOD;
|
||||
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
if (isDebug) {
|
||||
logger.beforeInterceptor(target, args);
|
||||
}
|
||||
|
||||
Trace trace = traceContext.currentTraceObject();
|
||||
|
||||
if (trace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
trace.traceBlockBegin();
|
||||
trace.markBeforeTime();
|
||||
|
||||
trace.recordServiceType(serviceType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
if (isDebug) {
|
||||
logger.afterInterceptor(target, args);
|
||||
}
|
||||
|
||||
Trace trace = traceContext.currentTraceObject();
|
||||
|
||||
if (trace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
trace.recordApi(descriptor);
|
||||
trace.recordException(throwable);
|
||||
|
||||
if (args[0] != null) {
|
||||
BlocRequest blocRequest = (BlocRequest)args[0];
|
||||
trace.recordAttribute(AnnotationKey.CAll_URL, blocRequest.getPath());
|
||||
trace.recordAttribute(AnnotationKey.PROTOCAL, blocRequest.getProtocol());
|
||||
}
|
||||
|
||||
trace.markAfterTime();
|
||||
} finally {
|
||||
trace.traceBlockEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMethodDescriptor(MethodDescriptor descriptor) {
|
||||
this.descriptor = descriptor;
|
||||
this.traceContext.cacheApi(descriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTraceContext(TraceContext traceContext) {
|
||||
this.traceContext = traceContext;
|
||||
}
|
||||
}
|
||||
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.connector.lucynet;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.method.interceptor.MethodInterceptor;
|
||||
|
||||
/**
|
||||
* target lib = lucy-net-1.5.4
|
||||
*
|
||||
* @author netspider
|
||||
*
|
||||
*/
|
||||
public class CompositeInvocationFutureModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public CompositeInvocationFutureModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/lucy/net/invoker/CompositeInvocationFuture";
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", javassistClassName);
|
||||
}
|
||||
|
||||
try {
|
||||
InstrumentClass aClass = byteCodeInstrumentor.getClass(classLoader, javassistClassName, classFileBuffer);
|
||||
|
||||
// FIXME 이렇게 하면 api type이 internal method로 보이는데 사실 NPC_CLIENT, NIMM_CLIENT로 보여야함. servicetype으로 넣기에 애매해서. 어떻게 수정할 것인지는 나중에 고민.
|
||||
aClass.addInterceptor("getReturnValue", null, new MethodInterceptor());
|
||||
|
||||
return aClass.toBytecode();
|
||||
} catch (Throwable e) {
|
||||
logger.warn("NimmInvoker modifier error. Caused:{}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.connector.lucynet;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.method.interceptor.MethodInterceptor;
|
||||
|
||||
/**
|
||||
* target lib = lucy-net-1.5.4
|
||||
*
|
||||
* @author netspider
|
||||
*
|
||||
*/
|
||||
public class DefaultInvocationFutureModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public DefaultInvocationFutureModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/lucy/net/invoker/DefaultInvocationFuture";
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", javassistClassName);
|
||||
}
|
||||
|
||||
try {
|
||||
InstrumentClass aClass = byteCodeInstrumentor.getClass(classLoader, javassistClassName, classFileBuffer);
|
||||
|
||||
// FIXME 이렇게 하면 api type이 internal method로 보이는데 사실 NPC_CLIENT, NIMM_CLIENT로 보여야함. servicetype으로 넣기에 애매해서. 어떻게 수정할 것인지는 나중에 고민.
|
||||
aClass.addInterceptor("getReturnValue", null, new MethodInterceptor());
|
||||
aClass.addInterceptor("get", null, new MethodInterceptor());
|
||||
|
||||
return aClass.toBytecode();
|
||||
} catch (Throwable e) {
|
||||
logger.warn("NimmInvoker modifier error. Caused:{}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.connector.nimm;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author netspider
|
||||
*
|
||||
*/
|
||||
public class NimmInvokerModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public NimmInvokerModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/lucy/nimm/connector/bloc/NimmInvoker";
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", javassistClassName);
|
||||
}
|
||||
|
||||
try {
|
||||
InstrumentClass aClass = byteCodeInstrumentor.getClass(classLoader, javassistClassName, classFileBuffer);
|
||||
|
||||
// trace variable
|
||||
aClass.addTraceVariable("_nimmAddress", "__setNimmAddress", "__getNimmAddress", "java.lang.String");
|
||||
|
||||
// TODO nimm socket도 수집해야하나??
|
||||
// aClass.addTraceVariable("_nimmSocket", "__setNimmSocket", "__getNimmSocket", "com.nhncorp.lucy.nimm.connector.NimmSocket");
|
||||
|
||||
// constructor
|
||||
Interceptor constructorInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.connector.nimm.interceptor.NimmInvokerConstructorInterceptor");
|
||||
aClass.addConstructorInterceptor(new String[] { "com.nhncorp.lucy.nimm.connector.address.NimmAddress", "com.nhncorp.lucy.nimm.connector.NimmSocket", "long" }, constructorInterceptor);
|
||||
|
||||
// invoke method
|
||||
Interceptor invokeInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.connector.nimm.interceptor.InvokeMethodInterceptor");
|
||||
aClass.addInterceptor("invoke", new String[] { "long", "java.lang.String", "java.lang.String", "java.lang.Object[]" }, invokeInterceptor);
|
||||
|
||||
return aClass.toBytecode();
|
||||
} catch (Throwable e) {
|
||||
logger.warn("NimmInvoker modifier error. Caused:{}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.connector.nimm.interceptor;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.*;
|
||||
import com.nhn.pinpoint.common.AnnotationKey;
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import com.nhn.pinpoint.bootstrap.context.Trace;
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceContext;
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceId;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
import com.nhn.pinpoint.bootstrap.util.MetaObject;
|
||||
|
||||
/**
|
||||
* target lib = com.nhncorp.lucy.lucy-nimmconnector-2.1.4
|
||||
*
|
||||
* @author netspider
|
||||
*/
|
||||
public class InvokeMethodInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport, TargetClassLoader {
|
||||
|
||||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
// TODO nimm socket도 수집해야하나?? nimmAddress는 constructor에서 string으로 변환한 값을 들고
|
||||
// 있음.
|
||||
private MetaObject<String> getNimmAddress = new MetaObject<String>("__getNimmAddress");
|
||||
|
||||
private MethodDescriptor descriptor;
|
||||
private TraceContext traceContext;
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
if (isDebug) {
|
||||
logger.beforeInterceptor(target, args);
|
||||
}
|
||||
|
||||
Trace trace = traceContext.currentRawTraceObject();
|
||||
if (trace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// final long timeoutMillis = (Long) args[0];
|
||||
final String objectName = (String) args[1];
|
||||
final String methodName = (String) args[2];
|
||||
final Object[] params = (Object[]) args[3];
|
||||
|
||||
// UUID format을 그대로.
|
||||
final boolean sampling = trace.canSampled();
|
||||
if (!sampling) {
|
||||
// TODO header 추가.
|
||||
return;
|
||||
}
|
||||
|
||||
trace.traceBlockBegin();
|
||||
trace.markBeforeTime();
|
||||
|
||||
TraceId nextId = trace.getTraceId().getNextTraceId();
|
||||
trace.recordNextSpanId(nextId.getSpanId());
|
||||
|
||||
trace.recordServiceType(ServiceType.NIMM_CLIENT);
|
||||
|
||||
// TODO protocol은 어떻게 표기하지???
|
||||
|
||||
String nimmAddress = getNimmAddress.invoke(target);
|
||||
trace.recordDestinationId(nimmAddress);
|
||||
|
||||
// DestinationId와 동일하므로 없는게 맞음.
|
||||
// trace.recordEndPoint(nimmAddress);
|
||||
|
||||
if (objectName != null) {
|
||||
trace.recordAttribute(AnnotationKey.NIMM_OBJECT_NAME, objectName);
|
||||
}
|
||||
if (methodName != null) {
|
||||
trace.recordAttribute(AnnotationKey.NIMM_METHOD_NAME, methodName);
|
||||
}
|
||||
if (params != null) {
|
||||
trace.recordAttribute(AnnotationKey.NIMM_PARAM, Arrays.toString(params));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
if (isDebug) {
|
||||
// result는 로깅하지 않는다.
|
||||
logger.afterInterceptor(target, args);
|
||||
}
|
||||
|
||||
Trace trace = traceContext.currentTraceObject();
|
||||
if (trace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
trace.recordApi(descriptor);
|
||||
trace.recordException(throwable);
|
||||
trace.markAfterTime();
|
||||
} finally {
|
||||
trace.traceBlockEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMethodDescriptor(MethodDescriptor descriptor) {
|
||||
this.descriptor = descriptor;
|
||||
traceContext.cacheApi(descriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTraceContext(TraceContext traceContext) {
|
||||
this.traceContext = traceContext;
|
||||
}
|
||||
}
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.connector.nimm.interceptor;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
import com.nhn.pinpoint.bootstrap.util.MetaObject;
|
||||
import com.nhncorp.lucy.nimm.connector.address.NimmAddress.Species;
|
||||
|
||||
/**
|
||||
* target lib = com.nhncorp.lucy.lucy-nimmconnector-2.1.4
|
||||
*
|
||||
* @author netspider
|
||||
*
|
||||
*/
|
||||
public class NimmInvokerConstructorInterceptor implements SimpleAroundInterceptor, TargetClassLoader {
|
||||
|
||||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
// private MethodDescriptor descriptor;
|
||||
// private TraceContext traceContext;
|
||||
|
||||
// TODO nimm socket도 수집해야하나?? nimmAddress는 constructor에서 string으로 변환한 값을 들고
|
||||
// 있음.
|
||||
private MetaObject<String> setNimmAddress = new MetaObject<String>("__setNimmAddress", String.class);
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
if (isDebug) {
|
||||
logger.beforeInterceptor(target, args);
|
||||
}
|
||||
|
||||
if (args[0] instanceof com.nhncorp.lucy.nimm.connector.address.NimmAddress) {
|
||||
com.nhncorp.lucy.nimm.connector.address.NimmAddress nimmAddress = (com.nhncorp.lucy.nimm.connector.address.NimmAddress) args[0];
|
||||
|
||||
StringBuilder address = new StringBuilder();
|
||||
if (Species.Service.equals(nimmAddress.getSpecies())) {
|
||||
address.append("S");
|
||||
} else if (Species.Management.equals(nimmAddress.getSpecies())) {
|
||||
address.append("M");
|
||||
} else {
|
||||
address.append("unknown");
|
||||
}
|
||||
address.append(":");
|
||||
address.append(nimmAddress.getDomainId()).append(":");
|
||||
address.append(nimmAddress.getIdcId()).append(":");
|
||||
address.append(nimmAddress.getServerId()).append(":");
|
||||
address.append(nimmAddress.getSocketId());
|
||||
|
||||
setNimmAddress.invoke(target, address.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void setMethodDescriptor(MethodDescriptor descriptor) {
|
||||
// this.descriptor = descriptor;
|
||||
// traceContext.cacheApi(descriptor);
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public void setTraceContext(TraceContext traceContext) {
|
||||
// this.traceContext = traceContext;
|
||||
// }
|
||||
}
|
||||
-72
@@ -1,72 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.connector.npc;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor.InvokeInterceptor;
|
||||
import com.nhn.pinpoint.profiler.modifier.method.interceptor.MethodInterceptor;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* NPC Hessian connector modifier
|
||||
*
|
||||
* based on NPC client 1.5.18
|
||||
*
|
||||
* @author netspider
|
||||
*/
|
||||
public class KeepAliveNpcHessianConnectorModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public KeepAliveNpcHessianConnectorModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/lucy/npc/connector/KeepAliveNpcHessianConnector";
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", javassistClassName);
|
||||
}
|
||||
|
||||
try {
|
||||
InstrumentClass connectorClass = byteCodeInstrumentor.getClass(classLoader, javassistClassName, classFileBuffer);
|
||||
|
||||
// trace variables
|
||||
connectorClass.addTraceVariable("_serverAddress", "__setServerAddress", "__getServerAddress", "java.net.InetSocketAddress");
|
||||
|
||||
// package constructor
|
||||
Interceptor constructorInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor.ConnectorConstructorInterceptor");
|
||||
connectorClass.addConstructorInterceptor(new String[] { "com.nhncorp.lucy.npc.connector.NpcConnectorOption" }, constructorInterceptor);
|
||||
|
||||
// public constructor
|
||||
Interceptor constructorInterceptor2 = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor.ConnectorConstructorInterceptor");
|
||||
connectorClass.addConstructorInterceptor(new String[] { "java.net.InetSocketAddress", "long", "long", "java.nio.charset.Charset" }, constructorInterceptor2);
|
||||
|
||||
// initializing connector
|
||||
Interceptor initializeConnectorInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor.InitializeConnectorInterceptor");
|
||||
connectorClass.addInterceptor("initializeConnector", null, initializeConnectorInterceptor);
|
||||
|
||||
// invokeImpl
|
||||
Interceptor invokeImplInterceptor = new MethodInterceptor();
|
||||
connectorClass.addInterceptor("invokeImpl", new String[] { "java.lang.String", "java.lang.String", "java.nio.charset.Charset", "java.lang.Object[]" }, invokeImplInterceptor);
|
||||
|
||||
// invoke
|
||||
Interceptor invokeInterceptor = new InvokeInterceptor();
|
||||
connectorClass.addInterceptor("invoke", new String[] { "java.lang.String", "java.lang.String", "java.nio.charset.Charset", "java.lang.Object[]" }, invokeInterceptor);
|
||||
|
||||
return connectorClass.toBytecode();
|
||||
} catch (Throwable e) {
|
||||
logger.warn(this.getClass().getSimpleName() + " modifier error. Caused:{}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.connector.npc;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor.InvokeInterceptor;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* NPC Hessian connector modifier
|
||||
*
|
||||
* based on NPC client 1.5.18
|
||||
*
|
||||
* @author netspider
|
||||
*/
|
||||
public class LightWeightConnectorModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public LightWeightConnectorModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/lucy/npc/connector/LightWeightConnector";
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", javassistClassName);
|
||||
}
|
||||
|
||||
try {
|
||||
InstrumentClass connectorClass = byteCodeInstrumentor.getClass(classLoader, javassistClassName, classFileBuffer);
|
||||
|
||||
// trace variables
|
||||
connectorClass.addTraceVariable("_serverAddress", "__setServerAddress", "__getServerAddress", "java.net.InetSocketAddress");
|
||||
|
||||
// constructor
|
||||
Interceptor constructorInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor.ConnectorConstructorInterceptor");
|
||||
connectorClass.addConstructorInterceptor(new String[] { "com.nhncorp.lucy.npc.connector.NpcConnectorOption" }, constructorInterceptor);
|
||||
|
||||
// invoke
|
||||
Interceptor invokeInterceptor = new InvokeInterceptor();
|
||||
connectorClass.addInterceptor("invoke", new String[] { "java.lang.String", "java.lang.String", "java.nio.charset.Charset", "java.lang.Object[]" }, invokeInterceptor);
|
||||
|
||||
return connectorClass.toBytecode();
|
||||
} catch (Throwable e) {
|
||||
logger.warn(this.getClass().getSimpleName() + " modifier error. Caused:{}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.connector.npc;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor.InvokeInterceptor;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* NPC Hessian connector modifier
|
||||
*
|
||||
* based on NPC client 1.5.18
|
||||
*
|
||||
* @author netspider
|
||||
*/
|
||||
public class LightWeightNbfpConnectorModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public LightWeightNbfpConnectorModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/lucy/npc/connector/LightWeightNbfpConnector";
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", javassistClassName);
|
||||
}
|
||||
|
||||
try {
|
||||
InstrumentClass connectorClass = byteCodeInstrumentor.getClass(classLoader, javassistClassName, classFileBuffer);
|
||||
|
||||
// trace variables
|
||||
connectorClass.addTraceVariable("_serverAddress", "__setServerAddress", "__getServerAddress", "java.net.InetSocketAddress");
|
||||
|
||||
// constructor
|
||||
Interceptor constructorInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor.ConnectorConstructorInterceptor");
|
||||
connectorClass.addConstructorInterceptor(new String[] { "com.nhncorp.lucy.npc.connector.NpcConnectorOption" }, constructorInterceptor);
|
||||
|
||||
// invoke
|
||||
Interceptor invokeInterceptor = new InvokeInterceptor();
|
||||
connectorClass.addInterceptor("invoke", new String[] { "java.lang.String", "java.lang.String", "java.nio.charset.Charset", "java.lang.Object[]" }, invokeInterceptor);
|
||||
|
||||
return connectorClass.toBytecode();
|
||||
} catch (Throwable e) {
|
||||
logger.warn(this.getClass().getSimpleName() + " modifier error. Caused:{}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.connector.npc;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor.InvokeInterceptor;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* NPC Hessian connector modifier
|
||||
*
|
||||
* based on NPC client 1.5.18
|
||||
*
|
||||
* @author netspider
|
||||
*/
|
||||
public class LightWeightNpcHessianConnectorModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public LightWeightNpcHessianConnectorModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/lucy/npc/connector/LightWeightNpcHessianConnector";
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", javassistClassName);
|
||||
}
|
||||
|
||||
try {
|
||||
InstrumentClass connectorClass = byteCodeInstrumentor.getClass(classLoader, javassistClassName, classFileBuffer);
|
||||
|
||||
// trace variables
|
||||
connectorClass.addTraceVariable("_serverAddress", "__setServerAddress", "__getServerAddress", "java.net.InetSocketAddress");
|
||||
|
||||
// constructor
|
||||
Interceptor constructorInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor.ConnectorConstructorInterceptor");
|
||||
connectorClass.addConstructorInterceptor(new String[] { "com.nhncorp.lucy.npc.connector.NpcConnectorOption" }, constructorInterceptor);
|
||||
|
||||
// invoke
|
||||
Interceptor invokeInterceptor = new InvokeInterceptor();
|
||||
connectorClass.addInterceptor("invoke", new String[] { "java.lang.String", "java.lang.String", "java.nio.charset.Charset", "java.lang.Object[]" }, invokeInterceptor);
|
||||
|
||||
return connectorClass.toBytecode();
|
||||
} catch (Throwable e) {
|
||||
logger.warn(this.getClass().getSimpleName() + " modifier error. Caused:{}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.connector.npc;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor.InvokeInterceptor;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* NPC Hessian connector modifier
|
||||
*
|
||||
* based on NPC client 1.5.18
|
||||
*
|
||||
* @author netspider
|
||||
*/
|
||||
public class NioNpcHessianConnectorModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public NioNpcHessianConnectorModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/lucy/npc/connector/NioNpcHessianConnector";
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", javassistClassName);
|
||||
}
|
||||
|
||||
try {
|
||||
InstrumentClass connectorClass = byteCodeInstrumentor.getClass(classLoader, javassistClassName, classFileBuffer);
|
||||
|
||||
// trace variables
|
||||
connectorClass.addTraceVariable("_serverAddress", "__setServerAddress", "__getServerAddress", "java.net.InetSocketAddress");
|
||||
|
||||
// constructor
|
||||
Interceptor constructorInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor.ConnectorConstructorInterceptor");
|
||||
connectorClass.addConstructorInterceptor(new String[] { "com.nhncorp.lucy.npc.connector.NpcConnectorOption" }, constructorInterceptor);
|
||||
|
||||
// invoke
|
||||
Interceptor invokeInterceptor = new InvokeInterceptor();
|
||||
connectorClass.addInterceptor("invoke", new String[] { "java.lang.String", "java.lang.String", "java.nio.charset.Charset", "java.lang.Object[]" }, invokeInterceptor);
|
||||
|
||||
return connectorClass.toBytecode();
|
||||
} catch (Throwable e) {
|
||||
logger.warn(this.getClass().getSimpleName() + " modifier error. Caused:{}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.connector.npc;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.method.interceptor.MethodInterceptor;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* NPC Hessian connector modifier
|
||||
*
|
||||
* based on NPC client 1.5.18
|
||||
*
|
||||
* @author netspider
|
||||
*/
|
||||
public class NpcHessianConnectorModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public NpcHessianConnectorModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/lucy/npc/connector/NpcHessianConnector";
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", javassistClassName);
|
||||
}
|
||||
|
||||
try {
|
||||
InstrumentClass connectorClass = byteCodeInstrumentor.getClass(classLoader, javassistClassName, classFileBuffer);
|
||||
|
||||
// create connector
|
||||
if (connectorClass.hasDeclaredMethod("createConnecor", new String[] { "com.nhncorp.lucy.npc.connector.NpcConnectorOption" })) {
|
||||
Interceptor connectInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor.CreateConnectorInterceptor");
|
||||
connectorClass.addInterceptor("createConnecor", new String[] { "com.nhncorp.lucy.npc.connector.NpcConnectorOption" }, connectInterceptor);
|
||||
}
|
||||
|
||||
// invoke
|
||||
Interceptor invokeInterceptor = new MethodInterceptor();
|
||||
connectorClass.addInterceptor("invoke", new String[] { "java.lang.String", "java.lang.String", "java.nio.charset.Charset", "java.lang.Object[]" }, invokeInterceptor);
|
||||
|
||||
return connectorClass.toBytecode();
|
||||
} catch (Throwable e) {
|
||||
logger.warn(this.getClass().getSimpleName() + " modifier error. Caused:{}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
-99
@@ -1,99 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import com.nhn.pinpoint.common.AnnotationKey;
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import com.nhn.pinpoint.bootstrap.context.Trace;
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceContext;
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceId;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.ByteCodeMethodDescriptorSupport;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.MethodDescriptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TraceContextSupport;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
|
||||
/**
|
||||
* based on NPC client 1.5.18
|
||||
*
|
||||
* @author netspider
|
||||
*
|
||||
*/
|
||||
public class ConnectInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
|
||||
|
||||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
private MethodDescriptor descriptor;
|
||||
private TraceContext traceContext;
|
||||
|
||||
// private int apiId;
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
if (isDebug) {
|
||||
logger.beforeInterceptor(target, args);
|
||||
}
|
||||
|
||||
// Trace trace = traceContext.currentRawTraceObject();
|
||||
// sampling 레이트를 추가로 확인하여 액션을 취하는 로직이 없으므로 그냥 currentTraceObject()를 호출한다.
|
||||
Trace trace = traceContext.currentTraceObject();
|
||||
if (trace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
com.nhncorp.lucy.npc.connector.NpcConnectorOption connectorOption = (com.nhncorp.lucy.npc.connector.NpcConnectorOption) args[0];
|
||||
|
||||
trace.traceBlockBegin();
|
||||
trace.markBeforeTime();
|
||||
|
||||
TraceId nextId = trace.getTraceId().getNextTraceId();
|
||||
trace.recordNextSpanId(nextId.getSpanId());
|
||||
|
||||
trace.recordServiceType(ServiceType.NPC_CLIENT);
|
||||
|
||||
InetSocketAddress serverAddress = connectorOption.getAddress();
|
||||
int port = serverAddress.getPort();
|
||||
String endpiont = serverAddress.getHostName() + ((port > 0) ? ":" + port : "");
|
||||
// DestinationId와 동일하므로 없는게 맞음.
|
||||
// trace.recordEndPoint(endpiont);
|
||||
trace.recordDestinationId(endpiont);
|
||||
|
||||
trace.recordAttribute(AnnotationKey.NPC_URL, serverAddress.toString());
|
||||
trace.recordAttribute(AnnotationKey.NPC_CONNECT_OPTION, connectorOption.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
if (isDebug) {
|
||||
// result는 로깅하지 않는다.
|
||||
logger.afterInterceptor(target, args);
|
||||
}
|
||||
|
||||
Trace trace = traceContext.currentTraceObject();
|
||||
if (trace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
trace.recordApi(descriptor);
|
||||
trace.recordException(throwable);
|
||||
|
||||
trace.markAfterTime();
|
||||
} finally {
|
||||
trace.traceBlockEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMethodDescriptor(MethodDescriptor descriptor) {
|
||||
this.descriptor = descriptor;
|
||||
traceContext.cacheApi(descriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTraceContext(TraceContext traceContext) {
|
||||
this.traceContext = traceContext;
|
||||
}
|
||||
}
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.*;
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import com.nhn.pinpoint.bootstrap.context.Trace;
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceContext;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
import com.nhn.pinpoint.bootstrap.util.MetaObject;
|
||||
import com.nhncorp.lucy.npc.connector.KeepAliveNpcHessianConnector;
|
||||
import com.nhncorp.lucy.npc.connector.NpcConnectorOption;
|
||||
|
||||
/**
|
||||
* based on NPC client 1.5.18
|
||||
*
|
||||
* @author netspider
|
||||
*
|
||||
*/
|
||||
public class ConnectorConstructorInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport, TargetClassLoader {
|
||||
|
||||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
private MethodDescriptor descriptor;
|
||||
private TraceContext traceContext;
|
||||
|
||||
private final MetaObject<InetSocketAddress> setServerAddress = new MetaObject<InetSocketAddress>("__setServerAddress", InetSocketAddress.class);
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
if (isDebug) {
|
||||
logger.beforeInterceptor(target, args);
|
||||
}
|
||||
|
||||
InetSocketAddress serverAddress = null;
|
||||
|
||||
if (target instanceof KeepAliveNpcHessianConnector) {
|
||||
/*
|
||||
* com.nhncorp.lucy.npc.connector.KeepAliveNpcHessianConnector.
|
||||
* KeepAliveNpcHessianConnector(InetSocketAddress, long, long,
|
||||
* Charset)
|
||||
*/
|
||||
if (args.length == 4) {
|
||||
if (args[0] instanceof InetSocketAddress) {
|
||||
serverAddress = (InetSocketAddress) args[0];
|
||||
}
|
||||
} else if (args.length == 1) {
|
||||
if (args[0] instanceof NpcConnectorOption) {
|
||||
NpcConnectorOption option = (NpcConnectorOption) args[0];
|
||||
serverAddress = option.getAddress();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (args[0] instanceof NpcConnectorOption) {
|
||||
NpcConnectorOption option = (NpcConnectorOption) args[0];
|
||||
serverAddress = option.getAddress();
|
||||
}
|
||||
}
|
||||
|
||||
setServerAddress.invoke(target, serverAddress);
|
||||
|
||||
Trace trace = traceContext.currentTraceObject();
|
||||
if (trace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
trace.traceBlockBegin();
|
||||
trace.markBeforeTime();
|
||||
trace.recordServiceType(ServiceType.NPC_CLIENT);
|
||||
|
||||
if (serverAddress != null) {
|
||||
int port = serverAddress.getPort();
|
||||
String endPoint = serverAddress.getHostName() + ((port > 0) ? ":" + port : "");
|
||||
trace.recordDestinationId(endPoint);
|
||||
} else {
|
||||
// destination id가 없으면 안되기 때문에 unknown으로 지정.
|
||||
trace.recordDestinationId("unknown");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
if (isDebug) {
|
||||
logger.afterInterceptor(target, args);
|
||||
}
|
||||
|
||||
Trace trace = traceContext.currentTraceObject();
|
||||
if (trace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
trace.recordApi(descriptor);
|
||||
trace.recordException(throwable);
|
||||
trace.markAfterTime();
|
||||
} finally {
|
||||
trace.traceBlockEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMethodDescriptor(MethodDescriptor descriptor) {
|
||||
this.descriptor = descriptor;
|
||||
traceContext.cacheApi(descriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTraceContext(TraceContext traceContext) {
|
||||
this.traceContext = traceContext;
|
||||
}
|
||||
}
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.*;
|
||||
import com.nhn.pinpoint.common.AnnotationKey;
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import com.nhn.pinpoint.bootstrap.context.Trace;
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceContext;
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceId;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
import com.nhncorp.lucy.npc.connector.NpcConnectorOption;
|
||||
|
||||
public class CreateConnectorInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport, TargetClassLoader {
|
||||
|
||||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
private MethodDescriptor descriptor;
|
||||
private TraceContext traceContext;
|
||||
|
||||
// private int apiId;
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
if (isDebug) {
|
||||
logger.beforeInterceptor(target, args);
|
||||
}
|
||||
// Trace trace = traceContext.currentRawTraceObject();
|
||||
// sampling 레이트를 추가로 확인하여 액션을 취하는 로직이 없으므로 그냥 currentTraceObject()를 호출한다.
|
||||
final Trace trace = traceContext.currentTraceObject();
|
||||
if (trace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
trace.traceBlockBegin();
|
||||
trace.markBeforeTime();
|
||||
|
||||
TraceId nextId = trace.getTraceId().getNextTraceId();
|
||||
trace.recordNextSpanId(nextId.getSpanId());
|
||||
trace.recordServiceType(ServiceType.NPC_CLIENT);
|
||||
|
||||
NpcConnectorOption option = (NpcConnectorOption) args[0];
|
||||
|
||||
InetSocketAddress serverAddress = option.getAddress();
|
||||
int port = serverAddress.getPort();
|
||||
String endPoint = serverAddress.getHostName() + ((port > 0) ? ":" + port : "");
|
||||
// DestinationId와 동일하므로 없는게 맞음.
|
||||
// trace.recordEndPoint(endpint);
|
||||
trace.recordDestinationId(endPoint);
|
||||
|
||||
trace.recordAttribute(AnnotationKey.NPC_URL, serverAddress.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
if (isDebug) {
|
||||
logger.afterInterceptor(target, args);
|
||||
}
|
||||
|
||||
final Trace trace = traceContext.currentTraceObject();
|
||||
if (trace == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
trace.recordApi(descriptor);
|
||||
trace.recordException(throwable);
|
||||
|
||||
trace.markAfterTime();
|
||||
} finally {
|
||||
trace.traceBlockEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMethodDescriptor(MethodDescriptor descriptor) {
|
||||
this.descriptor = descriptor;
|
||||
traceContext.cacheApi(descriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTraceContext(TraceContext traceContext) {
|
||||
this.traceContext = traceContext;
|
||||
}
|
||||
}
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.*;
|
||||
import com.nhn.pinpoint.common.AnnotationKey;
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import com.nhn.pinpoint.bootstrap.context.Trace;
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceContext;
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceId;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
import com.nhn.pinpoint.bootstrap.util.MetaObject;
|
||||
|
||||
public class InitializeConnectorInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport, TargetClassLoader {
|
||||
|
||||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
private final MetaObject<InetSocketAddress> getServerAddress = new MetaObject<InetSocketAddress>("__getServerAddress");
|
||||
|
||||
private MethodDescriptor descriptor;
|
||||
private TraceContext traceContext;
|
||||
|
||||
// private int apiId;
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
if (isDebug) {
|
||||
logger.beforeInterceptor(target, args);
|
||||
}
|
||||
|
||||
// Trace trace = traceContext.currentRawTraceObject();
|
||||
// sampling 레이트를 추가로 확인하여 액션을 취하는 로직이 없으므로 그냥 currentTraceObject()fmf g
|
||||
Trace trace = traceContext.currentTraceObject();
|
||||
if (trace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
trace.traceBlockBegin();
|
||||
trace.markBeforeTime();
|
||||
|
||||
TraceId nextId = trace.getTraceId().getNextTraceId();
|
||||
trace.recordNextSpanId(nextId.getSpanId());
|
||||
|
||||
trace.recordServiceType(ServiceType.NPC_CLIENT);
|
||||
|
||||
InetSocketAddress serverAddress = getServerAddress.invoke(target);
|
||||
int port = serverAddress.getPort();
|
||||
String endPoint = serverAddress.getHostName() + ((port > 0) ? ":" + port : "");
|
||||
trace.recordDestinationId(endPoint);
|
||||
|
||||
trace.recordAttribute(AnnotationKey.NPC_URL, serverAddress.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
if (isDebug) {
|
||||
logger.afterInterceptor(target, args);
|
||||
}
|
||||
|
||||
Trace trace = traceContext.currentTraceObject();
|
||||
if (trace == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
trace.recordApi(descriptor);
|
||||
trace.recordException(throwable);
|
||||
|
||||
trace.markAfterTime();
|
||||
} finally {
|
||||
trace.traceBlockEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMethodDescriptor(MethodDescriptor descriptor) {
|
||||
this.descriptor = descriptor;
|
||||
traceContext.cacheApi(descriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTraceContext(TraceContext traceContext) {
|
||||
this.traceContext = traceContext;
|
||||
}
|
||||
}
|
||||
-117
@@ -1,117 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.connector.npc.interceptor;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import com.nhn.pinpoint.common.AnnotationKey;
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import com.nhn.pinpoint.bootstrap.context.Trace;
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceContext;
|
||||
import com.nhn.pinpoint.bootstrap.context.TraceId;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.ByteCodeMethodDescriptorSupport;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.MethodDescriptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TraceContextSupport;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
import com.nhn.pinpoint.bootstrap.util.MetaObject;
|
||||
|
||||
public class InvokeInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
|
||||
|
||||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
private final MetaObject<InetSocketAddress> getServerAddress = new MetaObject<InetSocketAddress>("__getServerAddress");
|
||||
|
||||
private MethodDescriptor descriptor;
|
||||
private TraceContext traceContext;
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
if (isDebug) {
|
||||
logger.beforeInterceptor(target, args);
|
||||
}
|
||||
|
||||
// Trace trace = traceContext.currentRawTraceObject();
|
||||
// 이부분은 현재 remote 호출시 traceId를 넣지 않으므로 currentRawTraceObject()를 호출하지 않는다.
|
||||
final Trace trace = traceContext.currentTraceObject();
|
||||
if (trace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String objectName;
|
||||
String methodName;
|
||||
Charset charset;
|
||||
Object params;
|
||||
|
||||
if (args.length == 3) {
|
||||
objectName = (String) args[0];
|
||||
methodName = (String) args[1];
|
||||
// TODO charset을 com.nhncorp.lucy.npc.connector.AbstractConnector.getDefaultCharset() 에서 조회 가능하긴 함.
|
||||
charset = null;
|
||||
params = args[2];
|
||||
} else if (args.length == 4) {
|
||||
objectName = (String) args[0];
|
||||
methodName = (String) args[1];
|
||||
charset = (Charset) args[2];
|
||||
params = args[3];
|
||||
}
|
||||
|
||||
//
|
||||
// TODO add sampling logic here.
|
||||
//
|
||||
|
||||
trace.traceBlockBegin();
|
||||
trace.markBeforeTime();
|
||||
|
||||
TraceId nextId = trace.getTraceId().getNextTraceId();
|
||||
trace.recordNextSpanId(nextId.getSpanId());
|
||||
|
||||
//
|
||||
// TODO add pinpoint headers to the request message here.
|
||||
//
|
||||
|
||||
trace.recordServiceType(ServiceType.NPC_CLIENT);
|
||||
|
||||
InetSocketAddress serverAddress = getServerAddress.invoke(target);
|
||||
int port = serverAddress.getPort();
|
||||
String endPoint = serverAddress.getHostName() + ((port > 0) ? ":" + port : "");
|
||||
// DestinationId와 동일하므로 없는게 맞음.
|
||||
// trace.recordEndPoint(endPoint);
|
||||
trace.recordDestinationId(endPoint);
|
||||
|
||||
trace.recordAttribute(AnnotationKey.NPC_URL, serverAddress.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
if (isDebug) {
|
||||
// result는 로깅하지 않는다.
|
||||
logger.afterInterceptor(target, args);
|
||||
}
|
||||
|
||||
final Trace trace = traceContext.currentTraceObject();
|
||||
if (trace == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
trace.recordApi(descriptor);
|
||||
trace.recordException(throwable);
|
||||
|
||||
trace.markAfterTime();
|
||||
} finally {
|
||||
trace.traceBlockEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMethodDescriptor(MethodDescriptor descriptor) {
|
||||
this.descriptor = descriptor;
|
||||
traceContext.cacheApi(descriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTraceContext(TraceContext traceContext) {
|
||||
this.traceContext = traceContext;
|
||||
}
|
||||
}
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.linegame;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
|
||||
/**
|
||||
* line game의 baseframework에서 netty pipeline으로 사용하는 HttpCustomServerHandler의 비동기
|
||||
* processor인 InvokeTask를 수정하는 클래스
|
||||
*
|
||||
* @author netspider
|
||||
*
|
||||
*/
|
||||
public class HandlerInvokeTaskModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public HandlerInvokeTaskModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
public String getTargetClass() {
|
||||
return "com/linecorp/games/common/baseFramework/handlers/HttpCustomServerHandler$InvokeTask";
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {} @ {}", javassistClassName, classLoader);
|
||||
}
|
||||
|
||||
try {
|
||||
InstrumentClass aClass = byteCodeInstrumentor.getClass(classLoader, javassistClassName, classFileBuffer);
|
||||
|
||||
// constructor parameter trace object
|
||||
aClass.addTraceVariable("__channelHandlerContext", "__setChannelHandlerContext", "__getChannelHandlerContext", "org.jboss.netty.channel.ChannelHandlerContext");
|
||||
aClass.addTraceVariable("__messageEvent", "__setMessageEvent", "__getMessageEvent", "org.jboss.netty.channel.MessageEvent");
|
||||
|
||||
// non static inner class는 constructor argument의 첫번째가 parent class임.
|
||||
Interceptor constInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.linegame.interceptor.InvokeTaskConstructorInterceptor");
|
||||
aClass.addConstructorInterceptor(new String[] { "com.linecorp.games.common.baseFramework.handlers.HttpCustomServerHandler", "org.jboss.netty.channel.ChannelHandlerContext", "org.jboss.netty.channel.MessageEvent" }, constInterceptor);
|
||||
|
||||
Interceptor runInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.linegame.interceptor.InvokeTaskRunInterceptor");
|
||||
aClass.addInterceptor("run", null, runInterceptor);
|
||||
|
||||
return aClass.toBytecode();
|
||||
} catch (InstrumentException e) {
|
||||
logger.info("modify fail. Cause:{}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.linegame;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentException;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author netspider
|
||||
*
|
||||
*/
|
||||
public class HttpCustomServerHandlerModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public HttpCustomServerHandlerModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
public String getTargetClass() {
|
||||
return "com/linecorp/games/common/baseFramework/handlers/HttpCustomServerHandler";
|
||||
}
|
||||
|
||||
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {} @ {}", javassistClassName, classLoader);
|
||||
}
|
||||
|
||||
try {
|
||||
InstrumentClass aClass = byteCodeInstrumentor.getClass(classLoader, javassistClassName, classFileBuffer);
|
||||
|
||||
// /**
|
||||
// * modify inner class
|
||||
// */
|
||||
// InstrumentClass iClass = aClass.getNestedClass("com.linecorp.games.common.baseFramework.handlers.HttpCustomServerHandler$InvokeTask");
|
||||
//
|
||||
// // constructor parameter trace object
|
||||
// iClass.addTraceVariable("__channelHandlerContext", "__setChannelHandlerContext", "__getChannelHandlerContext", "org.jboss.netty.channel.ChannelHandlerContext");
|
||||
// iClass.addTraceVariable("__messageEvent", "__setMessageEvent", "__getMessageEvent", "org.jboss.netty.channel.MessageEvent");
|
||||
//
|
||||
// // non static inner class는 constructor argument의 첫번째가 parent class임.
|
||||
// Interceptor constInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.linegame.interceptor.InvokeTaskConstructorInterceptor");
|
||||
// iClass.addConstructorInterceptor(new String[] { "com.linecorp.games.common.baseFramework.handlers.HttpCustomServerHandler", "org.jboss.netty.channel.ChannelHandlerContext", "org.jboss.netty.channel.MessageEvent" }, constInterceptor);
|
||||
//
|
||||
// Interceptor runInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.linegame.interceptor.InvokeTaskRunInterceptor");
|
||||
// iClass.addInterceptor("run", null, runInterceptor);
|
||||
//
|
||||
// return aClass.toBytecode();
|
||||
|
||||
// DO NOTHING
|
||||
return null;
|
||||
} catch (InstrumentException e) {
|
||||
logger.info("modify fail. Cause:{}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.linegame.interceptor;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
|
||||
import com.nhn.pinpoint.bootstrap.util.MetaObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author netspider
|
||||
*
|
||||
*/
|
||||
public class InvokeTaskConstructorInterceptor implements SimpleAroundInterceptor, TargetClassLoader {
|
||||
|
||||
private MetaObject<org.jboss.netty.channel.ChannelHandlerContext> setChannelHandlerContext = new MetaObject<org.jboss.netty.channel.ChannelHandlerContext>("__setChannelHandlerContext", org.jboss.netty.channel.ChannelHandlerContext.class);
|
||||
private MetaObject<org.jboss.netty.channel.MessageEvent> setMessageEvent = new MetaObject<org.jboss.netty.channel.MessageEvent>("__setMessageEvent", org.jboss.netty.channel.MessageEvent.class);
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
// 대상 class가 non-static이기 때문에 코드상의 argument length는 2이지만 byte code상으로는
|
||||
// 3이다.
|
||||
if (args.length != 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(args[1] instanceof org.jboss.netty.channel.ChannelHandlerContext)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(args[2] instanceof org.jboss.netty.channel.MessageEvent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
setChannelHandlerContext.invoke(target, (org.jboss.netty.channel.ChannelHandlerContext) args[1]);
|
||||
setMessageEvent.invoke(target, (org.jboss.netty.channel.MessageEvent) args[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
|
||||
}
|
||||
}
|
||||
-452
@@ -1,452 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.linegame.interceptor;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.context.*;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.*;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.handler.codec.http.HttpMethod;
|
||||
import org.jboss.netty.handler.codec.http.HttpRequest;
|
||||
import org.jboss.netty.handler.codec.http.QueryStringDecoder;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.config.ProfilerConfig;
|
||||
import com.nhn.pinpoint.bootstrap.sampler.SamplingFlagUtils;
|
||||
import com.nhn.pinpoint.bootstrap.util.MetaObject;
|
||||
import com.nhn.pinpoint.bootstrap.util.NumberUtils;
|
||||
import com.nhn.pinpoint.bootstrap.util.StringUtils;
|
||||
import com.nhn.pinpoint.common.AnnotationKey;
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import com.nhn.pinpoint.profiler.context.SpanId;
|
||||
import org.jboss.netty.util.CharsetUtil;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* com/linecorp/games/common/baseFramework/handlers/HttpCustomServerHandler$InvokeTask.run()를 인터셉트한다.
|
||||
* invoke task의 run메소드는 http request를 분석하고 bo를 찾아 실행 후 결과를 반환하는 역할을 담당하는 클래스이다.
|
||||
* </pre>
|
||||
*
|
||||
* @author netspider
|
||||
* @author emeroad
|
||||
*/
|
||||
public class InvokeTaskRunInterceptor extends SpanSimpleAroundInterceptor implements TargetClassLoader {
|
||||
|
||||
private static final String DEFAULT_CHARSET = "UTF-8";
|
||||
|
||||
public InvokeTaskRunInterceptor() {
|
||||
super(InvokeTaskRunInterceptor.class);
|
||||
}
|
||||
|
||||
private MetaObject<org.jboss.netty.channel.ChannelHandlerContext> getChannelHandlerContext = new MetaObject<org.jboss.netty.channel.ChannelHandlerContext>("__getChannelHandlerContext");
|
||||
private MetaObject<org.jboss.netty.channel.MessageEvent> getMessageEvent = new MetaObject<org.jboss.netty.channel.MessageEvent>("__getMessageEvent");
|
||||
|
||||
private int paramDumpSize = 512;
|
||||
private int entityDumpSize = 512;
|
||||
|
||||
@Override
|
||||
public void doInBeforeTrace(RecordableTrace trace, Object target, Object[] args) {
|
||||
|
||||
org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext = getChannelHandlerContext.invoke(target);
|
||||
org.jboss.netty.channel.MessageEvent e = getMessageEvent.invoke(target);
|
||||
|
||||
if (channelHandlerContext == null) {
|
||||
logger.debug("ChannelHandlerContext is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (e == null) {
|
||||
logger.debug("MessageEvent is null.");
|
||||
// after에서도 체크하지않으면 사실 로직이 이상해짐.
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(e.getMessage() instanceof org.jboss.netty.handler.codec.http.HttpRequest)) {
|
||||
logger.debug("MessageEvent is not instance of org.jboss.netty.handler.codec.http.HttpRequest. {}", e.getMessage());
|
||||
return;
|
||||
}
|
||||
org.jboss.netty.handler.codec.http.HttpRequest request = (org.jboss.netty.handler.codec.http.HttpRequest) e.getMessage();
|
||||
Channel channel = e.getChannel();
|
||||
if (channel == null) {
|
||||
logger.debug("Channel is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
String requestURL = request.getUri();
|
||||
// FIXME 모든 address는 / 로 시작하나???
|
||||
|
||||
|
||||
final String endPoint = getLocalAddress(channel);
|
||||
|
||||
trace.markBeforeTime();
|
||||
if (trace.canSampled()) {
|
||||
|
||||
trace.recordServiceType(ServiceType.STAND_ALONE);
|
||||
trace.recordRpcName(requestURL);
|
||||
|
||||
trace.recordEndPoint(endPoint);
|
||||
|
||||
final String remoteAddr = getRemoteAddress(channel);
|
||||
trace.recordRemoteAddress(remoteAddr);
|
||||
}
|
||||
|
||||
// 서버 맵을 통계정보에서 조회하려면 remote로 호출되는 WAS의 관계를 알아야해서 부모의 application
|
||||
// name을 전달받음.
|
||||
if (!trace.isRoot()) {
|
||||
String parentApplicationName = populateParentApplicationNameFromRequest(request);
|
||||
short parentApplicationType = populateParentApplicationTypeFromRequest(request);
|
||||
if (parentApplicationName != null) {
|
||||
trace.recordParentApplication(parentApplicationName, parentApplicationType);
|
||||
trace.recordAcceptorHost(endPoint);
|
||||
}
|
||||
} else {
|
||||
// TODO 여기에서 client 정보를 수집할 수 있다.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected Trace createTrace(Object target, Object[] args) {
|
||||
org.jboss.netty.channel.MessageEvent messageEvent = getMessageEvent.invoke(target);
|
||||
org.jboss.netty.handler.codec.http.HttpRequest request = (org.jboss.netty.handler.codec.http.HttpRequest) messageEvent.getMessage();
|
||||
|
||||
Channel channel = messageEvent.getChannel();
|
||||
if (channel == null) {
|
||||
logger.debug("Channel is null.");
|
||||
return null;
|
||||
}
|
||||
|
||||
// FIXME 모든 address는 / 로 시작하나???
|
||||
// String remoteAddr = channel.getRemoteAddress().toString().substring(1);
|
||||
// String endPoint = channel.getLocalAddress().toString().substring(1);
|
||||
|
||||
// check sampled
|
||||
final boolean sampling = isSamplingEnabled(request);
|
||||
if (!sampling) {
|
||||
// 샘플링 대상이 아닐 경우도 TraceObject를 생성하여, sampling 대상이 아니라는것을 명시해야
|
||||
// 한다.
|
||||
// sampling 대상이 아닐경우 rpc 호출에서 sampling 대상이 아닌 것에 rpc호출 파라미터에
|
||||
// sampling disable 파라미터를 박을수 있다.
|
||||
final TraceContext traceContext = getTraceContext();
|
||||
final Trace trace = traceContext.disableSampling();
|
||||
if (isDebug) {
|
||||
String requestURL = request.getUri();
|
||||
String remoteAddr = getRemoteAddress(channel);
|
||||
logger.debug("remotecall sampling flag found. skip trace requestUrl:{}, remoteAddr:{}", requestURL, remoteAddr);
|
||||
}
|
||||
return trace;
|
||||
}
|
||||
|
||||
final TraceId traceId = populateTraceIdFromRequest(request);
|
||||
if (traceId != null) {
|
||||
// TODO remote에서 sampling flag로 마크가되는 대상으로 왔을 경우도 추가로 샘플링 칠수 있어야
|
||||
// 할것으로 보임.
|
||||
final TraceContext traceContext = getTraceContext();
|
||||
final Trace trace = traceContext.continueTraceObject(traceId);
|
||||
if (trace.canSampled()) {
|
||||
if (isDebug) {
|
||||
String requestURL = request.getUri();
|
||||
String remoteAddr = getRemoteAddress(channel);
|
||||
logger.debug("TraceID exist. continue trace. traceId:{}, requestUrl:{}, remoteAddr:{}", new Object[]{traceId, requestURL, remoteAddr});
|
||||
}
|
||||
return trace;
|
||||
} else {
|
||||
if (isDebug) {
|
||||
String requestURL = request.getUri();
|
||||
String remoteAddr = getRemoteAddress(channel);
|
||||
logger.debug("TraceID exist. camSampled is false. skip trace. traceId:{}, requestUrl:{}, remoteAddr:{}", new Object[]{traceId, requestURL, remoteAddr});
|
||||
|
||||
}
|
||||
return trace;
|
||||
}
|
||||
} else {
|
||||
TraceContext traceContext = getTraceContext();
|
||||
final Trace trace = traceContext.newTraceObject();
|
||||
if (trace.canSampled()) {
|
||||
if (isDebug) {
|
||||
String requestURL = request.getUri();
|
||||
String remoteAddr = getRemoteAddress(channel);
|
||||
logger.debug("TraceID not exist. start new trace. requestUrl:{}, remoteAddr:{}", new Object[]{requestURL, remoteAddr});
|
||||
}
|
||||
return trace;
|
||||
} else {
|
||||
if (isDebug) {
|
||||
String requestURL = request.getUri();
|
||||
String remoteAddr = getRemoteAddress(channel);
|
||||
logger.debug("TraceID not exist. camSampled is false. skip trace. requestUrl:{}, remoteAddr:{}", new Object[]{requestURL, remoteAddr});
|
||||
}
|
||||
return trace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getLocalAddress(Channel channel) {
|
||||
return channel.getLocalAddress().toString().substring(1);
|
||||
}
|
||||
|
||||
private String getRemoteAddress(Channel channel) {
|
||||
return channel.getRemoteAddress().toString().substring(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doInAfterTrace(RecordableTrace trace, Object target, Object[] args, Object result, Throwable throwable) {
|
||||
|
||||
if (trace.canSampled()) {
|
||||
org.jboss.netty.channel.MessageEvent e = getMessageEvent.invoke(target);
|
||||
|
||||
if (e != null) {
|
||||
recordHttpParameter2(trace, e);
|
||||
}
|
||||
|
||||
trace.recordApi(getMethodDescriptor());
|
||||
}
|
||||
trace.recordException(throwable);
|
||||
trace.markAfterTime();
|
||||
|
||||
}
|
||||
|
||||
private void recordHttpParameter2(RecordableTrace trace, MessageEvent e) {
|
||||
final Object message = e.getMessage();
|
||||
if (message instanceof org.jboss.netty.handler.codec.http.HttpRequest) {
|
||||
final org.jboss.netty.handler.codec.http.HttpRequest request = (org.jboss.netty.handler.codec.http.HttpRequest) message;
|
||||
HttpMethod reqMethod = request.getMethod();
|
||||
|
||||
if (reqMethod.equals(HttpMethod.POST) || reqMethod.equals(HttpMethod.PUT) || reqMethod.equals(HttpMethod.DELETE)) {
|
||||
ChannelBuffer content = request.getContent();
|
||||
if (content.readable()) {
|
||||
// FIXME request body type에 따른 처리가 필요함.
|
||||
// HttpPostRequestDecoder
|
||||
int contentSize = content.array().length;
|
||||
if (contentSize > entityDumpSize) {
|
||||
contentSize = entityDumpSize;
|
||||
}
|
||||
// netty 3.9 면 getHeader가 deprecated 되었다. 추후 없어질수는 있기는 한데 일단 동작에 문제가 없는듯 함.
|
||||
final Charset charset = getCharset(request);
|
||||
String bodyStr = content.toString(0, contentSize, charset);
|
||||
if (bodyStr != null && bodyStr.length() > 0) {
|
||||
trace.recordAttribute(AnnotationKey.HTTP_PARAM_ENTITY, bodyStr);
|
||||
}
|
||||
}
|
||||
} else if (reqMethod.equals(HttpMethod.GET)) {
|
||||
// String parameters = getRequestParameter_old(request, 64,
|
||||
// 512);
|
||||
String parameters = getRequestParameter(request, paramDumpSize);
|
||||
if (parameters != null && parameters.length() > 0) {
|
||||
trace.recordAttribute(AnnotationKey.HTTP_PARAM, parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// buffer index를 정확하게 계산하는 로직이나 before에서 데이터를 읽어야 함.
|
||||
private void recordHttpParameter(Trace trace, MessageEvent e) {
|
||||
final Object message = e.getMessage();
|
||||
if (message instanceof org.jboss.netty.handler.codec.http.HttpRequest) {
|
||||
final org.jboss.netty.handler.codec.http.HttpRequest request = (org.jboss.netty.handler.codec.http.HttpRequest) message;
|
||||
|
||||
final HttpMethod reqMethod = request.getMethod();
|
||||
|
||||
if (equalMethod(HttpMethod.POST, reqMethod) || equalMethod(HttpMethod.PUT, reqMethod) || equalMethod(HttpMethod.DELETE, reqMethod)) {
|
||||
ChannelBuffer content = request.getContent();
|
||||
int contentSize = content.readableBytes();
|
||||
if (contentSize > 0) {
|
||||
// FIXME request body type에 따른 처리가 필요함.
|
||||
// HttpPostRequestDecoder
|
||||
if (contentSize > entityDumpSize) {
|
||||
contentSize = entityDumpSize;
|
||||
}
|
||||
final Charset charset = getCharset(request);
|
||||
|
||||
// 해당 메소드의 경우 readerIndex를 after에서 읽을경우 다음으로 갈수 있음.
|
||||
String bodyStr = content.toString(content.readerIndex(), contentSize, charset);
|
||||
if (bodyStr != null && bodyStr.length() > 0) {
|
||||
trace.recordAttribute(AnnotationKey.HTTP_PARAM_ENTITY, bodyStr);
|
||||
}
|
||||
}
|
||||
} else if (equalMethod(HttpMethod.GET, reqMethod)) {
|
||||
// String parameters = getRequestParameter_old(request, 64,
|
||||
// 512);
|
||||
String parameters = getRequestParameter(request, paramDumpSize);
|
||||
if (parameters != null && parameters.length() > 0) {
|
||||
trace.recordAttribute(AnnotationKey.HTTP_PARAM, parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Charset getCharset(HttpRequest request) {
|
||||
return CharsetUtil.UTF_8;
|
||||
// http 스펙상으로는 아래가 맞긴한데. 강제 설정 변경수가 있어서. 아래 처럼할 경우 문제가 생길수 있는것 같음.
|
||||
// 코드에 utf8로 박혀 있으면 그냥 UTF-8로 하는게 더 안전할듯함.
|
||||
// // netty 3.9 면 getHeader가 deprecated 되었다. 추후 없어질수는 있기는 한데 일단 동작에 문제가 없는듯 함.
|
||||
// final String contentTypeValue = request.getHeader("Content-Type");
|
||||
// // charset.forName을 부르는게 그렇게 좋지는 않은것 같음.
|
||||
// return Charset.forName(HttpUtils.parseContentTypeCharset(contentTypeValue, DEFAULT_CHARSET));
|
||||
}
|
||||
|
||||
|
||||
private boolean equalMethod(HttpMethod thisMethod, HttpMethod thatMethod) {
|
||||
if (thatMethod == null) {
|
||||
return false;
|
||||
}
|
||||
return thisMethod.getName().equals(thatMethod.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* request header에 sampling 정보가 포함되어있는지 확인.
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
private boolean isSamplingEnabled(final org.jboss.netty.handler.codec.http.HttpRequest request) {
|
||||
String samplingFlag = request.getHeader(Header.HTTP_SAMPLED.toString());
|
||||
if (isDebug) {
|
||||
logger.debug("SamplingFlag:{}", samplingFlag);
|
||||
}
|
||||
return SamplingFlagUtils.isSamplingFlag(samplingFlag);
|
||||
}
|
||||
|
||||
/**
|
||||
* request header에서 traceid를 뽑아낸다.
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
private TraceId populateTraceIdFromRequest(final org.jboss.netty.handler.codec.http.HttpRequest request) {
|
||||
String transactionId = request.getHeader(Header.HTTP_TRACE_ID.toString());
|
||||
if (transactionId != null) {
|
||||
|
||||
long parentSpanID = NumberUtils.parseLong(request.getHeader(Header.HTTP_PARENT_SPAN_ID.toString()), SpanId.NULL);
|
||||
long spanID = NumberUtils.parseLong(request.getHeader(Header.HTTP_SPAN_ID.toString()), SpanId.NULL);
|
||||
short flags = NumberUtils.parseShort(request.getHeader(Header.HTTP_FLAGS.toString()), (short) 0);
|
||||
|
||||
TraceId id = getTraceContext().createTraceId(transactionId, parentSpanID, spanID, flags);
|
||||
if (isDebug) {
|
||||
logger.debug("TraceID exist. continue trace. {}", id);
|
||||
}
|
||||
return id;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* request header에서 parent application name 추출
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
private String populateParentApplicationNameFromRequest(final org.jboss.netty.handler.codec.http.HttpRequest request) {
|
||||
return request.getHeader(Header.HTTP_PARENT_APPLICATION_NAME.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* request header에서 parent application type 추출
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
private short populateParentApplicationTypeFromRequest(final org.jboss.netty.handler.codec.http.HttpRequest request) {
|
||||
String type = request.getHeader(Header.HTTP_PARENT_APPLICATION_TYPE.toString());
|
||||
if (type != null) {
|
||||
return Short.valueOf(type);
|
||||
}
|
||||
return ServiceType.UNDEFINED.getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* request uri에서 query string 추출 (복잡한 처리 없이 그냥 ? 뒤로 붙어있는 문자열만 추출.)
|
||||
*
|
||||
* @param request
|
||||
* @param totalLimit
|
||||
* @return
|
||||
*/
|
||||
private String getRequestParameter(final org.jboss.netty.handler.codec.http.HttpRequest request, int totalLimit) {
|
||||
String uri = request.getUri();
|
||||
|
||||
if (uri == null || uri.length() < 2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int pos = uri.indexOf("?") + 1;
|
||||
|
||||
if (pos > 1 && pos < uri.length()) {
|
||||
return StringUtils.drop(uri.substring(pos), totalLimit);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* request uri에서 querystring 추출
|
||||
*
|
||||
* @param request
|
||||
* @param eachLimit
|
||||
* @param totalLimit
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
private String getRequestParameter_old(final org.jboss.netty.handler.codec.http.HttpRequest request, int eachLimit, int totalLimit) {
|
||||
QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.getUri());
|
||||
Map<String, List<String>> queries = queryStringDecoder.getParameters();
|
||||
|
||||
if (queries.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder params = new StringBuilder(64);
|
||||
Iterator<Entry<String, List<String>>> entryIterator = queries.entrySet().iterator();
|
||||
|
||||
while (entryIterator.hasNext()) {
|
||||
Entry<String, List<String>> entry = entryIterator.next();
|
||||
|
||||
params.append(entry.getKey());
|
||||
params.append("=");
|
||||
|
||||
List<String> values = entry.getValue();
|
||||
|
||||
if (values.size() > 1) {
|
||||
Iterator<String> valueIterator = values.iterator();
|
||||
while (valueIterator.hasNext()) {
|
||||
params.append(StringUtils.drop(valueIterator.next(), eachLimit));
|
||||
if (valueIterator.hasNext()) {
|
||||
params.append(",");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
params.append(StringUtils.drop(values.get(0), eachLimit));
|
||||
}
|
||||
|
||||
if (params.length() > totalLimit) {
|
||||
if (entryIterator.hasNext()) {
|
||||
params.append("...");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (entryIterator.hasNext()) {
|
||||
params.append("&");
|
||||
}
|
||||
}
|
||||
|
||||
return params.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setTraceContext(TraceContext traceContext) {
|
||||
super.setTraceContext(traceContext);
|
||||
|
||||
final ProfilerConfig profilerConfig = traceContext.getProfilerConfig();
|
||||
|
||||
this.paramDumpSize = profilerConfig.getLineGameNettyParamDumpSize();
|
||||
this.entityDumpSize = profilerConfig.getLineGameNettyEntityDumpSize();
|
||||
}
|
||||
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.NotFoundInstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
|
||||
/**
|
||||
* jedis(redis client) modifier
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class BinaryJedisModifier extends JedisModifier {
|
||||
|
||||
public BinaryJedisModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "redis/clients/jedis/BinaryJedis";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void beforeAddInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws NotFoundInstrumentException, InstrumentException {
|
||||
// trace endPoint.
|
||||
instrumentClass.addTraceValue(MapTraceValue.class);
|
||||
}
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
|
||||
/**
|
||||
* RedisCluster(nBase-ARC client) modifier
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class BinaryRedisClusterModifier extends RedisClusterModifier {
|
||||
|
||||
public BinaryRedisClusterModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/redis/cluster/BinaryRedisCluster";
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.NotFoundInstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
|
||||
/**
|
||||
* RedisCluster(nBase-ARC client) modifier
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class BinaryTriplesRedisClusterModifier extends RedisClusterModifier {
|
||||
|
||||
public BinaryTriplesRedisClusterModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/redis/cluster/triples/BinaryTriplesRedisCluster";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void beforeAddInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws NotFoundInstrumentException, InstrumentException {
|
||||
// trace destinationId, endPoint
|
||||
instrumentClass.addTraceValue(MapTraceValue.class);
|
||||
}
|
||||
}
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.MethodInfo;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
|
||||
/**
|
||||
* Gateway(nBase-ARC client) modifier
|
||||
* - trace destinationId
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class GatewayModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public GatewayModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/redis/cluster/gateway/Gateway";
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] modify(ClassLoader classLoader, String className, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", className);
|
||||
}
|
||||
|
||||
try {
|
||||
final InstrumentClass instrumentClass = byteCodeInstrumentor.getClass(classLoader, className, classFileBuffer);
|
||||
|
||||
// trace destinationId
|
||||
instrumentClass.addTraceValue(MapTraceValue.class);
|
||||
final Interceptor constructorInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.redis.interceptor.GatewayConstructorInterceptor");
|
||||
instrumentClass.addConstructorInterceptor(new String[] { "com.nhncorp.redis.cluster.gateway.GatewayConfig" }, constructorInterceptor);
|
||||
|
||||
// method
|
||||
final List<MethodInfo> declaredMethods = instrumentClass.getDeclaredMethods();
|
||||
for (MethodInfo method : declaredMethods) {
|
||||
if (method.getName().equals("getServer")) {
|
||||
final Interceptor methodInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.redis.interceptor.GatewayMethodInterceptor");
|
||||
instrumentClass.addInterceptor(method.getName(), method.getParameterTypes(), methodInterceptor);
|
||||
}
|
||||
}
|
||||
|
||||
return instrumentClass.toBytecode();
|
||||
} catch (Exception e) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to modifier. caused={}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.MethodInfo;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
|
||||
/**
|
||||
* RedisCluster(nBase-ARC client) modifier
|
||||
* - trace destinationId
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class GatewayServerModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public GatewayServerModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/redis/cluster/gateway/GatewayServer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] modify(ClassLoader classLoader, String className, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", className);
|
||||
}
|
||||
|
||||
try {
|
||||
final InstrumentClass instrumentClass = byteCodeInstrumentor.getClass(classLoader, className, classFileBuffer);
|
||||
|
||||
// trace destinationId
|
||||
instrumentClass.addTraceValue(MapTraceValue.class);
|
||||
|
||||
// method
|
||||
final List<MethodInfo> declaredMethods = instrumentClass.getDeclaredMethods();
|
||||
for (MethodInfo method : declaredMethods) {
|
||||
if (method.getName().equals("getResource")) {
|
||||
final Interceptor methodInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.redis.interceptor.GatewayServerMethodInterceptor");
|
||||
instrumentClass.addInterceptor(method.getName(), method.getParameterTypes(), methodInterceptor);
|
||||
}
|
||||
}
|
||||
|
||||
return instrumentClass.toBytecode();
|
||||
} catch (Exception e) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to modifier. caused={}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
|
||||
/**
|
||||
* jedis(redis client) Client modifier
|
||||
* - trace endPoint
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class JedisClientModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public JedisClientModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "redis/clients/jedis/Client";
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] modify(ClassLoader classLoader, String className, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", className);
|
||||
}
|
||||
|
||||
try {
|
||||
final InstrumentClass instrumentClass = byteCodeInstrumentor.getClass(classLoader, className, classFileBuffer);
|
||||
|
||||
// trace endPoint
|
||||
instrumentClass.addTraceValue(MapTraceValue.class);
|
||||
|
||||
final Interceptor constructorInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.redis.interceptor.JedisClientConstructorInterceptor");
|
||||
instrumentClass.addConstructorInterceptor(new String[] { "java.lang.String" }, constructorInterceptor);
|
||||
instrumentClass.addConstructorInterceptor(new String[] { "java.lang.String", "int" }, constructorInterceptor);
|
||||
|
||||
return instrumentClass.toBytecode();
|
||||
} catch (Exception e) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to modifier. caused={}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
-93
@@ -1,93 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.MethodInfo;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.NotFoundInstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.filter.JedisMethodNames;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.filter.NameBasedMethodFilter;
|
||||
|
||||
/**
|
||||
* jedis(redis client) modifier
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class JedisModifier extends AbstractModifier {
|
||||
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public JedisModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "redis/clients/jedis/Jedis";
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] modify(ClassLoader classLoader, String className, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", className);
|
||||
}
|
||||
|
||||
try {
|
||||
final InstrumentClass instrumentClass = byteCodeInstrumentor.getClass(classLoader, className, classFileBuffer);
|
||||
|
||||
beforeAddInterceptor(classLoader, protectedDomain, instrumentClass);
|
||||
|
||||
// add constructor
|
||||
addConstructorInterceptor(classLoader, protectedDomain, instrumentClass);
|
||||
|
||||
// add method
|
||||
addMethodInterceptor(classLoader, protectedDomain, instrumentClass);
|
||||
|
||||
return instrumentClass.toBytecode();
|
||||
} catch (Exception e) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to modifier. caused={}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void beforeAddInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws NotFoundInstrumentException, InstrumentException {
|
||||
// nothing
|
||||
}
|
||||
|
||||
protected void addConstructorInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws InstrumentException, NotFoundInstrumentException {
|
||||
final Interceptor constructorInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.redis.interceptor.JedisConstructorInterceptor");
|
||||
instrumentClass.addConstructorInterceptor(new String[] { "java.lang.String" }, constructorInterceptor);
|
||||
try {
|
||||
instrumentClass.addConstructorInterceptor(new String[] { "java.lang.String", "int" }, constructorInterceptor);
|
||||
instrumentClass.addConstructorInterceptor(new String[] { "java.lang.String", "int", "int" }, constructorInterceptor);
|
||||
instrumentClass.addConstructorInterceptor(new String[] { "java.net.URI" }, constructorInterceptor);
|
||||
instrumentClass.addConstructorInterceptor(new String[] { "redis.clients.jedis.JedisShardInfo" }, constructorInterceptor);
|
||||
} catch (Exception e) {
|
||||
// backward compatibility error
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to add constructor interceptor('not found redis.clients.jedis.JedisShardInfo' is compatibility error). caused={}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void addMethodInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws NotFoundInstrumentException, InstrumentException {
|
||||
final List<MethodInfo> declaredMethods = instrumentClass.getDeclaredMethods(new NameBasedMethodFilter(JedisMethodNames.get()));
|
||||
for (MethodInfo method : declaredMethods) {
|
||||
final Interceptor methodInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.redis.interceptor.JedisMethodInterceptor");
|
||||
instrumentClass.addInterceptor(method.getName(), method.getParameterTypes(), methodInterceptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
|
||||
/**
|
||||
* jedis(redis client) pipeline modifier
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class JedisMultiKeyPipelineBaseModifier extends JedisPipelineBaseModifier {
|
||||
|
||||
public JedisMultiKeyPipelineBaseModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "redis/clients/jedis/MultiKeyPipelineBase";
|
||||
}
|
||||
}
|
||||
-74
@@ -1,74 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.MethodInfo;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.NotFoundInstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.filter.JedisPipelineMethodNames;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.filter.NameBasedMethodFilter;
|
||||
|
||||
/**
|
||||
* jedis(redis client) pipeline modifier
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class JedisPipelineBaseModifier extends AbstractModifier {
|
||||
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public JedisPipelineBaseModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "redis/clients/jedis/PipelineBase";
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] modify(ClassLoader classLoader, String className, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", className);
|
||||
}
|
||||
|
||||
try {
|
||||
final InstrumentClass instrumentClass = byteCodeInstrumentor.getClass(classLoader, className, classFileBuffer);
|
||||
|
||||
beforeAddInterceptor(classLoader, protectedDomain, instrumentClass);
|
||||
|
||||
// method
|
||||
addMethodInterceptor(classLoader, protectedDomain, instrumentClass);
|
||||
|
||||
return instrumentClass.toBytecode();
|
||||
} catch (Exception e) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to modifier. caused={}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void beforeAddInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws NotFoundInstrumentException, InstrumentException {
|
||||
// nothing
|
||||
}
|
||||
|
||||
protected void addMethodInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws NotFoundInstrumentException, InstrumentException {
|
||||
final List<MethodInfo> declaredMethods = instrumentClass.getDeclaredMethods(new NameBasedMethodFilter(JedisPipelineMethodNames.get()));
|
||||
for (MethodInfo method : declaredMethods) {
|
||||
final Interceptor methodInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.redis.interceptor.JedisPipelineMethodInterceptor");
|
||||
instrumentClass.addInterceptor(method.getName(), method.getParameterTypes(), methodInterceptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.MethodInfo;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.NotFoundInstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
|
||||
/**
|
||||
* jedis(redis client) pipeline modifier
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class JedisPipelineModifier extends JedisPipelineBaseModifier {
|
||||
|
||||
public JedisPipelineModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "redis/clients/jedis/Pipeline";
|
||||
}
|
||||
|
||||
protected void beforeAddInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws NotFoundInstrumentException, InstrumentException {
|
||||
// trace endPoint
|
||||
instrumentClass.addTraceValue(MapTraceValue.class);
|
||||
|
||||
addConstructorInterceptor(classLoader, protectedDomain, instrumentClass);
|
||||
addSetClientMethodInterceptor(classLoader, protectedDomain, instrumentClass);
|
||||
}
|
||||
|
||||
private void addSetClientMethodInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws NotFoundInstrumentException, InstrumentException {
|
||||
for (MethodInfo method : instrumentClass.getDeclaredMethods()) {
|
||||
if (method.getName().equals("setClient")) {
|
||||
// jedis 2.x
|
||||
final Interceptor methodInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.redis.interceptor.JedisPipelineSetClientMethodInterceptor");
|
||||
instrumentClass.addInterceptor("setClient", new String[] { "redis.clients.jedis.Client" }, methodInterceptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addConstructorInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws InstrumentException {
|
||||
final Interceptor constructorInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.redis.interceptor.JedisPipelineConstructorInterceptor");
|
||||
try {
|
||||
// jedis 1.x
|
||||
instrumentClass.addConstructorInterceptor(new String[] { "redis.clients.jedis.Client" }, constructorInterceptor);
|
||||
} catch (Exception e) {
|
||||
// backward compatibility error
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to add constructor interceptor(only jedis 1.x). caused={}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-90
@@ -1,90 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.MethodInfo;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.NotFoundInstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.filter.NameBasedMethodFilter;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.filter.RedisClusterMethodNames;
|
||||
|
||||
/**
|
||||
* RedisCluster(nBase-ARC client) modifier
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class RedisClusterModifier extends AbstractModifier {
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public RedisClusterModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/redis/cluster/RedisCluster";
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] modify(ClassLoader classLoader, String className, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", className);
|
||||
}
|
||||
|
||||
try {
|
||||
final InstrumentClass instrumentClass = byteCodeInstrumentor.getClass(classLoader, className, classFileBuffer);
|
||||
|
||||
beforeAddInterceptor(classLoader, protectedDomain, instrumentClass);
|
||||
|
||||
// add constructor
|
||||
addConstructorInterceptor(classLoader, protectedDomain, instrumentClass);
|
||||
|
||||
// method
|
||||
addMethodInterceptor(classLoader, protectedDomain, instrumentClass);
|
||||
|
||||
return instrumentClass.toBytecode();
|
||||
} catch (Exception e) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to modifier. caused={}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void beforeAddInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws InstrumentException {
|
||||
// nothing
|
||||
}
|
||||
|
||||
protected void addMethodInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws InstrumentException {
|
||||
final List<MethodInfo> declaredMethods = instrumentClass.getDeclaredMethods(new NameBasedMethodFilter(RedisClusterMethodNames.get()));
|
||||
for (MethodInfo method : declaredMethods) {
|
||||
try {
|
||||
final Interceptor methodInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.redis.interceptor.RedisClusterMethodInterceptor");
|
||||
instrumentClass.addInterceptor(method.getName(), method.getParameterTypes(), methodInterceptor);
|
||||
} catch (Exception e) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to add method interceptor('not found ...' is jedis compatibility error). caused={}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void addConstructorInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws InstrumentException, NotFoundInstrumentException {
|
||||
final Interceptor constructorInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.redis.interceptor.RedisClusterConstructorInterceptor");
|
||||
instrumentClass.addConstructorInterceptor(new String[]{"java.lang.String"}, constructorInterceptor);
|
||||
instrumentClass.addConstructorInterceptor(new String[] { "java.lang.String", "int" }, constructorInterceptor);
|
||||
instrumentClass.addConstructorInterceptor(new String[] { "java.lang.String", "int", "int" }, constructorInterceptor);
|
||||
}
|
||||
}
|
||||
-91
@@ -1,91 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentClass;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.InstrumentException;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.MethodInfo;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.filter.NameBasedMethodFilter;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.filter.RedisClusterPipelineMethodNames;
|
||||
|
||||
/**
|
||||
* RedisCluster(nBase-ARC client) pipeline modifier
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class RedisClusterPipelineModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public RedisClusterPipelineModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/redis/cluster/pipeline/RedisClusterPipeline";
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] modify(ClassLoader classLoader, String className, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", className);
|
||||
}
|
||||
|
||||
try {
|
||||
final InstrumentClass instrumentClass = byteCodeInstrumentor.getClass(classLoader, className, classFileBuffer);
|
||||
|
||||
// trace destinationId, endPoint
|
||||
instrumentClass.addTraceValue(MapTraceValue.class);
|
||||
|
||||
addConstructorInterceptor(classLoader, protectedDomain, instrumentClass);
|
||||
|
||||
// method
|
||||
addMethodInterceptor(classLoader, protectedDomain, instrumentClass);
|
||||
|
||||
return instrumentClass.toBytecode();
|
||||
} catch (Exception e) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to modifier. caused={}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void addConstructorInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws InstrumentException {
|
||||
final Interceptor constructorInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.redis.interceptor.RedisClusterPipelineConstructorInterceptor");
|
||||
try {
|
||||
instrumentClass.addConstructorInterceptor(new String[] { "com.nhncorp.redis.cluster.gateway.GatewayServer" }, constructorInterceptor);
|
||||
} catch (Exception e) {
|
||||
// backward compatibility error
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to add constructor interceptor. caused={}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void addMethodInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws InstrumentException {
|
||||
final List<MethodInfo> declaredMethods = instrumentClass.getDeclaredMethods(new NameBasedMethodFilter(RedisClusterPipelineMethodNames.get()));
|
||||
for (MethodInfo method : declaredMethods) {
|
||||
try {
|
||||
final Interceptor methodInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.redis.interceptor.RedisClusterPipelineMethodInterceptor");
|
||||
instrumentClass.addInterceptor(method.getName(), method.getParameterTypes(), methodInterceptor);
|
||||
} catch (Exception e) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to add method interceptor('not found ...' is jedis compatibility error). caused={}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.ByteCodeInstrumentor;
|
||||
|
||||
/**
|
||||
* RedisCluster(nBase-ARC client) modifier
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class TriplesRedisClusterModifier extends RedisClusterModifier {
|
||||
|
||||
public TriplesRedisClusterModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/redis/cluster/triples/TriplesRedisCluster";
|
||||
}
|
||||
}
|
||||
-188
@@ -1,188 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis.filter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Jedis method names
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class JedisMethodNames {
|
||||
|
||||
private static Set<String> names = null;
|
||||
|
||||
|
||||
public static Set<String> get() {
|
||||
if(names != null) {
|
||||
return names;
|
||||
}
|
||||
|
||||
final String[] methodNames = {
|
||||
"get",
|
||||
"type",
|
||||
"append",
|
||||
"keys",
|
||||
"set",
|
||||
"exists",
|
||||
"sort",
|
||||
"rename",
|
||||
"hvals",
|
||||
"scan",
|
||||
"hexists",
|
||||
"hmget",
|
||||
"hincrBy",
|
||||
"del",
|
||||
"randomKey",
|
||||
"renamenx",
|
||||
"expire",
|
||||
"expireAt",
|
||||
"move",
|
||||
"ttl",
|
||||
"mget",
|
||||
"getSet",
|
||||
"setnx",
|
||||
"mset",
|
||||
"setex",
|
||||
"hlen",
|
||||
"hkeys",
|
||||
"hdel",
|
||||
"zrangeWithScores",
|
||||
"zrevrangeWithScores",
|
||||
"zrangeByScoreWithScores",
|
||||
"zrevrangeByScore",
|
||||
"zrevrangeByScoreWithScores",
|
||||
"zremrangeByRank",
|
||||
"zremrangeByScore",
|
||||
"objectRefcount",
|
||||
"objectEncoding",
|
||||
"objectIdletime",
|
||||
"incrBy",
|
||||
"decr",
|
||||
"incr",
|
||||
"decrBy",
|
||||
"msetnx",
|
||||
"hset",
|
||||
"substr",
|
||||
"hget",
|
||||
"hsetnx",
|
||||
"hmset",
|
||||
"hgetAll",
|
||||
"rpush",
|
||||
"lpush",
|
||||
"llen",
|
||||
"lrange",
|
||||
"ltrim",
|
||||
"lindex",
|
||||
"lset",
|
||||
"lrem",
|
||||
"lpop",
|
||||
"rpop",
|
||||
"rpoplpush",
|
||||
"sadd",
|
||||
"smembers",
|
||||
"srem",
|
||||
"spop",
|
||||
"smove",
|
||||
"scard",
|
||||
"sismember",
|
||||
"sinter",
|
||||
"sinterstore",
|
||||
"sunion",
|
||||
"sunionstore",
|
||||
"sdiff",
|
||||
"sdiffstore",
|
||||
"srandmember",
|
||||
"zadd",
|
||||
"zrange",
|
||||
"zrem",
|
||||
"zincrby",
|
||||
"zrank",
|
||||
"zrevrank",
|
||||
"zrevrange",
|
||||
"zcard",
|
||||
"zscore",
|
||||
"watch",
|
||||
"blpop",
|
||||
"brpop",
|
||||
"zcount",
|
||||
"zrangeByScore",
|
||||
"zunionstore",
|
||||
"zinterstore",
|
||||
"strlen",
|
||||
"lpushx",
|
||||
"persist",
|
||||
"rpushx",
|
||||
"echo",
|
||||
"linsert",
|
||||
"brpoplpush",
|
||||
"setbit",
|
||||
"getbit",
|
||||
"setrange",
|
||||
"getrange",
|
||||
"configGet",
|
||||
"configSet",
|
||||
"eval",
|
||||
"subscribe",
|
||||
"publish",
|
||||
"psubscribe",
|
||||
"evalsha",
|
||||
"scriptExists",
|
||||
"scriptLoad",
|
||||
"slowlogGet",
|
||||
"bitcount",
|
||||
"bitop",
|
||||
"dump",
|
||||
"restore",
|
||||
"pexpire",
|
||||
"pexpireAt",
|
||||
"pttl",
|
||||
"incrByFloat",
|
||||
"psetex",
|
||||
"clientKill",
|
||||
"clientSetname",
|
||||
"migrate",
|
||||
"hincrByFloat",
|
||||
"hscan",
|
||||
"sscan",
|
||||
"zscan",
|
||||
"shutdown",
|
||||
"debug",
|
||||
"save",
|
||||
"sync",
|
||||
"time",
|
||||
"select",
|
||||
"resetState",
|
||||
"configResetStat",
|
||||
"randomBinaryKey",
|
||||
"monitor",
|
||||
"unwatch",
|
||||
"slowlogReset",
|
||||
"slowlogLen",
|
||||
"ping",
|
||||
"quit",
|
||||
"flushDB",
|
||||
"dbSize",
|
||||
"flushAll",
|
||||
"auth",
|
||||
"bgsave",
|
||||
"bgrewriteaof",
|
||||
"lastsave",
|
||||
"slaveof",
|
||||
"slaveofNoOne",
|
||||
"getDB",
|
||||
"multi",
|
||||
"scriptFlush",
|
||||
"scriptKill",
|
||||
"clientGetname",
|
||||
"clientList",
|
||||
"slowlogGetBinary",
|
||||
"info"
|
||||
};
|
||||
|
||||
names = new HashSet<String>(Arrays.asList(methodNames));
|
||||
return names;
|
||||
}
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis.filter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* JedisPipeline method names
|
||||
* - jedis method names + pipeline method names
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class JedisPipelineMethodNames {
|
||||
|
||||
private static Set<String> names = null;
|
||||
|
||||
public static Set<String> get() {
|
||||
if(names != null) {
|
||||
return names;
|
||||
}
|
||||
|
||||
final String[] methodNames = {
|
||||
"sync",
|
||||
"syncAndReturnAll"
|
||||
};
|
||||
|
||||
final Set<String> jedisMethoNames = JedisMethodNames.get();
|
||||
jedisMethoNames.addAll(Arrays.asList(methodNames));
|
||||
names = jedisMethoNames;
|
||||
|
||||
return names;
|
||||
}
|
||||
}
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis.filter;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Set;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.instrument.MethodInfo;
|
||||
import com.nhn.pinpoint.bootstrap.instrument.MethodFilter;
|
||||
|
||||
/**
|
||||
* Name based on method filter
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class NameBasedMethodFilter implements MethodFilter {
|
||||
private static final int SYNTHETIC = 0x00001000;
|
||||
private final Set<String> methodNames;
|
||||
|
||||
public NameBasedMethodFilter(final Set<String> methodNames) {
|
||||
this.methodNames = methodNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean filter(MethodInfo ctMethod) {
|
||||
final int modifiers = ctMethod.getModifiers();
|
||||
|
||||
if (isSynthetic(modifiers) || !Modifier.isPublic(modifiers) || Modifier.isStatic(modifiers) || Modifier.isAbstract(modifiers) || Modifier.isNative(modifiers)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (methodNames.contains(ctMethod.getName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isSynthetic(int mod) {
|
||||
return (mod & SYNTHETIC) != 0;
|
||||
}
|
||||
}
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis.filter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* RedisClusterPipeline method names
|
||||
* - jedis method names + RedisCluster method names
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class RedisClusterMethodNames {
|
||||
|
||||
private static Set<String> names = null;
|
||||
|
||||
public static Set<String> get() {
|
||||
if(names != null) {
|
||||
return names;
|
||||
}
|
||||
|
||||
final String[] methodNames = {
|
||||
"zadd2",
|
||||
"slkeys",
|
||||
"slget",
|
||||
"slmget",
|
||||
"sladd",
|
||||
"sladdAt",
|
||||
"slset",
|
||||
"sldel",
|
||||
"slrem",
|
||||
"slcount",
|
||||
"slexists",
|
||||
"slexpire",
|
||||
"slttl",
|
||||
"ssget",
|
||||
"ssmget",
|
||||
"sskeys",
|
||||
"ssadd",
|
||||
"ssaddAt",
|
||||
"ssset",
|
||||
"ssdel",
|
||||
"ssrem",
|
||||
"sscount",
|
||||
"ssexists",
|
||||
"ssexpire",
|
||||
"ssttl"
|
||||
};
|
||||
|
||||
final Set<String> jedisMethodNames = JedisMethodNames.get();
|
||||
jedisMethodNames.addAll(Arrays.asList(methodNames));
|
||||
names = jedisMethodNames;
|
||||
|
||||
return names;
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis.filter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* RedisClusterPipeline method names
|
||||
* - RedisCluster method names + pipeline method names
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class RedisClusterPipelineMethodNames {
|
||||
|
||||
private static Set<String> names = null;
|
||||
|
||||
public static Set<String> get() {
|
||||
if(names != null) {
|
||||
return names;
|
||||
}
|
||||
|
||||
final String[] methodNames = {
|
||||
"sync",
|
||||
"syncAndReturnAll",
|
||||
"close"
|
||||
};
|
||||
|
||||
final Set<String> redisClusterMethodNames = RedisClusterMethodNames.get();
|
||||
redisClusterMethodNames.addAll(Arrays.asList(methodNames));
|
||||
names = redisClusterMethodNames;
|
||||
|
||||
return names;
|
||||
}
|
||||
}
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis.interceptor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
import com.nhncorp.redis.cluster.gateway.GatewayConfig;
|
||||
|
||||
/**
|
||||
* Gateway(nBase-ARC client) constructor interceptor - trace destinationId
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class GatewayConstructorInterceptor implements SimpleAroundInterceptor, TargetClassLoader {
|
||||
|
||||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
if (isDebug) {
|
||||
logger.beforeInterceptor(target, args);
|
||||
}
|
||||
|
||||
if (!(target instanceof MapTraceValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Map<String, Object> traceValue = new HashMap<String, Object>();
|
||||
try {
|
||||
final GatewayConfig config = (GatewayConfig) args[0];
|
||||
if (config.getDomainAddress() != null) {
|
||||
traceValue.put("destinationId", config.getDomainAddress());
|
||||
} else if (config.getIpAddress() != null) {
|
||||
traceValue.put("destinationId", config.getIpAddress());
|
||||
} else if (config.getClusterName() != null) {
|
||||
// over 1.1.x
|
||||
traceValue.put("destinationId", config.getClusterName());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// backward compatibility error or expect 'class not found exception - GatewayConfig'
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to trace destinationId('not found getClusterName' is compatibility error). caused={}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
((MapTraceValue) target).__setTraceBindValue(traceValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis.interceptor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
|
||||
/**
|
||||
* Gateway(nBase-ARC client) getServer() method interceptor
|
||||
* - trace destinationId
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class GatewayMethodInterceptor implements SimpleAroundInterceptor, TargetClassLoader {
|
||||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
if (isDebug) {
|
||||
logger.beforeInterceptor(target, args);
|
||||
}
|
||||
|
||||
if (!(target instanceof MapTraceValue) || result == null || !(result instanceof MapTraceValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// result - GatewayServer
|
||||
final Map<String, Object> gatewayTraceValue = ((MapTraceValue) target).__getTraceBindValue();
|
||||
if (gatewayTraceValue != null) {
|
||||
final Map<String, Object> traceValue = new HashMap<String, Object>();
|
||||
// copy to destinationId
|
||||
traceValue.put("destinationId", gatewayTraceValue.get("destinationId"));
|
||||
((MapTraceValue) result).__setTraceBindValue(traceValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis.interceptor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
|
||||
/**
|
||||
* GatewayServer(nBase-ARC client) getResource() method interceptor
|
||||
* - trace destinationId
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class GatewayServerMethodInterceptor implements SimpleAroundInterceptor, TargetClassLoader {
|
||||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
if (isDebug) {
|
||||
logger.beforeInterceptor(target, args);
|
||||
}
|
||||
|
||||
if (!(target instanceof MapTraceValue) || result == null || !(result instanceof MapTraceValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// result - RedisCluster
|
||||
final Map<String, Object> gatewayServerTraceValue = ((MapTraceValue) target).__getTraceBindValue();
|
||||
if (gatewayServerTraceValue != null) {
|
||||
final Map<String, Object> traceValue = ((MapTraceValue) result).__getTraceBindValue();
|
||||
// copy to destinationId
|
||||
if (traceValue != null) {
|
||||
traceValue.put("destinationId", gatewayServerTraceValue.get("destinationId"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis.interceptor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
|
||||
/**
|
||||
* Jedis client(redis client) constructor interceptor
|
||||
* - trace endPoint
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class JedisClientConstructorInterceptor implements SimpleAroundInterceptor, TargetClassLoader {
|
||||
|
||||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
if (isDebug) {
|
||||
logger.beforeInterceptor(target, args);
|
||||
}
|
||||
|
||||
// trace endPoint
|
||||
if (!(target instanceof MapTraceValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final StringBuilder endPoint = new StringBuilder();
|
||||
// first arg - host
|
||||
if (args[0] instanceof String) {
|
||||
endPoint.append(args[0]);
|
||||
|
||||
// second arg - port
|
||||
if (args.length >= 2 && args[1] instanceof Integer) {
|
||||
endPoint.append(":").append(args[1]);
|
||||
} else {
|
||||
// default port
|
||||
endPoint.append(":").append(6379);
|
||||
}
|
||||
}
|
||||
|
||||
final Map<String, Object> traceValue = new HashMap<String, Object>();
|
||||
traceValue.put("endPoint", endPoint.toString());
|
||||
((MapTraceValue) target).__setTraceBindValue(traceValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
}
|
||||
}
|
||||
-76
@@ -1,76 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis.interceptor;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import redis.clients.jedis.JedisShardInfo;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
|
||||
/**
|
||||
* Jedis (redis client) constructor interceptor
|
||||
* - trace endPoint
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class JedisConstructorInterceptor implements SimpleAroundInterceptor, TargetClassLoader {
|
||||
|
||||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
if (isDebug) {
|
||||
logger.beforeInterceptor(target, args);
|
||||
}
|
||||
|
||||
// trace endPoint
|
||||
if (!(target instanceof MapTraceValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final StringBuilder endPoint = new StringBuilder();
|
||||
try {
|
||||
// first arg - host
|
||||
if (args[0] instanceof String) {
|
||||
endPoint.append(args[0]);
|
||||
// second arg - port
|
||||
if (args.length >= 2 && args[1] instanceof Integer) {
|
||||
endPoint.append(":").append(args[1]);
|
||||
} else {
|
||||
// default port
|
||||
endPoint.append(":").append(6379);
|
||||
}
|
||||
} else if (args[0] instanceof URI) {
|
||||
final URI uri = (URI) args[0];
|
||||
endPoint.append(uri.getHost());
|
||||
endPoint.append(":");
|
||||
endPoint.append(uri.getPort());
|
||||
} else if (args[0] instanceof JedisShardInfo) {
|
||||
final JedisShardInfo info = (JedisShardInfo) args[0];
|
||||
endPoint.append(info.getHost());
|
||||
endPoint.append(":");
|
||||
endPoint.append(info.getPort());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// expect 'class not found exception - JedisShardInfo'
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to trace endPoint('not found JedisShardInfo' is compatibility error). caused={}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
final Map<String, Object> traceValue = new HashMap<String, Object>();
|
||||
traceValue.put("endPoint", endPoint.toString());
|
||||
((MapTraceValue) target).__setTraceBindValue(traceValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis.interceptor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.context.RecordableTrace;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SpanEventSimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
|
||||
/**
|
||||
* Jedis (redis client) method interceptor
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class JedisMethodInterceptor extends SpanEventSimpleAroundInterceptor implements TargetClassLoader {
|
||||
|
||||
public JedisMethodInterceptor() {
|
||||
super(JedisMethodInterceptor.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doInBeforeTrace(RecordableTrace trace, Object target, Object[] args) {
|
||||
trace.markBeforeTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doInAfterTrace(RecordableTrace trace, Object target, Object[] args, Object result, Throwable throwable) {
|
||||
String endPoint = null;
|
||||
if (target instanceof MapTraceValue) {
|
||||
final Map<String, Object> traceValue = ((MapTraceValue) target).__getTraceBindValue();
|
||||
if (traceValue != null) {
|
||||
endPoint = (String) traceValue.get("endPoint");
|
||||
}
|
||||
}
|
||||
|
||||
trace.recordApi(getMethodDescriptor());
|
||||
trace.recordEndPoint(endPoint != null ? endPoint : "Unknown");
|
||||
trace.recordDestinationId(ServiceType.REDIS.toString());
|
||||
trace.recordServiceType(ServiceType.REDIS);
|
||||
trace.recordException(throwable);
|
||||
trace.markAfterTime();
|
||||
}
|
||||
}
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis.interceptor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
|
||||
/**
|
||||
* Jedis Pipeline(redis client) constructor interceptor
|
||||
* - trace endPoint
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class JedisPipelineConstructorInterceptor implements SimpleAroundInterceptor, TargetClassLoader {
|
||||
|
||||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
if (isDebug) {
|
||||
logger.beforeInterceptor(target, args);
|
||||
}
|
||||
|
||||
// trace endPoint
|
||||
if (!(target instanceof MapTraceValue) || !(args[0] instanceof MapTraceValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// first arg - redis.clients.jedis.Client
|
||||
final Map<String, Object> clientTraceValue = ((MapTraceValue) args[0]).__getTraceBindValue();
|
||||
if (clientTraceValue == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Map<String, Object> traceValue = new HashMap<String, Object>();
|
||||
traceValue.put("endPoint", clientTraceValue.get("endPoint"));
|
||||
((MapTraceValue) target).__setTraceBindValue(traceValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis.interceptor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.context.RecordableTrace;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SpanEventSimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
|
||||
/**
|
||||
* Jedis Pipeline(redis client) method interceptor
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class JedisPipelineMethodInterceptor extends SpanEventSimpleAroundInterceptor implements TargetClassLoader {
|
||||
|
||||
public JedisPipelineMethodInterceptor() {
|
||||
super(JedisPipelineMethodInterceptor.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doInBeforeTrace(RecordableTrace trace, Object target, Object[] args) {
|
||||
trace.markBeforeTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doInAfterTrace(RecordableTrace trace, Object target, Object[] args, Object result, Throwable throwable) {
|
||||
String endPoint = null;
|
||||
if (target instanceof MapTraceValue) {
|
||||
final Map<String, Object> traceValue = ((MapTraceValue) target).__getTraceBindValue();
|
||||
if (traceValue != null) {
|
||||
endPoint = (String) traceValue.get("endPoint");
|
||||
}
|
||||
}
|
||||
|
||||
trace.recordApi(getMethodDescriptor());
|
||||
trace.recordEndPoint(endPoint != null ? endPoint : "Unknown");
|
||||
trace.recordDestinationId(ServiceType.REDIS.toString());
|
||||
trace.recordServiceType(ServiceType.REDIS);
|
||||
trace.recordException(throwable);
|
||||
trace.markAfterTime();
|
||||
}
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis.interceptor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
|
||||
/**
|
||||
* Jedis pipeline (redis client) setClient method interceptor
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class JedisPipelineSetClientMethodInterceptor implements SimpleAroundInterceptor, TargetClassLoader {
|
||||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
if (isDebug) {
|
||||
logger.beforeInterceptor(target, args);
|
||||
}
|
||||
|
||||
// trace endPoint
|
||||
if (!(target instanceof MapTraceValue) || !(args[0] instanceof MapTraceValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// first arg - redis.clients.jedis.Client
|
||||
final Map<String, Object> clientTraceValue = ((MapTraceValue) args[0]).__getTraceBindValue();
|
||||
if (clientTraceValue == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Map<String, Object> traceValue = new HashMap<String, Object>();
|
||||
traceValue.put("endPoint", clientTraceValue.get("endPoint"));
|
||||
((MapTraceValue) target).__setTraceBindValue(traceValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
}
|
||||
}
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis.interceptor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLogger;
|
||||
import com.nhn.pinpoint.bootstrap.logging.PLoggerFactory;
|
||||
|
||||
/**
|
||||
* RedisCluster(nBase-ARC client) constructor interceptor - trace endPoint
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class RedisClusterConstructorInterceptor implements SimpleAroundInterceptor, TargetClassLoader {
|
||||
|
||||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
|
||||
private final boolean isDebug = logger.isDebugEnabled();
|
||||
|
||||
@Override
|
||||
public void before(Object target, Object[] args) {
|
||||
if (isDebug) {
|
||||
logger.beforeInterceptor(target, args);
|
||||
}
|
||||
|
||||
if (!(target instanceof MapTraceValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// trace endPoint
|
||||
// first arg - host
|
||||
final StringBuilder endPoint = new StringBuilder();
|
||||
if (args[0] instanceof String) {
|
||||
endPoint.append(args[0]);
|
||||
// second arg - port
|
||||
if (args.length >= 2 && args[1] instanceof Integer) {
|
||||
endPoint.append(":").append(args[1]);
|
||||
} else {
|
||||
// default port
|
||||
endPoint.append(":").append(6379);
|
||||
}
|
||||
}
|
||||
|
||||
final Map<String, Object> traceValue = new HashMap<String, Object>();
|
||||
traceValue.put("endPoint", endPoint.toString());
|
||||
((MapTraceValue) target).__setTraceBindValue(traceValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(Object target, Object[] args, Object result, Throwable throwable) {
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user