Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
eb0ecded
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,发现更多精彩内容 >>
提交
eb0ecded
编写于
6月 22, 2012
作者:
F
Frankie Wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
model merger enhanced
上级
afd9ab2c
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
79 addition
and
161 deletion
+79
-161
cat-consumer/pom.xml
cat-consumer/pom.xml
+1
-1
cat-consumer/src/main/java/com/dianping/cat/consumer/heartbeat/HeartbeatAnalyzer.java
...om/dianping/cat/consumer/heartbeat/HeartbeatAnalyzer.java
+0
-1
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionAnalyzer.java
...ianping/cat/consumer/transaction/TransactionAnalyzer.java
+1
-2
cat-consumer/src/main/resources/META-INF/dal/model/event-report-model.xml
.../main/resources/META-INF/dal/model/event-report-model.xml
+1
-1
cat-consumer/src/main/resources/META-INF/dal/model/heartbeat-report-model.xml
...n/resources/META-INF/dal/model/heartbeat-report-model.xml
+1
-1
cat-consumer/src/main/resources/META-INF/dal/model/ip-report-model.xml
...src/main/resources/META-INF/dal/model/ip-report-model.xml
+1
-1
cat-consumer/src/main/resources/META-INF/dal/model/problem-report-model.xml
...ain/resources/META-INF/dal/model/problem-report-model.xml
+1
-1
cat-consumer/src/main/resources/META-INF/dal/model/system-report-model.xml
...main/resources/META-INF/dal/model/system-report-model.xml
+0
-36
cat-consumer/src/main/resources/META-INF/dal/model/transaction-report-model.xml
...resources/META-INF/dal/model/transaction-report-model.xml
+1
-1
cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/Test.java
...ain/java/com/dianping/cat/report/page/heartbeat/Test.java
+7
-11
cat-home/src/main/java/com/dianping/cat/report/page/model/event/HistoricalEventService.java
...g/cat/report/page/model/event/HistoricalEventService.java
+0
-1
cat-home/src/main/java/com/dianping/cat/report/page/model/event/LocalEventService.java
...anping/cat/report/page/model/event/LocalEventService.java
+0
-1
cat-home/src/main/java/com/dianping/cat/report/page/model/problem/HistoricalProblemService.java
...t/report/page/model/problem/HistoricalProblemService.java
+0
-1
cat-home/src/main/java/com/dianping/cat/report/page/model/transaction/TransactionReportMerger.java
...eport/page/model/transaction/TransactionReportMerger.java
+41
-52
cat-home/src/test/java/com/dianping/cat/AllTests.java
cat-home/src/test/java/com/dianping/cat/AllTests.java
+0
-8
cat-home/src/test/java/com/dianping/cat/report/page/transaction/GraphDateTest.java
...m/dianping/cat/report/page/transaction/GraphDateTest.java
+0
-1
cat-home/src/test/java/com/dianping/cat/report/page/transaction/TransactionReportMergerTest.java
.../report/page/transaction/TransactionReportMergerTest.java
+21
-21
cat-home/src/test/resources/com/dianping/cat/report/page/transaction/TransactionReportMergeAllIpAllName.xml
...t/page/transaction/TransactionReportMergeAllIpAllName.xml
+1
-18
cat-home/src/test/resources/com/dianping/cat/report/page/transaction/TransactionReportNew.xml
...ping/cat/report/page/transaction/TransactionReportNew.xml
+1
-1
cat-home/src/test/resources/com/dianping/cat/report/page/transaction/TransactionReportOld.xml
...ping/cat/report/page/transaction/TransactionReportOld.xml
+1
-1
未找到文件。
cat-consumer/pom.xml
浏览文件 @
eb0ecded
...
...
@@ -30,7 +30,7 @@
<plugin>
<groupId>
org.unidal.maven.plugins
</groupId>
<artifactId>
codegen-maven-plugin
</artifactId>
<version>
1.1.
1
</version>
<version>
1.1.
3
</version>
<executions>
<execution>
<id>
generate heartbeat report model
</id>
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/heartbeat/HeartbeatAnalyzer.java
浏览文件 @
eb0ecded
...
...
@@ -16,7 +16,6 @@ import com.dianping.cat.configuration.NetworkInterfaceManager;
import
com.dianping.cat.consumer.heartbeat.model.entity.Disk
;
import
com.dianping.cat.consumer.heartbeat.model.entity.HeartbeatReport
;
import
com.dianping.cat.consumer.heartbeat.model.entity.Period
;
import
com.dianping.cat.consumer.heartbeat.model.transform.DefaultDomParser
;
import
com.dianping.cat.consumer.heartbeat.model.transform.DefaultSaxParser
;
import
com.dianping.cat.consumer.heartbeat.model.transform.DefaultXmlBuilder
;
import
com.dianping.cat.hadoop.dal.Report
;
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionAnalyzer.java
浏览文件 @
eb0ecded
...
...
@@ -11,8 +11,8 @@ import java.util.HashMap;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
...
...
@@ -28,7 +28,6 @@ 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.DefaultSaxParser
;
import
com.dianping.cat.consumer.transaction.model.transform.DefaultXmlBuilder
;
import
com.dianping.cat.consumer.transaction.model.transform.DefaultDomParser
;
import
com.dianping.cat.hadoop.dal.Report
;
import
com.dianping.cat.hadoop.dal.ReportDao
;
import
com.dianping.cat.hadoop.dal.Task
;
...
...
cat-consumer/src/main/resources/META-INF/dal/model/event-report-model.xml
浏览文件 @
eb0ecded
<?xml version="1.0" encoding="UTF-8"?>
<model
model-package=
"com.dianping.cat.consumer.event.model"
enable-merger=
"true"
enable-json-builder=
"true"
enable-xml-parser=
"true"
enable-sax-parser=
"true"
enable-base-visitor=
"true"
>
enable-xml-parser=
"true"
enable-sax-parser=
"true"
enable-
json-parser=
"true"
enable-
base-visitor=
"true"
>
<entity
name=
"event-report"
root=
"true"
>
<attribute
name=
"domain"
key=
"true"
/>
<element
name=
"domain"
value-type=
"String"
type=
"set"
names=
"domain-names"
/>
...
...
cat-consumer/src/main/resources/META-INF/dal/model/heartbeat-report-model.xml
浏览文件 @
eb0ecded
<?xml version="1.0" encoding="UTF-8"?>
<model
model-package=
"com.dianping.cat.consumer.heartbeat.model"
enable-merger=
"true"
enable-json-builder=
"true"
enable-xml-parser=
"true"
enable-sax-parser=
"true"
enable-base-visitor=
"true"
>
enable-xml-parser=
"true"
enable-sax-parser=
"true"
enable-
json-parser=
"true"
enable-
base-visitor=
"true"
>
<entity
name=
"heartbeat-report"
root=
"true"
>
<attribute
name=
"domain"
value-type=
"String"
key=
"true"
/>
<attribute
name=
"startTime"
value-type=
"Date"
format=
"yyyy-MM-dd HH:mm:ss"
/>
...
...
cat-consumer/src/main/resources/META-INF/dal/model/ip-report-model.xml
浏览文件 @
eb0ecded
<?xml version="1.0" encoding="UTF-8"?>
<model
model-package=
"com.dianping.cat.consumer.ip.model"
enable-merger=
"true"
enable-json-builder=
"true"
enable-xml-parser=
"true"
enable-sax-parser=
"true"
enable-base-visitor=
"true"
>
enable-xml-parser=
"true"
enable-sax-parser=
"true"
enable-
json-parser=
"true"
enable-
base-visitor=
"true"
>
<entity
name=
"ip-report"
root=
"true"
>
<attribute
name=
"domain"
key=
"true"
/>
<element
name=
"domain"
value-type=
"String"
type=
"set"
names=
"domain-names"
/>
...
...
cat-consumer/src/main/resources/META-INF/dal/model/problem-report-model.xml
浏览文件 @
eb0ecded
<?xml version="1.0" encoding="UTF-8"?>
<model
model-package=
"com.dianping.cat.consumer.problem.model"
enable-merger=
"true"
enable-json-builder=
"true"
enable-xml-parser=
"true"
enable-sax-parser=
"true"
enable-
base-visitor=
"true"
enable-model-test=
"fals
e"
>
enable-xml-parser=
"true"
enable-sax-parser=
"true"
enable-
json-parser=
"true"
enable-base-visitor=
"tru
e"
>
<entity
name=
"problem-report"
root=
"true"
>
<attribute
name=
"domain"
value-type=
"String"
key=
"true"
/>
<element
name=
"domain"
value-type=
"String"
type=
"set"
names=
"domain-names"
/>
...
...
cat-consumer/src/main/resources/META-INF/dal/model/system-report-model.xml
已删除
100644 → 0
浏览文件 @
afd9ab2c
<?xml version="1.0" encoding="UTF-8"?>
<model
model-package=
"com.dianping.cat.consumer.system.model"
enable-merger=
"true"
enable-json-builder=
"true"
enable-xml-parser=
"true"
enable-base-visitor=
"true"
>
<entity
name=
"system-report"
root=
"true"
>
<attribute
name=
"domain"
value-type=
"String"
key=
"true"
/>
<attribute
name=
"startTime"
value-type=
"Date"
format=
"yyyy-MM-dd HH:mm:ss"
/>
<attribute
name=
"endTime"
value-type=
"Date"
format=
"yyyy-MM-dd HH:mm:ss"
/>
<element
name=
"domain"
value-type=
"String"
type=
"set"
names=
"domain-names"
/>
<element
name=
"ip"
value-type=
"String"
type=
"set"
names=
"ips"
/>
<entity-ref
name=
"machine"
type=
"map"
names=
"machines"
method-find-or-create=
"true"
/>
</entity>
<entity
name=
"machine"
>
<attribute
name=
"ip"
value-type=
"String"
key=
"true"
/>
<entity-ref
name=
"period"
type=
"list"
names=
"periods"
/>
</entity>
<entity
name=
"period"
>
<attribute
name=
"minute"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"thread-count"
value-type=
"int"
primitive=
"true"
/>
<attribute
name=
"daemon-count"
value-type=
"int"
primitive=
"true"
/>
<attribute
name=
"total-started-count"
value-type=
"int"
primitive=
"true"
/>
<attribute
name=
"cat-thread-count"
value-type=
"int"
primitive=
"true"
/>
<attribute
name=
"pigeon-thread-count"
value-type=
"int"
primitive=
"true"
/>
<attribute
name=
"gc-count"
value-type=
"int"
primitive=
"true"
/>
<attribute
name=
"memory-free"
value-type=
"double"
primitive=
"true"
/>
<attribute
name=
"heap-usage"
value-type=
"double"
primitive=
"true"
/>
<attribute
name=
"none-heap-usage"
value-type=
"double"
primitive=
"true"
/>
<attribute
name=
"disk-free"
value-type=
"double"
primitive=
"true"
/>
<attribute
name=
"disk-useable"
value-type=
"double"
primitive=
"true"
/>
<attribute
name=
"system-load-average"
value-type=
"double"
primitive=
"true"
/>
<attribute
name=
"cat-message-produced"
value-type=
"long"
primitive=
"true"
/>
<attribute
name=
"cat-message-overflow"
value-type=
"long"
primitive=
"true"
/>
<attribute
name=
"cat-message-size"
value-type=
"double"
primitive=
"true"
/>
</entity>
</model>
cat-consumer/src/main/resources/META-INF/dal/model/transaction-report-model.xml
浏览文件 @
eb0ecded
<?xml version="1.0" encoding="UTF-8"?>
<model
model-package=
"com.dianping.cat.consumer.transaction.model"
enable-merger=
"true"
enable-json-builder=
"true"
enable-xml-parser=
"true"
enable-sax-parser=
"true"
enable-base-visitor=
"true"
>
enable-xml-parser=
"true"
enable-sax-parser=
"true"
enable-
json-parser=
"true"
enable-
base-visitor=
"true"
>
<entity
name=
"transaction-report"
root=
"true"
>
<attribute
name=
"domain"
key=
"true"
/>
<attribute
name=
"startTime"
value-type=
"Date"
format=
"yyyy-MM-dd HH:mm:ss"
/>
...
...
cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/Test.java
浏览文件 @
eb0ecded
package
com.dianping.cat.report.page.heartbeat
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
Test
{
public
static
void
main
(
String
[]
args
)
{
/* Map<String,String> s=new HashMap<String,String>();
s.put("", "kitty");
String k=s.get("")
;
k="jianmei";
*/
System
.
out
.
println
(
"sssssssssssss"
);
}
/*
* Map<String,String> s=new HashMap<String,String>();
s.put("", "kitty");
* String k=s.get(""); k="jianmei"
;
*/
System
.
out
.
println
(
"sssssssssssss"
);
}
}
cat-home/src/main/java/com/dianping/cat/report/page/model/event/HistoricalEventService.java
浏览文件 @
eb0ecded
...
...
@@ -4,7 +4,6 @@ import java.util.Date;
import
java.util.List
;
import
com.dianping.cat.consumer.event.model.entity.EventReport
;
import
com.dianping.cat.consumer.event.model.transform.DefaultDomParser
;
import
com.dianping.cat.consumer.event.model.transform.DefaultSaxParser
;
import
com.dianping.cat.hadoop.dal.Report
;
import
com.dianping.cat.hadoop.dal.ReportDao
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/model/event/LocalEventService.java
浏览文件 @
eb0ecded
package
com.dianping.cat.report.page.model.event
;
import
com.dianping.cat.consumer.event.model.entity.EventReport
;
import
com.dianping.cat.consumer.event.model.transform.DefaultDomParser
;
import
com.dianping.cat.consumer.event.model.transform.DefaultSaxParser
;
import
com.dianping.cat.report.page.model.spi.ModelPeriod
;
import
com.dianping.cat.report.page.model.spi.ModelRequest
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/model/problem/HistoricalProblemService.java
浏览文件 @
eb0ecded
...
...
@@ -4,7 +4,6 @@ import java.util.Date;
import
java.util.List
;
import
com.dianping.cat.consumer.problem.model.entity.ProblemReport
;
import
com.dianping.cat.consumer.problem.model.transform.DefaultDomParser
;
import
com.dianping.cat.consumer.problem.model.transform.DefaultSaxParser
;
import
com.dianping.cat.hadoop.dal.Report
;
import
com.dianping.cat.hadoop.dal.ReportDao
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/model/transaction/TransactionReportMerger.java
浏览文件 @
eb0ecded
package
com.dianping.cat.report.page.model.transaction
;
import
java.util.Map
;
import
com.dianping.cat.consumer.transaction.StatisticsComputer
;
import
com.dianping.cat.consumer.transaction.model.entity.Duration
;
import
com.dianping.cat.consumer.transaction.model.entity.Machine
;
...
...
@@ -21,23 +19,21 @@ public class TransactionReportMerger extends DefaultMerger {
private
String
m_type
;
private
Machine
m_allMachines
;
private
TransactionName
m_allNames
;
public
TransactionReportMerger
(
TransactionReport
transactionReport
)
{
super
(
transactionReport
);
transactionReport
.
accept
(
new
StatisticsComputer
());
}
@Override
public
void
visitMachine
(
Machine
machine
)
{
super
.
visitMachine
(
machine
);
}
@Override
protected
void
mergeDuration
(
Duration
old
,
Duration
duration
)
{
old
.
setCount
(
old
.
getCount
()
+
duration
.
getCount
());
}
@Override
protected
void
mergeMachine
(
Machine
old
,
Machine
machine
)
{
}
...
...
@@ -91,40 +87,14 @@ public class TransactionReportMerger extends DefaultMerger {
public
Machine
mergesForAllMachine
(
TransactionReport
report
)
{
Machine
machine
=
new
Machine
(
CatString
.
ALL_IP
);
for
(
Machine
temp
:
report
.
getMachines
().
values
())
{
if
(!
temp
.
getIp
().
equals
(
CatString
.
ALL_IP
))
{
mergeMachine
(
machine
,
temp
);
visitMachineChildren
(
machine
,
temp
);
}
}
return
machine
;
}
public
TransactionName
mergesForAllName
(
TransactionReport
report
)
{
TransactionName
name
=
new
TransactionName
(
"ALL"
);
TransactionType
type
=
report
.
getMachines
().
get
(
m_ip
).
findType
(
m_type
);
if
(
type
!=
null
)
{
for
(
TransactionName
n
:
type
.
getNames
().
values
())
{
if
(!
n
.
getId
().
equals
(
"ALL"
))
{
mergeName
(
name
,
n
);
visitNameChildren
(
name
,
n
);
}
for
(
Machine
m
:
report
.
getMachines
().
values
())
{
if
(!
m
.
getIp
().
equals
(
CatString
.
ALL_IP
))
{
visitMachineChildren
(
machine
,
m
);
}
}
return
name
;
}
public
TransactionReport
mergesFrom
(
TransactionReport
report
)
{
report
.
accept
(
this
);
return
getTransactionReport
();
}
@Override
protected
void
mergeTransactionReport
(
TransactionReport
old
,
TransactionReport
transactionReport
)
{
super
.
mergeTransactionReport
(
old
,
transactionReport
);
return
machine
;
}
@Override
...
...
@@ -194,26 +164,45 @@ public class TransactionReportMerger extends DefaultMerger {
}
}
@Override
public
void
visitMachine
(
Machine
machine
)
{
if
(
m_allIp
)
{
visitMachineChildren
(
m_allMachines
,
machine
);
}
else
{
super
.
visitMachine
(
machine
);
}
}
@Override
public
void
visitName
(
TransactionName
name
)
{
if
(
m_allName
)
{
visitNameChildren
(
m_allNames
,
name
);
}
else
{
super
.
visitName
(
name
);
}
}
@Override
public
void
visitTransactionReport
(
TransactionReport
transactionReport
)
{
TransactionReport
report
=
getTransactionReport
();
if
(
m_allIp
)
{
Map
<
String
,
Machine
>
machines
=
transactionReport
.
getMachines
();
Machine
allMachines
=
mergesForAllMachine
(
transactionReport
);
machines
.
clear
();
transactionReport
.
addMachine
(
allMachines
);
m_allMachines
=
report
.
findOrCreateMachine
(
CatString
.
ALL_IP
);
}
if
(
m_allName
)
{
Machine
machine
=
transactionReport
.
getMachines
().
get
(
m_ip
);
if
(
machine
!=
null
)
{
TransactionName
mergesForAllName
=
mergesForAllName
(
transactionReport
);
TransactionType
type
=
machine
.
getTypes
().
get
(
m_type
);
type
.
getNames
().
clear
();
type
.
addName
(
mergesForAllName
);
}
m_allNames
=
report
.
findOrCreateMachine
(
m_ip
).
findOrCreateType
(
m_type
).
findOrCreateName
(
"ALL"
);
}
super
.
visitTransactionReport
(
transactionReport
);
getTransactionReport
().
getDomainNames
().
addAll
(
transactionReport
.
getDomainNames
());
getTransactionReport
().
getIps
().
addAll
(
transactionReport
.
getIps
());
report
.
getDomainNames
().
addAll
(
transactionReport
.
getDomainNames
());
report
.
getIps
().
addAll
(
transactionReport
.
getIps
());
}
@Override
public
void
visitType
(
TransactionType
type
)
{
if
(!
m_allName
||
m_allName
&&
m_type
.
equals
(
type
.
getId
()))
{
super
.
visitType
(
type
);
}
}
}
cat-home/src/test/java/com/dianping/cat/AllTests.java
浏览文件 @
eb0ecded
...
...
@@ -21,14 +21,6 @@ import com.dianping.cat.report.task.TaskHelperTest;
@RunWith
(
Suite
.
class
)
@SuiteClasses
({
/* .report.page.ip */
DisplayModelTest
.
class
,
/* .report.page.model */
EventReportFilterTest
.
class
,
TransactionReportFilterTest
.
class
,
/* .report.page.model.event */
EventModelServiceTest
.
class
,
...
...
cat-home/src/test/java/com/dianping/cat/report/page/transaction/GraphDateTest.java
浏览文件 @
eb0ecded
...
...
@@ -3,7 +3,6 @@ package com.dianping.cat.report.page.transaction;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
...
...
cat-home/src/test/java/com/dianping/cat/report/page/transaction/TransactionReportMergerTest.java
浏览文件 @
eb0ecded
...
...
@@ -21,58 +21,58 @@ public class TransactionReportMergerTest {
"utf-8"
);
TransactionReportMerger
merger
=
new
TransactionReportMerger
(
reportOld
);
merger
.
mergesFrom
(
reportNew
);
String
actual
=
new
DefaultXmlBuilder
().
buildXml
(
reportOld
);
reportNew
.
accept
(
merger
);
Assert
.
assertEquals
(
"Check the merge result!"
,
expected
.
replace
(
"\r"
,
""
),
actual
.
replace
(
"\r"
,
""
));
Assert
.
assertEquals
(
"Check the merge result!"
,
expected
.
replace
(
"\r"
,
""
),
reportOld
.
toString
().
replace
(
"\r"
,
""
));
Assert
.
assertEquals
(
"Source report is changed!"
,
newXml
.
replace
(
"\r"
,
""
),
reportNew
.
toString
().
replace
(
"\r"
,
""
));
}
@Test
public
void
testMergeAllIp
()
throws
Exception
{
public
void
testMergeAllIp
()
throws
Exception
{
String
oldXml
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"TransactionReportOld.xml"
),
"utf-8"
);
String
newXml
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"TransactionReportNew.xml"
),
"utf-8"
);
TransactionReport
reportOld
=
new
DefaultDomParser
().
parse
(
oldXml
);
TransactionReport
reportNew
=
new
DefaultDomParser
().
parse
(
newXml
);
String
expected
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"TransactionReportMergeAllResult.xml"
),
"utf-8"
);
TransactionReportMerger
merger
=
new
TransactionReportMerger
(
new
TransactionReport
(
reportOld
.
getDomain
()));
merger
.
setAllIp
(
true
);
reportOld
.
accept
(
merger
);
reportNew
.
accept
(
merger
);
String
actual
=
new
DefaultXmlBuilder
().
buildXml
(
merger
.
getTransactionReport
());
Assert
.
assertEquals
(
"Check the merge result!"
,
expected
.
replace
(
"\r"
,
""
),
actual
.
replace
(
"\r"
,
""
));
Assert
.
assertEquals
(
"Source report is changed!"
,
oldXml
.
replace
(
"\r"
,
""
),
reportOld
.
toString
().
replace
(
"\r"
,
""
));
Assert
.
assertEquals
(
"Source report is changed!"
,
newXml
.
replace
(
"\r"
,
""
),
reportNew
.
toString
().
replace
(
"\r"
,
""
));
}
@Test
public
void
testMergeAllIpAllName
()
throws
Exception
{
public
void
testMergeAllIpAllName
()
throws
Exception
{
String
oldXml
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"TransactionReportOld.xml"
),
"utf-8"
);
String
newXml
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"TransactionReportNew.xml"
),
"utf-8"
);
TransactionReport
reportOld
=
new
DefaultDomParser
().
parse
(
oldXml
);
TransactionReport
reportNew
=
new
DefaultDomParser
().
parse
(
newXml
);
String
expected
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"TransactionReportMergeAllIpAllName.xml"
),
"utf-8"
);
String
expected
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"TransactionReportMergeAllIpAllName.xml"
),
"utf-8"
);
TransactionReportMerger
merger
=
new
TransactionReportMerger
(
new
TransactionReport
(
reportOld
.
getDomain
()));
merger
.
setAllIp
(
true
);
merger
.
setIp
(
CatString
.
ALL_IP
);
merger
.
setAllName
(
true
);
merger
.
setType
(
"URL"
);
System
.
out
.
println
(
""
);
reportOld
.
accept
(
merger
);
reportNew
.
accept
(
merger
);
String
actual
=
new
DefaultXmlBuilder
().
buildXml
(
merger
.
getTransactionReport
());
Assert
.
assertEquals
(
"Check the merge result!"
,
expected
.
replace
(
"\r"
,
""
),
actual
.
replace
(
"\r"
,
""
));
Assert
.
assertEquals
(
"Source report is changed!"
,
oldXml
.
replace
(
"\r"
,
""
),
reportOld
.
toString
().
replace
(
"\r"
,
""
));
Assert
.
assertEquals
(
"Source report is changed!"
,
newXml
.
replace
(
"\r"
,
""
),
reportNew
.
toString
().
replace
(
"\r"
,
""
));
}
}
cat-home/src/test/resources/com/dianping/cat/report/page/transaction/TransactionReportMergeAllIpAllName.xml
浏览文件 @
eb0ecded
...
...
@@ -3,29 +3,12 @@
<ip>
192.168.165.1
</ip>
<ip>
192.168.165.2
</ip>
<machine
ip=
"All"
>
<type
id=
"Task1"
totalCount=
"2"
failCount=
"0"
failPercent=
"0.00"
min=
"21.422"
max=
"28.35"
avg=
"24.9"
sum=
"49.8"
sum2=
"1262.6"
std=
"3.5"
tps=
"0.00"
line95Value=
"28.00"
line95Sum=
"28.00"
line95Count=
"1"
>
<successMessageUrl>
Cat-c0a8a501-1337230848968-0
</successMessageUrl>
<name
id=
"Status1"
totalCount=
"2"
failCount=
"0"
failPercent=
"0.00"
min=
"21.422"
max=
"28.35"
avg=
"24.9"
sum=
"49.8"
sum2=
"1262.6"
std=
"3.5"
tps=
"0.00"
line95Value=
"28.00"
line95Sum=
"28.00"
line95Count=
"1"
>
<successMessageUrl>
Cat-c0a8a501-1337230848968-0
</successMessageUrl>
<range
value=
"0"
count=
"2"
sum=
"49.772000000000006"
avg=
"24.9"
fails=
"0"
/>
<duration
value=
"32"
count=
"2"
/>
</name>
</type>
<type
id=
"URL"
totalCount=
"2"
failCount=
"0"
failPercent=
"0.00"
min=
"39780.276"
max=
"39780.276"
avg=
"39780.3"
sum=
"79560.6"
sum2=
"3164940717.2"
std=
"0.0"
tps=
"0.00"
line95Value=
"39780.00"
line95Sum=
"79560.00"
line95Count=
"2"
>
<successMessageUrl>
Cat-c0a8a501-1337230896586-0
</successMessageUrl>
<name
id=
"ALL"
totalCount=
"2"
failCount=
"0"
failPercent=
"0.00"
min=
"39780.276"
max=
"39780.276"
avg=
"39780.3"
sum=
"79560.6"
sum2=
"3164940717.2"
std=
"0.0"
tps=
"0.00"
line95Value=
"39780.00"
line95Sum=
"79560.00"
line95Count=
"2"
>
<successMessageUrl>
Cat-c0a8a501-1337230896586-0
</successMessageUrl>
<name
id=
"ALL"
totalCount=
"0"
failCount=
"0"
failPercent=
"0.00"
min=
"8.64E7"
max=
"-1.0"
avg=
"0.0"
sum=
"0.0"
sum2=
"0.0"
std=
"0.0"
tps=
"0.00"
line95Value=
"0.00"
line95Sum=
"0.00"
line95Count=
"0"
>
<range
value=
"0"
count=
"2"
sum=
"79560.552"
avg=
"39780.3"
fails=
"0"
/>
<duration
value=
"65536"
count=
"2"
/>
</name>
</type>
<type
id=
"Task"
totalCount=
"2"
failCount=
"0"
failPercent=
"0.00"
min=
"21.422"
max=
"28.35"
avg=
"24.9"
sum=
"49.8"
sum2=
"1262.6"
std=
"3.5"
tps=
"0.00"
line95Value=
"28.00"
line95Sum=
"28.00"
line95Count=
"1"
>
<successMessageUrl>
Cat-c0a8a501-1337230848968-0
</successMessageUrl>
<name
id=
"Status"
totalCount=
"2"
failCount=
"0"
failPercent=
"0.00"
min=
"21.422"
max=
"28.35"
avg=
"24.9"
sum=
"49.8"
sum2=
"1262.6"
std=
"3.5"
tps=
"0.00"
line95Value=
"28.00"
line95Sum=
"28.00"
line95Count=
"1"
>
<successMessageUrl>
Cat-c0a8a501-1337230848968-0
</successMessageUrl>
<range
value=
"0"
count=
"2"
sum=
"49.772000000000006"
avg=
"24.9"
fails=
"0"
/>
<duration
value=
"32"
count=
"2"
/>
</name>
</type>
</machine>
</transaction-report>
cat-home/src/test/resources/com/dianping/cat/report/page/transaction/TransactionReportNew.xml
浏览文件 @
eb0ecded
...
...
@@ -19,4 +19,4 @@
</name>
</type>
</machine>
</transaction-report>
\ No newline at end of file
</transaction-report>
cat-home/src/test/resources/com/dianping/cat/report/page/transaction/TransactionReportOld.xml
浏览文件 @
eb0ecded
...
...
@@ -19,4 +19,4 @@
</name>
</type>
</machine>
</transaction-report>
\ No newline at end of file
</transaction-report>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录