Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
223b917f
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,发现更多精彩内容 >>
提交
223b917f
编写于
5月 16, 2012
作者:
Y
You Yong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change the transaction and event merger
上级
af0f3ad3
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
248 addition
and
473 deletion
+248
-473
cat-home/src/main/java/com/dianping/cat/report/page/event/DisplayEventNameReport.java
...ianping/cat/report/page/event/DisplayEventNameReport.java
+2
-2
cat-home/src/main/java/com/dianping/cat/report/page/event/Handler.java
...main/java/com/dianping/cat/report/page/event/Handler.java
+7
-40
cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/MobileHeartbeatModel.java
...nping/cat/report/page/heartbeat/MobileHeartbeatModel.java
+71
-71
cat-home/src/main/java/com/dianping/cat/report/page/model/event/CompositeEventService.java
...ng/cat/report/page/model/event/CompositeEventService.java
+7
-17
cat-home/src/main/java/com/dianping/cat/report/page/model/event/EventNameAggregator.java
...ping/cat/report/page/model/event/EventNameAggregator.java
+0
-73
cat-home/src/main/java/com/dianping/cat/report/page/model/event/EventReportMerger.java
...anping/cat/report/page/model/event/EventReportMerger.java
+80
-28
cat-home/src/main/java/com/dianping/cat/report/page/model/transaction/CompositeTransactionService.java
...t/page/model/transaction/CompositeTransactionService.java
+7
-19
cat-home/src/main/java/com/dianping/cat/report/page/model/transaction/TransactionNameAggregator.java
...ort/page/model/transaction/TransactionNameAggregator.java
+0
-110
cat-home/src/main/java/com/dianping/cat/report/page/model/transaction/TransactionReportMerger.java
...eport/page/model/transaction/TransactionReportMerger.java
+67
-24
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Handler.java
...ava/com/dianping/cat/report/page/transaction/Handler.java
+7
-39
cat-home/src/test/java/com/dianping/cat/AllTests.java
cat-home/src/test/java/com/dianping/cat/AllTests.java
+0
-6
cat-home/src/test/java/com/dianping/cat/report/page/model/event/EventNameAggregatorTest.java
.../cat/report/page/model/event/EventNameAggregatorTest.java
+0
-22
cat-home/src/test/java/com/dianping/cat/report/page/model/transaction/TransactionNameAggregatorTest.java
...page/model/transaction/TransactionNameAggregatorTest.java
+0
-22
未找到文件。
cat-home/src/main/java/com/dianping/cat/report/page/event/DisplayEventNameReport.java
浏览文件 @
223b917f
...
...
@@ -20,11 +20,11 @@ public class DisplayEventNameReport {
return
m_results
;
}
public
DisplayEventNameReport
display
(
String
sorted
,
String
type
,
String
ip
,
EventReport
report
)
{
public
DisplayEventNameReport
display
(
String
sorted
,
String
type
,
String
ip
,
EventReport
report
)
{
Map
<
String
,
EventType
>
types
=
report
.
getMachines
().
get
(
ip
).
getTypes
();
if
(
types
!=
null
)
{
EventType
names
=
types
.
get
(
type
);
for
(
Entry
<
String
,
EventName
>
entry
:
names
.
getNames
().
entrySet
())
{
m_results
.
add
(
new
EventNameModel
(
entry
.
getKey
(),
entry
.
getValue
()));
}
...
...
cat-home/src/main/java/com/dianping/cat/report/page/event/Handler.java
浏览文件 @
223b917f
...
...
@@ -53,31 +53,6 @@ public class Handler implements PageHandler<Context>, Initializable {
private
StatisticsComputer
m_computer
=
new
StatisticsComputer
();
private
EventName
getAggregatedEventName
(
Payload
payload
)
{
String
domain
=
payload
.
getDomain
();
String
type
=
payload
.
getType
();
String
ipAddress
=
payload
.
getIpAddress
();
String
date
=
String
.
valueOf
(
payload
.
getDate
());
ModelRequest
request
=
new
ModelRequest
(
domain
,
payload
.
getPeriod
())
//
.
setProperty
(
"date"
,
date
)
//
.
setProperty
(
"type"
,
type
)
//
.
setProperty
(
"name"
,
"*"
)
//
.
setProperty
(
"all"
,
"true"
)
//
.
setProperty
(
"ip"
,
ipAddress
);
ModelResponse
<
EventReport
>
response
=
m_service
.
invoke
(
request
);
String
ip
=
payload
.
getIpAddress
();
EventReport
report
=
response
.
getModel
();
EventType
t
=
report
==
null
?
null
:
report
.
getMachines
().
get
(
ip
).
findType
(
type
);
if
(
t
!=
null
)
{
EventName
all
=
t
.
findName
(
"ALL"
);
return
all
;
}
else
{
return
null
;
}
}
private
EventName
getEventName
(
Payload
payload
)
{
String
domain
=
payload
.
getDomain
();
String
type
=
payload
.
getType
();
...
...
@@ -90,7 +65,11 @@ public class Handler implements PageHandler<Context>, Initializable {
.
setProperty
(
"type"
,
payload
.
getType
())
//
.
setProperty
(
"name"
,
payload
.
getName
())
//
.
setProperty
(
"ip"
,
ipAddress
);
;
if
(
name
==
null
||
name
.
length
()
==
0
)
{
request
.
setProperty
(
"name"
,
"*"
);
request
.
setProperty
(
"all"
,
"true"
);
name
=
"ALL"
;
}
ModelResponse
<
EventReport
>
response
=
m_service
.
invoke
(
request
);
EventReport
report
=
response
.
getModel
();
EventType
t
=
report
.
getMachines
().
get
(
ip
).
findType
(
type
);
...
...
@@ -191,13 +170,7 @@ public class Handler implements PageHandler<Context>, Initializable {
}
private
MobileEventGraphs
showMobileGraphs
(
Model
model
,
Payload
payload
)
{
EventName
name
;
if
(
payload
.
getName
()
==
null
||
payload
.
getName
().
length
()
==
0
)
{
name
=
getAggregatedEventName
(
payload
);
}
else
{
name
=
getEventName
(
payload
);
}
EventName
name
=
getEventName
(
payload
);
if
(
name
==
null
)
{
return
null
;
...
...
@@ -219,13 +192,7 @@ public class Handler implements PageHandler<Context>, Initializable {
}
private
void
showGraphs
(
Model
model
,
Payload
payload
)
{
EventName
name
;
if
(
payload
.
getName
()
==
null
||
payload
.
getName
().
length
()
==
0
)
{
name
=
getAggregatedEventName
(
payload
);
}
else
{
name
=
getEventName
(
payload
);
}
EventName
name
=
getEventName
(
payload
);
if
(
name
==
null
)
{
return
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/MobileHeartbeatModel.java
浏览文件 @
223b917f
...
...
@@ -46,6 +46,12 @@ public class MobileHeartbeatModel {
private
transient
ValueTranslater
m_tansalater
=
new
DefaultValueTranslater
();
private
void
creatGraph
(
MobileGraphItem
graph
,
double
[]
values
,
String
title
)
{
graph
.
setTitle
(
title
);
graph
.
setValue
(
values
);
graph
.
setMaxValue
(
m_tansalater
.
getMaxValue
(
values
));
}
public
MobileHeartbeatModel
display
(
Model
model
,
DisplayHeartbeat
heartbeat
)
{
if
(
heartbeat
==
null
)
{
return
this
;
...
...
@@ -78,154 +84,148 @@ public class MobileHeartbeatModel {
return
this
;
}
private
void
creatGraph
(
MobileGraphItem
graph
,
double
[]
values
,
String
title
)
{
graph
.
setTitle
(
title
);
graph
.
setValue
(
values
);
graph
.
setMaxValue
(
m_tansalater
.
getMaxValue
(
values
));
public
MobileGraphItem
getActiveThreads
()
{
return
m_activeThreads
;
}
public
List
<
String
>
getIps
()
{
return
m_
ips
;
public
MobileGraphItem
getAddCatMessageOverflow
()
{
return
m_
addCatMessageOverflow
;
}
public
void
setIps
(
List
<
String
>
ips
)
{
m_ips
=
ips
;
public
MobileGraphItem
getAddCatMessageProduced
(
)
{
return
m_addCatMessageProduced
;
}
public
String
getCurrentIp
()
{
return
m_
currentIp
;
public
MobileGraphItem
getAddCatMessageSize
()
{
return
m_
addCatMessageSize
;
}
public
void
setCurrentIp
(
String
currentIp
)
{
m_currentIp
=
currentIp
;
public
MobileGraphItem
getAddNewGcCount
(
)
{
return
m_addNewGcCount
;
}
public
MobileGraphItem
getA
ctiveThreads
()
{
return
m_a
ctiveThreads
;
public
MobileGraphItem
getA
ddOldGcCount
()
{
return
m_a
ddOldGcCount
;
}
public
void
setActiveThreads
(
MobileGraphItem
activeThreads
)
{
m_activeThreads
=
activeThreads
;
public
MobileGraphItem
getCatThreads
()
{
return
m_catThreads
;
}
public
String
getCurrentIp
()
{
return
m_currentIp
;
}
public
MobileGraphItem
getDaemonThreads
()
{
return
m_daemonThreads
;
}
public
void
setDaemonThreads
(
MobileGraphItem
daemonThreads
)
{
m_daemonThreads
=
daemonThreads
;
public
List
<
MobileGraphItem
>
getDisks
()
{
return
m_disks
;
}
public
MobileGraphItem
getHeapUsage
()
{
return
m_heapUsage
;
}
public
MobileGraphItem
getTotalThread
s
()
{
return
m_
totalThread
s
;
public
List
<
String
>
getIp
s
()
{
return
m_
ip
s
;
}
public
void
setTotalThreads
(
MobileGraphItem
totalThreads
)
{
m_totalThreads
=
totalThreads
;
public
MobileGraphItem
getMemoryFree
(
)
{
return
m_memoryFree
;
}
public
MobileGraphItem
getNewThreads
()
{
return
m_newThreads
;
}
public
void
setNewThreads
(
MobileGraphItem
newThreads
)
{
m_newThreads
=
newThreads
;
}
public
MobileGraphItem
getCatThreads
()
{
return
m_catThreads
;
}
public
void
setCatThreads
(
MobileGraphItem
catThreads
)
{
m_catThreads
=
catThreads
;
public
MobileGraphItem
getNoneHeapUsage
()
{
return
m_noneHeapUsage
;
}
public
MobileGraphItem
getPigeonTheads
()
{
return
m_pigeonTheads
;
}
public
void
setPigeonTheads
(
MobileGraphItem
pigeonTheads
)
{
m_pigeonTheads
=
pigeonTheads
;
}
public
MobileGraphItem
getAddCatMessageProduced
()
{
return
m_addCatMessageProduced
;
public
MobileGraphItem
getSystemLoadAverage
()
{
return
m_systemLoadAverage
;
}
public
void
setAddCatMessageProduced
(
MobileGraphItem
addCatMessageProduced
)
{
m_addCatMessageProduced
=
addCatMessageProduced
;
public
MobileGraphItem
getTotalThreads
(
)
{
return
m_totalThreads
;
}
public
MobileGraphItem
getAddCatMessageOverflow
(
)
{
return
m_addCatMessageOverflow
;
public
void
setActiveThreads
(
MobileGraphItem
activeThreads
)
{
m_activeThreads
=
activeThreads
;
}
public
void
setAddCatMessageOverflow
(
MobileGraphItem
addCatMessageOverflow
)
{
m_addCatMessageOverflow
=
addCatMessageOverflow
;
}
public
MobileGraphItem
getAddCatMessageSize
(
)
{
return
m_addCatMessageSize
;
public
void
setAddCatMessageProduced
(
MobileGraphItem
addCatMessageProduced
)
{
m_addCatMessageProduced
=
addCatMessageProduced
;
}
public
void
setAddCatMessageSize
(
MobileGraphItem
addCatMessageSize
)
{
m_addCatMessageSize
=
addCatMessageSize
;
}
public
MobileGraphItem
getAddNewGcCount
()
{
return
m_addNewGcCount
;
}
public
void
setAddNewGcCount
(
MobileGraphItem
addNewGcCount
)
{
m_addNewGcCount
=
addNewGcCount
;
}
public
MobileGraphItem
getAddOldGcCount
()
{
return
m_addOldGcCount
;
}
public
void
setAddOldGcCount
(
MobileGraphItem
addOldGcCount
)
{
m_addOldGcCount
=
addOldGcCount
;
}
public
MobileGraphItem
getHeapUsage
(
)
{
return
m_heapUsage
;
public
void
setCatThreads
(
MobileGraphItem
catThreads
)
{
m_catThreads
=
catThreads
;
}
public
void
set
HeapUsage
(
MobileGraphItem
heapUsage
)
{
m_
heapUsage
=
heapUsage
;
public
void
set
CurrentIp
(
String
currentIp
)
{
m_
currentIp
=
currentIp
;
}
public
MobileGraphItem
getNoneHeapUsage
(
)
{
return
m_noneHeapUsage
;
public
void
setDaemonThreads
(
MobileGraphItem
daemonThreads
)
{
m_daemonThreads
=
daemonThreads
;
}
public
void
setNoneHeapUsage
(
MobileGraphItem
noneHeapUsage
)
{
m_noneHeapUsage
=
noneHeapUsage
;
public
void
setDisks
(
List
<
MobileGraphItem
>
disks
)
{
m_disks
=
disks
;
}
public
void
setHeapUsage
(
MobileGraphItem
heapUsage
)
{
m_heapUsage
=
heapUsage
;
}
public
MobileGraphItem
getMemoryFree
(
)
{
return
m_memoryFree
;
public
void
setIps
(
List
<
String
>
ips
)
{
m_ips
=
ips
;
}
public
void
setMemoryFree
(
MobileGraphItem
memoryFree
)
{
m_memoryFree
=
memoryFree
;
}
public
MobileGraphItem
getSystemLoadAverage
()
{
return
m_systemLoadAverage
;
public
void
setNewThreads
(
MobileGraphItem
newThreads
)
{
m_newThreads
=
newThreads
;
}
public
void
setNoneHeapUsage
(
MobileGraphItem
noneHeapUsage
)
{
m_noneHeapUsage
=
noneHeapUsage
;
}
public
void
setPigeonTheads
(
MobileGraphItem
pigeonTheads
)
{
m_pigeonTheads
=
pigeonTheads
;
}
public
void
setSystemLoadAverage
(
MobileGraphItem
systemLoadAverage
)
{
m_systemLoadAverage
=
systemLoadAverage
;
}
public
List
<
MobileGraphItem
>
getDisks
()
{
return
m_disks
;
}
public
void
setDisks
(
List
<
MobileGraphItem
>
disks
)
{
m_disks
=
disks
;
}
public
void
setTotalThreads
(
MobileGraphItem
totalThreads
)
{
m_totalThreads
=
totalThreads
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/model/event/CompositeEventService.java
浏览文件 @
223b917f
...
...
@@ -2,9 +2,7 @@ package com.dianping.cat.report.page.model.event;
import
java.util.List
;
import
com.dianping.cat.consumer.event.model.entity.EventName
;
import
com.dianping.cat.consumer.event.model.entity.EventReport
;
import
com.dianping.cat.consumer.event.model.entity.EventType
;
import
com.dianping.cat.helper.CatString
;
import
com.dianping.cat.report.page.model.spi.ModelRequest
;
import
com.dianping.cat.report.page.model.spi.ModelResponse
;
...
...
@@ -28,9 +26,15 @@ public class CompositeEventService extends BaseCompositeModelService<EventReport
}
EventReportMerger
merger
=
new
EventReportMerger
(
new
EventReport
(
request
.
getDomain
()));
String
ip
=
request
.
getProperty
(
"ip"
);
merger
.
setIp
(
ip
);
if
(
ip
.
equals
(
CatString
.
ALL_IP
))
{
merger
.
setAllIp
(
true
);
}
String
all
=
request
.
getProperty
(
"all"
);
if
(
"true"
.
equals
(
all
))
{
merger
.
setAllName
(
true
);
merger
.
setType
(
request
.
getProperty
(
"type"
));
}
for
(
ModelResponse
<
EventReport
>
response
:
responses
)
{
EventReport
model
=
response
.
getModel
();
if
(
model
!=
null
)
{
...
...
@@ -38,20 +42,6 @@ public class CompositeEventService extends BaseCompositeModelService<EventReport
}
}
EventReport
report
=
merger
.
getEventReport
();
String
all
=
request
.
getProperty
(
"all"
);
if
(
"true"
.
equals
(
all
))
{
String
type
=
request
.
getProperty
(
"type"
);
EventNameAggregator
aggregator
=
new
EventNameAggregator
(
report
);
EventName
n
=
aggregator
.
mergesFor
(
type
,
ip
);
EventType
t
=
new
EventType
(
type
).
addName
(
n
);
EventReport
result
=
new
EventReport
(
request
.
getDomain
());
result
.
findOrCreateMachine
(
ip
).
addType
(
t
);
return
result
;
}
else
{
return
report
;
}
return
merger
.
getEventReport
();
}
}
cat-home/src/main/java/com/dianping/cat/report/page/model/event/EventNameAggregator.java
已删除
100644 → 0
浏览文件 @
af0f3ad3
package
com.dianping.cat.report.page.model.event
;
import
com.dianping.cat.consumer.event.model.entity.EventName
;
import
com.dianping.cat.consumer.event.model.entity.EventReport
;
import
com.dianping.cat.consumer.event.model.entity.EventType
;
import
com.dianping.cat.consumer.event.model.entity.Range
;
import
com.dianping.cat.consumer.event.model.transform.DefaultMerger
;
public
class
EventNameAggregator
extends
DefaultMerger
{
public
EventNameAggregator
(
EventReport
eventReport
)
{
super
(
eventReport
);
}
@Override
protected
void
mergeName
(
EventName
old
,
EventName
other
)
{
old
.
setTotalCount
(
old
.
getTotalCount
()
+
other
.
getTotalCount
());
old
.
setFailCount
(
old
.
getFailCount
()
+
other
.
getFailCount
());
if
(
old
.
getTotalCount
()
>
0
)
{
old
.
setFailPercent
(
old
.
getFailCount
()
*
100.0
/
old
.
getTotalCount
());
}
if
(
old
.
getSuccessMessageUrl
()
==
null
)
{
old
.
setSuccessMessageUrl
(
other
.
getSuccessMessageUrl
());
}
if
(
old
.
getFailMessageUrl
()
==
null
)
{
old
.
setFailMessageUrl
(
other
.
getFailMessageUrl
());
}
}
@Override
protected
void
mergeRange
(
Range
old
,
Range
range
)
{
old
.
setCount
(
old
.
getCount
()
+
range
.
getCount
());
old
.
setFails
(
old
.
getFails
()
+
range
.
getFails
());
}
public
EventReport
mergesFrom
(
EventReport
report
)
{
report
.
accept
(
this
);
return
getEventReport
();
}
@Override
public
void
visitRange
(
Range
range
)
{
Object
parent
=
getStack
().
peek
();
Range
old
=
null
;
if
(
parent
instanceof
EventName
)
{
EventName
name
=
(
EventName
)
parent
;
old
=
name
.
findOrCreateRange
(
range
.
getValue
());
mergeRange
(
old
,
range
);
}
visitRangeChildren
(
old
,
range
);
}
public
EventName
mergesFor
(
String
typeName
,
String
ip
)
{
EventName
name
=
new
EventName
(
"ALL"
);
EventReport
report
=
getEventReport
();
EventType
type
=
report
.
getMachines
().
get
(
ip
).
findType
(
typeName
);
if
(
type
!=
null
)
{
for
(
EventName
n
:
type
.
getNames
().
values
())
{
mergeName
(
name
,
n
);
visitNameChildren
(
name
,
n
);
}
}
return
name
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/model/event/EventReportMerger.java
浏览文件 @
223b917f
...
...
@@ -12,38 +12,27 @@ import com.dianping.cat.helper.CatString;
public
class
EventReportMerger
extends
DefaultMerger
{
private
boolean
m_allIp
=
false
;
public
EventReportMerger
setAllIp
(
boolean
allIp
)
{
m_allIp
=
allIp
;
return
this
;
}
private
boolean
m_allName
=
false
;
private
String
m_ip
;
private
String
m_type
;
public
EventReportMerger
(
EventReport
eventReport
)
{
super
(
eventReport
);
eventReport
.
accept
(
new
StatisticsComputer
());
}
@Override
public
void
visitMachine
(
Machine
machine
)
{
if
(
m_allIp
)
{
Machine
newMachine
=
new
Machine
(
CatString
.
ALL_IP
);
for
(
EventType
type
:
machine
.
getTypes
().
values
())
{
newMachine
.
addType
(
type
);
}
super
.
visitMachine
(
newMachine
);
}
else
{
super
.
visitMachine
(
machine
);
}
}
protected
void
mergeEventReport
(
EventReport
old
,
EventReport
eventReport
)
{
super
.
mergeEventReport
(
old
,
eventReport
);
@Override
public
void
visitEventReport
(
EventReport
eventReport
)
{
super
.
visitEventReport
(
eventReport
);
getEventReport
().
getDomainNames
().
addAll
(
eventReport
.
getDomainNames
());
getEventReport
().
getIps
().
addAll
(
eventReport
.
getIps
());
}
@Override
protected
void
mergeMachine
(
Machine
old
,
Machine
machine
)
{
}
@Override
protected
void
mergeName
(
EventName
old
,
EventName
other
)
{
old
.
setTotalCount
(
old
.
getTotalCount
()
+
other
.
getTotalCount
());
...
...
@@ -68,16 +57,50 @@ public class EventReportMerger extends DefaultMerger {
old
.
setFails
(
old
.
getFails
()
+
range
.
getFails
());
}
public
EventReport
mergesFrom
(
EventReport
report
)
{
report
.
accept
(
this
);
public
EventName
mergesFor
(
String
typeName
,
String
ip
)
{
EventName
name
=
new
EventName
(
"ALL"
);
EventReport
report
=
getEventReport
();
EventType
type
=
report
.
getMachines
().
get
(
ip
).
findType
(
typeName
);
return
getEventReport
();
if
(
type
!=
null
)
{
for
(
EventName
n
:
type
.
getNames
().
values
())
{
mergeName
(
name
,
n
);
visitNameChildren
(
name
,
n
);
}
}
return
name
;
}
@Override
protected
void
mergeEventReport
(
EventReport
old
,
EventReport
eventReport
)
{
super
.
mergeEventReport
(
old
,
eventReport
);
public
Machine
mergesForAllMachine
()
{
Machine
machine
=
new
Machine
(
CatString
.
ALL_IP
);
EventReport
report
=
getEventReport
();
for
(
Machine
temp
:
report
.
getMachines
().
values
())
{
mergeMachine
(
machine
,
temp
);
visitMachineChildren
(
machine
,
temp
);
}
return
machine
;
}
public
EventName
mergesForAllName
()
{
EventName
name
=
new
EventName
(
"ALL"
);
EventReport
report
=
getEventReport
();
EventType
type
=
report
.
getMachines
().
get
(
m_ip
).
findType
(
m_type
);
if
(
type
!=
null
)
{
for
(
EventName
n
:
type
.
getNames
().
values
())
{
mergeName
(
name
,
n
);
visitNameChildren
(
name
,
n
);
}
}
return
name
;
}
public
EventReport
mergesFrom
(
EventReport
report
)
{
report
.
accept
(
this
);
return
getEventReport
();
}
@Override
...
...
@@ -98,4 +121,33 @@ public class EventReportMerger extends DefaultMerger {
}
}
public
EventReportMerger
setAllIp
(
boolean
allIp
)
{
m_allIp
=
allIp
;
return
this
;
}
public
void
setAllName
(
boolean
allName
)
{
m_allName
=
allName
;
}
public
void
setIp
(
String
ip
)
{
m_ip
=
ip
;
}
public
void
setType
(
String
type
)
{
m_type
=
type
;
}
@Override
public
void
visitEventReport
(
EventReport
eventReport
)
{
super
.
visitEventReport
(
eventReport
);
if
(
m_allIp
)
{
getEventReport
().
addMachine
(
mergesForAllMachine
());
}
if
(
m_allName
)
{
getEventReport
().
getMachines
().
get
(
m_ip
).
getTypes
().
get
(
m_type
).
addName
(
mergesForAllName
());
}
getEventReport
().
getDomainNames
().
addAll
(
eventReport
.
getDomainNames
());
getEventReport
().
getIps
().
addAll
(
eventReport
.
getIps
());
}
}
cat-home/src/main/java/com/dianping/cat/report/page/model/transaction/CompositeTransactionService.java
浏览文件 @
223b917f
...
...
@@ -2,9 +2,7 @@ package com.dianping.cat.report.page.model.transaction;
import
java.util.List
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionName
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionType
;
import
com.dianping.cat.helper.CatString
;
import
com.dianping.cat.report.page.model.spi.ModelRequest
;
import
com.dianping.cat.report.page.model.spi.ModelResponse
;
...
...
@@ -28,10 +26,15 @@ public class CompositeTransactionService extends BaseCompositeModelService<Trans
}
TransactionReportMerger
merger
=
new
TransactionReportMerger
(
new
TransactionReport
(
request
.
getDomain
()));
String
ip
=
request
.
getProperty
(
"ip"
);
merger
.
setIp
(
ip
);
if
(
ip
.
equals
(
CatString
.
ALL_IP
))
{
merger
.
setAllIp
(
true
);
}
String
all
=
request
.
getProperty
(
"all"
);
if
(
"true"
.
equals
(
all
))
{
merger
.
setAllName
(
true
);
merger
.
setType
(
request
.
getProperty
(
"type"
));
}
for
(
ModelResponse
<
TransactionReport
>
response
:
responses
)
{
if
(
response
!=
null
)
{
TransactionReport
model
=
response
.
getModel
();
...
...
@@ -40,21 +43,6 @@ public class CompositeTransactionService extends BaseCompositeModelService<Trans
}
}
}
TransactionReport
report
=
merger
.
getTransactionReport
();
String
all
=
request
.
getProperty
(
"all"
);
if
(
"true"
.
equals
(
all
))
{
String
type
=
request
.
getProperty
(
"type"
);
TransactionNameAggregator
aggregator
=
new
TransactionNameAggregator
(
report
);
TransactionName
n
=
aggregator
.
mergesFor
(
type
,
ip
);
TransactionType
t
=
new
TransactionType
(
type
).
addName
(
n
);
TransactionReport
result
=
new
TransactionReport
(
request
.
getDomain
());
result
.
findOrCreateMachine
(
ip
).
addType
(
t
);
return
result
;
}
else
{
return
report
;
}
return
merger
.
getTransactionReport
();
}
}
cat-home/src/main/java/com/dianping/cat/report/page/model/transaction/TransactionNameAggregator.java
已删除
100644 → 0
浏览文件 @
af0f3ad3
package
com.dianping.cat.report.page.model.transaction
;
import
com.dianping.cat.consumer.transaction.model.entity.Duration
;
import
com.dianping.cat.consumer.transaction.model.entity.Range
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionName
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionType
;
import
com.dianping.cat.consumer.transaction.model.transform.DefaultMerger
;
public
class
TransactionNameAggregator
extends
DefaultMerger
{
public
TransactionNameAggregator
(
TransactionReport
transactionReport
)
{
super
(
transactionReport
);
}
@Override
protected
void
mergeDuration
(
Duration
old
,
Duration
duration
)
{
old
.
setCount
(
old
.
getCount
()
+
duration
.
getCount
());
}
@Override
public
void
visitDuration
(
Duration
duration
)
{
Object
parent
=
getStack
().
peek
();
Duration
old
=
null
;
if
(
parent
instanceof
TransactionName
)
{
TransactionName
name
=
(
TransactionName
)
parent
;
old
=
name
.
findOrCreateDuration
(
duration
.
getValue
());
mergeDuration
(
old
,
duration
);
}
visitDurationChildren
(
old
,
duration
);
}
@Override
public
void
visitRange
(
Range
range
)
{
Object
parent
=
getStack
().
peek
();
Range
old
=
null
;
if
(
parent
instanceof
TransactionName
)
{
TransactionName
name
=
(
TransactionName
)
parent
;
old
=
name
.
findOrCreateRange
(
range
.
getValue
());
mergeRange
(
old
,
range
);
}
visitRangeChildren
(
old
,
range
);
}
@Override
protected
void
mergeName
(
TransactionName
old
,
TransactionName
other
)
{
old
.
setTotalCount
(
old
.
getTotalCount
()
+
other
.
getTotalCount
());
old
.
setFailCount
(
old
.
getFailCount
()
+
other
.
getFailCount
());
if
(
other
.
getMin
()
<
old
.
getMin
())
{
old
.
setMin
(
other
.
getMin
());
}
if
(
other
.
getMax
()
>
old
.
getMax
())
{
old
.
setMax
(
other
.
getMax
());
}
old
.
setSum
(
old
.
getSum
()
+
other
.
getSum
());
old
.
setSum2
(
old
.
getSum2
()
+
other
.
getSum2
());
if
(
old
.
getTotalCount
()
>
0
)
{
old
.
setFailPercent
(
old
.
getFailCount
()
*
100.0
/
old
.
getTotalCount
());
old
.
setAvg
(
old
.
getSum
()
/
old
.
getTotalCount
());
old
.
setStd
(
std
(
old
.
getTotalCount
(),
old
.
getAvg
(),
old
.
getSum2
()));
}
if
(
old
.
getSuccessMessageUrl
()
==
null
)
{
old
.
setSuccessMessageUrl
(
other
.
getSuccessMessageUrl
());
}
if
(
old
.
getFailMessageUrl
()
==
null
)
{
old
.
setFailMessageUrl
(
other
.
getFailMessageUrl
());
}
}
@Override
protected
void
mergeRange
(
Range
old
,
Range
range
)
{
old
.
setCount
(
old
.
getCount
()
+
range
.
getCount
());
old
.
setFails
(
old
.
getFails
()
+
range
.
getFails
());
old
.
setSum
(
old
.
getSum
()
+
range
.
getSum
());
if
(
old
.
getCount
()
>
0
)
{
old
.
setAvg
(
old
.
getSum
()
/
old
.
getCount
());
}
}
public
TransactionName
mergesFor
(
String
typeName
,
String
ip
)
{
TransactionName
name
=
new
TransactionName
(
"ALL"
);
TransactionReport
report
=
getTransactionReport
();
TransactionType
type
=
report
.
getMachines
().
get
(
ip
).
findType
(
typeName
);
if
(
type
!=
null
)
{
for
(
TransactionName
n
:
type
.
getNames
().
values
())
{
mergeName
(
name
,
n
);
visitNameChildren
(
name
,
n
);
}
}
return
name
;
}
protected
double
std
(
long
count
,
double
ave
,
double
sum2
)
{
return
Math
.
sqrt
(
sum2
/
count
-
ave
*
ave
);
}
}
cat-home/src/main/java/com/dianping/cat/report/page/model/transaction/TransactionReportMerger.java
浏览文件 @
223b917f
...
...
@@ -13,10 +13,11 @@ import com.dianping.cat.helper.CatString;
public
class
TransactionReportMerger
extends
DefaultMerger
{
private
boolean
m_allIp
=
false
;
public
TransactionReportMerger
setAllIp
(
boolean
allIp
)
{
m_allIp
=
allIp
;
return
this
;
}
private
boolean
m_allName
=
false
;
private
String
m_ip
;
private
String
m_type
;
public
TransactionReportMerger
(
TransactionReport
transactionReport
)
{
super
(
transactionReport
);
...
...
@@ -25,28 +26,12 @@ public class TransactionReportMerger extends DefaultMerger {
}
@Override
public
void
visitMachine
(
Machine
machine
)
{
if
(
m_allIp
)
{
Machine
newMachine
=
new
Machine
(
CatString
.
ALL_IP
);
for
(
TransactionType
type
:
machine
.
getTypes
().
values
())
{
newMachine
.
addType
(
type
);
}
super
.
visitMachine
(
newMachine
);
}
else
{
super
.
visitMachine
(
machine
);
}
}
@Override
public
void
visitTransactionReport
(
TransactionReport
transactionReport
)
{
super
.
visitTransactionReport
(
transactionReport
);
getTransactionReport
().
getDomainNames
().
addAll
(
transactionReport
.
getDomainNames
());
getTransactionReport
().
getIps
().
addAll
(
transactionReport
.
getIps
());
protected
void
mergeDuration
(
Duration
old
,
Duration
duration
)
{
old
.
setCount
(
old
.
getCount
()
+
duration
.
getCount
());
}
@Override
protected
void
mergeDuration
(
Duration
old
,
Duration
duration
)
{
old
.
setCount
(
old
.
getCount
()
+
duration
.
getCount
());
protected
void
mergeMachine
(
Machine
old
,
Machine
machine
)
{
}
@Override
...
...
@@ -91,6 +76,31 @@ public class TransactionReportMerger extends DefaultMerger {
}
}
public
Machine
mergesForAllMachine
()
{
Machine
machine
=
new
Machine
(
CatString
.
ALL_IP
);
TransactionReport
report
=
getTransactionReport
();
for
(
Machine
temp
:
report
.
getMachines
().
values
())
{
mergeMachine
(
machine
,
temp
);
visitMachineChildren
(
machine
,
temp
);
}
return
machine
;
}
public
TransactionName
mergesForAllName
()
{
TransactionName
name
=
new
TransactionName
(
"ALL"
);
TransactionReport
report
=
getTransactionReport
();
TransactionType
type
=
report
.
getMachines
().
get
(
m_ip
).
findType
(
m_type
);
if
(
type
!=
null
)
{
for
(
TransactionName
n
:
type
.
getNames
().
values
())
{
mergeName
(
name
,
n
);
visitNameChildren
(
name
,
n
);
}
}
return
name
;
}
public
TransactionReport
mergesFrom
(
TransactionReport
report
)
{
report
.
accept
(
this
);
...
...
@@ -114,8 +124,8 @@ public class TransactionReportMerger extends DefaultMerger {
if
(
other
.
getMax
()
>
old
.
getMax
())
{
old
.
setMax
(
other
.
getMax
());
}
old
.
setSum
(
old
.
getSum
()
+
other
.
getSum
());
old
.
setSum2
(
old
.
getSum2
()
+
other
.
getSum2
());
if
(
old
.
getTotalCount
()
>
0
)
{
...
...
@@ -133,6 +143,26 @@ public class TransactionReportMerger extends DefaultMerger {
}
}
public
TransactionReportMerger
setAllIp
(
boolean
allIp
)
{
m_allIp
=
allIp
;
return
this
;
}
public
TransactionReportMerger
setAllName
(
boolean
allName
)
{
m_allName
=
allName
;
return
this
;
}
public
TransactionReportMerger
setIp
(
String
ip
)
{
m_ip
=
ip
;
return
this
;
}
public
TransactionReportMerger
setType
(
String
type
)
{
m_type
=
type
;
return
this
;
}
protected
double
std
(
long
count
,
double
avg
,
double
sum2
,
double
max
)
{
double
value
=
sum2
/
count
-
avg
*
avg
;
...
...
@@ -144,4 +174,17 @@ public class TransactionReportMerger extends DefaultMerger {
return
Math
.
sqrt
(
value
);
}
}
@Override
public
void
visitTransactionReport
(
TransactionReport
transactionReport
)
{
super
.
visitTransactionReport
(
transactionReport
);
if
(
m_allIp
)
{
getTransactionReport
().
addMachine
(
mergesForAllMachine
());
}
if
(
m_allName
)
{
getTransactionReport
().
getMachines
().
get
(
m_ip
).
getTypes
().
get
(
m_type
).
addName
(
mergesForAllName
());
}
getTransactionReport
().
getDomainNames
().
addAll
(
transactionReport
.
getDomainNames
());
getTransactionReport
().
getIps
().
addAll
(
transactionReport
.
getIps
());
}
}
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Handler.java
浏览文件 @
223b917f
...
...
@@ -55,31 +55,6 @@ public class Handler implements PageHandler<Context>, Initializable {
private
StatisticsComputer
m_computer
=
new
StatisticsComputer
();
private
TransactionName
getAggregatedTransactionName
(
Payload
payload
)
{
String
domain
=
payload
.
getDomain
();
String
type
=
payload
.
getType
();
String
date
=
String
.
valueOf
(
payload
.
getDate
());
String
ipAddress
=
payload
.
getIpAddress
();
ModelRequest
request
=
new
ModelRequest
(
domain
,
payload
.
getPeriod
())
//
.
setProperty
(
"date"
,
date
)
//
.
setProperty
(
"type"
,
type
)
//
.
setProperty
(
"name"
,
"*"
)
//
.
setProperty
(
"all"
,
"true"
)
//
.
setProperty
(
"ip"
,
ipAddress
);
ModelResponse
<
TransactionReport
>
response
=
m_service
.
invoke
(
request
);
String
ip
=
payload
.
getIpAddress
();
TransactionReport
report
=
response
.
getModel
();
TransactionType
t
=
report
==
null
?
null
:
report
.
getMachines
().
get
(
ip
).
findType
(
type
);
if
(
t
!=
null
)
{
TransactionName
all
=
t
.
findName
(
"ALL"
);
return
all
;
}
else
{
return
null
;
}
}
private
TransactionName
getTransactionName
(
Payload
payload
)
{
String
domain
=
payload
.
getDomain
();
String
type
=
payload
.
getType
();
...
...
@@ -92,6 +67,11 @@ public class Handler implements PageHandler<Context>, Initializable {
.
setProperty
(
"type"
,
payload
.
getType
())
//
.
setProperty
(
"name"
,
payload
.
getName
())
//
.
setProperty
(
"ip"
,
ipAddress
);
if
(
name
==
null
||
name
.
length
()
==
0
)
{
request
.
setProperty
(
"name"
,
"*"
);
request
.
setProperty
(
"all"
,
"true"
);
name
=
"ALL"
;
}
ModelResponse
<
TransactionReport
>
response
=
m_service
.
invoke
(
request
);
TransactionReport
report
=
response
.
getModel
();
TransactionType
t
=
report
.
getMachines
().
get
(
ip
).
findType
(
type
);
...
...
@@ -246,13 +226,7 @@ public class Handler implements PageHandler<Context>, Initializable {
}
private
MobileTransactionGraphs
showMobileGraphs
(
Model
model
,
Payload
payload
)
{
TransactionName
name
;
if
(
payload
.
getName
()
==
null
||
payload
.
getName
().
length
()
==
0
)
{
name
=
getAggregatedTransactionName
(
payload
);
}
else
{
name
=
getTransactionName
(
payload
);
}
TransactionName
name
=
getTransactionName
(
payload
);
if
(
name
==
null
)
{
return
null
;
...
...
@@ -262,13 +236,7 @@ public class Handler implements PageHandler<Context>, Initializable {
}
private
void
showGraphs
(
Model
model
,
Payload
payload
)
{
TransactionName
name
;
if
(
payload
.
getName
()
==
null
||
payload
.
getName
().
length
()
==
0
)
{
name
=
getAggregatedTransactionName
(
payload
);
}
else
{
name
=
getTransactionName
(
payload
);
}
TransactionName
name
=
getTransactionName
(
payload
);
if
(
name
==
null
)
{
return
;
...
...
cat-home/src/test/java/com/dianping/cat/AllTests.java
浏览文件 @
223b917f
...
...
@@ -9,9 +9,7 @@ import com.dianping.cat.report.page.ip.location.IPSeekerTest;
import
com.dianping.cat.report.page.model.EventReportFilterTest
;
import
com.dianping.cat.report.page.model.TransactionReportFilterTest
;
import
com.dianping.cat.report.page.model.event.EventModelServiceTest
;
import
com.dianping.cat.report.page.model.event.EventNameAggregatorTest
;
import
com.dianping.cat.report.page.model.transaction.TransactionModelServiceTest
;
import
com.dianping.cat.report.page.model.transaction.TransactionNameAggregatorTest
;
import
com.dianping.cat.report.page.transaction.TransactionReportMergerTest
;
@RunWith
(
Suite
.
class
)
...
...
@@ -28,13 +26,9 @@ TransactionReportFilterTest.class,
/* .report.page.model.event */
EventModelServiceTest
.
class
,
EventNameAggregatorTest
.
class
,
/* .report.page.model.transaction */
TransactionModelServiceTest
.
class
,
TransactionNameAggregatorTest
.
class
,
/* .report.page.transaction */
TransactionReportMergerTest
.
class
,
...
...
cat-home/src/test/java/com/dianping/cat/report/page/model/event/EventNameAggregatorTest.java
已删除
100644 → 0
浏览文件 @
af0f3ad3
package
com.dianping.cat.report.page.model.event
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
com.dianping.cat.consumer.event.model.entity.EventName
;
import
com.dianping.cat.consumer.event.model.entity.EventReport
;
import
com.dianping.cat.consumer.event.model.transform.DefaultDomParser
;
import
com.site.helper.Files
;
public
class
EventNameAggregatorTest
{
@Test
public
void
test
()
throws
Exception
{
DefaultDomParser
parser
=
new
DefaultDomParser
();
String
source
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"event.xml"
),
"utf-8"
);
EventReport
report
=
parser
.
parse
(
source
);
String
expected
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"event-names.xml"
),
"utf-8"
);
EventName
all
=
new
EventNameAggregator
(
report
).
mergesFor
(
"URL"
,
""
);
Assert
.
assertEquals
(
expected
.
replace
(
"\r"
,
""
),
all
.
toString
().
replace
(
"\r"
,
""
));
}
}
cat-home/src/test/java/com/dianping/cat/report/page/model/transaction/TransactionNameAggregatorTest.java
已删除
100644 → 0
浏览文件 @
af0f3ad3
package
com.dianping.cat.report.page.model.transaction
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionName
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
import
com.dianping.cat.consumer.transaction.model.transform.DefaultDomParser
;
import
com.site.helper.Files
;
public
class
TransactionNameAggregatorTest
{
@Test
public
void
test
()
throws
Exception
{
DefaultDomParser
parser
=
new
DefaultDomParser
();
String
source
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"transaction.xml"
),
"utf-8"
);
TransactionReport
report
=
parser
.
parse
(
source
);
String
expected
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"transaction-names.xml"
),
"utf-8"
);
TransactionName
all
=
new
TransactionNameAggregator
(
report
).
mergesFor
(
"URL"
,
""
);
Assert
.
assertEquals
(
expected
.
replace
(
"\r"
,
""
),
all
.
toString
().
replace
(
"\r"
,
""
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录