Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
e998fa56
C
cat
项目概览
梦中观雨
/
cat
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
cat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e998fa56
编写于
2月 09, 2015
作者:
Y
youyong205
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify the cross analyzer
上级
ae9cdfa0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
65 addition
and
64 deletion
+65
-64
cat-consumer/src/main/java/com/dianping/cat/consumer/cross/CrossAnalyzer.java
...n/java/com/dianping/cat/consumer/cross/CrossAnalyzer.java
+65
-64
未找到文件。
cat-consumer/src/main/java/com/dianping/cat/consumer/cross/CrossAnalyzer.java
浏览文件 @
e998fa56
...
...
@@ -30,35 +30,39 @@ public class CrossAnalyzer extends AbstractMessageAnalyzer<CrossReport> implemen
@Inject
protected
IpConvertManager
m_ipConvertManager
;
private
static
final
String
UNKNOWN
=
"Unknown"
;
private
int
m_discardLogs
=
0
;
private
int
m_errorAppName
;
public
CrossInfo
convertCrossInfo
(
String
client
,
CrossInfo
crossInfo
)
{
String
local
Ip
=
crossInfo
.
getLocalAddress
();
String
local
Address
=
crossInfo
.
getLocalAddress
();
String
remoteAddress
=
crossInfo
.
getRemoteAddress
();
int
index
=
remoteAddress
.
indexOf
(
":"
);
if
(
index
>
0
)
{
remoteAddress
=
remoteAddress
.
substring
(
0
,
index
);
}
if
(
localAddress
!=
null
&&
remoteAddress
!=
null
)
{
int
index
=
remoteAddress
.
indexOf
(
":"
);
if
(
index
>
0
)
{
remoteAddress
=
remoteAddress
.
substring
(
0
,
index
);
}
CrossInfo
info
=
new
CrossInfo
();
info
.
setLocalAddress
(
remoteAddress
);
String
clientPort
=
crossInfo
.
getClientPort
();
CrossInfo
info
=
new
CrossInfo
();
info
.
setLocalAddress
(
remoteAddress
);
if
(
clientPort
==
null
)
{
info
.
setRemoteAddress
(
localAddress
);
}
else
{
info
.
setRemoteAddress
(
localAddress
+
":"
+
clientPort
);
}
info
.
setRemoteRole
(
"Pigeon.Caller"
);
info
.
setDetailType
(
"PigeonCall"
);
info
.
setApp
(
client
);
String
clientPort
=
crossInfo
.
getClientPort
();
if
(
clientPort
==
null
)
{
info
.
setRemoteAddress
(
localIp
);
return
info
;
}
else
{
info
.
setRemoteAddress
(
localIp
+
":"
+
clientPort
)
;
return
null
;
}
info
.
setRemoteRole
(
"Pigeon.Caller"
);
info
.
setDetailType
(
"PigeonCall"
);
info
.
setApp
(
client
);
return
info
;
}
@Override
...
...
@@ -107,7 +111,7 @@ public class CrossAnalyzer extends AbstractMessageAnalyzer<CrossReport> implemen
private
CrossInfo
parsePigeonClientTransaction
(
Transaction
t
,
MessageTree
tree
)
{
CrossInfo
crossInfo
=
new
CrossInfo
();
String
local
Ip
=
tree
.
getIpAddress
();
String
local
Address
=
tree
.
getIpAddress
();
List
<
Message
>
messages
=
t
.
getChildren
();
for
(
Message
message
:
messages
)
{
...
...
@@ -126,7 +130,7 @@ public class CrossAnalyzer extends AbstractMessageAnalyzer<CrossReport> implemen
}
}
crossInfo
.
setLocalAddress
(
local
Ip
);
crossInfo
.
setLocalAddress
(
local
Address
);
crossInfo
.
setRemoteRole
(
"Pigeon.Server"
);
crossInfo
.
setDetailType
(
"PigeonCall"
);
return
crossInfo
;
...
...
@@ -134,7 +138,7 @@ public class CrossAnalyzer extends AbstractMessageAnalyzer<CrossReport> implemen
private
CrossInfo
parsePigeonServerTransaction
(
Transaction
t
,
MessageTree
tree
)
{
CrossInfo
crossInfo
=
new
CrossInfo
();
String
local
Ip
=
tree
.
getIpAddress
();
String
local
Address
=
tree
.
getIpAddress
();
List
<
Message
>
messages
=
t
.
getChildren
();
for
(
Message
message
:
messages
)
{
...
...
@@ -150,12 +154,7 @@ public class CrossAnalyzer extends AbstractMessageAnalyzer<CrossReport> implemen
}
}
if
(
crossInfo
.
getRemoteAddress
().
equals
(
UNKNOWN
))
{
m_discardLogs
++;
return
null
;
}
crossInfo
.
setLocalAddress
(
localIp
);
crossInfo
.
setLocalAddress
(
localAddress
);
crossInfo
.
setRemoteRole
(
"Pigeon.Client"
);
crossInfo
.
setDetailType
(
"PigeonService"
);
return
crossInfo
;
...
...
@@ -180,11 +179,16 @@ public class CrossAnalyzer extends AbstractMessageAnalyzer<CrossReport> implemen
if
(
crossInfo
!=
null
)
{
updateCrossReport
(
report
,
t
,
crossInfo
);
String
domain
=
crossInfo
.
getApp
();
if
(
m_serverConfigManager
.
isRpcClient
(
t
.
getType
())
&&
StringUtils
.
isNotEmpty
(
domain
))
{
CrossInfo
info
=
convertCrossInfo
(
tree
.
getDomain
(),
crossInfo
);
String
targetDomain
=
crossInfo
.
getApp
();
if
(
m_serverConfigManager
.
isRpcClient
(
t
.
getType
())
&&
StringUtils
.
isNotEmpty
(
targetDomain
))
{
CrossInfo
serverCrossInfo
=
convertCrossInfo
(
tree
.
getDomain
(),
crossInfo
);
if
(
serverCrossInfo
!=
null
)
{
CrossReport
serverReport
=
m_reportManager
.
getHourlyReport
(
getStartTime
(),
targetDomain
,
true
);
updateServerCrossReport
(
t
,
domain
,
info
);
updateCrossReport
(
serverReport
,
t
,
serverCrossInfo
);
}
}
else
{
m_errorAppName
++;
}
...
...
@@ -215,55 +219,52 @@ public class CrossAnalyzer extends AbstractMessageAnalyzer<CrossReport> implemen
String
remoteIp
=
info
.
getRemoteAddress
();
String
role
=
info
.
getRemoteRole
();
String
transactionName
=
t
.
getName
();
Local
local
=
report
.
findOrCreateLocal
(
localIp
);
String
remoteId
=
remoteIp
+
":"
+
role
;
Remote
remote
=
local
.
findOrCreateRemote
(
remoteId
);
report
.
addIp
(
localIp
);
remote
.
setIp
(
remote
Ip
);
remote
.
setRole
(
role
)
;
remote
.
setApp
(
info
.
getApp
()
);
if
(
localIp
!=
null
&&
remoteIp
!=
null
)
{
Local
local
=
report
.
findOrCreateLocal
(
local
Ip
);
String
remoteId
=
remoteIp
+
":"
+
role
;
Remote
remote
=
local
.
findOrCreateRemote
(
remoteId
);
Type
type
=
remote
.
getType
();
report
.
addIp
(
localIp
);
remote
.
setIp
(
remoteIp
);
remote
.
setRole
(
role
);
remote
.
setApp
(
info
.
getApp
());
if
(
type
==
null
)
{
type
=
new
Type
();
type
.
setId
(
info
.
getDetailType
());
remote
.
setType
(
type
);
}
Type
type
=
remote
.
getType
();
Name
name
=
type
.
findOrCreateName
(
transactionName
);
if
(
type
==
null
)
{
type
=
new
Type
();
type
.
setId
(
info
.
getDetailType
());
remote
.
setType
(
type
);
}
type
.
incTotalCount
();
name
.
incTotalCount
();
Name
name
=
type
.
findOrCreateName
(
transactionName
);
if
(!
t
.
isSuccess
())
{
type
.
incFailCount
();
name
.
incFailCount
();
}
type
.
incTotalCount
();
name
.
incTotalCount
();
double
duration
=
t
.
getDurationInMicros
()
/
1000
d
;
if
(!
t
.
isSuccess
())
{
type
.
incFailCount
();
name
.
incFailCount
();
}
type
.
setSum
(
type
.
getSum
()
+
duration
);
name
.
setSum
(
name
.
getSum
()
+
duration
);
}
double
duration
=
t
.
getDurationInMicros
()
/
1000
d
;
private
void
updateServerCrossReport
(
Transaction
t
,
String
domain
,
CrossInfo
info
)
{
CrossReport
report
=
m_reportManager
.
getHourlyReport
(
getStartTime
(),
domain
,
true
);
updateCrossReport
(
report
,
t
,
info
);
type
.
setSum
(
type
.
getSum
()
+
duration
);
name
.
setSum
(
name
.
getSum
()
+
duration
);
}
}
public
static
class
CrossInfo
{
private
String
m_remoteRole
=
UNKNOWN
;
private
String
m_remoteRole
;
private
String
m_LocalAddress
=
UNKNOWN
;
private
String
m_LocalAddress
;
private
String
m_RemoteAddress
=
UNKNOWN
;
private
String
m_RemoteAddress
;
private
String
m_detailType
=
UNKNOWN
;
private
String
m_detailType
;
private
String
m_app
=
""
;
private
String
m_app
;
private
String
m_clientPort
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录