Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
570e7bc7
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,发现更多精彩内容 >>
提交
570e7bc7
编写于
6月 28, 2012
作者:
F
Frankie Wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support native builder & parser
上级
f073eb09
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
971 addition
and
1029 deletion
+971
-1029
cat-consumer/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
...m/dianping/cat/consumer/build/ComponentsConfigurator.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
+2
-1
cat-consumer/src/main/resources/META-INF/dal/model/heartbeat-report-model.xml
...n/resources/META-INF/dal/model/heartbeat-report-model.xml
+2
-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
+2
-1
cat-consumer/src/main/resources/META-INF/dal/model/problem-report-model.xml
...ain/resources/META-INF/dal/model/problem-report-model.xml
+21
-12
cat-consumer/src/main/resources/META-INF/dal/model/transaction-report-model.xml
...resources/META-INF/dal/model/transaction-report-model.xml
+2
-1
cat-core/src/main/resources/META-INF/dal/model/client-codegen.xml
.../src/main/resources/META-INF/dal/model/client-codegen.xml
+1
-0
cat-home/src/main/java/com/dianping/cat/report/page/model/problem/CompositeProblemService.java
...at/report/page/model/problem/CompositeProblemService.java
+0
-2
cat-home/src/main/java/com/dianping/cat/report/page/model/problem/ProblemReportMerger.java
...ng/cat/report/page/model/problem/ProblemReportMerger.java
+40
-54
cat-home/src/test/java/com/dianping/cat/report/page/problem/ProblemReportMergerTest.java
...ping/cat/report/page/problem/ProblemReportMergerTest.java
+7
-60
cat-home/src/test/resources/com/dianping/cat/report/page/problem/ProblemReportMergeResult.xml
...ping/cat/report/page/problem/ProblemReportMergeResult.xml
+357
-357
cat-home/src/test/resources/com/dianping/cat/report/page/problem/ProblemReportNew.xml
...com/dianping/cat/report/page/problem/ProblemReportNew.xml
+268
-269
cat-home/src/test/resources/com/dianping/cat/report/page/problem/ProblemReportOld.xml
...com/dianping/cat/report/page/problem/ProblemReportOld.xml
+268
-269
未找到文件。
cat-consumer/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
浏览文件 @
570e7bc7
...
...
@@ -3,8 +3,8 @@ package com.dianping.cat.consumer.build;
import
static
com
.
dianping
.
cat
.
consumer
.
problem
.
ProblemType
.
ERROR
;
import
static
com
.
dianping
.
cat
.
consumer
.
problem
.
ProblemType
.
FAILURE
;
import
static
com
.
dianping
.
cat
.
consumer
.
problem
.
ProblemType
.
HEARTBEAT
;
import
static
com
.
dianping
.
cat
.
consumer
.
problem
.
ProblemType
.
LONG_URL
;
import
static
com
.
dianping
.
cat
.
consumer
.
problem
.
ProblemType
.
LONG_SQL
;
import
static
com
.
dianping
.
cat
.
consumer
.
problem
.
ProblemType
.
LONG_URL
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -14,7 +14,6 @@ import com.dianping.cat.consumer.AnalyzerFactory;
import
com.dianping.cat.consumer.DefaultAnalyzerFactory
;
import
com.dianping.cat.consumer.RealtimeConsumer
;
import
com.dianping.cat.consumer.dump.DumpAnalyzer
;
import
com.dianping.cat.consumer.dump.DumpChannel
;
import
com.dianping.cat.consumer.dump.DumpChannelManager
;
import
com.dianping.cat.consumer.dump.DumpUploader
;
import
com.dianping.cat.consumer.event.EventAnalyzer
;
...
...
cat-consumer/src/main/resources/META-INF/dal/model/event-report-model.xml
浏览文件 @
570e7bc7
<?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-json-parser=
"true"
enable-base-visitor=
"true"
>
enable-xml-parser=
"true"
enable-sax-parser=
"true"
enable-json-parser=
"true"
enable-base-visitor=
"true"
enable-native-builder=
"true"
enable-native-parser=
"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
浏览文件 @
570e7bc7
<?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-json-parser=
"true"
enable-base-visitor=
"true"
>
enable-xml-parser=
"true"
enable-sax-parser=
"true"
enable-json-parser=
"true"
enable-base-visitor=
"true"
enable-native-builder=
"true"
enable-native-parser=
"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
浏览文件 @
570e7bc7
<?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-json-parser=
"true"
enable-base-visitor=
"true"
>
enable-xml-parser=
"true"
enable-sax-parser=
"true"
enable-json-parser=
"true"
enable-base-visitor=
"true"
enable-native-builder=
"true"
enable-native-parser=
"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
浏览文件 @
570e7bc7
<?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-json-parser=
"true"
enable-base-visitor=
"true"
>
<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-json-parser=
"true"
enable-base-visitor=
"true"
enable-native-builder=
"true"
enable-native-parser=
"true"
>
<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"
/>
<element
name=
"ip"
value-type=
"String"
type=
"set"
names=
"ips"
/>
<entity-ref
name=
"machine"
type=
"map"
names=
"machines"
method-find-or-create=
"true"
/>
<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"
/>
<attribute
name=
"ip"
value-type=
"String"
key=
"true"
/>
</entity>
<entity
name=
"entry"
>
<entity-ref
name=
"thread"
type=
"map"
names=
"threads"
method-find-or-create=
"true"
/>
<entity-ref
name=
"duration"
type=
"map"
names=
"durations"
method-find-or-create=
"true"
/>
<entity-ref
name=
"thread"
type=
"map"
names=
"threads"
method-find-or-create=
"true"
/>
<entity-ref
name=
"duration"
type=
"map"
names=
"durations"
method-find-or-create=
"true"
/>
</entity>
<entity
name=
"thread"
class-name=
"java-thread"
>
<attribute
name=
"id"
value-type=
"String"
key=
"true"
/>
<entity-ref
name=
"segment"
type=
"map"
names=
"segments"
method-find-or-create=
"true"
/>
<entity-ref
name=
"segment"
type=
"map"
names=
"segments"
method-find-or-create=
"true"
/>
</entity>
<entity
name=
"segment"
>
<attribute
name=
"id"
value-type=
"int"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"count"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
</entity>
<entity
name=
"duration"
>
<attribute
name=
"value"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
</entity>
<entity
name=
"duration"
>
<attribute
name=
"value"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
</entity>
</model>
cat-consumer/src/main/resources/META-INF/dal/model/transaction-report-model.xml
浏览文件 @
570e7bc7
<?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-json-parser=
"true"
enable-base-visitor=
"true"
>
enable-xml-parser=
"true"
enable-sax-parser=
"true"
enable-json-parser=
"true"
enable-base-visitor=
"true"
enable-native-builder=
"true"
enable-native-parser=
"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-core/src/main/resources/META-INF/dal/model/client-codegen.xml
浏览文件 @
570e7bc7
...
...
@@ -4,6 +4,7 @@
<attribute
name=
"mode"
value-type=
"String"
/>
<attribute
name=
"enabled"
value-type=
"boolean"
/>
<attribute
name=
"dev-mode"
value-type=
"boolean"
/>
<entity-ref
name=
"server"
type=
"list"
names=
"servers"
xml-indent=
"true"
/>
<entity-ref
name=
"domain"
type=
"list"
names=
"domains"
/>
<entity-ref
name=
"bind"
/>
...
...
cat-home/src/main/java/com/dianping/cat/report/page/model/problem/CompositeProblemService.java
浏览文件 @
570e7bc7
...
...
@@ -3,12 +3,10 @@ package com.dianping.cat.report.page.model.problem;
import
java.util.List
;
import
com.dianping.cat.consumer.problem.model.entity.ProblemReport
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
import
com.dianping.cat.report.page.model.spi.ModelRequest
;
import
com.dianping.cat.report.page.model.spi.ModelResponse
;
import
com.dianping.cat.report.page.model.spi.internal.BaseCompositeModelService
;
import
com.dianping.cat.report.page.model.spi.internal.BaseRemoteModelService
;
import
com.dianping.cat.report.page.model.transaction.TransactionReportMerger
;
public
class
CompositeProblemService
extends
BaseCompositeModelService
<
ProblemReport
>
{
public
CompositeProblemService
()
{
...
...
cat-home/src/main/java/com/dianping/cat/report/page/model/problem/ProblemReportMerger.java
浏览文件 @
570e7bc7
package
com.dianping.cat.report.page.model.problem
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.dianping.cat.consumer.problem.model.entity.Duration
;
import
com.dianping.cat.consumer.problem.model.entity.Entry
;
import
com.dianping.cat.consumer.problem.model.entity.JavaThread
;
import
com.dianping.cat.consumer.problem.model.entity.Machine
;
import
com.dianping.cat.consumer.problem.model.entity.ProblemReport
;
import
com.dianping.cat.consumer.problem.model.entity.Segment
;
import
com.dianping.cat.consumer.problem.model.transform.DefaultMerger
;
public
class
ProblemReportMerger
extends
DefaultMerger
{
public
ProblemReportMerger
(
ProblemReport
problemReport
)
{
super
(
problemReport
);
}
// protected Entry findEntry(Machine machine, Entry entry) {
// String type = entry.getType();
// String status = entry.getStatus();
//
// List<Entry> entries = machine.getEntries();
//
// for (Entry temp : entries) {
// if (temp.getType().equals(type) && temp.getStatus().equals(status)) {
// return entry;
// }
// }
// return null;
// }
//
// @Override
// public void visitEntry(Entry entry) {
// Machine machine1 = getProblemReport().getMachines().get("192.168.165.1");
// Machine machine = (Machine) getObjects().peek();
// Entry old = findEntry(machine, entry);
//
// if (old == null) {
// old = new Entry();
// old.setType(entry.getType());
// old.setStatus(entry.getStatus());
// System.out.println("add: " + entry.getType() + ":" + entry.getStatus());
// machine.addEntry(old);
// }
//
// visitEntryChildren(old, entry);
// }
//
// @Override
// protected void mergeDuration(Duration old, Duration duration) {
// old.setValue(duration.getValue());
// old.setCount(old.getCount() + duration.getCount());
// old.getMessages().addAll(duration.getMessages());
// }
//
// @Override
// protected void mergeThread(JavaThread old, JavaThread thread) {
// super.mergeThread(old, thread);
// }
//
// @Override
// protected void mergeSegment(Segment old, Segment segment) {
// old.setCount(old.getCount() + segment.getCount());
// old.getMessages().addAll(segment.getMessages());
// }
protected
Entry
findEntry
(
Machine
machine
,
Entry
entry
)
{
String
type
=
entry
.
getType
();
String
status
=
entry
.
getStatus
();
for
(
Entry
e
:
machine
.
getEntries
())
{
if
(
e
.
getType
().
equals
(
type
)
&&
e
.
getStatus
().
equals
(
status
))
{
return
e
;
}
}
return
null
;
}
@Override
protected
void
mergeDuration
(
Duration
old
,
Duration
duration
)
{
old
.
setValue
(
duration
.
getValue
());
old
.
setCount
(
old
.
getCount
()
+
duration
.
getCount
());
old
.
getMessages
().
addAll
(
duration
.
getMessages
());
}
@Override
protected
void
mergeSegment
(
Segment
old
,
Segment
segment
)
{
old
.
setCount
(
old
.
getCount
()
+
segment
.
getCount
());
old
.
getMessages
().
addAll
(
segment
.
getMessages
());
}
@Override
public
void
visitEntry
(
Entry
entry
)
{
Machine
machine
=
(
Machine
)
getObjects
().
peek
();
Entry
old
=
findEntry
(
machine
,
entry
);
if
(
old
==
null
)
{
old
=
new
Entry
();
old
.
setType
(
entry
.
getType
()).
setStatus
(
entry
.
getStatus
());
machine
.
addEntry
(
old
);
}
visitEntryChildren
(
old
,
entry
);
}
@Override
public
void
visitProblemReport
(
ProblemReport
problemReport
)
{
...
...
cat-home/src/test/java/com/dianping/cat/report/page/problem/ProblemReportMergerTest.java
浏览文件 @
570e7bc7
...
...
@@ -5,7 +5,7 @@ import org.junit.Test;
import
org.unidal.webres.helper.Files
;
import
com.dianping.cat.consumer.problem.model.entity.ProblemReport
;
import
com.dianping.cat.consumer.problem.model.transform.Default
Dom
Parser
;
import
com.dianping.cat.consumer.problem.model.transform.Default
Sax
Parser
;
import
com.dianping.cat.report.page.model.problem.ProblemReportMerger
;
public
class
ProblemReportMergerTest
{
...
...
@@ -13,69 +13,16 @@ public class ProblemReportMergerTest {
public
void
testProblemReportMerge
()
throws
Exception
{
String
oldXml
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"ProblemReportOld.xml"
),
"utf-8"
);
String
newXml
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"ProblemReportNew.xml"
),
"utf-8"
);
ProblemReport
reportOld
=
new
DefaultDomParser
().
parse
(
oldXml
);
ProblemReport
reportNew
=
new
DefaultDomParser
().
parse
(
newXml
);
String
expected
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"ProblemReportMergeResult.xml"
),
"utf-8"
);
ProblemReport
reportOld
=
DefaultSaxParser
.
parse
(
oldXml
);
ProblemReport
reportNew
=
DefaultSaxParser
.
parse
(
newXml
);
String
expected
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"ProblemReportMergeResult.xml"
),
"utf-8"
);
ProblemReportMerger
merger
=
new
ProblemReportMerger
(
new
ProblemReport
(
reportOld
.
getDomain
()));
reportOld
.
accept
(
merger
);
reportNew
.
accept
(
merger
);
System
.
out
.
println
(
reportOld
);
System
.
out
.
println
(
reportNew
);
Assert
.
assertEquals
(
"Check the merge result!"
,
expected
.
replace
(
"\r"
,
""
),
reportNew
.
toString
().
replace
(
"\r"
,
""
));
Assert
.
assertEquals
(
"Check the merge result!"
,
expected
.
replace
(
"\r"
,
""
),
merger
.
getProblemReport
().
toString
().
replace
(
"\r"
,
""
));
Assert
.
assertEquals
(
"Check the merge result!"
,
expected
.
replace
(
"\r"
,
""
),
merger
.
getProblemReport
().
toString
()
.
replace
(
"\r"
,
""
));
Assert
.
assertEquals
(
"Source report is changed!"
,
newXml
.
replace
(
"\r"
,
""
),
reportNew
.
toString
().
replace
(
"\r"
,
""
));
}
// @Test
// 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 {
// 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");
//
// TransactionReportMerger merger = new TransactionReportMerger(new TransactionReport(reportOld.getDomain()));
//
// merger.setAllIp(true);
// merger.setIp(CatString.ALL_IP);
// merger.setAllName(true);
// merger.setType("URL");
//
// 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/problem/ProblemReportMergeResult.xml
浏览文件 @
570e7bc7
此差异已折叠。
点击以展开。
cat-home/src/test/resources/com/dianping/cat/report/page/problem/ProblemReportNew.xml
浏览文件 @
570e7bc7
此差异已折叠。
点击以展开。
cat-home/src/test/resources/com/dianping/cat/report/page/problem/ProblemReportOld.xml
浏览文件 @
570e7bc7
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录