Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
32716dd8
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,发现更多精彩内容 >>
提交
32716dd8
编写于
6月 12, 2012
作者:
Y
You Yong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify the cat
上级
9f9c503f
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
282 addition
and
31 deletion
+282
-31
cat-hadoop/src/main/resources/META-INF/dal/jdbc/dal.xml
cat-hadoop/src/main/resources/META-INF/dal/jdbc/dal.xml
+12
-1
cat-home/src/main/java/com/dianping/cat/report/page/problem/Action.java
...ain/java/com/dianping/cat/report/page/problem/Action.java
+3
-1
cat-home/src/main/java/com/dianping/cat/report/page/problem/JspFile.java
...in/java/com/dianping/cat/report/page/problem/JspFile.java
+3
-1
cat-home/src/main/java/com/dianping/cat/report/page/problem/JspViewer.java
.../java/com/dianping/cat/report/page/problem/JspViewer.java
+2
-0
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Handler.java
...ava/com/dianping/cat/report/page/transaction/Handler.java
+108
-26
cat-home/src/main/java/com/dianping/cat/report/task/DefaultTaskConsumer.java
...ava/com/dianping/cat/report/task/DefaultTaskConsumer.java
+1
-1
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+12
-0
cat-home/src/main/webapp/jsp/report/transactionHistoryGraphs.jsp
...e/src/main/webapp/jsp/report/transactionHistoryGraphs.jsp
+1
-1
cat-home/src/test/java/com/dianping/cat/report/page/transaction/GraphDateTest.java
...m/dianping/cat/report/page/transaction/GraphDateTest.java
+140
-0
未找到文件。
cat-hadoop/src/main/resources/META-INF/dal/jdbc/dal.xml
浏览文件 @
32716dd8
...
...
@@ -237,9 +237,12 @@
(
<VALUES/>
)
]]>
</statement>
</query>
<query
name=
"find-by-domain-name-ip-duration"
type=
"SELECT"
>
<query
name=
"find-by-domain-name-ip-duration"
type=
"SELECT"
multiple=
"true"
>
<param
name=
"start-date"
/>
<param
name=
"end-date"
/>
<param
name=
"ip"
/>
<param
name=
"domain"
/>
<param
name=
"name"
/>
<statement>
<![CDATA[
SELECT <FIELDS/>
FROM
<TABLE/>
...
...
@@ -250,9 +253,17 @@
</IF>
AND
<FIELD
name=
'period'
/>
>= ${start-date}
AND
<FIELD
name=
'period'
/>
<
${end-date}
ORDER BY
<FIELD
name=
'period'
/>
ASC
]]>
</statement>
</query>
</query-defs>
</entity>
</entities>
cat-home/src/main/java/com/dianping/cat/report/page/problem/Action.java
浏览文件 @
32716dd8
...
...
@@ -11,7 +11,9 @@ public enum Action implements com.site.web.mvc.Action {
MOBILE
(
"mobile"
),
HISTORY
(
"history"
);
HISTORY
(
"history"
),
HISTORY_GRAPH
(
"historyGraph"
);
private
String
m_name
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/problem/JspFile.java
浏览文件 @
32716dd8
...
...
@@ -12,7 +12,9 @@ public enum JspFile {
MOBILE
(
"/jsp/report/problem_mobile.jsp"
),
HISTORY
(
"/jsp/report/problemHistoryReport.jsp"
),;
HISTORY
(
"/jsp/report/problemHistoryReport.jsp"
),
HISTORY_GRAPH
(
"/jsp/report/problemHistoryGraph.jsp"
);
private
String
m_path
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/problem/JspViewer.java
浏览文件 @
32716dd8
...
...
@@ -21,6 +21,8 @@ public class JspViewer extends BaseJspViewer<ReportPage, Action, Context, Model>
return
JspFile
.
MOBILE
.
getPath
();
case
HISTORY:
return
JspFile
.
HISTORY
.
getPath
();
case
HISTORY_GRAPH:
return
JspFile
.
HISTORY_GRAPH
.
getPath
();
}
throw
new
RuntimeException
(
"Unknown action: "
+
action
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Handler.java
浏览文件 @
32716dd8
package
com.dianping.cat.report.page.transaction
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -18,6 +20,9 @@ import com.dianping.cat.consumer.transaction.model.transform.DefaultDomParser;
import
com.dianping.cat.hadoop.dal.Dailyreport
;
import
com.dianping.cat.hadoop.dal.DailyreportDao
;
import
com.dianping.cat.hadoop.dal.DailyreportEntity
;
import
com.dianping.cat.hadoop.dal.Graph
;
import
com.dianping.cat.hadoop.dal.GraphDao
;
import
com.dianping.cat.hadoop.dal.GraphEntity
;
import
com.dianping.cat.helper.CatString
;
import
com.dianping.cat.report.ReportPage
;
import
com.dianping.cat.report.graph.GraphBuilder
;
...
...
@@ -31,6 +36,7 @@ import com.dianping.cat.report.page.transaction.GraphPayload.FailurePayload;
import
com.dianping.cat.report.page.transaction.GraphPayload.HitPayload
;
import
com.dianping.cat.report.page.trend.GraphItem
;
import
com.google.gson.Gson
;
import
com.site.dal.jdbc.DalException
;
import
com.site.lookup.annotation.Inject
;
import
com.site.lookup.util.StringUtils
;
import
com.site.web.mvc.PageHandler
;
...
...
@@ -39,6 +45,9 @@ import com.site.web.mvc.annotation.OutboundActionMeta;
import
com.site.web.mvc.annotation.PayloadMeta
;
public
class
Handler
implements
PageHandler
<
Context
>
{
public
static
final
long
ONE_HOUR
=
3600
*
1000L
;
@Inject
private
JspViewer
m_jspViewer
;
...
...
@@ -54,6 +63,9 @@ public class Handler implements PageHandler<Context> {
@Inject
private
DailyreportDao
dailyreportDao
;
@Inject
private
GraphDao
graphDao
;
private
StatisticsComputer
m_computer
=
new
StatisticsComputer
();
private
DefaultDomParser
transactionParser
=
new
DefaultDomParser
();
...
...
@@ -197,44 +209,34 @@ public class Handler implements PageHandler<Context> {
private
void
buildTrendGraph
(
Model
model
,
Payload
payload
)
{
Date
start
=
payload
.
getHistoryStartDate
();
Date
end
=
payload
.
getHistoryEndDate
();
String
domain
=
model
.
getDomain
();
String
ip
=
model
.
getIpAddress
();
String
type
=
payload
.
getType
();
String
name
=
payload
.
getName
();
String
display
=
name
!=
null
?
name
:
type
;
long
current
=
System
.
currentTimeMillis
();
current
=
current
-
current
%
(
3600
*
1000
);
long
date
=
current
-
24
*
3600
*
1000
;
start
=
new
Date
(
date
);
end
=
new
Date
(
current
);
int
size
=
(
int
)
(
current
-
date
)
/
(
3600
*
1000
);
int
size
=
(
int
)
((
end
.
getTime
()
-
start
.
getTime
())
/
ONE_HOUR
);
GraphItem
item
=
new
GraphItem
();
item
.
setStart
(
start
);
item
.
setSize
(
size
);
// TO GET The Data from database
// TODO
// For URL
item
.
setTitles
(
display
+
" Response Trend"
);
double
[]
ylable1
=
new
double
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
// TODO
ylable1
[
i
]
=
Math
.
random
()
*
192
;
Map
<
String
,
double
[]>
graphData
=
getGraphData
(
model
,
payload
);
double
[]
sum
=
graphData
.
get
(
"sum"
);
double
[]
totalCount
=
graphData
.
get
(
"total_count"
);
double
[]
avg
=
new
double
[
sum
.
length
];
for
(
int
i
=
1
;
i
<
sum
.
length
;
i
++)
{
if
(
totalCount
[
i
]
>
0
)
{
avg
[
i
]
=
sum
[
i
]
/
totalCount
[
i
];
}
}
item
.
addValue
(
ylable1
);
item
.
addValue
(
avg
);
model
.
setResponseTrend
(
item
.
getJsonString
());
item
.
setTitles
(
display
+
" Hit Trend"
);
item
.
getValues
().
clear
();
ylable1
=
new
double
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
ylable1
[
i
]
=
Math
.
random
()
*
192
;
}
item
.
addValue
(
ylable1
);
model
.
setHitTrend
(
item
.
getJsonString
());
item
.
addValue
(
totalCount
);
model
.
setHitTrend
(
item
.
getJsonString
());
}
private
void
showSummarizeReport
(
Model
model
,
Payload
payload
)
{
...
...
@@ -373,15 +375,95 @@ public class Handler implements PageHandler<Context> {
}
}
public
Map
<
String
,
double
[]>
get
DetailInfo
(
Model
model
,
Payload
payload
)
{
Date
start
=
payload
.
getHistoryEndDate
(
);
public
Map
<
String
,
double
[]>
get
GraphData
(
Model
model
,
Payload
payload
)
{
Date
start
=
new
Date
(
payload
.
getDate
()
);
Date
end
=
payload
.
getHistoryEndDate
();
String
domain
=
model
.
getDomain
();
String
ip
=
model
.
getIpAddress
();
String
type
=
payload
.
getType
();
String
name
=
payload
.
getName
();
String
ip
=
model
.
getIpAddress
();
List
<
Graph
>
graphs
=
new
ArrayList
<
Graph
>();
try
{
graphs
=
this
.
graphDao
.
findByDomainNameIpDuration
(
start
,
end
,
ip
,
domain
,
"transaction"
,
GraphEntity
.
READSET_FULL
);
}
catch
(
DalException
e
)
{
e
.
printStackTrace
();
}
return
null
;
Map
<
String
,
double
[]>
result
=
buildGraphDates
(
start
,
end
,
type
,
name
,
graphs
);
return
result
;
}
Map
<
String
,
double
[]>
buildGraphDates
(
Date
start
,
Date
end
,
String
type
,
String
name
,
List
<
Graph
>
graphs
)
{
Map
<
String
,
double
[]>
result
=
new
HashMap
<
String
,
double
[]>();
List
<
Date
>
periods
=
new
ArrayList
<
Date
>();
for
(
long
i
=
start
.
getTime
();
i
<
end
.
getTime
();
i
=
i
+
ONE_HOUR
)
{
periods
.
add
(
new
Date
(
i
));
}
int
size
=
periods
.
size
();
double
[]
total_count
=
new
double
[
size
];
double
[]
failure_count
=
new
double
[
size
];
double
[]
min
=
new
double
[
size
];
double
[]
max
=
new
double
[
size
];
double
[]
sum
=
new
double
[
size
];
double
[]
sum2
=
new
double
[
size
];
if
(!
isEmpty
(
type
)
&&
isEmpty
(
name
))
{
for
(
Graph
graph
:
graphs
)
{
int
indexOfperiod
=
periods
.
indexOf
(
graph
.
getPeriod
());
String
summaryContent
=
graph
.
getSummaryContent
();
String
[]
allLines
=
summaryContent
.
split
(
"\n"
);
for
(
int
j
=
0
;
j
<
allLines
.
length
;
j
++)
{
String
[]
records
=
allLines
[
j
].
split
(
"\t"
);
if
(
records
[
SummaryOrder
.
TYPE
.
ordinal
()].
equals
(
type
))
{
total_count
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
SummaryOrder
.
TOTAL_COUNT
.
ordinal
()]);
failure_count
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
SummaryOrder
.
FAILURE_COUNT
.
ordinal
()]);
min
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
SummaryOrder
.
MIN
.
ordinal
()]);
max
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
SummaryOrder
.
MAX
.
ordinal
()]);
sum
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
SummaryOrder
.
SUM
.
ordinal
()]);
sum2
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
SummaryOrder
.
SUM2
.
ordinal
()]);
}
}
}
}
else
if
(!
isEmpty
(
type
)
&&
!
isEmpty
(
name
))
{
for
(
Graph
graph
:
graphs
)
{
int
indexOfperiod
=
periods
.
indexOf
(
graph
.
getPeriod
());
String
detailContent
=
graph
.
getDetailContent
();
String
[]
allLines
=
detailContent
.
split
(
"\n"
);
for
(
int
j
=
0
;
j
<
allLines
.
length
;
j
++)
{
String
[]
records
=
allLines
[
j
].
split
(
"\t"
);
if
(
records
[
DetailOrder
.
TYPE
.
ordinal
()].
equals
(
type
)
&&
records
[
DetailOrder
.
NAME
.
ordinal
()].
equals
(
name
))
{
total_count
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
DetailOrder
.
TOTAL_COUNT
.
ordinal
()]);
failure_count
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
DetailOrder
.
FAILURE_COUNT
.
ordinal
()]);
min
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
DetailOrder
.
MIN
.
ordinal
()]);
max
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
DetailOrder
.
MAX
.
ordinal
()]);
sum
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
DetailOrder
.
SUM
.
ordinal
()]);
sum2
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
DetailOrder
.
SUM2
.
ordinal
()]);
}
}
}
}
result
.
put
(
"total_count"
,
total_count
);
result
.
put
(
"failure_count"
,
failure_count
);
result
.
put
(
"min"
,
min
);
result
.
put
(
"max"
,
max
);
result
.
put
(
"sum"
,
sum
);
result
.
put
(
"sum2"
,
sum2
);
return
result
;
}
private
boolean
isEmpty
(
String
content
)
{
return
content
==
null
||
content
.
equals
(
""
);
}
public
enum
SummaryOrder
{
TYPE
,
TOTAL_COUNT
,
FAILURE_COUNT
,
MIN
,
MAX
,
SUM
,
SUM2
}
public
enum
DetailOrder
{
TYPE
,
NAME
,
TOTAL_COUNT
,
FAILURE_COUNT
,
MIN
,
MAX
,
SUM
,
SUM2
}
}
cat-home/src/main/java/com/dianping/cat/report/task/DefaultTaskConsumer.java
浏览文件 @
32716dd8
...
...
@@ -396,7 +396,7 @@ public class DefaultTaskConsumer extends TaskConsumer implements LogEnabled {
graphs
.
add
(
graph
);
}
Graph
allGraph
=
new
Graph
();
Graph
allGraph
=
new
Graph
();
allGraph
.
setIp
(
null
);
allGraph
.
setDomain
(
domainName
);
allGraph
.
setName
(
reportName
);
...
...
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
32716dd8
...
...
@@ -450,12 +450,24 @@
<requirement>
<role>
com.dianping.cat.hadoop.dal.DailyreportDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.hadoop.dal.GraphDao
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.transaction.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.transaction.JspViewer
</implementation>
</component>
<component>
<role>
com.dianping.cat.hadoop.dal.GraphDao
</role>
<implementation>
com.dianping.cat.hadoop.dal.GraphDao
</implementation>
<requirements>
<requirement>
<role>
com.site.dal.jdbc.QueryEngine
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.event.Handler
</role>
<implementation>
com.dianping.cat.report.page.event.Handler
</implementation>
...
...
cat-home/src/main/webapp/jsp/report/transactionHistoryGraphs.jsp
浏览文件 @
32716dd8
...
...
@@ -9,7 +9,7 @@
</style>
<script
type=
"text/javascript"
src=
"/cat/js/jquery-1.7.1.js"
></script>
<script
type=
"text/javascript"
src=
"/cat/js/flotr2.js"
></script>
<script
type=
"text/javascript"
src=
"/cat/js/
g
raph.js"
></script>
<script
type=
"text/javascript"
src=
"/cat/js/
transactionG
raph.js"
></script>
<table>
<tr>
...
...
cat-home/src/test/java/com/dianping/cat/report/page/transaction/GraphDateTest.java
0 → 100644
浏览文件 @
32716dd8
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.Collections
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
junit.framework.Assert
;
import
org.junit.Test
;
import
com.dianping.cat.hadoop.dal.Graph
;
public
class
GraphDateTest
{
public
static
final
long
ONE_HOUR
=
3600
*
1000L
;
@Test
public
void
testBuildGraphDatesByType
(){
Handler
handler
=
new
Handler
();
SimpleDateFormat
sf
=
new
SimpleDateFormat
(
"yyyyMMddHH"
);
try
{
Date
start
=
sf
.
parse
(
"2012060612"
);
Date
end
=
sf
.
parse
(
"2012060622"
);
List
<
Graph
>
graphs
=
buildGraph
(
start
,
end
);
String
type
=
"URL"
;
Map
<
String
,
double
[]>
graphDates
=
handler
.
buildGraphDates
(
start
,
end
,
type
,
null
,
graphs
);
double
[]
total_count
={
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
};
double
[]
failure_count
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
double
[]
min
=
{
11.836555
,
11.836555
,
11.836555
,
11.836555
,
11.836555
,
11.836555
,
11.836555
,
11.836555
,
11.836555
,
11.836555
};
double
[]
max
=
{
225244.724
,
225244.724
,
225244.724
,
225244.724
,
225244.724
,
225244.724
,
225244.724
,
225244.724
,
225244.724
,
225244.724
};
double
[]
sum
=
{
234038.7
,
234038.7
,
234038.7
,
234038.7
,
234038.7
,
234038.7
,
234038.7
,
234038.7
,
234038.7
,
234038.7
};
double
[]
sum2
={
5.07448582695E10
,
5.07448582695E10
,
5.07448582695E10
,
5.07448582695E10
,
5.07448582695E10
,
5.07448582695E10
,
5.07448582695E10
,
5.07448582695E10
,
5.07448582695E10
,
5.07448582695E10
};
double
[]
expectTotalCount
=
graphDates
.
get
(
"total_count"
);
double
[]
expectFailureCount
=
graphDates
.
get
(
"failure_count"
);
double
[]
expectMin
=
graphDates
.
get
(
"min"
);
double
[]
expectMax
=
graphDates
.
get
(
"max"
);
double
[]
expectSum2
=
graphDates
.
get
(
"sum2"
);
double
[]
expectSum
=
graphDates
.
get
(
"sum"
);
Assert
.
assertEquals
(
true
,
Arrays
.
equals
(
total_count
,
expectTotalCount
)
);
Assert
.
assertEquals
(
true
,
Arrays
.
equals
(
failure_count
,
expectFailureCount
));
Assert
.
assertEquals
(
true
,
Arrays
.
equals
(
min
,
expectMin
));
Assert
.
assertEquals
(
true
,
Arrays
.
equals
(
max
,
expectMax
));
Assert
.
assertEquals
(
true
,
Arrays
.
equals
(
sum
,
expectSum
));
Assert
.
assertEquals
(
true
,
Arrays
.
equals
(
sum2
,
expectSum2
));
}
catch
(
ParseException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
@Test
public
void
testBuildGraphDatesByTypeAndName
(){
Handler
handler
=
new
Handler
();
SimpleDateFormat
sf
=
new
SimpleDateFormat
(
"yyyyMMddHH"
);
try
{
Date
start
=
sf
.
parse
(
"2012060612"
);
Date
end
=
sf
.
parse
(
"2012060622"
);
List
<
Graph
>
graphs
=
buildGraph
(
start
,
end
);
String
type
=
"Result"
;
String
name
=
"cacheService:cacheConfigService_1.0.0:getKeyConfigurations"
;
Map
<
String
,
double
[]>
graphDates
=
handler
.
buildGraphDates
(
start
,
end
,
type
,
name
,
graphs
);
double
[]
total_count
={
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
};
double
[]
failure_count
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
double
[]
min
=
{
6.83
,
6.83
,
6.83
,
6.83
,
6.83
,
6.83
,
6.83
,
6.83
,
6.83
,
6.83
};
double
[]
max
=
{
7.583
,
7.583
,
7.583
,
7.583
,
7.583
,
7.583
,
7.583
,
7.583
,
7.583
,
7.583
};
double
[]
sum
=
{
43.2
,
43.2
,
43.2
,
43.2
,
43.2
,
43.2
,
43.2
,
43.2
,
43.2
,
43.2
};
double
[]
sum2
={
311.0
,
311.0
,
311.0
,
311.0
,
311.0
,
311.0
,
311.0
,
311.0
,
311.0
,
311.0
};
double
[]
expectTotalCount
=
graphDates
.
get
(
"total_count"
);
double
[]
expectFailureCount
=
graphDates
.
get
(
"failure_count"
);
double
[]
expectMin
=
graphDates
.
get
(
"min"
);
double
[]
expectMax
=
graphDates
.
get
(
"max"
);
double
[]
expectSum2
=
graphDates
.
get
(
"sum2"
);
double
[]
expectSum
=
graphDates
.
get
(
"sum"
);
Assert
.
assertEquals
(
true
,
Arrays
.
equals
(
total_count
,
expectTotalCount
)
);
Assert
.
assertEquals
(
true
,
Arrays
.
equals
(
failure_count
,
expectFailureCount
));
Assert
.
assertEquals
(
true
,
Arrays
.
equals
(
min
,
expectMin
));
Assert
.
assertEquals
(
true
,
Arrays
.
equals
(
max
,
expectMax
));
Assert
.
assertEquals
(
true
,
Arrays
.
equals
(
sum
,
expectSum
));
Assert
.
assertEquals
(
true
,
Arrays
.
equals
(
sum2
,
expectSum2
));
}
catch
(
ParseException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
@Test
public
void
testBuildGraphDatesEmpty
(){
Handler
handler
=
new
Handler
();
SimpleDateFormat
sf
=
new
SimpleDateFormat
(
"yyyyMMddHH"
);
try
{
Date
start
=
sf
.
parse
(
"2012060612"
);
Date
end
=
sf
.
parse
(
"2012060622"
);
List
<
Graph
>
graphs
=
buildGraph
(
start
,
end
);
String
type
=
"Result"
;
String
name
=
"Result"
;
Map
<
String
,
double
[]>
graphDates
=
handler
.
buildGraphDates
(
start
,
end
,
type
,
name
,
graphs
);
double
[]
expectSum
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
double
[]
sum
=
graphDates
.
get
(
"sum"
);
Assert
.
assertEquals
(
true
,
Arrays
.
equals
(
sum
,
expectSum
));
}
catch
(
ParseException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
private
List
<
Graph
>
buildGraph
(
Date
start
,
Date
end
){
List
<
Graph
>
graphs
=
new
ArrayList
<
Graph
>();
String
summary
=
"Call 13704 0 0.993 505.822 133680.3 7678055.5"
+
"\n"
+
"Result 13704 0 0.096 73.104 13377.4 156669.3"
+
"\n"
+
"Task 26 0 36.406555 60.022 1102.4 47641.6"
+
"\n"
+
"URL 15 0 11.836555 225244.724 234038.7 5.07448582695E10"
+
"\n"
;
String
detail
=
"Call cacheService:cacheConfigService_1.0.0:getCacheConfigurations 6 0 261.046 481.68 2369.7 989806.8"
+
"\n"
+
"Call cacheService:cacheConfigService_1.0.0:getKeyConfigurations 6 0 40.301 43.161 250.6 10472.6"
+
"\n"
+
"Call shopService:shopService_1.0.0:findShopRegions 2348 0 1.874 505.822 31048.6 1893017.0"
+
"\n"
+
"Call shopService:shopService_1.0.0:findShops 11344 0 0.993 294.569 100011.4 4784759.1"
+
"\n"
+
"Result cacheService:cacheConfigService_1.0.0:getCacheConfigurations 6 0 28.769 64.718 302.0 16596.8"
+
"\n"
+
"Result cacheService:cacheConfigService_1.0.0:getKeyConfigurations 6 0 6.83 7.583 43.2 311.0"
;
List
<
Date
>
periods
=
new
ArrayList
<
Date
>();
for
(
long
i
=
start
.
getTime
();
i
<
end
.
getTime
();
i
=
i
+
ONE_HOUR
)
{
periods
.
add
(
new
Date
(
i
));
}
for
(
int
i
=
0
;
i
<
10
;
i
++){
Graph
graph
=
new
Graph
();
graph
.
setDetailContent
(
detail
);
graph
.
setSummaryContent
(
summary
);
graphs
.
add
(
graph
);
graph
.
setPeriod
(
periods
.
get
(
i
));
}
return
graphs
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录