Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
d883535b
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,发现更多精彩内容 >>
提交
d883535b
编写于
3月 04, 2012
作者:
F
Frankie Wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
implement 4 graphs in transaction page
上级
a4356bfd
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
429 addition
and
98 deletion
+429
-98
cat-consumer/src/main/java/META-INF/MANIFEST.MF
cat-consumer/src/main/java/META-INF/MANIFEST.MF
+0
-3
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/MeanSquareDeviationComputer.java
...cat/consumer/transaction/MeanSquareDeviationComputer.java
+10
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionAnalyzer.java
...ianping/cat/consumer/transaction/TransactionAnalyzer.java
+30
-0
cat-consumer/src/main/resources/META-INF/dal/model/transaction-report-codegen.xml
...sources/META-INF/dal/model/transaction-report-codegen.xml
+1
-1
cat-consumer/src/main/resources/META-INF/dal/model/transaction-report.xml
.../main/resources/META-INF/dal/model/transaction-report.xml
+1
-1
cat-home/src/main/java/com/dianping/cat/report/graph/AbstractGraphPayload.java
...a/com/dianping/cat/report/graph/AbstractGraphPayload.java
+31
-7
cat-home/src/main/java/com/dianping/cat/report/graph/DefaultGraphBuilder.java
...va/com/dianping/cat/report/graph/DefaultGraphBuilder.java
+40
-28
cat-home/src/main/java/com/dianping/cat/report/graph/DefaultValueTranslater.java
...com/dianping/cat/report/graph/DefaultValueTranslater.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/graph/GraphPayload.java
...main/java/com/dianping/cat/report/graph/GraphPayload.java
+8
-2
cat-home/src/main/java/com/dianping/cat/report/page/ip/Model.java
.../src/main/java/com/dianping/cat/report/page/ip/Model.java
+22
-23
cat-home/src/main/java/com/dianping/cat/report/page/model/spi/ModelRequest.java
.../com/dianping/cat/report/page/model/spi/ModelRequest.java
+2
-1
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Handler.java
...ava/com/dianping/cat/report/page/transaction/Handler.java
+229
-18
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Model.java
.../java/com/dianping/cat/report/page/transaction/Model.java
+35
-5
cat-home/src/main/webapp/css/transaction.css
cat-home/src/main/webapp/css/transaction.css
+4
-5
cat-home/src/main/webapp/jsp/report/transaction.jsp
cat-home/src/main/webapp/jsp/report/transaction.jsp
+1
-1
cat-home/src/main/webapp/jsp/report/transaction_graphs.jsp
cat-home/src/main/webapp/jsp/report/transaction_graphs.jsp
+14
-2
未找到文件。
cat-consumer/src/main/java/META-INF/MANIFEST.MF
已删除
100644 → 0
浏览文件 @
a4356bfd
Manifest-Version: 1.0
Class-Path:
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/MeanSquareDeviationComputer.java
浏览文件 @
d883535b
package
com.dianping.cat.consumer.transaction
;
import
com.dianping.cat.consumer.transaction.model.entity.Range
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionName
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionType
;
import
com.dianping.cat.consumer.transaction.model.transform.BaseVisitor
;
...
...
@@ -7,6 +8,8 @@ import com.dianping.cat.consumer.transaction.model.transform.BaseVisitor;
public
class
MeanSquareDeviationComputer
extends
BaseVisitor
{
@Override
public
void
visitName
(
TransactionName
name
)
{
super
.
visitName
(
name
);
long
count
=
name
.
getTotalCount
();
if
(
count
>
0
)
{
...
...
@@ -21,6 +24,13 @@ public class MeanSquareDeviationComputer extends BaseVisitor {
}
}
@Override
public
void
visitRange
(
Range
range
)
{
if
(
range
.
getCount
()
>
0
)
{
range
.
setAvg
(
range
.
getSum
()
/
range
.
getCount
());
}
}
@Override
public
void
visitType
(
TransactionType
type
)
{
super
.
visitType
(
type
);
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionAnalyzer.java
浏览文件 @
d883535b
...
...
@@ -4,6 +4,7 @@ import java.io.File;
import
java.io.IOException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Date
;
...
...
@@ -18,6 +19,8 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationExce
import
com.dianping.cat.configuration.model.entity.Config
;
import
com.dianping.cat.configuration.model.entity.Property
;
import
com.dianping.cat.consumer.transaction.model.entity.Duration
;
import
com.dianping.cat.consumer.transaction.model.entity.Range
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionName
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionType
;
...
...
@@ -219,6 +222,8 @@ public class TransactionAnalyzer extends AbstractMessageAnalyzer<TransactionRepo
type
.
setSum
(
type
.
getSum
()
+
duration
);
type
.
setSum2
(
type
.
getSum2
()
+
duration
*
duration
);
processTransactionGrpah
(
name
,
t
);
List
<
Message
>
children
=
t
.
getChildren
();
for
(
Message
child
:
children
)
{
...
...
@@ -230,6 +235,31 @@ public class TransactionAnalyzer extends AbstractMessageAnalyzer<TransactionRepo
return
count
;
}
void
processTransactionGrpah
(
TransactionName
name
,
Transaction
t
)
{
long
d
=
t
.
getDuration
();
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTimeInMillis
(
t
.
getTimestamp
());
int
min
=
cal
.
get
(
Calendar
.
MINUTE
);
int
dk
=
1
;
int
tk
=
min
-
min
%
5
;
while
(
dk
<
d
)
{
dk
<<=
1
;
}
Duration
duration
=
name
.
findOrCreateDuration
(
dk
);
Range
range
=
name
.
findOrCreateRange
(
tk
);
duration
.
incCount
();
range
.
incCount
();
if
(!
t
.
isSuccess
())
{
range
.
incFails
();
}
range
.
setSum
(
range
.
getSum
()
+
d
);
}
public
void
setAnalyzerInfo
(
long
startTime
,
long
duration
,
String
domain
,
long
extraTime
)
{
m_extraTime
=
extraTime
;
m_startTime
=
startTime
;
...
...
cat-consumer/src/main/resources/META-INF/dal/model/transaction-report-codegen.xml
浏览文件 @
d883535b
...
...
@@ -41,7 +41,7 @@
<entity
name=
"range"
>
<attribute
name=
"value"
value-type=
"int"
/>
<attribute
name=
"count"
value-type=
"int"
/>
<attribute
name=
"sum"
value-type=
"
int
"
/>
<attribute
name=
"sum"
value-type=
"
double
"
/>
<attribute
name=
"avg"
value-type=
"double"
/>
<attribute
name=
"fails"
value-type=
"int"
/>
</entity>
...
...
cat-consumer/src/main/resources/META-INF/dal/model/transaction-report.xml
浏览文件 @
d883535b
...
...
@@ -38,7 +38,7 @@
<entity
name=
"range"
>
<attribute
name=
"value"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"sum"
value-type=
"
int
"
primitive=
"true"
/>
<attribute
name=
"sum"
value-type=
"
double
"
primitive=
"true"
/>
<attribute
name=
"avg"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"fails"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
</entity>
...
...
cat-home/src/main/java/com/dianping/cat/report/graph/AbstractGraphPayload.java
浏览文件 @
d883535b
...
...
@@ -13,22 +13,36 @@ public abstract class AbstractGraphPayload implements GraphPayload {
m_title
=
title
;
m_axisXLabel
=
axisXLabel
;
m_axisYLabel
=
axisYLabel
;
m_values
=
getValues
();
}
public
final
double
[]
getValues
()
{
if
(
m_values
==
null
)
{
m_values
=
loadValues
();
}
return
m_values
;
}
protected
abstract
double
[]
loadValues
();
@Override
public
String
getAxisXLabel
(
int
index
)
{
return
String
.
valueOf
(
index
);
}
@Override
public
String
getAxisX
Label
()
{
public
String
getAxisX
Title
()
{
return
m_axisXLabel
;
}
@Override
public
String
getAxisY
Label
()
{
public
String
getAxisY
Title
()
{
return
m_axisYLabel
;
}
@Override
public
int
getColumns
()
{
return
m_values
.
length
;
return
getValues
()
.
length
;
}
@Override
...
...
@@ -48,12 +62,12 @@ public abstract class AbstractGraphPayload implements GraphPayload {
@Override
public
int
getHeight
()
{
return
2
8
0
;
return
2
5
0
;
}
@Override
public
int
getMarginBottom
()
{
return
5
0
;
return
6
0
;
}
@Override
...
...
@@ -68,7 +82,7 @@ public abstract class AbstractGraphPayload implements GraphPayload {
@Override
public
int
getMarginTop
()
{
return
5
0
;
return
4
0
;
}
@Override
...
...
@@ -85,4 +99,14 @@ public abstract class AbstractGraphPayload implements GraphPayload {
public
int
getWidth
()
{
return
580
;
}
@Override
public
boolean
isAxisXLabelRotated
()
{
return
false
;
}
@Override
public
boolean
isAxisXLabelSkipped
()
{
return
getValues
().
length
>=
16
;
}
}
cat-home/src/main/java/com/dianping/cat/report/graph/DefaultGraphBuilder.java
浏览文件 @
d883535b
...
...
@@ -14,7 +14,11 @@ public class DefaultGraphBuilder implements GraphBuilder {
int
maxValue
=
m_translater
.
getMaxValue
(
values
);
XmlBuilder
b
=
new
XmlBuilder
();
buildHeader
(
payload
,
b
);
if
(
maxValue
<
payload
.
getRows
())
{
maxValue
=
payload
.
getRows
();
}
buildHeader
(
payload
,
b
,
maxValue
);
buildCoordinate
(
payload
,
b
);
buildYLabels
(
payload
,
b
,
maxValue
);
buildXLabels
(
payload
,
b
);
...
...
@@ -109,7 +113,7 @@ public class DefaultGraphBuilder implements GraphBuilder {
b
.
tag
(
"path"
,
"id"
,
"ys"
,
"d"
,
p
.
build
());
}
if
(
cols
>=
16
)
{
if
(
payload
.
isAxisXLabelSkipped
()
)
{
p
.
moveTo
(
left
,
top
+
h
).
mark
().
v
(
9
).
m
(
xstep
,
-
9
).
v
(
5
).
m
(
xstep
,
-
5
).
repeat
(
cols
/
2
);
if
(
cols
%
2
==
0
)
{
...
...
@@ -129,7 +133,7 @@ public class DefaultGraphBuilder implements GraphBuilder {
b
.
tag2
(
"svg"
);
}
protected
void
buildHeader
(
GraphPayload
payload
,
XmlBuilder
b
)
{
protected
void
buildHeader
(
GraphPayload
payload
,
XmlBuilder
b
,
int
maxValue
)
{
int
height
=
payload
.
getHeight
();
int
width
=
payload
.
getWidth
();
int
top
=
payload
.
getMarginTop
();
...
...
@@ -153,22 +157,23 @@ public class DefaultGraphBuilder implements GraphBuilder {
b
.
tag1
(
"g"
);
String
axisX
Label
=
payload
.
getAxisXLabel
();
String
axisX
Title
=
payload
.
getAxisXTitle
();
if
(
axisX
Label
!=
null
)
{
int
x
=
(
width
-
left
-
right
-
axisX
Label
.
length
()
*
9
)
/
2
+
left
;
if
(
axisX
Title
!=
null
)
{
int
x
=
(
width
-
left
-
right
-
axisX
Title
.
length
()
*
9
)
/
2
+
left
;
int
y
=
height
-
4
;
b
.
tagWithText
(
"text"
,
axisXLabel
,
"x"
,
x
,
"y"
,
y
,
"font-size"
,
"18"
);
b
.
tagWithText
(
"text"
,
axisXTitle
,
"x"
,
x
,
"y"
,
y
,
"font-size"
,
"18"
);
}
String
axisY
Label
=
payload
.
getAxisYLabel
();
String
axisY
Title
=
payload
.
getAxisYTitle
();
if
(
axisY
Label
!=
null
)
{
int
x
=
16
;
int
y
=
(
height
-
top
-
bottom
+
axisY
Label
.
length
()
*
9
)
/
2
+
top
;
if
(
axisY
Title
!=
null
)
{
int
x
=
left
-
20
-
String
.
valueOf
(
maxValue
).
length
()
*
9
;
int
y
=
(
height
-
top
-
bottom
+
axisY
Title
.
length
()
*
9
)
/
2
+
top
;
String
transform
=
"rotate(-90,"
+
x
+
","
+
y
+
")"
;
b
.
tagWithText
(
"text"
,
axisY
Label
,
"x"
,
x
,
"y"
,
y
,
"font-size"
,
"18"
,
"transform"
,
transform
);
b
.
tagWithText
(
"text"
,
axisY
Title
,
"x"
,
x
,
"y"
,
y
,
"font-size"
,
"18"
,
"transform"
,
transform
);
}
if
(
title
!=
null
)
{
...
...
@@ -192,27 +197,34 @@ public class DefaultGraphBuilder implements GraphBuilder {
b
.
tag1
(
"g"
,
"id"
,
"xt"
);
if
(
cols
>=
16
)
{
for
(
int
i
=
0
;
i
<=
cols
;
i
+=
2
)
{
int
x
=
left
+
xstep
*
i
-
4
;
int
y
=
height
-
bottom
+
22
;
boolean
rotated
=
payload
.
isAxisXLabelRotated
();
boolean
skipped
=
payload
.
isAxisXLabelSkipped
();
if
(
i
>=
10
)
{
x
-=
4
;
}
for
(
int
i
=
0
;
i
<=
cols
;)
{
int
x
=
left
+
xstep
*
i
-
4
;
int
y
=
height
-
bottom
+
20
+
(
skipped
?
2
:
0
);
String
label
=
payload
.
getAxisXLabel
(
i
);
b
.
tagWithText
(
"text"
,
i
,
"x"
,
x
,
"y"
,
y
);
if
(!
rotated
)
{
if
(
label
.
length
()
>
1
)
{
x
-=
4
*
(
label
.
length
()
-
1
);
}
}
else
{
y
-=
10
;
}
}
else
{
for
(
int
i
=
0
;
i
<=
cols
;
i
++)
{
int
x
=
left
+
xstep
*
i
-
4
;
int
y
=
height
-
bottom
+
20
;
if
(
i
>=
10
)
{
x
-=
4
;
}
if
(
rotated
)
{
String
transform
=
"rotate(90,"
+
x
+
","
+
y
+
")"
;
b
.
tagWithText
(
"text"
,
label
,
"x"
,
x
,
"y"
,
y
,
"transform"
,
transform
);
}
else
{
b
.
tagWithText
(
"text"
,
label
,
"x"
,
x
,
"y"
,
y
);
}
b
.
tagWithText
(
"text"
,
i
,
"x"
,
x
,
"y"
,
y
);
if
(
skipped
)
{
i
+=
2
;
}
else
{
i
++;
}
}
...
...
cat-home/src/main/java/com/dianping/cat/report/graph/DefaultValueTranslater.java
浏览文件 @
d883535b
...
...
@@ -25,7 +25,7 @@ public class DefaultValueTranslater implements ValueTranslater {
while
(
maxValue
>
max
*
2
)
{
maxValue
=
maxValue
/
2
;
}
return
maxValue
;
}
...
...
cat-home/src/main/java/com/dianping/cat/report/graph/GraphPayload.java
浏览文件 @
d883535b
package
com.dianping.cat.report.graph
;
public
interface
GraphPayload
{
public
String
getAxisX
Label
();
public
String
getAxisX
Title
();
public
String
getAxisYLabel
();
public
String
getAxisYTitle
();
public
String
getAxisXLabel
(
int
index
);
public
int
getColumns
();
...
...
@@ -30,4 +32,8 @@ public interface GraphPayload {
public
int
getDisplayHeight
();
public
int
getDisplayWidth
();
public
boolean
isAxisXLabelRotated
();
public
boolean
isAxisXLabelSkipped
();
}
cat-home/src/main/java/com/dianping/cat/report/page/ip/Model.java
浏览文件 @
d883535b
...
...
@@ -4,25 +4,24 @@ import java.util.ArrayList;
import
java.util.List
;
import
com.dianping.cat.consumer.ip.model.entity.IpReport
;
import
com.dianping.cat.report.
ReportPage
;
import
com.dianping.cat.report.
page.AbstractReportModel
;
import
com.dianping.cat.report.view.UrlNav
;
import
com.site.web.mvc.ViewModel
;
public
class
Model
extends
ViewModel
<
ReportPage
,
Action
,
Context
>
{
public
class
Model
extends
AbstractReportModel
<
Action
,
Context
>
{
private
IpReport
m_report
;
private
List
<
DisplayModel
>
m_displayModels
;
private
List
<
String
>
m_domains
;
private
String
m_currentDomain
;
private
String
m_current
;
private
String
m_reportTitle
;
private
String
m_generateTime
;
private
String
m_urlPrefix
;
private
List
<
UrlNav
>
m_urlNavs
;
...
...
@@ -44,30 +43,30 @@ public class Model extends ViewModel<ReportPage, Action, Context> {
public
List
<
String
>
getDomains
()
{
return
m_domains
;
}
public
String
getUrlPrefix
()
{
return
m_urlPrefix
;
}
return
m_urlPrefix
;
}
public
void
setUrlPrefix
(
String
urlPrefix
)
{
m_urlPrefix
=
urlPrefix
;
}
m_urlPrefix
=
urlPrefix
;
}
public
List
<
UrlNav
>
getUrlNavs
()
{
return
m_urlNavs
;
}
return
m_urlNavs
;
}
public
void
setUrlNavs
(
List
<
UrlNav
>
urlNavs
)
{
m_urlNavs
=
urlNavs
;
}
m_urlNavs
=
urlNavs
;
}
public
String
getCurrentDomain
()
{
return
m_currentDomain
;
}
return
m_currentDomain
;
}
public
void
setCurrentDomain
(
String
currentDomain
)
{
m_currentDomain
=
currentDomain
;
}
m_currentDomain
=
currentDomain
;
}
public
IpReport
getReport
()
{
return
m_report
;
...
...
@@ -106,11 +105,11 @@ public class Model extends ViewModel<ReportPage, Action, Context> {
}
public
String
getGenerateTime
()
{
return
m_generateTime
;
}
return
m_generateTime
;
}
public
void
setGenerateTime
(
String
generateTime
)
{
m_generateTime
=
generateTime
;
}
m_generateTime
=
generateTime
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/model/spi/ModelRequest.java
浏览文件 @
d883535b
...
...
@@ -40,12 +40,13 @@ public class ModelRequest {
}
}
public
void
setProperty
(
String
name
,
String
value
)
{
public
ModelRequest
setProperty
(
String
name
,
String
value
)
{
if
(
m_properties
==
null
)
{
m_properties
=
new
HashMap
<
String
,
String
>();
}
m_properties
.
put
(
name
,
value
);
return
this
;
}
public
static
ModelRequest
from
(
String
domain
,
String
period
)
{
...
...
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Handler.java
浏览文件 @
d883535b
package
com.dianping.cat.report.page.transaction
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.servlet.ServletException
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
com.dianping.cat.consumer.transaction.MeanSquareDeviationComputer
;
import
com.dianping.cat.consumer.transaction.model.entity.Duration
;
import
com.dianping.cat.consumer.transaction.model.entity.Range
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionName
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionType
;
import
com.dianping.cat.report.ReportPage
;
import
com.dianping.cat.report.graph.AbstractGraphPayload
;
import
com.dianping.cat.report.graph.GraphBuilder
;
...
...
@@ -21,7 +31,7 @@ import com.site.web.mvc.annotation.PayloadMeta;
* @author sean.wang
* @since Feb 6, 2012
*/
public
class
Handler
implements
PageHandler
<
Context
>
{
public
class
Handler
implements
PageHandler
<
Context
>
,
Initializable
{
@Inject
private
JspViewer
m_jspViewer
;
...
...
@@ -31,6 +41,42 @@ public class Handler implements PageHandler<Context> {
@Inject
private
GraphBuilder
m_builder
;
private
Map
<
Integer
,
Integer
>
m_map
=
new
HashMap
<
Integer
,
Integer
>();
private
MeanSquareDeviationComputer
m_computer
=
new
MeanSquareDeviationComputer
();
private
TransactionName
getName
(
Payload
payload
)
{
String
domain
=
payload
.
getDomain
();
String
type
=
payload
.
getType
();
String
name
=
payload
.
getName
();
ModelRequest
request
=
new
ModelRequest
(
domain
,
payload
.
getPeriod
())
//
.
setProperty
(
"type"
,
type
).
setProperty
(
"name"
,
name
);
ModelResponse
<
TransactionReport
>
response
=
m_service
.
invoke
(
request
);
TransactionReport
report
=
response
.
getModel
();
TransactionType
t
=
report
.
findType
(
type
);
if
(
t
!=
null
)
{
TransactionName
n
=
t
.
findName
(
name
);
if
(
n
!=
null
)
{
n
.
accept
(
m_computer
);
}
return
n
;
}
return
null
;
}
private
TransactionReport
getReport
(
Payload
payload
)
{
String
domain
=
payload
.
getDomain
();
ModelRequest
request
=
new
ModelRequest
(
domain
,
payload
.
getPeriod
());
ModelResponse
<
TransactionReport
>
response
=
m_service
.
invoke
(
request
);
TransactionReport
report
=
response
.
getModel
();
return
report
;
}
@Override
@PayloadMeta
(
Payload
.
class
)
@InboundActionMeta
(
name
=
"t"
)
...
...
@@ -52,36 +98,201 @@ public class Handler implements PageHandler<Context> {
showReport
(
model
,
payload
);
break
;
case
GRAPHS:
String
graph
=
m_builder
.
build
(
new
AbstractGraphPayload
(
"Duration Chart"
,
"Hour of day"
,
"Average time(ms)"
)
{
@Override
public
double
[]
getValues
()
{
double
[]
values
=
new
double
[
12
];
showGraphs
(
model
,
payload
);
break
;
}
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
values
[
i
]
=
Math
.
random
()
*
(
i
+
1
)
*
110
;
}
m_jspViewer
.
view
(
ctx
,
model
);
}
return
values
;
}
})
;
@Override
public
void
initialize
()
throws
InitializationException
{
int
k
=
1
;
model
.
setGraph
(
graph
);
break
;
m_map
.
put
(
0
,
0
);
for
(
int
i
=
0
;
i
<
17
;
i
++)
{
m_map
.
put
(
k
,
i
);
k
<<=
1
;
}
}
private
void
showGraphs
(
Model
model
,
Payload
payload
)
{
final
TransactionName
name
=
getName
(
payload
);
if
(
name
==
null
)
{
return
;
}
m_jspViewer
.
view
(
ctx
,
model
);
String
graph1
=
m_builder
.
build
(
new
DurationPayload
(
"Transaction Duration"
,
"Duration (ms)"
,
"Count"
,
name
));
String
graph2
=
m_builder
.
build
(
new
HitPayload
(
"Hits Over Time"
,
"Time (min)"
,
"Count"
,
name
));
String
graph3
=
m_builder
.
build
(
new
AverageTimePayload
(
"Average Duration Over Time"
,
"Time (min)"
,
"Average Duration (ms)"
,
name
));
String
graph4
=
m_builder
.
build
(
new
FailurePayload
(
"Failures Over Time"
,
"Time (min)"
,
"Count"
,
name
));
model
.
setGraph1
(
graph1
);
model
.
setGraph2
(
graph2
);
model
.
setGraph3
(
graph3
);
model
.
setGraph4
(
graph4
);
}
private
void
showReport
(
Model
model
,
Payload
payload
)
{
try
{
String
domain
=
payload
.
getDomain
();
ModelRequest
request
=
new
ModelRequest
(
domain
,
payload
.
getPeriod
());
ModelResponse
<
TransactionReport
>
response
=
m_service
.
invoke
(
request
);
TransactionReport
report
=
response
.
getModel
();
TransactionReport
report
=
getReport
(
payload
);
report
.
accept
(
m_computer
);
model
.
setReport
(
report
);
}
catch
(
Throwable
e
)
{
model
.
setException
(
e
);
}
}
abstract
class
AbstractPayload
extends
AbstractGraphPayload
{
public
AbstractPayload
(
String
title
,
String
axisXLabel
,
String
axisYLabel
)
{
super
(
title
,
axisXLabel
,
axisYLabel
);
}
@Override
public
int
getWidth
()
{
return
super
.
getWidth
()
+
120
;
}
@Override
public
int
getDisplayHeight
()
{
return
(
int
)
(
super
.
getDisplayHeight
()
*
0.7
);
}
@Override
public
int
getDisplayWidth
()
{
return
(
int
)
(
super
.
getDisplayWidth
()
*
0.7
);
}
@Override
public
String
getAxisXLabel
(
int
index
)
{
return
String
.
valueOf
(
index
*
5
);
}
}
final
class
AverageTimePayload
extends
AbstractPayload
{
private
final
TransactionName
m_name
;
public
AverageTimePayload
(
String
title
,
String
axisXLabel
,
String
axisYLabel
,
TransactionName
name
)
{
super
(
title
,
axisXLabel
,
axisYLabel
);
m_name
=
name
;
}
@Override
protected
double
[]
loadValues
()
{
double
[]
values
=
new
double
[
12
];
for
(
Range
range
:
m_name
.
getRanges
())
{
int
value
=
range
.
getValue
();
int
k
=
value
/
5
;
values
[
k
]
+=
range
.
getAvg
();
}
return
values
;
}
}
final
class
DurationPayload
extends
AbstractPayload
{
private
final
TransactionName
m_name
;
public
DurationPayload
(
String
title
,
String
axisXLabel
,
String
axisYLabel
,
TransactionName
name
)
{
super
(
title
,
axisXLabel
,
axisYLabel
);
m_name
=
name
;
}
@Override
public
String
getAxisXLabel
(
int
index
)
{
if
(
index
==
0
)
{
return
"0"
;
}
int
k
=
1
;
for
(
int
i
=
1
;
i
<
index
;
i
++)
{
k
<<=
1
;
}
return
String
.
valueOf
(
k
);
}
@Override
public
boolean
isAxisXLabelRotated
()
{
return
true
;
}
@Override
public
boolean
isAxisXLabelSkipped
()
{
return
false
;
}
@Override
protected
double
[]
loadValues
()
{
double
[]
values
=
new
double
[
17
];
for
(
Duration
duration
:
m_name
.
getDurations
())
{
int
d
=
duration
.
getValue
();
Integer
k
=
m_map
.
get
(
d
);
if
(
k
!=
null
)
{
values
[
k
]
+=
duration
.
getCount
();
}
}
return
values
;
}
}
final
class
FailurePayload
extends
AbstractPayload
{
private
final
TransactionName
m_name
;
public
FailurePayload
(
String
title
,
String
axisXLabel
,
String
axisYLabel
,
TransactionName
name
)
{
super
(
title
,
axisXLabel
,
axisYLabel
);
m_name
=
name
;
}
@Override
protected
double
[]
loadValues
()
{
double
[]
values
=
new
double
[
12
];
for
(
Range
range
:
m_name
.
getRanges
())
{
int
value
=
range
.
getValue
();
int
k
=
value
/
5
;
values
[
k
]
+=
range
.
getFails
();
}
return
values
;
}
}
final
class
HitPayload
extends
AbstractPayload
{
private
final
TransactionName
m_name
;
public
HitPayload
(
String
title
,
String
axisXLabel
,
String
axisYLabel
,
TransactionName
name
)
{
super
(
title
,
axisXLabel
,
axisYLabel
);
m_name
=
name
;
}
@Override
protected
double
[]
loadValues
()
{
double
[]
values
=
new
double
[
12
];
for
(
Range
range
:
m_name
.
getRanges
())
{
int
value
=
range
.
getValue
();
int
k
=
value
/
5
;
values
[
k
]
+=
range
.
getCount
();
}
return
values
;
}
}
}
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Model.java
浏览文件 @
d883535b
...
...
@@ -16,7 +16,13 @@ public class Model extends ViewModel<ReportPage, Action, Context> {
private
Throwable
m_exception
;
private
String
m_graph
;
private
String
m_graph1
;
private
String
m_graph2
;
private
String
m_graph3
;
private
String
m_graph4
;
public
Model
(
Context
ctx
)
{
super
(
ctx
);
...
...
@@ -49,10 +55,22 @@ public class Model extends ViewModel<ReportPage, Action, Context> {
return
m_exception
;
}
public
String
getGraph
()
{
return
m_graph
;
public
String
getGraph
1
()
{
return
m_graph
1
;
}
public
String
getGraph2
()
{
return
m_graph2
;
}
public
String
getGraph3
()
{
return
m_graph3
;
}
public
String
getGraph4
()
{
return
m_graph4
;
}
public
String
getLogViewBaseUri
()
{
return
buildPageUri
(
ReportPage
.
LOGVIEW
.
getPath
(),
null
);
}
...
...
@@ -74,10 +92,22 @@ public class Model extends ViewModel<ReportPage, Action, Context> {
m_exception
=
exception
;
}
public
void
setGraph
(
String
graph
)
{
m_graph
=
graph
;
public
void
setGraph
1
(
String
graph1
)
{
m_graph
1
=
graph1
;
}
public
void
setGraph2
(
String
graph2
)
{
m_graph2
=
graph2
;
}
public
void
setGraph3
(
String
graph3
)
{
m_graph3
=
graph3
;
}
public
void
setGraph4
(
String
graph4
)
{
m_graph4
=
graph4
;
}
public
void
setReport
(
TransactionReport
report
)
{
m_report
=
report
;
}
...
...
cat-home/src/main/webapp/css/transaction.css
浏览文件 @
d883535b
...
...
@@ -11,11 +11,6 @@
font-size
:
small
;
}
.graph
{
width
:
400px
;
height
:
100px
;
}
tr
.odd
td
{
background-color
:
#eee
;
font-size
:
small
;
...
...
@@ -47,4 +42,8 @@ tr.link td {
.error
{
color
:
red
;
}
.graphs
{
height
:
1px
;
}
\ No newline at end of file
cat-home/src/main/webapp/jsp/report/transaction.jsp
浏览文件 @
d883535b
...
...
@@ -45,7 +45,7 @@
<td><a
href=
"${model.logViewBaseUri}/${empty e.failMessageUrl ? e.successMessageUrl : e.failMessageUrl}"
>
Log View
</a></td>
<td>
${w:format(e.min,'0')}/${w:format(e.max,'0')}/${w:format(e.avg,'0.0')}/${w:format(e.std,'0.0')}
</td>
</tr>
<tr
class=
"graphs"
><td
>
</td><td
colspan=
"5
"
><div
id=
"${status.index}"
></div></td></tr>
<tr
class=
"graphs"
><td
colspan=
"6
"
><div
id=
"${status.index}"
></div></td></tr>
</c:forEach>
</c:otherwise>
</c:choose>
...
...
cat-home/src/main/webapp/jsp/report/transaction_graphs.jsp
浏览文件 @
d883535b
<%@ page
contentType=
"image/html; charset=utf-8"
%>
<%@ page
contentType=
"text/html; charset=utf-8"
%>
<jsp:useBean
id=
"ctx"
type=
"com.dianping.cat.report.page.transaction.Context"
scope=
"request"
/>
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.report.page.transaction.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.report.page.transaction.Model"
scope=
"request"
/>
${model.graph}
\ No newline at end of file
<table>
<tr>
<td>
${model.graph1}
</td>
<td>
${model.graph2}
</td>
</tr>
<tr>
<td>
${model.graph3}
</td>
<td>
${model.graph4}
</td>
</tr>
</table>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录