Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
javalover123888
SkyWalking
提交
85949734
S
SkyWalking
项目概览
javalover123888
/
SkyWalking
与 Fork 源项目一致
Fork自
山不在高_有仙则灵 / SkyWalking
通知
2
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,发现更多精彩内容 >>
提交
85949734
编写于
8月 03, 2016
作者:
A
ascrutae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改Dubbo插件
上级
d6507d2f
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
63 addition
and
133 deletion
+63
-133
skywalking-collector/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/ai/cloud/skywalking/plugin/dubbo/DubboPluginDefine.java
...m/ai/cloud/skywalking/plugin/dubbo/DubboPluginDefine.java
+7
-6
skywalking-collector/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/ai/cloud/skywalking/plugin/dubbo/MonitorFilterInterceptor.java
...oud/skywalking/plugin/dubbo/MonitorFilterInterceptor.java
+56
-48
skywalking-collector/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/ai/cloud/skywalking/plugin/dubbo/ProtocolFilterBuildChainInterceptor.java
...ing/plugin/dubbo/ProtocolFilterBuildChainInterceptor.java
+0
-78
skywalking-collector/skywalking-sdk-plugin/dubbo-plugin/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter
...ain/resources/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter
+0
-1
未找到文件。
skywalking-collector/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/ai/cloud/skywalking/plugin/dubbo/DubboPluginDefine.java
浏览文件 @
85949734
package
com.ai.cloud.skywalking.plugin.dubbo
;
import
com.ai.cloud.skywalking.plugin.interceptor.MethodMatcher
;
import
com.ai.cloud.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
com.ai.cloud.skywalking.plugin.interceptor.enhance.ClassStaticMethodsEnhancePluginDefine
;
import
com.ai.cloud.skywalking.plugin.interceptor.enhance.StaticMethodsAroundInterceptor
;
import
com.ai.cloud.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher
;
public
class
DubboPluginDefine
extends
Class
Static
MethodsEnhancePluginDefine
{
public
class
DubboPluginDefine
extends
Class
Instance
MethodsEnhancePluginDefine
{
@Override
protected
MethodMatcher
[]
get
Static
MethodsMatchers
()
{
return
new
MethodMatcher
[]{
new
SimpleMethodMatcher
(
"
buildInvokerChain
"
)};
protected
MethodMatcher
[]
get
Instance
MethodsMatchers
()
{
return
new
MethodMatcher
[]{
new
SimpleMethodMatcher
(
"
invoke
"
)};
}
@Override
protected
String
get
Static
MethodsInterceptor
()
{
return
"com.ai.cloud.skywalking.plugin.dubbo.
ProtocolFilterBuildChain
Interceptor"
;
protected
String
get
Instance
MethodsInterceptor
()
{
return
"com.ai.cloud.skywalking.plugin.dubbo.
MonitorFilter
Interceptor"
;
}
@Override
protected
String
enhanceClassName
()
{
return
"com.alibaba.dubbo.
rpc.protocol.ProtocolFilterWrapp
er"
;
return
"com.alibaba.dubbo.
monitor.support.MonitorFilt
er"
;
}
}
skywalking-collector/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/ai/cloud/skywalking/plugin/dubbo/
SWDubboEnhanceFilte
r.java
→
skywalking-collector/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/ai/cloud/skywalking/plugin/dubbo/
MonitorFilterIntercepto
r.java
浏览文件 @
85949734
package
com.ai.cloud.skywalking.plugin.dubbo
;
import
com.ai.cloud.skywalking.invoke.monitor.RPCServerInvokeMonitor
;
import
com.ai.cloud.skywalking.invoke.monitor.RPCClientInvokeMonitor
;
import
com.ai.cloud.skywalking.
conf.AuthDesc
;
import
com.ai.cloud.skywalking.
invoke.monitor.RPCServerInvokeMonitor
;
import
com.ai.cloud.skywalking.model.ContextData
;
import
com.ai.cloud.skywalking.model.Identification
;
import
com.ai.cloud.skywalking.plugin.dubbox.bugfix.below283.BugFixAcitve
;
import
com.ai.cloud.skywalking.plugin.dubbox.bugfix.below283.SWBaseBean
;
import
com.alibaba.dubbo.common.extension.Activate
;
import
com.alibaba.dubbo.rpc.*
;
@Activate
public
class
SWDubboEnhanceFilter
implements
Filter
{
public
Result
invoke
(
Invoker
<?>
invoker
,
Invocation
invocation
)
throws
RpcException
{
if
(!
AuthDesc
.
isAuth
())
{
return
invoker
.
invoke
(
invocation
);
}
RpcContext
context
=
RpcContext
.
getContext
();
boolean
isConsumer
=
context
.
isConsumerSide
();
Result
result
=
null
;
import
com.ai.cloud.skywalking.plugin.interceptor.EnhancedClassInstanceContext
;
import
com.ai.cloud.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext
;
import
com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
com.ai.cloud.skywalking.plugin.interceptor.enhance.MethodInterceptResult
;
import
com.alibaba.dubbo.rpc.Invocation
;
import
com.alibaba.dubbo.rpc.Invoker
;
import
com.alibaba.dubbo.rpc.Result
;
import
com.alibaba.dubbo.rpc.RpcContext
;
public
class
MonitorFilterInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
onConstruct
(
EnhancedClassInstanceContext
context
,
ConstructorInvokeContext
interceptorContext
)
{
// do nothing
}
@Override
public
void
beforeMethod
(
EnhancedClassInstanceContext
context
,
InstanceMethodInvokeContext
interceptorContext
,
MethodInterceptResult
result
)
{
Object
[]
arguments
=
interceptorContext
.
allArguments
();
Invoker
invoker
=
(
Invoker
)
arguments
[
0
];
Invocation
invocation
=
(
Invocation
)
arguments
[
1
];
RpcContext
rpcContext
=
RpcContext
.
getContext
();
boolean
isConsumer
=
rpcContext
.
isConsumerSide
();
context
.
set
(
"isConsumer"
,
isConsumer
);
if
(
isConsumer
)
{
RPCClientInvokeMonitor
rpcClientInvokeMonitor
=
new
RPCClientInvokeMonitor
();
context
.
set
(
"rpcClientInvokeMonitor"
,
rpcClientInvokeMonitor
);
ContextData
contextData
=
rpcClientInvokeMonitor
.
beforeInvoke
(
createIdentification
(
invoker
,
invocation
));
String
contextDataStr
=
contextData
.
toString
();
...
...
@@ -43,32 +54,18 @@ public class SWDubboEnhanceFilter implements Filter {
// 在Rest模式中attachment会被抹除,不会传入到服务端
// Rest模式会将attachment存放到header里面,具体见com.alibaba.dubbo.rpc.protocol.rest.RpcContextFilter
//invocation.getAttachments().put("contextData", contextDataStr);
c
ontext
.
getAttachments
().
put
(
"contextData"
,
contextDataStr
);
rpcC
ontext
.
getAttachments
().
put
(
"contextData"
,
contextDataStr
);
}
else
{
fix283SendNoAttachmentIssue
(
invocation
,
contextDataStr
);
}
try
{
//执行结果
result
=
invoker
.
invoke
(
invocation
);
//结果是否包含异常
if
(
result
.
getException
()
!=
null
)
{
rpcClientInvokeMonitor
.
occurException
(
result
.
getException
());
}
}
catch
(
RpcException
e
)
{
// 自身异常
rpcClientInvokeMonitor
.
occurException
(
e
);
throw
e
;
}
finally
{
rpcClientInvokeMonitor
.
afterInvoke
();
}
}
else
{
// 读取参数
RPCServerInvokeMonitor
rpcServerInvokeMonitor
=
new
RPCServerInvokeMonitor
();
context
.
set
(
"rpcServerInvokeMonitor"
,
rpcServerInvokeMonitor
);
String
contextDataStr
;
if
(!
BugFixAcitve
.
isActive
)
{
contextDataStr
=
c
ontext
.
getAttachment
(
"contextData"
);
contextDataStr
=
rpcC
ontext
.
getAttachment
(
"contextData"
);
}
else
{
contextDataStr
=
fix283RecvNoAttachmentIssue
(
invocation
);
}
...
...
@@ -79,24 +76,34 @@ public class SWDubboEnhanceFilter implements Filter {
}
rpcServerInvokeMonitor
.
beforeInvoke
(
contextData
,
createIdentification
(
invoker
,
invocation
));
}
try
{
//执行结果
result
=
invoker
.
invoke
(
invocation
);
//结果是否包含异常
}
@Override
public
Object
afterMethod
(
EnhancedClassInstanceContext
context
,
InstanceMethodInvokeContext
interceptorContext
,
Object
ret
)
{
Result
result
=
(
Result
)
ret
;
if
(
result
.
getException
()
!=
null
)
{
rpcServerInvokeMonitor
.
occurException
(
result
.
getException
()
);
dealException
(
result
.
getException
(),
context
);
}
}
catch
(
RpcException
e
)
{
// 自身异常
rpcServerInvokeMonitor
.
occurException
(
e
);
throw
e
;
}
finally
{
rpcServerInvokeMonitor
.
afterInvoke
();
return
ret
;
}
@Override
public
void
handleMethodException
(
Throwable
t
,
EnhancedClassInstanceContext
context
,
InstanceMethodInvokeContext
interceptorContext
,
Object
ret
)
{
dealException
(
t
,
context
);
}
return
result
;
private
void
dealException
(
Throwable
t
,
EnhancedClassInstanceContext
context
)
{
boolean
isConsumer
=
(
boolean
)
context
.
get
(
"isConsumer"
);
if
(
isConsumer
)
{
((
RPCClientInvokeMonitor
)
context
.
get
(
"rpcClientInvokeMonitor"
)).
occurException
(
t
);
}
else
{
((
RPCServerInvokeMonitor
)
context
.
get
(
"rpcServerInvokeMonitor"
)).
occurException
(
t
);
}
}
private
static
Identification
createIdentification
(
Invoker
<?>
invoker
,
Invocation
invocation
)
{
...
...
@@ -115,7 +122,8 @@ public class SWDubboEnhanceFilter implements Filter {
}
viewPoint
.
append
(
")"
);
return
Identification
.
newBuilder
().
viewPoint
(
viewPoint
.
toString
()).
spanType
(
DubboBuriedPointType
.
instance
()).
build
();
return
Identification
.
newBuilder
().
viewPoint
(
viewPoint
.
toString
()).
spanType
(
DubboBuriedPointType
.
instance
())
.
build
();
}
...
...
skywalking-collector/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/ai/cloud/skywalking/plugin/dubbo/ProtocolFilterBuildChainInterceptor.java
已删除
100644 → 0
浏览文件 @
d6507d2f
package
com.ai.cloud.skywalking.plugin.dubbo
;
import
java.util.List
;
import
com.ai.cloud.skywalking.plugin.interceptor.enhance.MethodInterceptResult
;
import
com.ai.cloud.skywalking.plugin.interceptor.enhance.MethodInvokeContext
;
import
com.ai.cloud.skywalking.plugin.interceptor.enhance.StaticMethodsAroundInterceptor
;
import
com.alibaba.dubbo.common.URL
;
import
com.alibaba.dubbo.common.extension.ExtensionLoader
;
import
com.alibaba.dubbo.rpc.Filter
;
import
com.alibaba.dubbo.rpc.Invocation
;
import
com.alibaba.dubbo.rpc.Invoker
;
import
com.alibaba.dubbo.rpc.Result
;
import
com.alibaba.dubbo.rpc.RpcException
;
public
class
ProtocolFilterBuildChainInterceptor
implements
StaticMethodsAroundInterceptor
{
@SuppressWarnings
(
"rawtypes"
)
@Override
public
void
beforeMethod
(
MethodInvokeContext
interceptorContext
,
MethodInterceptResult
result
)
{
Object
[]
args
=
interceptorContext
.
allArguments
();
final
Invoker
<?>
invoker
=
(
Invoker
<?>)
args
[
0
];
String
key
=
(
String
)
args
[
1
];
String
group
=
(
String
)
args
[
2
];
final
URL
newURL
=
invoker
.
getUrl
().
addParameter
(
key
,
"skywalking$enhanceFilter"
);
Invoker
<?>
last
=
invoker
;
List
<
Filter
>
filters
=
ExtensionLoader
.
getExtensionLoader
(
Filter
.
class
).
getActivateExtension
(
newURL
,
key
,
group
);
if
(
filters
.
size
()
>
0
)
{
for
(
int
i
=
filters
.
size
()
-
1
;
i
>=
0
;
i
--)
{
final
Filter
filter
=
filters
.
get
(
i
);
final
Invoker
<?>
next
=
last
;
last
=
new
Invoker
()
{
public
Class
<?>
getInterface
()
{
return
invoker
.
getInterface
();
}
public
URL
getUrl
()
{
return
newURL
;
}
public
boolean
isAvailable
()
{
return
invoker
.
isAvailable
();
}
public
Result
invoke
(
Invocation
invocation
)
throws
RpcException
{
return
filter
.
invoke
(
next
,
invocation
);
}
public
void
destroy
()
{
invoker
.
destroy
();
}
@Override
public
String
toString
()
{
return
invoker
.
toString
();
}
};
}
}
result
.
defineReturnValue
(
last
);
}
@Override
public
Object
afterMethod
(
MethodInvokeContext
interceptorContext
,
Object
ret
)
{
return
null
;
//unreachable
}
@Override
public
void
handleMethodException
(
Throwable
t
,
MethodInvokeContext
interceptorContext
,
Object
ret
)
{
//unreachable
}
}
skywalking-collector/skywalking-sdk-plugin/dubbo-plugin/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter
已删除
100644 → 0
浏览文件 @
d6507d2f
skywalking$enhanceFilter=com.ai.cloud.skywalking.plugin.dubbo.SWDubboEnhanceFilter
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录