Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
9f9c503f
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,发现更多精彩内容 >>
提交
9f9c503f
编写于
6月 11, 2012
作者:
Y
You Yong
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
ssh://192.168.8.22:58422/cat
上级
37b4636f
39f42388
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
150 addition
and
56 deletion
+150
-56
Cat.sql
Cat.sql
+6
-2
cat-hadoop/src/main/resources/META-INF/dal/jdbc/codegen.xml
cat-hadoop/src/main/resources/META-INF/dal/jdbc/codegen.xml
+46
-7
cat-home/src/main/java/com/dianping/cat/report/task/DefaultTaskConsumer.java
...ava/com/dianping/cat/report/task/DefaultTaskConsumer.java
+98
-47
未找到文件。
Cat.sql
浏览文件 @
9f9c503f
...
...
@@ -87,7 +87,8 @@ CREATE TABLE `graph` (
`domain`
varchar
(
20
)
NOT
NULL
COMMENT
'报表处理的Domain信息'
,
`period`
datetime
NOT
NULL
COMMENT
'报表时间段'
,
`type`
tinyint
(
4
)
NOT
NULL
COMMENT
'报表数据格式, 1/xml, 2/json, 3/csv, 默认3'
,
`content`
mediumtext
NOT
NULL
COMMENT
'绘图内容'
,
`detail_content`
mediumtext
NOT
NULL
COMMENT
'详细绘图内容'
,
`summary_content`
mediumtext
NOT
NULL
COMMENT
'概要绘图内容'
,
`creation_date`
datetime
NOT
NULL
COMMENT
'报表创建时间'
,
PRIMARY
KEY
(
`id`
)
)
DEFAULT
CHARSET
=
utf8
COMMENT
=
'用于存放以小时为单位的绘图数据'
;
...
...
@@ -113,11 +114,14 @@ CREATE TABLE `dailygraph` (
`domain`
varchar
(
20
)
NOT
NULL
COMMENT
'报表处理的Domain信息'
,
`period`
datetime
NOT
NULL
COMMENT
'报表时间段'
,
`type`
tinyint
(
4
)
NOT
NULL
COMMENT
'报表数据格式, 1/xml, 2/json, 3/csv, 默认3'
,
`content`
mediumtext
NOT
NULL
COMMENT
'绘图内容'
,
`detail_content`
mediumtext
NOT
NULL
COMMENT
'详细绘图内容'
,
`summary_content`
mediumtext
NOT
NULL
COMMENT
'概要绘图内容'
,
`creation_date`
datetime
NOT
NULL
COMMENT
'报表创建时间'
,
PRIMARY
KEY
(
`id`
)
)
DEFAULT
CHARSET
=
utf8
COMMENT
=
'用于存放以天为单位的绘图数据'
;
CREATE
UNIQUE
INDEX
dailygraph_period_ip_domain_name
ON
dailygraph
(
period
,
ip
,
domain
,
name
);
CREATE
TABLE
`location`
(
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`lat`
double
NOT
NULL
,
...
...
cat-hadoop/src/main/resources/META-INF/dal/jdbc/codegen.xml
浏览文件 @
9f9c503f
...
...
@@ -5,8 +5,8 @@
<member
name=
"domain"
field=
"domain"
value-type=
"String"
length=
"50"
nullable=
"false"
/>
<member
name=
"author"
field=
"author"
value-type=
"String"
length=
"32"
nullable=
"false"
/>
<member
name=
"content"
field=
"content"
value-type=
"String"
length=
"1024"
nullable=
"false"
/>
<member
name=
"happened"
field=
"happened"
value-type=
"Date"
nullable=
"false"
/>
<member
name=
"status"
field=
"status"
value-type=
"int"
length=
"3"
nullable=
"false"
/>
<member
name=
"happened"
field=
"happened"
value-type=
"Date"
nullable=
"false"
/>
<member
name=
"creation-date"
field=
"creation_date"
value-type=
"Date"
nullable=
"false"
/>
<var
name=
"key-id"
value-type=
"int"
key-member=
"id"
/>
<primary-key
name=
"PRIMARY"
members=
"id"
/>
...
...
@@ -41,10 +41,12 @@
<member
name=
"domain"
field=
"domain"
value-type=
"String"
length=
"20"
nullable=
"false"
/>
<member
name=
"period"
field=
"period"
value-type=
"Date"
nullable=
"false"
/>
<member
name=
"type"
field=
"type"
value-type=
"int"
length=
"3"
nullable=
"false"
/>
<member
name=
"content"
field=
"content"
value-type=
"String"
length=
"16777215"
nullable=
"false"
/>
<member
name=
"detail-content"
field=
"detail_content"
value-type=
"String"
length=
"16777215"
nullable=
"false"
/>
<member
name=
"summary-content"
field=
"summary_content"
value-type=
"String"
length=
"16777215"
nullable=
"false"
/>
<member
name=
"creation-date"
field=
"creation_date"
value-type=
"Date"
nullable=
"false"
/>
<var
name=
"key-id"
value-type=
"int"
key-member=
"id"
/>
<primary-key
name=
"PRIMARY"
members=
"id"
/>
<index
name=
"dailygraph_period_ip_domain_name"
unique=
"true"
members=
"period ASC, ip ASC, domain ASC, name ASC"
/>
<readsets>
<readset
name=
"FULL"
all=
"true"
/>
</readsets>
...
...
@@ -111,10 +113,12 @@
<member
name=
"domain"
field=
"domain"
value-type=
"String"
length=
"20"
nullable=
"false"
/>
<member
name=
"period"
field=
"period"
value-type=
"Date"
nullable=
"false"
/>
<member
name=
"type"
field=
"type"
value-type=
"int"
length=
"3"
nullable=
"false"
/>
<member
name=
"content"
field=
"content"
value-type=
"String"
length=
"16777215"
nullable=
"false"
/>
<member
name=
"detail-content"
field=
"detail_content"
value-type=
"String"
length=
"16777215"
nullable=
"false"
/>
<member
name=
"summary-content"
field=
"summary_content"
value-type=
"String"
length=
"16777215"
nullable=
"false"
/>
<member
name=
"creation-date"
field=
"creation_date"
value-type=
"Date"
nullable=
"false"
/>
<var
name=
"key-id"
value-type=
"int"
key-member=
"id"
/>
<primary-key
name=
"PRIMARY"
members=
"id"
/>
<index
name=
"graph_period_ip_domain_name"
unique=
"true"
members=
"period ASC, ip ASC, domain ASC, name ASC"
/>
<readsets>
<readset
name=
"FULL"
all=
"true"
/>
</readsets>
...
...
@@ -139,7 +143,41 @@
</query>
</query-defs>
</entity>
<entity
name=
"logview"
table=
"logview"
alias=
"l"
>
<entity
name=
"location"
table=
"location"
alias=
"l"
>
<member
name=
"id"
field=
"id"
value-type=
"int"
length=
"10"
nullable=
"false"
key=
"true"
auto-increment=
"true"
/>
<member
name=
"lat"
field=
"lat"
value-type=
"double"
length=
"22"
nullable=
"false"
/>
<member
name=
"lng"
field=
"lng"
value-type=
"double"
length=
"22"
nullable=
"false"
/>
<member
name=
"total"
field=
"total"
value-type=
"int"
length=
"10"
nullable=
"false"
/>
<member
name=
"transaction-date"
field=
"transaction_date"
value-type=
"Date"
nullable=
"false"
/>
<member
name=
"creation-date"
field=
"creation_date"
value-type=
"Date"
nullable=
"false"
/>
<var
name=
"key-id"
value-type=
"int"
key-member=
"id"
/>
<primary-key
name=
"PRIMARY"
members=
"id"
/>
<index
name=
"transaction_date_lat_lng"
unique=
"true"
members=
"transaction_date ASC, lat ASC, lng ASC"
/>
<readsets>
<readset
name=
"FULL"
all=
"true"
/>
</readsets>
<updatesets>
<updateset
name=
"FULL"
all=
"true"
/>
</updatesets>
<query-defs>
<query
name=
"find-by-PK"
type=
"SELECT"
>
<param
name=
"key-id"
/>
<statement>
<![CDATA[SELECT <FIELDS/> FROM <TABLE/> WHERE <FIELD name='id'/> = ${key-id}]]>
</statement>
</query>
<query
name=
"insert"
type=
"INSERT"
>
<statement>
<![CDATA[INSERT INTO <TABLE/>(<FIELDS/>) VALUES(<VALUES/>)]]>
</statement>
</query>
<query
name=
"update-by-PK"
type=
"UPDATE"
>
<param
name=
"key-id"
/>
<statement>
<![CDATA[UPDATE <TABLE/> SET <FIELDS/> WHERE <FIELD name='id'/> = ${key-id}]]>
</statement>
</query>
<query
name=
"delete-by-PK"
type=
"DELETE"
>
<param
name=
"key-id"
/>
<statement>
<![CDATA[DELETE FROM <TABLE/> WHERE <FIELD name='id'/> = ${key-id}]]>
</statement>
</query>
</query-defs>
</entity>
<entity
name=
"logview"
table=
"logview"
alias=
"l2"
>
<member
name=
"id"
field=
"id"
value-type=
"int"
length=
"10"
nullable=
"false"
key=
"true"
auto-increment=
"true"
/>
<member
name=
"message-id"
field=
"message_id"
value-type=
"String"
length=
"64"
nullable=
"false"
/>
<member
name=
"data-path"
field=
"data_path"
value-type=
"String"
length=
"200"
nullable=
"false"
/>
...
...
@@ -264,16 +302,17 @@
<member
name=
"id"
field=
"id"
value-type=
"int"
length=
"10"
nullable=
"false"
key=
"true"
auto-increment=
"true"
/>
<member
name=
"producer"
field=
"producer"
value-type=
"String"
length=
"20"
nullable=
"false"
/>
<member
name=
"consumer"
field=
"consumer"
value-type=
"String"
length=
"20"
/>
<member
name=
"status"
field=
"status"
value-type=
"int"
length=
"3"
nullable=
"false"
/>
<member
name=
"failure-count"
field=
"failure_count"
value-type=
"int"
length=
"3"
nullable=
"false"
/>
<member
name=
"report-name"
field=
"report_name"
value-type=
"String"
length=
"20"
nullable=
"false"
/>
<member
name=
"report-domain"
field=
"report_domain"
value-type=
"String"
length=
"20"
nullable=
"false"
/>
<member
name=
"report-period"
field=
"report_period"
value-type=
"Date"
nullable=
"false"
/>
<member
name=
"status"
field=
"status"
value-type=
"int"
length=
"3"
nullable=
"false"
/>
<member
name=
"creation-date"
field=
"creation_date"
value-type=
"Date"
nullable=
"false"
/>
<member
name=
"start-date"
field=
"start_date"
value-type=
"Date"
nullable=
"false"
/>
<member
name=
"end-date"
field=
"end_date"
value-type=
"Date"
nullable=
"false"
/>
<member
name=
"start-date"
field=
"start_date"
value-type=
"Date"
/>
<member
name=
"end-date"
field=
"end_date"
value-type=
"Date"
/>
<var
name=
"key-id"
value-type=
"int"
key-member=
"id"
/>
<primary-key
name=
"PRIMARY"
members=
"id"
/>
<index
name=
"task_period_domain_name"
unique=
"true"
members=
"report_period ASC, report_domain ASC, report_name ASC"
/>
<readsets>
<readset
name=
"FULL"
all=
"true"
/>
</readsets>
...
...
cat-home/src/main/java/com/dianping/cat/report/task/DefaultTaskConsumer.java
浏览文件 @
9f9c503f
...
...
@@ -6,11 +6,11 @@ package com.dianping.cat.report.task;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
java.util.TreeMap
;
import
java.util.concurrent.locks.LockSupport
;
import
org.codehaus.plexus.logging.LogEnabled
;
...
...
@@ -311,7 +311,8 @@ public class DefaultTaskConsumer extends TaskConsumer implements LogEnabled {
private
List
<
Graph
>
splitTransactionReportToGraphs
(
Date
reportPeroid
,
String
domainName
,
String
reportName
,
TransactionReport
transactionReport
)
{
Set
<
String
>
ips
=
transactionReport
.
getIps
();
List
<
Graph
>
graphs
=
new
ArrayList
<
Graph
>(
ips
.
size
()
+
1
);
// all and every machine
Map
<
String
,
GraphLine
>
allGraphCache
=
new
HashMap
<
String
,
GraphLine
>();
Map
<
String
,
GraphLine
>
allDetailCache
=
new
TreeMap
<
String
,
GraphLine
>();
Map
<
String
,
GraphLine
>
allSummaryCache
=
new
TreeMap
<
String
,
GraphLine
>();
Date
creationDate
=
new
Date
();
for
(
String
ip
:
ips
)
{
Graph
graph
=
new
Graph
();
...
...
@@ -323,45 +324,75 @@ public class DefaultTaskConsumer extends TaskConsumer implements LogEnabled {
graph
.
setCreationDate
(
creationDate
);
Machine
machine
=
transactionReport
.
getMachines
().
get
(
ip
);
Map
<
String
,
TransactionType
>
types
=
machine
.
getTypes
();
StringBuilder
contentBuilder
=
new
StringBuilder
();
StringBuilder
detailBuilder
=
new
StringBuilder
();
StringBuilder
summaryBuilder
=
new
StringBuilder
();
for
(
Entry
<
String
,
TransactionType
>
transactionEntry
:
types
.
entrySet
())
{
TransactionType
transactionType
=
transactionEntry
.
getValue
();
summaryBuilder
.
append
(
transactionType
.
getId
());
summaryBuilder
.
append
(
'\t'
);
summaryBuilder
.
append
(
transactionType
.
getTotalCount
());
summaryBuilder
.
append
(
'\t'
);
summaryBuilder
.
append
(
transactionType
.
getFailCount
());
summaryBuilder
.
append
(
'\t'
);
summaryBuilder
.
append
(
transactionType
.
getMin
());
summaryBuilder
.
append
(
'\t'
);
summaryBuilder
.
append
(
transactionType
.
getMax
());
summaryBuilder
.
append
(
'\t'
);
summaryBuilder
.
append
(
transactionType
.
getSum
());
summaryBuilder
.
append
(
'\t'
);
summaryBuilder
.
append
(
transactionType
.
getSum2
());
summaryBuilder
.
append
(
'\n'
);
String
summaryKey
=
transactionType
.
getId
();
GraphLine
summaryLine
=
allSummaryCache
.
get
(
summaryKey
);
if
(
summaryLine
==
null
)
{
summaryLine
=
new
GraphLine
();
allSummaryCache
.
put
(
summaryKey
,
summaryLine
);
}
summaryLine
.
totalCount
+=
transactionType
.
getTotalCount
();
summaryLine
.
failCount
+=
transactionType
.
getFailCount
();
summaryLine
.
min
+=
transactionType
.
getMin
();
summaryLine
.
max
+=
transactionType
.
getMax
();
summaryLine
.
sum
+=
transactionType
.
getSum
();
summaryLine
.
sum2
+=
transactionType
.
getSum2
();
Map
<
String
,
TransactionName
>
names
=
transactionType
.
getNames
();
for
(
Entry
<
String
,
TransactionName
>
nameEntry
:
names
.
entrySet
())
{
TransactionName
transactionName
=
nameEntry
.
getValue
();
content
Builder
.
append
(
transactionType
.
getId
());
content
Builder
.
append
(
'\t'
);
content
Builder
.
append
(
transactionName
.
getId
());
content
Builder
.
append
(
'\t'
);
content
Builder
.
append
(
transactionName
.
getTotalCount
());
content
Builder
.
append
(
'\t'
);
content
Builder
.
append
(
transactionName
.
getFailCount
());
content
Builder
.
append
(
'\t'
);
content
Builder
.
append
(
transactionName
.
getMin
());
content
Builder
.
append
(
'\t'
);
content
Builder
.
append
(
transactionName
.
getMax
());
content
Builder
.
append
(
'\t'
);
content
Builder
.
append
(
transactionName
.
getSum
());
content
Builder
.
append
(
'\t'
);
content
Builder
.
append
(
transactionName
.
getSum2
());
content
Builder
.
append
(
'\n'
);
detail
Builder
.
append
(
transactionType
.
getId
());
detail
Builder
.
append
(
'\t'
);
detail
Builder
.
append
(
transactionName
.
getId
());
detail
Builder
.
append
(
'\t'
);
detail
Builder
.
append
(
transactionName
.
getTotalCount
());
detail
Builder
.
append
(
'\t'
);
detail
Builder
.
append
(
transactionName
.
getFailCount
());
detail
Builder
.
append
(
'\t'
);
detail
Builder
.
append
(
transactionName
.
getMin
());
detail
Builder
.
append
(
'\t'
);
detail
Builder
.
append
(
transactionName
.
getMax
());
detail
Builder
.
append
(
'\t'
);
detail
Builder
.
append
(
transactionName
.
getSum
());
detail
Builder
.
append
(
'\t'
);
detail
Builder
.
append
(
transactionName
.
getSum2
());
detail
Builder
.
append
(
'\n'
);
String
key
=
transactionType
.
getId
()
+
"\t"
+
transactionName
.
getId
();
GraphLine
graphLine
=
allGraph
Cache
.
get
(
key
);
if
(
graph
Line
==
null
)
{
graph
Line
=
new
GraphLine
();
all
GraphCache
.
put
(
key
,
graph
Line
);
GraphLine
detailLine
=
allDetail
Cache
.
get
(
key
);
if
(
detail
Line
==
null
)
{
detail
Line
=
new
GraphLine
();
all
DetailCache
.
put
(
key
,
detail
Line
);
}
graph
Line
.
totalCount
+=
transactionName
.
getTotalCount
();
graph
Line
.
failCount
+=
transactionName
.
getFailCount
();
graph
Line
.
min
+=
transactionName
.
getMin
();
graph
Line
.
max
+=
transactionName
.
getMax
();
graph
Line
.
sum
+=
transactionName
.
getSum
();
graph
Line
.
sum2
+=
transactionName
.
getSum2
();
detail
Line
.
totalCount
+=
transactionName
.
getTotalCount
();
detail
Line
.
failCount
+=
transactionName
.
getFailCount
();
detail
Line
.
min
+=
transactionName
.
getMin
();
detail
Line
.
max
+=
transactionName
.
getMax
();
detail
Line
.
sum
+=
transactionName
.
getSum
();
detail
Line
.
sum2
+=
transactionName
.
getSum2
();
}
}
graph
.
setContent
(
contentBuilder
.
toString
());
graph
.
setDetailContent
(
detailBuilder
.
toString
());
graph
.
setSummaryContent
(
summaryBuilder
.
toString
());
graphs
.
add
(
graph
);
}
...
...
@@ -373,25 +404,45 @@ public class DefaultTaskConsumer extends TaskConsumer implements LogEnabled {
allGraph
.
setType
(
3
);
allGraph
.
setCreationDate
(
creationDate
);
StringBuilder
sb
=
new
StringBuilder
();
for
(
Entry
<
String
,
GraphLine
>
entry
:
allGraphCache
.
entrySet
())
{
sb
.
append
(
entry
.
getKey
());
sb
.
append
(
'\t'
);
StringBuilder
detailSb
=
new
StringBuilder
();
for
(
Entry
<
String
,
GraphLine
>
entry
:
allDetailCache
.
entrySet
())
{
detailSb
.
append
(
entry
.
getKey
());
detailSb
.
append
(
'\t'
);
GraphLine
value
=
entry
.
getValue
();
detailSb
.
append
(
value
.
totalCount
);
detailSb
.
append
(
'\t'
);
detailSb
.
append
(
value
.
failCount
);
detailSb
.
append
(
'\t'
);
detailSb
.
append
(
value
.
min
);
detailSb
.
append
(
'\t'
);
detailSb
.
append
(
value
.
max
);
detailSb
.
append
(
'\t'
);
detailSb
.
append
(
value
.
sum
);
detailSb
.
append
(
'\t'
);
detailSb
.
append
(
value
.
sum2
);
detailSb
.
append
(
'\n'
);
}
allGraph
.
setDetailContent
(
detailSb
.
toString
());
StringBuilder
summarySb
=
new
StringBuilder
();
for
(
Entry
<
String
,
GraphLine
>
entry
:
allSummaryCache
.
entrySet
())
{
summarySb
.
append
(
entry
.
getKey
());
summarySb
.
append
(
'\t'
);
GraphLine
value
=
entry
.
getValue
();
sb
.
append
(
value
.
totalCount
);
sb
.
append
(
'\t'
);
sb
.
append
(
value
.
failCount
);
sb
.
append
(
'\t'
);
sb
.
append
(
value
.
min
);
sb
.
append
(
'\t'
);
sb
.
append
(
value
.
max
);
sb
.
append
(
'\t'
);
sb
.
append
(
value
.
sum
);
sb
.
append
(
'\t'
);
sb
.
append
(
value
.
sum2
);
sb
.
append
(
'\n'
);
s
ummaryS
b
.
append
(
value
.
totalCount
);
s
ummaryS
b
.
append
(
'\t'
);
s
ummaryS
b
.
append
(
value
.
failCount
);
s
ummaryS
b
.
append
(
'\t'
);
s
ummaryS
b
.
append
(
value
.
min
);
s
ummaryS
b
.
append
(
'\t'
);
s
ummaryS
b
.
append
(
value
.
max
);
s
ummaryS
b
.
append
(
'\t'
);
s
ummaryS
b
.
append
(
value
.
sum
);
s
ummaryS
b
.
append
(
'\t'
);
s
ummaryS
b
.
append
(
value
.
sum2
);
s
ummaryS
b
.
append
(
'\n'
);
}
allGraph
.
set
Content
(
s
b
.
toString
());
allGraph
.
set
SummaryContent
(
summaryS
b
.
toString
());
graphs
.
add
(
allGraph
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录