Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
cf3d287f
S
SkyWalking
项目概览
山不在高_有仙则灵
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
12
Star
0
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cf3d287f
编写于
6月 09, 2017
作者:
P
pengys5
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into feature/208-collectorside
上级
bec40b6e
db902e8d
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
53 addition
and
24 deletion
+53
-24
_config.yml
_config.yml
+0
-1
apm-collector/apm-collector-worker/docker/startup.sh
apm-collector/apm-collector-worker/docker/startup.sh
+1
-1
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefine.java
...m/agent/core/plugin/AbstractClassEnhancePluginDefine.java
+5
-13
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/PluginBootstrap.java
...org/skywalking/apm/agent/core/plugin/PluginBootstrap.java
+0
-4
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/TracingBootstrap.java
...rg/skywalking/apm/agent/core/plugin/TracingBootstrap.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/WitnessClassFinder.java
.../skywalking/apm/agent/core/plugin/WitnessClassFinder.java
+42
-0
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefineTest.java
...ent/core/plugin/AbstractClassEnhancePluginDefineTest.java
+2
-2
apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/SkyWalkingAgent.java
...c/main/java/org/skywalking/apm/agent/SkyWalkingAgent.java
+1
-1
未找到文件。
_config.yml
已删除
100644 → 0
浏览文件 @
bec40b6e
theme
:
jekyll-theme-tactile
\ No newline at end of file
apm-collector/apm-collector-worker/docker/startup.sh
浏览文件 @
cf3d287f
...
...
@@ -21,4 +21,4 @@ do
done
echo
"Starting collector...."
$_RUNJAVA
${
JAVA_OPTS
}
-classpath
$CLASSPATH
CollectorBootStartUp
\ No newline at end of file
$_RUNJAVA
${
JAVA_OPTS
}
-classpath
$CLASSPATH
org.skywalking.apm.collector.worker.CollectorBootStartUp
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefine.java
浏览文件 @
cf3d287f
package
org.skywalking.apm.agent.core.plugin
;
import
net.bytebuddy.dynamic.DynamicType
;
import
net.bytebuddy.pool.TypePool
;
import
net.bytebuddy.pool.TypePool.Resolution
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassEnhancePluginDefine
;
import
org.skywalking.apm.util.StringUtil
;
import
org.skywalking.apm.logging.ILog
;
...
...
@@ -17,18 +15,17 @@ import org.skywalking.apm.logging.LogManager;
public
abstract
class
AbstractClassEnhancePluginDefine
{
private
static
final
ILog
logger
=
LogManager
.
getLogger
(
AbstractClassEnhancePluginDefine
.
class
);
private
TypePool
classTypePool
;
/**
* Main entrance of enhancing the class.
*
* @param transformClassName target class.
* @param builder byte-buddy's builder to manipulate target class's bytecode.
* @param builder byte-buddy's builder to manipulate target class's bytecode.
* @param classLoader load the given transformClass
* @return the new builder, or <code>null</code> if not be enhanced.
* @throws PluginException, when set builder failure.
*/
public
DynamicType
.
Builder
<?>
define
(
String
transformClassName
,
DynamicType
.
Builder
<?>
buil
der
)
throws
PluginException
{
DynamicType
.
Builder
<?>
builder
,
ClassLoader
classLoa
der
)
throws
PluginException
{
String
interceptorDefineClassName
=
this
.
getClass
().
getName
();
if
(
StringUtil
.
isEmpty
(
transformClassName
))
{
...
...
@@ -44,8 +41,7 @@ public abstract class AbstractClassEnhancePluginDefine {
String
[]
witnessClasses
=
witnessClasses
();
if
(
witnessClasses
!=
null
)
{
for
(
String
witnessClass
:
witnessClasses
)
{
Resolution
witnessClassResolution
=
classTypePool
.
describe
(
witnessClass
);
if
(!
witnessClassResolution
.
isResolved
())
{
if
(!
WitnessClassFinder
.
INSTANCE
.
exist
(
witnessClass
,
classLoader
))
{
logger
.
warn
(
"enhance class {} by plugin {} is not working. Because witness class {} is not existed."
,
transformClassName
,
interceptorDefineClassName
,
witnessClass
);
return
null
;
...
...
@@ -64,7 +60,7 @@ public abstract class AbstractClassEnhancePluginDefine {
}
protected
abstract
DynamicType
.
Builder
<?>
enhance
(
String
enhanceOriginClassName
,
DynamicType
.
Builder
<?>
newClassBuilder
)
throws
PluginException
;
DynamicType
.
Builder
<?>
newClassBuilder
)
throws
PluginException
;
/**
* Define the classname of target class.
...
...
@@ -86,8 +82,4 @@ public abstract class AbstractClassEnhancePluginDefine {
protected
String
[]
witnessClasses
()
{
return
new
String
[]
{};
}
public
void
setClassTypePool
(
TypePool
classTypePool
)
{
this
.
classTypePool
=
classTypePool
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/PluginBootstrap.java
浏览文件 @
cf3d287f
package
org.skywalking.apm.agent.core.plugin
;
import
net.bytebuddy.pool.TypePool
;
import
org.skywalking.apm.logging.ILog
;
import
org.skywalking.apm.logging.LogManager
;
...
...
@@ -24,8 +23,6 @@ public class PluginBootstrap {
* @return plugin definition list.
*/
public
List
<
AbstractClassEnhancePluginDefine
>
loadPlugins
()
{
TypePool
classTypePool
=
TypePool
.
Default
.
ofClassPath
();
PluginResourcesResolver
resolver
=
new
PluginResourcesResolver
();
List
<
URL
>
resources
=
resolver
.
getResources
();
...
...
@@ -50,7 +47,6 @@ public class PluginBootstrap {
logger
.
debug
(
"loading plugin class {}."
,
pluginDefine
.
getDefineClass
());
AbstractClassEnhancePluginDefine
plugin
=
(
AbstractClassEnhancePluginDefine
)
Class
.
forName
(
pluginDefine
.
getDefineClass
()).
newInstance
();
plugin
.
setClassTypePool
(
classTypePool
);
plugins
.
add
(
plugin
);
}
catch
(
Throwable
t
)
{
logger
.
error
(
t
,
"load plugin [{}] failure."
,
pluginDefine
.
getDefineClass
());
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/TracingBootstrap.java
浏览文件 @
cf3d287f
...
...
@@ -30,7 +30,7 @@ public class TracingBootstrap {
* Main entrance for testing.
*
* @param args includes target classname ( which exists "public static void main(String[] args)" ) and arguments
*
list.
* list.
* @throws PluginException
* @throws ClassNotFoundException
* @throws NoSuchMethodException
...
...
@@ -62,7 +62,7 @@ public class TracingBootstrap {
}
DynamicType
.
Builder
<?>
newClassBuilder
=
new
ByteBuddy
().
rebase
(
resolution
.
resolve
(),
ClassFileLocator
.
ForClassLoader
.
ofClassPath
());
newClassBuilder
=
((
AbstractClassEnhancePluginDefine
)
plugin
).
define
(
enhanceClassName
,
newClassBuilder
);
newClassBuilder
=
((
AbstractClassEnhancePluginDefine
)
plugin
).
define
(
enhanceClassName
,
newClassBuilder
,
TracingBootstrap
.
class
.
getClassLoader
()
);
newClassBuilder
.
make
(
new
TypeResolutionStrategy
.
Active
()).
load
(
ClassLoader
.
getSystemClassLoader
(),
ClassLoadingStrategy
.
Default
.
INJECTION
)
.
getLoaded
();
}
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/WitnessClassFinder.java
0 → 100644
浏览文件 @
cf3d287f
package
org.skywalking.apm.agent.core.plugin
;
import
java.util.Map
;
import
java.util.HashMap
;
import
net.bytebuddy.pool.TypePool
;
/**
* The <code>WitnessClassFinder</code> represents a pool of {@link TypePool}s,
* each {@link TypePool} matches a {@link ClassLoader},
* which helps to find the class define existed or not.
*
* @author wusheng
*/
public
enum
WitnessClassFinder
{
INSTANCE
;
private
Map
<
ClassLoader
,
TypePool
>
poolMap
=
new
HashMap
<
ClassLoader
,
TypePool
>();
/**
* @param witnessClass
* @param classLoader for finding the witnessClass
* @return true, if the given witnessClass exists, through the given classLoader.
*/
public
boolean
exist
(
String
witnessClass
,
ClassLoader
classLoader
)
{
ClassLoader
mappingKey
=
classLoader
==
null
?
NullClassLoader
.
INSTANCE
:
classLoader
;
if
(!
poolMap
.
containsKey
(
mappingKey
))
{
synchronized
(
poolMap
)
{
if
(!
poolMap
.
containsKey
(
mappingKey
))
{
TypePool
classTypePool
=
classLoader
==
null
?
TypePool
.
Default
.
ofClassPath
()
:
TypePool
.
Default
.
of
(
classLoader
);
poolMap
.
put
(
mappingKey
,
classTypePool
);
}
}
}
TypePool
typePool
=
poolMap
.
get
(
mappingKey
);
TypePool
.
Resolution
witnessClassResolution
=
typePool
.
describe
(
witnessClass
);
return
witnessClassResolution
.
isResolved
();
}
}
final
class
NullClassLoader
extends
ClassLoader
{
static
NullClassLoader
INSTANCE
=
new
NullClassLoader
();
}
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefineTest.java
浏览文件 @
cf3d287f
...
...
@@ -104,12 +104,12 @@ public class AbstractClassEnhancePluginDefineTest {
private
DynamicType
.
Builder
<?>
transformStaticMethod
(
DynamicType
.
Builder
newBuilder
)
{
MockPluginStaticMethodInstrumentation
staticMethodInstrumentation
=
new
MockPluginStaticMethodInstrumentation
();
return
staticMethodInstrumentation
.
define
(
WEAVE_CLASS
,
newBuilder
);
return
staticMethodInstrumentation
.
define
(
WEAVE_CLASS
,
newBuilder
,
AbstractClassEnhancePluginDefineTest
.
class
.
getClassLoader
()
);
}
private
DynamicType
.
Builder
transformInstanceMethod
(
DynamicType
.
Builder
<?>
builder
)
{
MockPluginInstanceMethodInstrumentation
instrumentation
=
new
MockPluginInstanceMethodInstrumentation
();
return
instrumentation
.
define
(
WEAVE_CLASS
,
builder
);
return
instrumentation
.
define
(
WEAVE_CLASS
,
builder
,
AbstractClassEnhancePluginDefineTest
.
class
.
getClassLoader
()
);
}
}
...
...
apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/SkyWalkingAgent.java
浏览文件 @
cf3d287f
...
...
@@ -57,7 +57,7 @@ public class SkyWalkingAgent {
ClassLoader
classLoader
)
{
List
<
AbstractClassEnhancePluginDefine
>
pluginDefines
=
pluginFinder
.
find
(
typeDescription
.
getTypeName
());
for
(
AbstractClassEnhancePluginDefine
pluginDefine
:
pluginDefines
)
{
DynamicType
.
Builder
<?>
newBuilder
=
pluginDefine
.
define
(
typeDescription
.
getTypeName
(),
builder
);
DynamicType
.
Builder
<?>
newBuilder
=
pluginDefine
.
define
(
typeDescription
.
getTypeName
(),
builder
,
classLoader
);
if
(
newBuilder
!=
null
)
{
return
newBuilder
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录