Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
4a0609ae
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,发现更多精彩内容 >>
提交
4a0609ae
编写于
7月 16, 2014
作者:
J
jialinsun
浏览文件
操作
浏览文件
下载
差异文件
pull resolve conflicts
上级
3d37004c
251c82cf
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
3841 addition
and
76 deletion
+3841
-76
cat-core/src/main/java/com/dianping/cat/config/app/AppDataService.java
...main/java/com/dianping/cat/config/app/AppDataService.java
+42
-3
cat-core/src/main/resources/META-INF/dal/jdbc/app-dal.xml
cat-core/src/main/resources/META-INF/dal/jdbc/app-dal.xml
+42
-1
cat-home/src/main/java/com/dianping/cat/report/page/app/graph/AppGraphCreator.java
...m/dianping/cat/report/page/app/graph/AppGraphCreator.java
+2
-6
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+3687
-31
cat-home/src/main/webapp/js/baseGraph.js
cat-home/src/main/webapp/js/baseGraph.js
+30
-12
cat-home/src/main/webapp/jsp/report/app.jsp
cat-home/src/main/webapp/jsp/report/app.jsp
+1
-1
cat-home/src/test/java/com/dianping/cat/report/analyzer/TopologyGraphTest.java
...a/com/dianping/cat/report/analyzer/TopologyGraphTest.java
+35
-16
script/Cat.sql
script/Cat.sql
+2
-6
未找到文件。
cat-core/src/main/java/com/dianping/cat/config/app/AppDataService.java
浏览文件 @
4a0609ae
...
@@ -3,11 +3,23 @@ package com.dianping.cat.config.app;
...
@@ -3,11 +3,23 @@ package com.dianping.cat.config.app;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.Random
;
import
org.unidal.dal.jdbc.DalException
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.app.AppDataCommand
;
import
com.dianping.cat.app.AppDataCommandDao
;
import
com.dianping.cat.app.AppDataCommandEntity
;
public
class
AppDataService
{
public
class
AppDataService
{
@Inject
private
AppDataCommandDao
m_dao
;
public
static
final
String
SUCCESS_RATIO
=
"successRatio"
;
public
static
final
String
SUCCESS_RATIO
=
"successRatio"
;
public
static
final
String
REQUEST_COUNT
=
"requestCount"
;
public
static
final
String
REQUEST_COUNT
=
"requestCount"
;
...
@@ -52,6 +64,11 @@ public class AppDataService {
...
@@ -52,6 +64,11 @@ public class AppDataService {
return
map
;
return
map
;
}
}
private
Map
<
String
,
double
[]>
querySuccessRatio
(
QueryEntity
entity
)
{
return
makeMockValue
(
SUCCESS_RATIO
);
}
private
Map
<
String
,
double
[]>
queryDelayAvg
(
QueryEntity
entity
)
{
private
Map
<
String
,
double
[]>
queryDelayAvg
(
QueryEntity
entity
)
{
return
makeMockValue
(
DELAY_AVG
);
return
makeMockValue
(
DELAY_AVG
);
...
@@ -62,9 +79,31 @@ public class AppDataService {
...
@@ -62,9 +79,31 @@ public class AppDataService {
return
makeMockValue
(
REQUEST_COUNT
);
return
makeMockValue
(
REQUEST_COUNT
);
}
}
private
Map
<
String
,
double
[]>
querySuccessRatio
(
QueryEntity
entity
)
{
public
void
queryAvg
(
QueryEntity
entity
)
{
int
commandId
=
entity
.
getCommand
();
return
makeMockValue
(
SUCCESS_RATIO
);
Date
period
=
entity
.
getDate
();
int
city
=
entity
.
getCity
();
int
operator
=
entity
.
getOperator
();
int
network
=
entity
.
getNetwork
();
int
appVersion
=
entity
.
getVersion
();
int
connnectType
=
entity
.
getChannel
();
int
code
=
entity
.
getCode
();
int
platform
=
entity
.
getPlatfrom
();
try
{
List
<
AppDataCommand
>
datas
=
m_dao
.
findData
(
commandId
,
period
,
city
,
operator
,
network
,
appVersion
,
connnectType
,
code
,
platform
,
AppDataCommandEntity
.
READSET_DATA
);
for
(
AppDataCommand
data
:
datas
)
{
int
minuteOrder
=
data
.
getMinuteOrder
();
long
count
=
data
.
getAccessNumberSum
();
long
sum
=
data
.
getResponseSumTimeSum
();
double
avg
=
sum
/
count
;
}
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
}
}
}
public
static
class
Statistics
{
public
static
class
Statistics
{
...
...
cat-core/src/main/resources/META-INF/dal/jdbc/app-dal.xml
浏览文件 @
4a0609ae
...
@@ -16,9 +16,14 @@
...
@@ -16,9 +16,14 @@
<member
name=
"access-number-sum"
/>
<member
name=
"access-number-sum"
/>
<member
name=
"response-sum-time-sum"
/>
<member
name=
"response-sum-time-sum"
/>
</readset>
</readset>
<readset
name=
"SUCCESS-DATA"
>
<member
name=
"minute-order"
/>
<member
name=
"code"
/>
<member
name=
"access-number-sum"
/>
</readset>
</readsets>
</readsets>
<query-defs>
<query-defs>
<query
name=
"insert-data"
type=
"INSERT"
>
<query
name=
"insert-data"
type=
"INSERT"
>
<param
name=
"command-id"
/>
<param
name=
"command-id"
/>
<statement>
<![CDATA[INSERT INTO <TABLE/>
(
<FIELDS/>
)
<statement>
<![CDATA[INSERT INTO <TABLE/>
(
<FIELDS/>
)
VALUES(
<VALUES/>
)]]>
</statement>
VALUES(
<VALUES/>
)]]>
</statement>
...
@@ -59,6 +64,42 @@
...
@@ -59,6 +64,42 @@
</IF>
</IF>
group by
<FIELD
name=
'minute-order'
/>
]]>
</statement>
group by
<FIELD
name=
'minute-order'
/>
]]>
</statement>
</query>
</query>
<query
name=
"find-success-data"
type=
"SELECT"
multiple=
"true"
>
<param
name=
"command-id"
/><param
name=
"period"
/>
<param
name=
"period"
/>
<param
name=
"city"
/>
<param
name=
"operator"
/>
<param
name=
"network"
/>
<param
name=
"app-version"
/>
<param
name=
"connnect-type"
/>
<param
name=
"code"
/>
<param
name=
"platform"
/>
<statement>
<![CDATA[SELECT <FIELDS/>
FROM
<TABLE/>
WHERE
<FIELD
name=
'period'
/>
= ${period}
<IF
type=
'NOT_ZERO'
field=
'city'
>
AND
<FIELD
name=
'city'
/>
= ${city}
</IF>
<IF
type=
'NOT_ZERO'
field=
'operator'
>
AND
<FIELD
name=
'operator'
/>
= ${operator}
</IF>
<IF
type=
'NOT_ZERO'
field=
'network'
>
AND
<FIELD
name=
'network'
/>
= ${network}
</IF>
<IF
type=
'NOT_ZERO'
field=
'app-version'
>
AND
<FIELD
name=
'app-version'
/>
= ${app-version}
</IF>
<IF
type=
'NOT_ZERO'
field=
'connnect-type'
>
AND
<FIELD
name=
'connnect-type'
/>
= ${connnect-type}
</IF>
<IF
type=
'NOT_ZERO'
field=
'code'
>
AND
<FIELD
name=
'code'
/>
= ${code}
</IF>
<IF
type=
'NOT_ZERO'
field=
'platform'
>
AND
<FIELD
name=
'platform'
/>
= ${platform}
</IF>
group by
<FIELD
name=
'minute-order'
/>
,
<FIELD
name=
'code'
/>
]]>
</statement>
</query>
</query-defs>
</query-defs>
</entity>
</entity>
</entities>
</entities>
cat-home/src/main/java/com/dianping/cat/report/page/app/graph/AppGraphCreator.java
浏览文件 @
4a0609ae
...
@@ -44,18 +44,17 @@ public class AppGraphCreator extends AbstractGraphCreator {
...
@@ -44,18 +44,17 @@ public class AppGraphCreator extends AbstractGraphCreator {
lineChart
.
setId
(
startDate
.
toString
());
lineChart
.
setId
(
startDate
.
toString
());
lineChart
.
setHtmlTitle
(
key
);
lineChart
.
setHtmlTitle
(
key
);
Map
<
Long
,
Double
>
all
=
convertToMap
(
datas
.
get
(
key
),
startDate
,
endDate
,
5
);
Map
<
Long
,
Double
>
all
=
convertToMap
(
datas
.
get
(
key
),
startDate
,
5
);
lineChart
.
add
(
startDate
.
toString
(),
all
);
lineChart
.
add
(
startDate
.
toString
(),
all
);
}
}
return
lineChart
;
return
lineChart
;
}
}
protected
Map
<
Long
,
Double
>
convertToMap
(
double
[]
data
,
Date
start
,
Date
end
,
int
step
)
{
protected
Map
<
Long
,
Double
>
convertToMap
(
double
[]
data
,
Date
start
,
int
step
)
{
Map
<
Long
,
Double
>
map
=
new
LinkedHashMap
<
Long
,
Double
>();
Map
<
Long
,
Double
>
map
=
new
LinkedHashMap
<
Long
,
Double
>();
int
length
=
data
.
length
;
int
length
=
data
.
length
;
long
startTime
=
start
.
getTime
();
long
startTime
=
start
.
getTime
();
long
endTime
=
end
.
getTime
();
long
time
=
startTime
;
long
time
=
startTime
;
int
i
=
0
;
int
i
=
0
;
...
@@ -64,9 +63,6 @@ public class AppGraphCreator extends AbstractGraphCreator {
...
@@ -64,9 +63,6 @@ public class AppGraphCreator extends AbstractGraphCreator {
map
.
put
(
time
,
data
[
i
]);
map
.
put
(
time
,
data
[
i
]);
}
}
for
(;
time
<
endTime
;
time
+=
step
*
TimeUtil
.
ONE_MINUTE
)
{
map
.
put
(
time
,
-
1
D
);
}
return
map
;
return
map
;
}
}
}
}
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
4a0609ae
此差异已折叠。
点击以展开。
cat-home/src/main/webapp/js/baseGraph.js
浏览文件 @
4a0609ae
...
@@ -164,14 +164,33 @@ function graphMetricChart(container, data) {
...
@@ -164,14 +164,33 @@ function graphMetricChart(container, data) {
});
});
}
}
function
graphMetricChart2
(
container
,
data
)
{
function
parseMetricLineDataForApp
(
data
)
{
var
res
=
[];
data
.
subTitles
.
forEach
(
function
(
title
,
i
)
{
var
series
=
{}
series
.
name
=
title
;
series
.
data
=
[];
var
map
=
data
.
datas
[
i
];
var
j
=
0
;
for
(
var
key
in
map
)
{
var
value
=
map
[
key
];
series
.
data
[
j
]
=
value
;
j
++
;
}
res
.
push
(
series
);
});
return
res
;
}
function
graphMetricChartForApp
(
container
,
data
)
{
Highcharts
.
setOptions
({
Highcharts
.
setOptions
({
global
:
{
global
:
{
useUTC
:
false
useUTC
:
false
}
}
});
});
var
ylabelMin
=
data
.
minYlable
;
var
ylabelMin
=
data
.
minYlable
;
var
_data
=
parseMetricLineData
(
data
);
var
_data
=
parseMetricLineData
ForApp
(
data
);
$
(
container
).
highcharts
(
$
(
container
).
highcharts
(
{
{
chart
:
{
chart
:
{
...
@@ -182,16 +201,15 @@ function graphMetricChart2(container, data) {
...
@@ -182,16 +201,15 @@ function graphMetricChart2(container, data) {
useHTML
:
true
useHTML
:
true
},
},
xAxis
:
{
xAxis
:
{
type
:
'
datetime
'
,
type
:
"
category
"
,
dateTimeLabelFormats
:
{
labels
:
{
second
:
'
%H:%M:%S
'
,
step
:
12
,
minute
:
'
%H:%M
'
,
maxStaggerLines
:
1
,
hour
:
'
%H:%M
'
,
formatter
:
function
()
{
day
:
'
%m-%d
'
,
return
this
.
value
/
12
;
week
:
'
%Y-%m-%d
'
,
}
month
:
'
%m-%d
'
,
},
year
:
'
%Y-%m
'
max
:
288
},
},
},
yAxis
:
{
yAxis
:
{
min
:
ylabelMin
,
min
:
ylabelMin
,
...
...
cat-home/src/main/webapp/jsp/report/app.jsp
浏览文件 @
4a0609ae
...
@@ -174,7 +174,7 @@
...
@@ -174,7 +174,7 @@
}
}
var
data
=
$
{
model
.
lineChart
.
jsonString
};
var
data
=
$
{
model
.
lineChart
.
jsonString
};
graphMetricChart
2
(
document
.
getElementById
(
'
${model.lineChart.id}
'
),
data
);
graphMetricChart
ForApp
(
document
.
getElementById
(
'
${model.lineChart.id}
'
),
data
);
});
});
</script>
</script>
...
...
cat-home/src/test/java/com/dianping/cat/report/analyzer/TopologyGraphTest.java
浏览文件 @
4a0609ae
package
com.dianping.cat.report.analyzer
;
package
com.dianping.cat.report.analyzer
;
import
java.
text.ParseException
;
import
java.
io.File
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.unidal.eunit.helper.Files
;
import
org.unidal.lookup.ComponentTestCase
;
import
org.unidal.lookup.ComponentTestCase
;
import
com.dianping.cat.consumer.metric.ProductLineConfigManager
;
import
com.dianping.cat.home.dependency.graph.entity.TopologyGraph
;
import
com.dianping.cat.home.dependency.graph.entity.TopologyGraph
;
import
com.dianping.cat.report.page.dependency.graph.TopologyGraphManager
;
import
com.dianping.cat.report.page.dependency.graph.TopologyGraphManager
;
public
class
TopologyGraphTest
extends
ComponentTestCase
{
public
class
TopologyGraphTest
extends
ComponentTestCase
{
@Test
@Test
public
void
test
()
throws
ParseException
{
public
void
test
()
throws
Exception
{
build
(
"2014-07-06 18:00"
);
build
(
"2014-07-06 18:01"
);
build
(
"2014-07-06 18:02"
);
build
(
"2014-07-06 18:03"
);
build
(
"2014-07-06 18:04"
);
build
(
"2014-07-06 18:05"
);
build
(
"2014-07-06 18:06"
);
build
(
"2014-07-06 18:07"
);
build
(
"2014-07-06 18:08"
);
build
(
"2014-07-06 18:09"
);
}
public
void
build
(
String
date
)
throws
Exception
{
TopologyGraphManager
manager
=
lookup
(
TopologyGraphManager
.
class
);
TopologyGraphManager
manager
=
lookup
(
TopologyGraphManager
.
class
);
String
date
=
"2014-07-06 18:00"
;
SimpleDateFormat
formate
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
SimpleDateFormat
formate
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
TopologyGraph
graph
=
manager
.
queryGraphFromDB
(
formate
.
parse
(
date
).
getTime
());
try
{
TopologyGraph
graph
=
manager
.
queryGraphFromDB
(
formate
.
parse
(
date
).
getTime
());
System
.
out
.
println
(
graph
);
}
if
(
graph
!=
null
)
{
File
file
=
new
File
(
"/tmp/"
+
date
+
".txt"
);
@Test
public
void
test1
(){
if
(!
file
.
exists
())
{
ProductLineConfigManager
manager
=
lookup
(
ProductLineConfigManager
.
class
);
file
.
createNewFile
();
}
System
.
out
.
println
(
manager
.
getCompany
());
Files
.
forIO
().
writeTo
(
file
,
graph
.
toString
());
}
else
{
System
.
err
.
println
(
date
+
" is null1"
);
}
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
date
+
" is null1"
);
}
}
}
}
}
script/Cat.sql
浏览文件 @
4a0609ae
...
@@ -328,7 +328,7 @@ CREATE TABLE `alert_summary` (
...
@@ -328,7 +328,7 @@ CREATE TABLE `alert_summary` (
PRIMARY
KEY
(
`id`
)
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
COMMENT
=
'统一告警信息'
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
COMMENT
=
'统一告警信息'
;
CREATE
TABLE
`app_data_command`
(
CREATE
TABLE
`app_data_command
_1
`
(
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'自增长ID'
,
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'自增长ID'
,
`period`
date
NOT
NULL
COMMENT
'时间'
,
`period`
date
NOT
NULL
COMMENT
'时间'
,
`minute_order`
smallint
NOT
NULL
COMMENT
'分钟'
,
`minute_order`
smallint
NOT
NULL
COMMENT
'分钟'
,
...
@@ -353,8 +353,4 @@ CREATE TABLE `app_data_command` (
...
@@ -353,8 +353,4 @@ CREATE TABLE `app_data_command` (
KEY
IX_period_connnect_minute
(
period
,
connnect_type
,
minute_order
),
KEY
IX_period_connnect_minute
(
period
,
connnect_type
,
minute_order
),
KEY
IX_period_platform_minute
(
period
,
platform
,
minute_order
),
KEY
IX_period_platform_minute
(
period
,
platform
,
minute_order
),
KEY
IX_period_code_minute
(
period
,
code
,
minute_order
)
KEY
IX_period_code_minute
(
period
,
code
,
minute_order
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
COMMENT
=
'app基本数据'
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
COMMENT
=
'app基本数据'
;
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录