Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
月轩居士
SkyWalking
提交
b2ad6343
S
SkyWalking
项目概览
月轩居士
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
4
Star
0
Fork
0
代码
文件
提交
分支
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,体验更适合开发者的 AI 搜索 >>
提交
b2ad6343
编写于
2月 19, 2020
作者:
L
lsyf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix ehcache: performance issue
上级
e57176d0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
59 addition
and
16 deletion
+59
-16
apm-sniffer/apm-sdk-plugin/ehcache-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/ehcache/v2/EhcacheConstructorInterceptor.java
.../apm/plugin/ehcache/v2/EhcacheConstructorInterceptor.java
+4
-14
apm-sniffer/apm-sdk-plugin/ehcache-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/ehcache/v2/EhcachePrivateConstructorInterceptor.java
...ugin/ehcache/v2/EhcachePrivateConstructorInterceptor.java
+35
-0
apm-sniffer/apm-sdk-plugin/ehcache-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/ehcache/v2/define/EhcachePluginInstrumentation.java
...lugin/ehcache/v2/define/EhcachePluginInstrumentation.java
+13
-2
apm-sniffer/apm-sdk-plugin/ehcache-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/ehcache/v2/EhcacheInterceptorTest.java
...walking/apm/plugin/ehcache/v2/EhcacheInterceptorTest.java
+7
-0
未找到文件。
apm-sniffer/apm-sdk-plugin/ehcache-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/ehcache/v2/EhcacheConstructorInterceptor.java
浏览文件 @
b2ad6343
...
...
@@ -18,7 +18,6 @@
package
org.apache.skywalking.apm.plugin.ehcache.v2
;
import
net.sf.ehcache.Cache
;
import
net.sf.ehcache.config.CacheConfiguration
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor
;
...
...
@@ -26,20 +25,11 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceC
public
class
EhcacheConstructorInterceptor
implements
InstanceConstructorInterceptor
{
@Override
public
void
onConstruct
(
EnhancedInstance
objInst
,
Object
[]
allArguments
)
{
try
{
CacheConfiguration
cacheConfiguration
=
(
CacheConfiguration
)
allArguments
[
0
];
CacheConfiguration
cacheConfiguration
=
(
CacheConfiguration
)
allArguments
[
0
];
// get cache name
if
(
cacheConfiguration
!=
null
)
{
objInst
.
setSkyWalkingDynamicField
(
new
EhcacheEnhanceInfo
(
cacheConfiguration
.
getName
()));
}
}
catch
(
ClassCastException
e
)
{
Cache
cache
=
(
Cache
)
allArguments
[
0
];
// get cache name
if
(
cache
!=
null
&&
cache
.
getCacheConfiguration
()
!=
null
)
{
objInst
.
setSkyWalkingDynamicField
(
new
EhcacheEnhanceInfo
(
cache
.
getCacheConfiguration
().
getName
()));
}
// get cache name
if
(
cacheConfiguration
!=
null
)
{
objInst
.
setSkyWalkingDynamicField
(
new
EhcacheEnhanceInfo
(
cacheConfiguration
.
getName
()));
}
}
}
apm-sniffer/apm-sdk-plugin/ehcache-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/ehcache/v2/EhcachePrivateConstructorInterceptor.java
0 → 100644
浏览文件 @
b2ad6343
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.plugin.ehcache.v2
;
import
net.sf.ehcache.Cache
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor
;
public
class
EhcachePrivateConstructorInterceptor
implements
InstanceConstructorInterceptor
{
@Override
public
void
onConstruct
(
EnhancedInstance
objInst
,
Object
[]
allArguments
)
{
Cache
cache
=
(
Cache
)
allArguments
[
0
];
// get cache name
if
(
cache
!=
null
&&
cache
.
getCacheConfiguration
()
!=
null
)
{
objInst
.
setSkyWalkingDynamicField
(
new
EhcacheEnhanceInfo
(
cache
.
getCacheConfiguration
().
getName
()));
}
}
}
apm-sniffer/apm-sdk-plugin/ehcache-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/ehcache/v2/define/EhcachePluginInstrumentation.java
浏览文件 @
b2ad6343
...
...
@@ -38,6 +38,7 @@ public class EhcachePluginInstrumentation extends ClassInstanceMethodsEnhancePlu
public
static
final
String
INTERCEPT_CLASS
=
"net.sf.ehcache.Cache"
;
public
static
final
String
CONSTRUCTOR_CLASS_INTERCEPT_CLASS
=
"org.apache.skywalking.apm.plugin.ehcache.v2.EhcacheConstructorInterceptor"
;
public
static
final
String
PRIVATE_CONSTRUCTOR_CLASS_INTERCEPT_CLASS
=
"org.apache.skywalking.apm.plugin.ehcache.v2.EhcachePrivateConstructorInterceptor"
;
// get and put value
public
static
final
String
PUT_CACHE_ENHANCE_METHOD
=
"put"
;
...
...
@@ -80,14 +81,24 @@ public class EhcachePluginInstrumentation extends ClassInstanceMethodsEnhancePlu
new
ConstructorInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getConstructorMatcher
()
{
return
takesArgument
(
0
,
named
(
"net.sf.ehcache.config.CacheConfiguration"
))
.
or
(
isPrivate
().
and
(
takesArgument
(
0
,
named
(
"net.sf.ehcache.Cache"
))));
return
takesArgument
(
0
,
named
(
"net.sf.ehcache.config.CacheConfiguration"
));
}
@Override
public
String
getConstructorInterceptor
()
{
return
CONSTRUCTOR_CLASS_INTERCEPT_CLASS
;
}
},
new
ConstructorInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getConstructorMatcher
()
{
return
isPrivate
().
and
(
takesArgument
(
0
,
named
(
"net.sf.ehcache.Cache"
)));
}
@Override
public
String
getConstructorInterceptor
()
{
return
PRIVATE_CONSTRUCTOR_CLASS_INTERCEPT_CLASS
;
}
}
};
}
...
...
apm-sniffer/apm-sdk-plugin/ehcache-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/ehcache/v2/EhcacheInterceptorTest.java
浏览文件 @
b2ad6343
...
...
@@ -66,6 +66,7 @@ public class EhcacheInterceptorTest {
private
EhcacheOperateAllInterceptor
operateAllInterceptor
;
private
EhcacheLockInterceptor
lockInterceptor
;
private
EhcacheConstructorInterceptor
constructorInterceptor
;
private
EhcachePrivateConstructorInterceptor
privateConstructorInterceptor
;
private
EhcacheCacheNameInterceptor
cacheNameInterceptor
;
private
Object
[]
operateObjectArguments
;
private
Object
[]
operateElementArguments
;
...
...
@@ -106,6 +107,7 @@ public class EhcacheInterceptorTest {
operateElementInterceptor
=
new
EhcacheOperateElementInterceptor
();
operateAllInterceptor
=
new
EhcacheOperateAllInterceptor
();
constructorInterceptor
=
new
EhcacheConstructorInterceptor
();
privateConstructorInterceptor
=
new
EhcachePrivateConstructorInterceptor
();
cacheNameInterceptor
=
new
EhcacheCacheNameInterceptor
();
lockInterceptor
=
new
EhcacheLockInterceptor
();
...
...
@@ -139,6 +141,11 @@ public class EhcacheInterceptorTest {
constructorInterceptor
.
onConstruct
(
enhancedInstance
,
new
Object
[]
{
new
CacheConfiguration
(
CACHE_NAME
,
20
)});
}
@Test
public
void
assertPrivateConstruct
()
throws
Throwable
{
privateConstructorInterceptor
.
onConstruct
(
enhancedInstance
,
new
Object
[]
{
new
Cache
(
new
CacheConfiguration
(
CACHE_NAME
,
20
))});
}
@Test
public
void
assertSetNameSuccess
()
throws
Throwable
{
cacheNameInterceptor
.
beforeMethod
(
enhancedInstance
,
setNameMethod
,
cacheNameArguments
,
null
,
null
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录