Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
3a7ee76c
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,发现更多精彩内容 >>
提交
3a7ee76c
编写于
4月 22, 2013
作者:
F
Frankie Wu
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #45 from youyong205/biz
Biz
上级
78edf648
0b55b4e9
变更
39
隐藏空白更改
内联
并排
Showing
39 changed file
with
902 addition
and
724 deletion
+902
-724
cat-consumer/src/main/java/com/dianping/cat/consumer/matrix/MatrixAnalyzer.java
...java/com/dianping/cat/consumer/matrix/MatrixAnalyzer.java
+2
-58
cat-consumer/src/main/java/com/dianping/cat/consumer/matrix/MatrixReportFilter.java
.../com/dianping/cat/consumer/matrix/MatrixReportFilter.java
+66
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/Handler.java
...va/com/dianping/cat/consumer/problem/handler/Handler.java
+2
-1
cat-consumer/src/test/java/com/dianping/cat/consumer/matrix/MatrixReportFilterTest.java
.../dianping/cat/consumer/matrix/MatrixReportFilterTest.java
+1
-2
cat-consumer/src/test/resources/com/dianping/cat/consumer/transaction/TransactionAnalyzerTest.json
...ing/cat/consumer/transaction/TransactionAnalyzerTest.json
+73
-73
cat-core/src/main/java/com/dianping/cat/message/io/TcpSocketReceiver.java
...n/java/com/dianping/cat/message/io/TcpSocketReceiver.java
+4
-3
cat-home/src/main/java/com/dianping/cat/report/page/dashboard/Handler.java
.../java/com/dianping/cat/report/page/dashboard/Handler.java
+0
-3
cat-home/src/main/java/com/dianping/cat/report/page/event/DisplayNames.java
...java/com/dianping/cat/report/page/event/DisplayNames.java
+36
-20
cat-home/src/main/java/com/dianping/cat/report/page/event/Handler.java
...main/java/com/dianping/cat/report/page/event/Handler.java
+36
-18
cat-home/src/main/java/com/dianping/cat/report/page/event/HistoryGraphs.java
...ava/com/dianping/cat/report/page/event/HistoryGraphs.java
+54
-54
cat-home/src/main/java/com/dianping/cat/report/page/event/MergeAllMachine.java
...a/com/dianping/cat/report/page/event/MergeAllMachine.java
+76
-0
cat-home/src/main/java/com/dianping/cat/report/page/event/MergeAllName.java
...java/com/dianping/cat/report/page/event/MergeAllName.java
+90
-0
cat-home/src/main/java/com/dianping/cat/report/page/event/Model.java
...c/main/java/com/dianping/cat/report/page/event/Model.java
+8
-8
cat-home/src/main/java/com/dianping/cat/report/page/metric/Handler.java
...ain/java/com/dianping/cat/report/page/metric/Handler.java
+19
-18
cat-home/src/main/java/com/dianping/cat/report/page/metric/MetricConfig.java
...ava/com/dianping/cat/report/page/metric/MetricConfig.java
+16
-4
cat-home/src/main/java/com/dianping/cat/report/page/metric/MetricDisplay.java
...va/com/dianping/cat/report/page/metric/MetricDisplay.java
+42
-55
cat-home/src/main/java/com/dianping/cat/report/page/metric/Model.java
.../main/java/com/dianping/cat/report/page/metric/Model.java
+10
-0
cat-home/src/main/java/com/dianping/cat/report/page/model/event/CompositeEventService.java
...ng/cat/report/page/model/event/CompositeEventService.java
+0
-11
cat-home/src/main/java/com/dianping/cat/report/page/model/event/EventReportMerger.java
...anping/cat/report/page/model/event/EventReportMerger.java
+6
-69
cat-home/src/main/java/com/dianping/cat/report/page/model/transaction/CompositeTransactionService.java
...t/page/model/transaction/CompositeTransactionService.java
+1
-11
cat-home/src/main/java/com/dianping/cat/report/page/model/transaction/TransactionReportMerger.java
...eport/page/model/transaction/TransactionReportMerger.java
+20
-85
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Handler.java
...ava/com/dianping/cat/report/page/transaction/Handler.java
+20
-3
cat-home/src/main/java/com/dianping/cat/report/page/transaction/HistoryGraphs.java
...m/dianping/cat/report/page/transaction/HistoryGraphs.java
+62
-62
cat-home/src/main/java/com/dianping/cat/report/page/transaction/MergeAllMachine.java
...dianping/cat/report/page/transaction/MergeAllMachine.java
+88
-0
cat-home/src/main/java/com/dianping/cat/report/page/transaction/MergeAllName.java
...om/dianping/cat/report/page/transaction/MergeAllName.java
+107
-0
cat-home/src/main/java/com/dianping/cat/report/task/event/HistoryEventReportMerger.java
...nping/cat/report/task/event/HistoryEventReportMerger.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/task/health/HealthReportBuilder.java
.../dianping/cat/report/task/health/HealthReportBuilder.java
+8
-2
cat-home/src/main/java/com/dianping/cat/report/task/matrix/MatrixMerger.java
...ava/com/dianping/cat/report/task/matrix/MatrixMerger.java
+6
-2
cat-home/src/main/java/com/dianping/cat/report/task/transaction/HistoryTransactionReportMerger.java
...port/task/transaction/HistoryTransactionReportMerger.java
+1
-1
cat-home/src/main/java/com/dianping/cat/system/alarm/threshold/ThresholdRuleManager.java
...ping/cat/system/alarm/threshold/ThresholdRuleManager.java
+1
-1
cat-home/src/main/webapp/jsp/report/crossHistoryProject.jsp
cat-home/src/main/webapp/jsp/report/crossHistoryProject.jsp
+2
-2
cat-home/src/main/webapp/jsp/report/event.jsp
cat-home/src/main/webapp/jsp/report/event.jsp
+24
-26
cat-home/src/main/webapp/jsp/report/eventHistoryReport.jsp
cat-home/src/main/webapp/jsp/report/eventHistoryReport.jsp
+2
-2
cat-home/src/main/webapp/jsp/report/metric.jsp
cat-home/src/main/webapp/jsp/report/metric.jsp
+10
-16
cat-home/src/main/webapp/jsp/report/transaction.jsp
cat-home/src/main/webapp/jsp/report/transaction.jsp
+2
-2
cat-home/src/main/webapp/jsp/report/transactionHistoryReport.jsp
...e/src/main/webapp/jsp/report/transactionHistoryReport.jsp
+2
-2
cat-home/src/test/java/com/dianping/cat/demo/TestBusinessMessage.java
.../test/java/com/dianping/cat/demo/TestBusinessMessage.java
+4
-4
cat-home/src/test/java/com/dianping/cat/report/page/event/EventReportMergerTest.java
...dianping/cat/report/page/event/EventReportMergerTest.java
+0
-55
cat-home/src/test/java/com/dianping/cat/report/page/transaction/TransactionReportMergerTest.java
.../report/page/transaction/TransactionReportMergerTest.java
+0
-50
未找到文件。
cat-consumer/src/main/java/com/dianping/cat/consumer/matrix/MatrixAnalyzer.java
浏览文件 @
3a7ee76c
package
com.dianping.cat.consumer.matrix
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -11,6 +9,7 @@ import java.util.Set;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dainping.cat.consumer.dal.report.Report
;
import
com.dainping.cat.consumer.dal.report.ReportDao
;
...
...
@@ -27,7 +26,6 @@ import com.dianping.cat.message.spi.AbstractMessageAnalyzer;
import
com.dianping.cat.message.spi.MessageTree
;
import
com.dianping.cat.storage.Bucket
;
import
com.dianping.cat.storage.BucketManager
;
import
org.unidal.lookup.annotation.Inject
;
public
class
MatrixAnalyzer
extends
AbstractMessageAnalyzer
<
MatrixReport
>
implements
LogEnabled
{
@Inject
...
...
@@ -262,59 +260,5 @@ public class MatrixAnalyzer extends AbstractMessageAnalyzer<MatrixReport> implem
}
}
public
static
class
MatrixReportFilter
extends
com
.
dianping
.
cat
.
consumer
.
matrix
.
model
.
transform
.
DefaultXmlBuilder
{
private
String
m_domain
;
private
int
m_maxItems
;
public
MatrixReportFilter
(
int
maxItems
)
{
m_maxItems
=
maxItems
;
}
@Override
public
void
visitMatrixReport
(
MatrixReport
matrixReport
)
{
m_domain
=
matrixReport
.
getDomain
();
Map
<
String
,
Matrix
>
matrixs
=
matrixReport
.
getMatrixs
();
long
total
=
0
;
for
(
Matrix
matrix
:
matrixs
.
values
())
{
total
=
total
+
matrix
.
getCount
();
}
int
value
=
(
int
)
(
total
/
10000
);
String
urlSample
=
null
;
value
=
Math
.
min
(
value
,
5
);
if
(!
m_domain
.
equals
(
"Cat"
)
&&
(
value
>
0
))
{
int
totalCount
=
0
;
Collection
<
Matrix
>
matrix
=
matrixs
.
values
();
List
<
String
>
removeUrls
=
new
ArrayList
<
String
>();
if
(
matrix
.
size
()
>
m_maxItems
)
{
for
(
Matrix
temp
:
matrix
)
{
if
(
temp
.
getType
().
equals
(
"URL"
)
&&
temp
.
getCount
()
<
5
)
{
removeUrls
.
add
(
temp
.
getName
());
totalCount
+=
temp
.
getCount
();
if
(
urlSample
==
null
)
{
urlSample
=
temp
.
getUrl
();
}
}
}
for
(
String
url
:
removeUrls
)
{
matrixs
.
remove
(
url
);
}
if
(
totalCount
>
0
)
{
Matrix
other
=
new
Matrix
(
"OTHERS"
);
other
.
setUrl
(
urlSample
);
other
.
setType
(
"OTHERS"
);
other
.
setCount
(
totalCount
);
matrixs
.
put
(
"OTHERS"
,
other
);
}
}
}
super
.
visitMatrixReport
(
matrixReport
);
}
}
}
cat-consumer/src/main/java/com/dianping/cat/consumer/matrix/MatrixReportFilter.java
0 → 100644
浏览文件 @
3a7ee76c
package
com.dianping.cat.consumer.matrix
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Map
;
import
com.dianping.cat.consumer.matrix.model.entity.Matrix
;
import
com.dianping.cat.consumer.matrix.model.entity.MatrixReport
;
public
class
MatrixReportFilter
extends
com
.
dianping
.
cat
.
consumer
.
matrix
.
model
.
transform
.
DefaultXmlBuilder
{
private
String
m_domain
;
private
int
m_maxItems
;
private
static
final
String
OTHERS
=
"OTHERS"
;
public
MatrixReportFilter
(
int
maxItems
)
{
m_maxItems
=
maxItems
;
}
@Override
public
void
visitMatrixReport
(
MatrixReport
matrixReport
)
{
m_domain
=
matrixReport
.
getDomain
();
Map
<
String
,
Matrix
>
matrixs
=
matrixReport
.
getMatrixs
();
long
total
=
0
;
for
(
Matrix
matrix
:
matrixs
.
values
())
{
total
=
total
+
matrix
.
getCount
();
}
int
value
=
(
int
)
(
total
/
10000
);
String
urlSample
=
null
;
value
=
Math
.
min
(
value
,
5
);
if
(!
m_domain
.
equals
(
"Cat"
)
&&
(
value
>
0
))
{
int
totalCount
=
0
;
Collection
<
Matrix
>
matrix
=
matrixs
.
values
();
List
<
String
>
removeUrls
=
new
ArrayList
<
String
>();
if
(
matrix
.
size
()
>
m_maxItems
)
{
for
(
Matrix
temp
:
matrix
)
{
if
(
temp
.
getType
().
equals
(
"URL"
)
&&
temp
.
getCount
()
<
5
)
{
removeUrls
.
add
(
temp
.
getName
());
totalCount
+=
temp
.
getCount
();
if
(
urlSample
==
null
)
{
urlSample
=
temp
.
getUrl
();
}
}
}
for
(
String
url
:
removeUrls
)
{
matrixs
.
remove
(
url
);
}
if
(
totalCount
>
0
)
{
Matrix
other
=
matrixReport
.
findOrCreateMatrix
(
OTHERS
);
other
.
setUrl
(
urlSample
);
other
.
setType
(
OTHERS
);
other
.
setCount
(
totalCount
+
other
.
getCount
());
}
}
}
super
.
visitMatrixReport
(
matrixReport
);
}
}
\ No newline at end of file
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/Handler.java
浏览文件 @
3a7ee76c
...
...
@@ -42,7 +42,8 @@ public abstract class Handler {
messages
.
add
(
tree
.
getMessageId
());
}
JavaThread
thread
=
entry
.
findOrCreateThread
(
tree
.
getThreadId
());
//make problem thread id = thread group name, make report small
JavaThread
thread
=
entry
.
findOrCreateThread
(
tree
.
getThreadGroupName
());
if
(
thread
.
getGroupName
()
==
null
)
{
thread
.
setGroupName
(
tree
.
getThreadGroupName
());
...
...
cat-consumer/src/test/java/com/dianping/cat/consumer/matrix/MatrixReportFilterTest.java
浏览文件 @
3a7ee76c
...
...
@@ -3,11 +3,10 @@ package com.dianping.cat.consumer.matrix;
import
junit.framework.Assert
;
import
org.junit.Test
;
import
org.unidal.helper.Files
;
import
com.dianping.cat.consumer.matrix.MatrixAnalyzer.MatrixReportFilter
;
import
com.dianping.cat.consumer.matrix.model.entity.MatrixReport
;
import
com.dianping.cat.consumer.matrix.model.transform.DefaultDomParser
;
import
org.unidal.helper.Files
;
public
class
MatrixReportFilterTest
{
...
...
cat-consumer/src/test/resources/com/dianping/cat/consumer/transaction/TransactionAnalyzerTest.json
浏览文件 @
3a7ee76c
...
...
@@ -38,57 +38,57 @@
"line95Value"
:
"0.00"
,
"line95Sum"
:
"0.00"
,
"line95Count"
:
0
,
"ranges"
:
[
{
"ranges"
:
{
"0"
:
{
"value"
:
0
,
"count"
:
500
,
"sum"
:
500000.0
,
"avg"
:
"1000.0"
,
"fails"
:
0
}
]
,
"durations"
:
[
{
}
,
"durations"
:
{
"2"
:
{
"value"
:
2
,
"count"
:
1
},
{
"8"
:
{
"value"
:
8
,
"count"
:
1
},
{
"16"
:
{
"value"
:
16
,
"count"
:
2
},
{
"32"
:
{
"value"
:
32
,
"count"
:
4
},
{
"64"
:
{
"value"
:
64
,
"count"
:
8
},
{
"128"
:
{
"value"
:
128
,
"count"
:
16
},
{
"256"
:
{
"value"
:
256
,
"count"
:
32
},
{
"512"
:
{
"value"
:
512
,
"count"
:
64
},
{
"1024"
:
{
"value"
:
1024
,
"count"
:
128
},
{
"2048"
:
{
"value"
:
2048
,
"count"
:
244
}
]
}
},
"n0"
:
{
"id"
:
"n0"
,
...
...
@@ -106,57 +106,57 @@
"line95Value"
:
"0.00"
,
"line95Sum"
:
"0.00"
,
"line95Count"
:
0
,
"ranges"
:
[
{
"ranges"
:
{
"0"
:
{
"value"
:
0
,
"count"
:
500
,
"sum"
:
501000.0
,
"avg"
:
"1002.0"
,
"fails"
:
500
}
]
,
"durations"
:
[
{
}
,
"durations"
:
{
"4"
:
{
"value"
:
4
,
"count"
:
1
},
{
"8"
:
{
"value"
:
8
,
"count"
:
1
},
{
"16"
:
{
"value"
:
16
,
"count"
:
2
},
{
"32"
:
{
"value"
:
32
,
"count"
:
4
},
{
"64"
:
{
"value"
:
64
,
"count"
:
8
},
{
"128"
:
{
"value"
:
128
,
"count"
:
16
},
{
"256"
:
{
"value"
:
256
,
"count"
:
32
},
{
"512"
:
{
"value"
:
512
,
"count"
:
64
},
{
"1024"
:
{
"value"
:
1024
,
"count"
:
128
},
{
"2048"
:
{
"value"
:
2048
,
"count"
:
244
}
]
}
}
}
},
...
...
@@ -195,57 +195,57 @@
"line95Value"
:
"0.00"
,
"line95Sum"
:
"0.00"
,
"line95Count"
:
0
,
"ranges"
:
[
{
"ranges"
:
{
"0"
:
{
"value"
:
0
,
"count"
:
334
,
"sum"
:
167167.0
,
"avg"
:
"500.5"
,
"fails"
:
167
}
]
,
"durations"
:
[
{
}
,
"durations"
:
{
"1"
:
{
"value"
:
1
,
"count"
:
1
},
{
"4"
:
{
"value"
:
4
,
"count"
:
1
},
{
"8"
:
{
"value"
:
8
,
"count"
:
1
},
{
"16"
:
{
"value"
:
16
,
"count"
:
3
},
{
"32"
:
{
"value"
:
32
,
"count"
:
5
},
{
"64"
:
{
"value"
:
64
,
"count"
:
11
},
{
"128"
:
{
"value"
:
128
,
"count"
:
21
},
{
"256"
:
{
"value"
:
256
,
"count"
:
43
},
{
"512"
:
{
"value"
:
512
,
"count"
:
85
},
{
"1024"
:
{
"value"
:
1024
,
"count"
:
163
}
]
}
},
"n2"
:
{
"id"
:
"n2"
,
...
...
@@ -264,53 +264,53 @@
"line95Value"
:
"0.00"
,
"line95Sum"
:
"0.00"
,
"line95Count"
:
0
,
"ranges"
:
[
{
"ranges"
:
{
"0"
:
{
"value"
:
0
,
"count"
:
333
,
"sum"
:
166500.0
,
"avg"
:
"500.0"
,
"fails"
:
167
}
]
,
"durations"
:
[
{
}
,
"durations"
:
{
"2"
:
{
"value"
:
2
,
"count"
:
1
},
{
"8"
:
{
"value"
:
8
,
"count"
:
2
},
{
"16"
:
{
"value"
:
16
,
"count"
:
2
},
{
"32"
:
{
"value"
:
32
,
"count"
:
6
},
{
"64"
:
{
"value"
:
64
,
"count"
:
10
},
{
"128"
:
{
"value"
:
128
,
"count"
:
22
},
{
"256"
:
{
"value"
:
256
,
"count"
:
42
},
{
"512"
:
{
"value"
:
512
,
"count"
:
86
},
{
"1024"
:
{
"value"
:
1024
,
"count"
:
162
}
]
}
},
"n0"
:
{
"id"
:
"n0"
,
...
...
@@ -329,53 +329,53 @@
"line95Value"
:
"0.00"
,
"line95Sum"
:
"0.00"
,
"line95Count"
:
0
,
"ranges"
:
[
{
"ranges"
:
{
"0"
:
{
"value"
:
0
,
"count"
:
333
,
"sum"
:
166833.0
,
"avg"
:
"501.0"
,
"fails"
:
166
}
]
,
"durations"
:
[
{
}
,
"durations"
:
{
"4"
:
{
"value"
:
4
,
"count"
:
1
},
{
"8"
:
{
"value"
:
8
,
"count"
:
1
},
{
"16"
:
{
"value"
:
16
,
"count"
:
3
},
{
"32"
:
{
"value"
:
32
,
"count"
:
5
},
{
"64"
:
{
"value"
:
64
,
"count"
:
11
},
{
"128"
:
{
"value"
:
128
,
"count"
:
21
},
{
"256"
:
{
"value"
:
256
,
"count"
:
43
},
{
"512"
:
{
"value"
:
512
,
"count"
:
85
},
{
"1024"
:
{
"value"
:
1024
,
"count"
:
163
}
]
}
}
}
}
...
...
cat-core/src/main/java/com/dianping/cat/message/io/TcpSocketReceiver.java
浏览文件 @
3a7ee76c
...
...
@@ -66,9 +66,9 @@ public class TcpSocketReceiver implements LogEnabled {
private
int
m_queueSize
=
500000
;
private
int
m_errorCount
;
private
volatile
int
m_errorCount
;
private
long
m_processCount
;
private
volatile
long
m_processCount
;
@Inject
private
ServerConfigManager
m_serverConfigManager
;
...
...
@@ -267,7 +267,8 @@ public class TcpSocketReceiver implements LogEnabled {
m_serverStateManager
.
addMessageTotalLoss
(
CatConstants
.
ERROR_COUNT
);
if
(
m_errorCount
%
(
CatConstants
.
ERROR_COUNT
*
100
)
==
0
)
{
m_logger
.
warn
(
"The server can't process the tree! overflow : "
+
m_errorCount
);
m_logger
.
warn
(
"The server can't process the tree! overflow : "
+
m_errorCount
+
",current queue size:"
+
m_queue
.
size
());
}
}
}
else
{
...
...
cat-home/src/main/java/com/dianping/cat/report/page/dashboard/Handler.java
浏览文件 @
3a7ee76c
...
...
@@ -191,9 +191,6 @@ public class Handler implements PageHandler<Context> {
TransactionReport
transactionReport
=
getTransactionHourlyReport
(
domain
,
ip
,
null
);
if
(
transactionReport
==
null
){
return
data
;
}
Machine
transactionMachine
=
transactionReport
.
getMachines
().
get
(
ip
);
if
(
transactionMachine
!=
null
)
{
Collection
<
TransactionType
>
types
=
transactionMachine
.
getTypes
().
values
();
...
...
cat-home/src/main/java/com/dianping/cat/report/page/event/DisplayNames.java
浏览文件 @
3a7ee76c
...
...
@@ -7,40 +7,39 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
org.unidal.lookup.util.StringUtils
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.consumer.event.model.entity.EventName
;
import
com.dianping.cat.consumer.event.model.entity.EventReport
;
import
com.dianping.cat.consumer.event.model.entity.EventType
;
import
com.dianping.cat.consumer.event.model.entity.Machine
;
public
class
DisplayNames
{
private
List
<
EventNameModel
>
m_results
=
new
ArrayList
<
EventNameModel
>();
public
DisplayNames
display
(
String
sorted
,
String
type
,
String
ip
,
EventReport
report
)
{
try
{
Machine
machine
=
report
.
getMachines
().
get
(
ip
);
if
(
machine
==
null
)
{
return
this
;
}
Map
<
String
,
EventType
>
types
=
machine
.
getTypes
();
if
(
types
!=
null
)
{
EventType
names
=
types
.
get
(
type
);
if
(
names
==
null
)
{
return
this
;
}
Map
<
String
,
EventType
>
types
=
report
.
getMachines
().
get
(
ip
).
getTypes
();
EventName
all
=
new
EventName
(
"TOTAL"
);
all
.
setTotalPercent
(
1
);
if
(
types
!=
null
)
{
EventType
names
=
types
.
get
(
type
);
if
(
names
!=
null
)
{
for
(
Entry
<
String
,
EventName
>
entry
:
names
.
getNames
().
entrySet
())
{
m_results
.
add
(
new
EventNameModel
(
entry
.
getKey
(),
entry
.
getValue
()));
mergeName
(
all
,
entry
.
getValue
());
}
}
if
(!
StringUtils
.
isEmpty
(
sorted
))
{
Collections
.
sort
(
m_results
,
new
EventComparator
(
sorted
));
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
if
(
sorted
==
null
)
{
sorted
=
"avg"
;
}
Collections
.
sort
(
m_results
,
new
EventComparator
(
sorted
));
long
total
=
all
.
getTotalCount
();
for
(
EventNameModel
nameModel
:
m_results
)
{
EventName
eventName
=
nameModel
.
getDetail
();
eventName
.
setTotalPercent
(
eventName
.
getTotalCount
()
/
(
double
)
total
);
}
m_results
.
add
(
0
,
new
EventNameModel
(
"TOTAL"
,
all
));
return
this
;
}
...
...
@@ -48,6 +47,23 @@ public class DisplayNames {
return
m_results
;
}
public
void
mergeName
(
EventName
old
,
EventName
other
)
{
old
.
setTotalCount
(
old
.
getTotalCount
()
+
other
.
getTotalCount
());
old
.
setFailCount
(
old
.
getFailCount
()
+
other
.
getFailCount
());
if
(
old
.
getTotalCount
()
>
0
)
{
old
.
setFailPercent
(
old
.
getFailCount
()
*
100.0
/
old
.
getTotalCount
());
}
if
(
old
.
getSuccessMessageUrl
()
==
null
)
{
old
.
setSuccessMessageUrl
(
other
.
getSuccessMessageUrl
());
}
if
(
old
.
getFailMessageUrl
()
==
null
)
{
old
.
setFailMessageUrl
(
other
.
getFailMessageUrl
());
}
}
public
static
class
EventComparator
implements
Comparator
<
EventNameModel
>
{
private
String
m_sorted
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/event/Handler.java
浏览文件 @
3a7ee76c
...
...
@@ -57,6 +57,21 @@ public class Handler implements PageHandler<Context> {
private
StatisticsComputer
m_computer
=
new
StatisticsComputer
();
private
void
buildEventNameGraph
(
String
ip
,
String
type
,
EventReport
report
,
Model
model
)
{
PieChart
chart
=
new
PieChart
();
Collection
<
EventName
>
values
=
report
.
findOrCreateMachine
(
ip
).
findOrCreateType
(
type
).
getNames
().
values
();
List
<
Item
>
items
=
new
ArrayList
<
Item
>();
for
(
EventName
name
:
values
)
{
Item
item
=
new
Item
();
item
.
setNumber
(
name
.
getTotalCount
()).
setTitle
(
name
.
getId
());
items
.
add
(
item
);
}
chart
.
setItems
(
items
);
Gson
gson
=
new
Gson
();
model
.
setPieChart
(
gson
.
toJson
(
chart
));
}
private
void
calculateTps
(
Payload
payload
,
EventReport
report
)
{
if
(
payload
!=
null
&&
report
!=
null
)
{
boolean
isCurrent
=
payload
.
getPeriod
().
isCurrent
();
...
...
@@ -108,10 +123,23 @@ public class Handler implements PageHandler<Context> {
if
(
name
==
null
||
name
.
length
()
==
0
)
{
request
.
setProperty
(
"name"
,
"*"
);
request
.
setProperty
(
"all"
,
"true"
);
name
=
"ALL"
;
name
=
CatString
.
ALL_NAME
;
}
ModelResponse
<
EventReport
>
response
=
m_service
.
invoke
(
request
);
EventReport
report
=
response
.
getModel
();
if
(
CatString
.
ALL_IP
.
equalsIgnoreCase
(
ipAddress
))
{
MergeAllMachine
all
=
new
MergeAllMachine
();
all
.
visitEventReport
(
report
);
report
=
all
.
getReport
();
}
if
(
CatString
.
ALL_NAME
.
equalsIgnoreCase
(
name
))
{
MergeAllName
all
=
new
MergeAllName
();
all
.
visitEventReport
(
report
);
report
=
all
.
getReport
();
}
EventType
t
=
report
.
getMachines
().
get
(
ip
).
findType
(
type
);
if
(
t
!=
null
)
{
...
...
@@ -137,7 +165,6 @@ public class Handler implements PageHandler<Context> {
if
(
m_service
.
isEligable
(
request
))
{
ModelResponse
<
EventReport
>
response
=
m_service
.
invoke
(
request
);
EventReport
report
=
response
.
getModel
();
calculateTps
(
payload
,
report
);
if
(
payload
.
getPeriod
().
isLast
())
{
Set
<
String
>
domains
=
m_reportService
.
queryAllDomainNames
(
new
Date
(
payload
.
getDate
()),
...
...
@@ -146,7 +173,13 @@ public class Handler implements PageHandler<Context> {
domainNames
.
addAll
(
domains
);
}
if
(
CatString
.
ALL_IP
.
equalsIgnoreCase
(
ipAddress
))
{
MergeAllMachine
all
=
new
MergeAllMachine
();
all
.
visitEventReport
(
report
);
report
=
all
.
getReport
();
}
calculateTps
(
payload
,
report
);
return
report
;
}
else
{
throw
new
RuntimeException
(
"Internal error: no eligable event service registered for "
+
request
+
"!"
);
...
...
@@ -288,21 +321,6 @@ public class Handler implements PageHandler<Context> {
}
}
private
void
buildEventNameGraph
(
String
ip
,
String
type
,
EventReport
report
,
Model
model
)
{
PieChart
chart
=
new
PieChart
();
Collection
<
EventName
>
values
=
report
.
findOrCreateMachine
(
ip
).
findOrCreateType
(
type
).
getNames
().
values
();
List
<
Item
>
items
=
new
ArrayList
<
Item
>();
for
(
EventName
name
:
values
)
{
Item
item
=
new
Item
();
item
.
setNumber
(
name
.
getTotalCount
()).
setTitle
(
name
.
getId
());
items
.
add
(
item
);
}
chart
.
setItems
(
items
);
Gson
gson
=
new
Gson
();
model
.
setPieChart
(
gson
.
toJson
(
chart
));
}
private
MobileGraphs
showMobileGraphs
(
Model
model
,
Payload
payload
)
{
EventName
name
=
getEventName
(
payload
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/event/HistoryGraphs.java
浏览文件 @
3a7ee76c
...
...
@@ -43,36 +43,50 @@ public class HistoryGraphs {
}
}
public
Map
<
String
,
double
[]>
buildGraphDatasForHour
(
Date
start
,
Date
end
,
String
type
,
String
name
,
List
<
Graph
>
graphs
)
{
private
HistoryGraphItem
buildFail
(
List
<
Map
<
String
,
double
[]>>
datas
,
Date
start
,
int
size
,
long
step
,
String
name
)
{
HistoryGraphItem
item
=
new
HistoryGraphItem
();
item
.
setStart
(
start
);
item
.
setSize
(
size
);
item
.
setStep
(
step
);
item
.
setTitles
(
name
+
" Error (count)"
);
for
(
Map
<
String
,
double
[]>
data
:
datas
)
{
item
.
addValue
(
data
.
get
(
"failure_count"
));
}
return
item
;
}
public
Map
<
String
,
double
[]>
buildGraphDatasForDaily
(
Date
start
,
Date
end
,
String
type
,
String
name
,
List
<
Dailygraph
>
graphs
)
{
Map
<
String
,
double
[]>
result
=
new
HashMap
<
String
,
double
[]>();
int
size
=
(
int
)
((
end
.
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_
HOUR
*
12
);
int
size
=
(
int
)
((
end
.
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_
DAY
);
double
[]
total_count
=
new
double
[
size
];
double
[]
failure_count
=
new
double
[
size
];
if
(!
StringUtils
.
isEmpty
(
type
)
&&
StringUtils
.
isEmpty
(
name
))
{
for
(
G
raph
graph
:
graphs
)
{
int
indexOfperiod
=
(
int
)
((
graph
.
getPeriod
().
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_
HOUR
*
12
);
for
(
Dailyg
raph
graph
:
graphs
)
{
int
indexOfperiod
=
(
int
)
((
graph
.
getPeriod
().
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_
DAY
);
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
))
{
appendArray
(
total_count
,
indexOfperiod
,
records
[
SummaryOrder
.
TOTAL_COUNT
.
ordinal
()],
12
);
appendArray
(
failure_count
,
indexOfperiod
,
records
[
SummaryOrder
.
FAILURE_COUNT
.
ordinal
()],
12
);
total_count
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
SummaryOrder
.
TOTAL_COUNT
.
ordinal
()]
);
failure_count
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
SummaryOrder
.
FAILURE_COUNT
.
ordinal
()]
);
}
}
}
}
else
if
(!
StringUtils
.
isEmpty
(
type
)
&&
!
StringUtils
.
isEmpty
(
name
))
{
for
(
G
raph
graph
:
graphs
)
{
int
indexOfperiod
=
(
int
)
((
graph
.
getPeriod
().
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_
HOUR
*
12
);
for
(
Dailyg
raph
graph
:
graphs
)
{
int
indexOfperiod
=
(
int
)
((
graph
.
getPeriod
().
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_
DAY
);
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
))
{
appendArray
(
total_count
,
indexOfperiod
,
records
[
DetailOrder
.
TOTAL_COUNT
.
ordinal
()],
12
);
appendArray
(
failure_count
,
indexOfperiod
,
records
[
DetailOrder
.
FAILURE_COUNT
.
ordinal
()],
12
);
total_count
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
DetailOrder
.
TOTAL_COUNT
.
ordinal
()]);
failure_count
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
DetailOrder
.
FAILURE_COUNT
.
ordinal
()]);
}
}
}
...
...
@@ -82,37 +96,37 @@ public class HistoryGraphs {
result
.
put
(
"failure_count"
,
failure_count
);
return
result
;
}
public
Map
<
String
,
double
[]>
buildGraphDatasForDaily
(
Date
start
,
Date
end
,
String
type
,
String
name
,
List
<
Dailygraph
>
graphs
)
{
public
Map
<
String
,
double
[]>
buildGraphDatasForHour
(
Date
start
,
Date
end
,
String
type
,
String
name
,
List
<
Graph
>
graphs
)
{
Map
<
String
,
double
[]>
result
=
new
HashMap
<
String
,
double
[]>();
int
size
=
(
int
)
((
end
.
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_
DAY
);
int
size
=
(
int
)
((
end
.
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_
HOUR
*
12
);
double
[]
total_count
=
new
double
[
size
];
double
[]
failure_count
=
new
double
[
size
];
if
(!
StringUtils
.
isEmpty
(
type
)
&&
StringUtils
.
isEmpty
(
name
))
{
for
(
Dailyg
raph
graph
:
graphs
)
{
int
indexOfperiod
=
(
int
)
((
graph
.
getPeriod
().
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_
DAY
);
for
(
G
raph
graph
:
graphs
)
{
int
indexOfperiod
=
(
int
)
((
graph
.
getPeriod
().
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_
HOUR
*
12
);
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
()]
);
appendArray
(
total_count
,
indexOfperiod
,
records
[
SummaryOrder
.
TOTAL_COUNT
.
ordinal
()],
12
);
appendArray
(
failure_count
,
indexOfperiod
,
records
[
SummaryOrder
.
FAILURE_COUNT
.
ordinal
()],
12
);
}
}
}
}
else
if
(!
StringUtils
.
isEmpty
(
type
)
&&
!
StringUtils
.
isEmpty
(
name
))
{
for
(
Dailyg
raph
graph
:
graphs
)
{
int
indexOfperiod
=
(
int
)
((
graph
.
getPeriod
().
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_
DAY
);
for
(
G
raph
graph
:
graphs
)
{
int
indexOfperiod
=
(
int
)
((
graph
.
getPeriod
().
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_
HOUR
*
12
);
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
()]);
appendArray
(
total_count
,
indexOfperiod
,
records
[
DetailOrder
.
TOTAL_COUNT
.
ordinal
()],
12
);
appendArray
(
failure_count
,
indexOfperiod
,
records
[
DetailOrder
.
FAILURE_COUNT
.
ordinal
()],
12
);
}
}
}
...
...
@@ -138,20 +152,6 @@ public class HistoryGraphs {
return
item
;
}
private
HistoryGraphItem
buildFail
(
List
<
Map
<
String
,
double
[]>>
datas
,
Date
start
,
int
size
,
long
step
,
String
name
)
{
HistoryGraphItem
item
=
new
HistoryGraphItem
();
item
.
setStart
(
start
);
item
.
setSize
(
size
);
item
.
setStep
(
step
);
item
.
setTitles
(
name
+
" Error (count)"
);
for
(
Map
<
String
,
double
[]>
data
:
datas
)
{
item
.
addValue
(
data
.
get
(
"failure_count"
));
}
return
item
;
}
public
void
buildTrendGraph
(
Model
model
,
Payload
payload
)
{
Date
start
=
payload
.
getHistoryStartDate
();
Date
end
=
payload
.
getHistoryEndDate
();
...
...
@@ -197,47 +197,47 @@ public class HistoryGraphs {
model
.
setFailureTrend
(
item
.
getJsonString
());
}
p
rivate
Map
<
String
,
double
[]>
getGraphDatasFromDaily
(
Date
start
,
Date
end
,
Model
model
,
Payload
payload
)
{
p
ublic
Map
<
String
,
double
[]>
getGraphDatasForHour
(
Date
start
,
Date
end
,
Model
model
,
Payload
payload
)
{
String
domain
=
model
.
getDomain
();
String
type
=
payload
.
getType
();
String
name
=
payload
.
getName
();
String
ip
=
model
.
getIpAddress
();
String
queryIp
=
"All"
.
equalsIgnoreCase
(
ip
)
==
true
?
"All"
:
ip
;
List
<
Dailygraph
>
graphs
=
new
ArrayList
<
Dailygraph
>();
for
(
long
startLong
=
start
.
getTime
();
startLong
<
end
.
getTime
();
startLong
=
startLong
+
TimeUtil
.
ONE_DAY
)
{
String
queryIP
=
"All"
.
equals
(
ip
)
==
true
?
"all"
:
ip
;
List
<
Graph
>
events
=
new
ArrayList
<
Graph
>();
for
(
long
startLong
=
start
.
getTime
();
startLong
<
end
.
getTime
();
startLong
=
startLong
+
TimeUtil
.
ONE_HOUR
)
{
try
{
Dailygraph
graph
=
m_dailyGraphDao
.
findSingalByDomainNameIpDuration
(
new
Date
(
startLong
),
queryIp
,
domain
,
"event"
,
Dailyg
raphEntity
.
READSET_FULL
);
graph
s
.
add
(
graph
);
Graph
graph
=
m_graphDao
.
findSingalByDomainNameIpDuration
(
new
Date
(
startLong
),
queryIP
,
domain
,
"event"
,
G
raphEntity
.
READSET_FULL
);
event
s
.
add
(
graph
);
}
catch
(
DalNotFoundException
e
)
{
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
Map
<
String
,
double
[]>
result
=
buildGraphDatasFor
Daily
(
start
,
end
,
type
,
name
,
graph
s
);
Map
<
String
,
double
[]>
result
=
buildGraphDatasFor
Hour
(
start
,
end
,
type
,
name
,
event
s
);
return
result
;
}
p
ublic
Map
<
String
,
double
[]>
getGraphDatasForHour
(
Date
start
,
Date
end
,
Model
model
,
Payload
payload
)
{
p
rivate
Map
<
String
,
double
[]>
getGraphDatasFromDaily
(
Date
start
,
Date
end
,
Model
model
,
Payload
payload
)
{
String
domain
=
model
.
getDomain
();
String
type
=
payload
.
getType
();
String
name
=
payload
.
getName
();
String
ip
=
model
.
getIpAddress
();
String
queryIP
=
"All"
.
equals
(
ip
)
==
true
?
"all"
:
ip
;
List
<
Graph
>
events
=
new
ArrayList
<
Graph
>();
for
(
long
startLong
=
start
.
getTime
();
startLong
<
end
.
getTime
();
startLong
=
startLong
+
TimeUtil
.
ONE_HOUR
)
{
String
queryIp
=
"All"
.
equalsIgnoreCase
(
ip
)
==
true
?
"All"
:
ip
;
List
<
Dailygraph
>
graphs
=
new
ArrayList
<
Dailygraph
>();
for
(
long
startLong
=
start
.
getTime
();
startLong
<
end
.
getTime
();
startLong
=
startLong
+
TimeUtil
.
ONE_DAY
)
{
try
{
Graph
graph
=
m_graphDao
.
findSingalByDomainNameIpDuration
(
new
Date
(
startLong
),
queryIP
,
domain
,
"event"
,
G
raphEntity
.
READSET_FULL
);
event
s
.
add
(
graph
);
Dailygraph
graph
=
m_dailyGraphDao
.
findSingalByDomainNameIpDuration
(
new
Date
(
startLong
),
queryIp
,
domain
,
"event"
,
Dailyg
raphEntity
.
READSET_FULL
);
graph
s
.
add
(
graph
);
}
catch
(
DalNotFoundException
e
)
{
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
Map
<
String
,
double
[]>
result
=
buildGraphDatasFor
Hour
(
start
,
end
,
type
,
name
,
event
s
);
Map
<
String
,
double
[]>
result
=
buildGraphDatasFor
Daily
(
start
,
end
,
type
,
name
,
graph
s
);
return
result
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/event/MergeAllMachine.java
0 → 100644
浏览文件 @
3a7ee76c
package
com.dianping.cat.report.page.event
;
import
com.dianping.cat.consumer.event.model.entity.EventName
;
import
com.dianping.cat.consumer.event.model.entity.EventReport
;
import
com.dianping.cat.consumer.event.model.entity.EventType
;
import
com.dianping.cat.consumer.event.model.entity.Machine
;
import
com.dianping.cat.consumer.event.model.entity.Range
;
import
com.dianping.cat.consumer.event.model.transform.BaseVisitor
;
import
com.dianping.cat.helper.CatString
;
import
com.dianping.cat.report.page.model.event.EventReportMerger
;
public
class
MergeAllMachine
extends
BaseVisitor
{
public
EventReport
m_report
;
public
String
m_currentType
;
public
String
m_currentName
;
public
Integer
m_currentRange
;
public
Integer
m_currentDuration
;
public
EventReportMerger
m_merger
=
new
EventReportMerger
(
new
EventReport
());
public
EventReport
getReport
()
{
return
m_report
;
}
@Override
public
void
visitEventReport
(
EventReport
eventReport
)
{
m_report
=
new
EventReport
(
eventReport
.
getDomain
());
m_report
.
setStartTime
(
eventReport
.
getStartTime
());
m_report
.
setEndTime
(
eventReport
.
getEndTime
());
m_report
.
getDomainNames
().
addAll
(
eventReport
.
getDomainNames
());
m_report
.
getIps
().
addAll
(
eventReport
.
getIps
());
super
.
visitEventReport
(
eventReport
);
}
@Override
public
void
visitMachine
(
Machine
machine
)
{
m_report
.
findOrCreateMachine
(
CatString
.
ALL_IP
);
super
.
visitMachine
(
machine
);
}
@Override
public
void
visitName
(
EventName
name
)
{
m_currentName
=
name
.
getId
();
EventName
temp
=
m_report
.
findOrCreateMachine
(
CatString
.
ALL_IP
).
findOrCreateType
(
m_currentType
)
.
findOrCreateName
(
m_currentName
);
m_merger
.
mergeName
(
temp
,
name
);
super
.
visitName
(
name
);
}
@Override
public
void
visitRange
(
Range
range
)
{
m_currentRange
=
range
.
getValue
();
Range
temp
=
m_report
.
findOrCreateMachine
(
CatString
.
ALL_IP
).
findOrCreateType
(
m_currentType
)
.
findOrCreateName
(
m_currentName
).
findOrCreateRange
(
m_currentRange
);
m_merger
.
mergeRange
(
temp
,
range
);
super
.
visitRange
(
range
);
}
@Override
public
void
visitType
(
EventType
type
)
{
m_currentType
=
type
.
getId
();
EventType
temp
=
m_report
.
findOrCreateMachine
(
CatString
.
ALL_IP
).
findOrCreateType
(
m_currentType
);
m_merger
.
mergeType
(
temp
,
type
);
super
.
visitType
(
type
);
}
}
cat-home/src/main/java/com/dianping/cat/report/page/event/MergeAllName.java
0 → 100644
浏览文件 @
3a7ee76c
package
com.dianping.cat.report.page.event
;
import
com.dianping.cat.consumer.event.model.entity.EventName
;
import
com.dianping.cat.consumer.event.model.entity.EventReport
;
import
com.dianping.cat.consumer.event.model.entity.EventType
;
import
com.dianping.cat.consumer.event.model.entity.Machine
;
import
com.dianping.cat.consumer.event.model.entity.Range
;
import
com.dianping.cat.consumer.event.model.transform.BaseVisitor
;
import
com.dianping.cat.helper.CatString
;
import
com.dianping.cat.report.page.model.event.EventReportMerger
;
public
class
MergeAllName
extends
BaseVisitor
{
public
EventReport
m_report
;
public
String
m_currentIp
;
public
String
m_currentType
;
public
String
m_currentName
;
public
Integer
m_currentRange
;
public
Integer
m_currentDuration
;
public
EventReportMerger
m_merger
=
new
EventReportMerger
(
new
EventReport
());
public
EventReport
getReport
()
{
return
m_report
;
}
@Override
public
void
visitEventReport
(
EventReport
eventReport
)
{
m_report
=
new
EventReport
(
eventReport
.
getDomain
());
m_report
.
setStartTime
(
eventReport
.
getStartTime
());
m_report
.
setEndTime
(
eventReport
.
getEndTime
());
m_report
.
getDomainNames
().
addAll
(
eventReport
.
getDomainNames
());
m_report
.
getIps
().
addAll
(
eventReport
.
getIps
());
super
.
visitEventReport
(
eventReport
);
}
@Override
public
void
visitMachine
(
Machine
machine
)
{
m_currentIp
=
machine
.
getIp
();
m_report
.
findOrCreateMachine
(
m_currentIp
);
super
.
visitMachine
(
machine
);
}
@Override
public
void
visitName
(
EventName
name
)
{
m_currentName
=
name
.
getId
();
EventName
temp
=
m_report
.
findOrCreateMachine
(
m_currentIp
).
findOrCreateType
(
m_currentType
)
.
findOrCreateName
(
m_currentName
);
m_merger
.
mergeName
(
temp
,
name
);
EventName
all
=
m_report
.
findOrCreateMachine
(
m_currentIp
).
findOrCreateType
(
m_currentType
)
.
findOrCreateName
(
CatString
.
ALL_NAME
);
m_merger
.
mergeName
(
all
,
name
);
m_merger
.
mergeName
(
temp
,
name
);
super
.
visitName
(
name
);
}
@Override
public
void
visitRange
(
Range
range
)
{
m_currentRange
=
range
.
getValue
();
Range
temp
=
m_report
.
findOrCreateMachine
(
m_currentIp
).
findOrCreateType
(
m_currentType
)
.
findOrCreateName
(
m_currentName
).
findOrCreateRange
(
m_currentRange
);
m_merger
.
mergeRange
(
temp
,
range
);
Range
all
=
m_report
.
findOrCreateMachine
(
m_currentIp
).
findOrCreateType
(
m_currentType
)
.
findOrCreateName
(
CatString
.
ALL_NAME
).
findOrCreateRange
(
m_currentRange
);
m_merger
.
mergeRange
(
all
,
range
);
super
.
visitRange
(
range
);
}
@Override
public
void
visitType
(
EventType
type
)
{
m_currentType
=
type
.
getId
();
EventType
temp
=
m_report
.
findOrCreateMachine
(
m_currentIp
).
findOrCreateType
(
m_currentType
);
m_merger
.
mergeType
(
temp
,
type
);
super
.
visitType
(
type
);
}
}
cat-home/src/main/java/com/dianping/cat/report/page/event/Model.java
浏览文件 @
3a7ee76c
...
...
@@ -110,6 +110,10 @@ public class Model extends AbstractReportModel<Action, Context> {
return
m_mobileResponse
;
}
public
String
getPieChart
()
{
return
m_pieChart
;
}
public
EventReport
getReport
()
{
return
m_report
;
}
...
...
@@ -154,6 +158,10 @@ public class Model extends AbstractReportModel<Action, Context> {
m_mobileResponse
=
mobileResponse
;
}
public
void
setPieChart
(
String
pieChart
)
{
m_pieChart
=
pieChart
;
}
public
void
setReport
(
EventReport
report
)
{
m_report
=
report
;
}
...
...
@@ -162,12 +170,4 @@ public class Model extends AbstractReportModel<Action, Context> {
m_type
=
type
;
}
public
String
getPieChart
()
{
return
m_pieChart
;
}
public
void
setPieChart
(
String
pieChart
)
{
m_pieChart
=
pieChart
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/metric/Handler.java
浏览文件 @
3a7ee76c
...
...
@@ -24,10 +24,11 @@ public class Handler implements PageHandler<Context> {
@Inject
(
type
=
ModelService
.
class
,
value
=
"metric"
)
private
ModelService
<
MetricReport
>
m_service
;
private
static
final
String
TUAN
=
"TuanGou"
;
private
MetricReport
getReport
(
Payload
payload
)
{
String
group
=
payload
.
getGroup
();
String
channel
=
payload
.
getChannel
();
group
=
"TuanGou"
;
String
date
=
String
.
valueOf
(
payload
.
getDate
());
ModelRequest
request
=
new
ModelRequest
(
group
,
payload
.
getPeriod
())
//
.
setProperty
(
"date"
,
date
);
...
...
@@ -57,10 +58,12 @@ public class Handler implements PageHandler<Context> {
Model
model
=
new
Model
(
ctx
);
Payload
payload
=
ctx
.
getPayload
();
normalize
(
model
,
payload
);
MetricReport
report
=
getReport
(
payload
);
System
.
out
.
println
(
report
);
String
channel
=
payload
.
getChannel
();
if
(
report
!=
null
)
{
MetricDisplay
display
=
new
MetricDisplay
(
buildTuanGouMetricConfig
(
)
,
report
.
getStartTime
());
MetricDisplay
display
=
new
MetricDisplay
(
buildTuanGouMetricConfig
(
channel
),
channel
,
report
.
getStartTime
());
display
.
visitMetricReport
(
report
);
model
.
setDisplay
(
display
);
...
...
@@ -69,16 +72,15 @@ public class Handler implements PageHandler<Context> {
m_jspViewer
.
view
(
ctx
,
model
);
}
private
MetricConfig
buildTuanGouMetricConfig
()
{
private
MetricConfig
buildTuanGouMetricConfig
(
String
channel
)
{
MetricConfig
config
=
new
MetricConfig
();
MetricFlag
indexUrl
=
new
MetricFlag
(
"/index"
,
1
,
true
,
false
,
false
,
MetricTitle
.
INDEX
);
MetricFlag
detailUrl
=
new
MetricFlag
(
"/detail"
,
2
,
true
,
false
,
false
,
MetricTitle
.
DETAIL
);
MetricFlag
payUrl
=
new
MetricFlag
(
"/order/submitOrder"
,
3
,
true
,
false
,
false
,
MetricTitle
.
PAY
);
MetricFlag
orderKey
=
new
MetricFlag
(
"order"
,
4
,
false
,
true
,
false
,
MetricTitle
.
ORDER
);
MetricFlag
totalKey
=
new
MetricFlag
(
"payment.success"
,
5
,
false
,
true
,
false
,
MetricTitle
.
SUCCESS
);
MetricFlag
indexUrl
=
new
MetricFlag
(
"/index"
,
channel
,
1
,
true
,
false
,
false
,
MetricTitle
.
INDEX
);
MetricFlag
detailUrl
=
new
MetricFlag
(
"/detail"
,
channel
,
2
,
true
,
false
,
false
,
MetricTitle
.
DETAIL
);
MetricFlag
payUrl
=
new
MetricFlag
(
"/order/submitOrder"
,
channel
,
3
,
true
,
false
,
false
,
MetricTitle
.
PAY
);
MetricFlag
orderKey
=
new
MetricFlag
(
"order"
,
channel
,
4
,
false
,
true
,
false
,
MetricTitle
.
ORDER
);
MetricFlag
totalKey
=
new
MetricFlag
(
"payment.success"
,
channel
,
5
,
false
,
true
,
false
,
MetricTitle
.
SUCCESS
);
// MetricFlag sumKey = new MetricFlag("payment.pending", 5, false, true, false);
// config.put(sumKey);
config
.
put
(
indexUrl
);
config
.
put
(
detailUrl
);
...
...
@@ -89,6 +91,7 @@ public class Handler implements PageHandler<Context> {
}
private
void
normalize
(
Model
model
,
Payload
payload
)
{
payload
.
setGroup
(
TUAN
);
model
.
setIpAddress
(
payload
.
getIpAddress
());
model
.
setAction
(
Action
.
VIEW
);
model
.
setPage
(
ReportPage
.
METRIC
);
...
...
@@ -96,23 +99,21 @@ public class Handler implements PageHandler<Context> {
model
.
setDisplayDomain
(
payload
.
getDomain
());
model
.
setDomain
(
payload
.
getDomain
());
model
.
setGroup
(
payload
.
getGroup
());
model
.
setChannel
(
payload
.
getChannel
());
}
public
class
MetricTitle
{
public
static
final
String
INDEX
=
"团购首页"
;
public
static
final
String
DETAIL
=
"团购详情"
;
public
static
final
String
INDEX
=
"团购首页(次)"
;
public
static
final
String
PAY
=
"支付页面
"
;
public
static
final
String
DETAIL
=
"团购详情(次)
"
;
public
static
final
String
ORDER
=
"订单创建数量
"
;
public
static
final
String
PAY
=
"支付页面(次)
"
;
public
static
final
String
SUCCESS
=
"支付金额
"
;
public
static
final
String
ORDER
=
"订单创建数量(个)
"
;
public
static
final
String
INDEX_DETAIL
=
"首页到详情页转化率
"
;
public
static
final
String
SUCCESS
=
"支付金额(元)
"
;
public
static
final
String
DETAIL_PAY
=
"详情页到支付页转化率"
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/metric/MetricConfig.java
浏览文件 @
3a7ee76c
...
...
@@ -15,14 +15,16 @@ public class MetricConfig {
public
MetricFlag
get
(
String
key
)
{
return
m_flags
.
get
(
key
);
}
public
Collection
<
MetricFlag
>
getFlags
(){
public
Collection
<
MetricFlag
>
getFlags
()
{
return
m_flags
.
values
();
}
public
static
class
MetricFlag
{
private
String
m_key
;
private
String
m_key2
;
private
int
m_index
;
private
boolean
m_showCount
;
...
...
@@ -30,11 +32,13 @@ public class MetricConfig {
private
boolean
m_showSum
;
private
boolean
m_showAvg
;
private
String
m_title
;
public
MetricFlag
(
String
key
,
int
index
,
boolean
showCount
,
boolean
showSum
,
boolean
showAvg
,
String
title
)
{
public
MetricFlag
(
String
key
,
String
key2
,
int
index
,
boolean
showCount
,
boolean
showSum
,
boolean
showAvg
,
String
title
)
{
m_key
=
key
;
m_key2
=
key
;
m_index
=
index
;
m_showCount
=
showCount
;
m_showSum
=
showSum
;
...
...
@@ -42,6 +46,14 @@ public class MetricConfig {
m_title
=
title
;
}
public
String
getKey2
()
{
return
m_key2
;
}
public
void
setKey2
(
String
key2
)
{
m_key2
=
key2
;
}
public
int
getIndex
()
{
return
m_index
;
}
...
...
cat-home/src/main/java/com/dianping/cat/report/page/metric/MetricDisplay.java
浏览文件 @
3a7ee76c
...
...
@@ -2,11 +2,14 @@ package com.dianping.cat.report.page.metric;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.lang.StringUtils
;
import
com.dianping.cat.consumer.metric.model.entity.Metric
;
import
com.dianping.cat.consumer.metric.model.entity.MetricReport
;
import
com.dianping.cat.consumer.metric.model.entity.Point
;
...
...
@@ -19,19 +22,18 @@ public class MetricDisplay extends BaseVisitor {
private
Map
<
String
,
GraphItem
>
m_metrics
=
new
LinkedHashMap
<
String
,
GraphItem
>();
private
Map
<
String
,
GraphItem
>
m_conversionRates
=
new
LinkedHashMap
<
String
,
GraphItem
>();
private
String
m_key
;
private
String
m_channel
;
private
Date
m_start
;
private
MetricConfig
m_config
;
private
static
final
String
COUNT
=
":count"
;
public
MetricDisplay
(
MetricConfig
metricConfig
,
Date
start
)
{
public
MetricDisplay
(
MetricConfig
metricConfig
,
String
channel
,
Date
start
)
{
m_config
=
metricConfig
;
m_start
=
start
;
m_channel
=
channel
;
for
(
MetricFlag
flag
:
m_config
.
getFlags
())
{
String
title
=
flag
.
getTitle
();
...
...
@@ -40,7 +42,7 @@ public class MetricDisplay extends BaseVisitor {
m_metrics
.
put
(
key
,
new
GraphItem
(
m_start
,
title
,
flag
.
getKey
()));
}
if
(
flag
.
isShowCount
())
{
String
key
=
flag
.
getKey
()
+
COUNT
;
String
key
=
flag
.
getKey
()
+
":count"
;
m_metrics
.
put
(
key
,
new
GraphItem
(
m_start
,
title
,
flag
.
getKey
()));
}
if
(
flag
.
isShowAvg
())
{
...
...
@@ -50,33 +52,6 @@ public class MetricDisplay extends BaseVisitor {
}
}
public
MetricDisplay
buildConvertRate
(
String
key1
,
String
key2
,
String
title
)
{
GraphItem
item1
=
m_metrics
.
get
(
key1
+
COUNT
);
GraphItem
item2
=
m_metrics
.
get
(
key2
+
COUNT
);
if
(
item1
!=
null
&&
item2
!=
null
)
{
String
key
=
key1
+
":"
+
key2
;
GraphItem
item
=
new
GraphItem
(
m_start
,
title
,
key
);
double
[]
value1
=
item1
.
getValues
();
double
[]
value2
=
item2
.
getValues
();
int
size
=
item
.
getSize
();
double
[]
value
=
new
double
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
if
(
value1
[
i
]
>
0
)
{
value
[
i
]
=
value2
[
i
]
/
value1
[
i
];
}
}
item
.
setValues
(
value
);
m_conversionRates
.
put
(
key
,
item
);
}
return
this
;
}
public
List
<
GraphItem
>
getConversionRates
()
{
return
new
ArrayList
<
GraphItem
>(
m_conversionRates
.
values
());
}
public
List
<
GraphItem
>
getGroups
()
{
return
new
ArrayList
<
GraphItem
>(
m_metrics
.
values
());
}
...
...
@@ -84,35 +59,47 @@ public class MetricDisplay extends BaseVisitor {
@Override
public
void
visitMetric
(
Metric
metric
)
{
m_key
=
metric
.
getId
();
super
.
visitMetric
(
metric
);
}
@Override
public
void
visitMetricReport
(
MetricReport
metricReport
)
{
super
.
visitMetricReport
(
metricReport
);
if
(
StringUtils
.
isEmpty
(
m_channel
))
{
buildGraphItem
(
metric
.
getPoints
().
values
());
}
else
{
Map
<
String
,
Metric
>
metrics
=
metric
.
getMetrics
();
Metric
m
=
metrics
.
get
(
"channel="
+
m_channel
);
if
(
m
!=
null
)
{
buildGraphItem
(
m
.
getPoints
().
values
());
}
}
}
@Override
public
void
visitPoint
(
Point
point
)
{
int
min
=
point
.
getId
();
long
count
=
point
.
getCount
();
double
sum
=
point
.
getSum
();
double
avg
=
point
.
getAvg
();
private
void
buildGraphItem
(
Collection
<
Point
>
points
)
{
for
(
Point
point
:
points
)
{
GraphItem
graphItem
=
m_metrics
.
get
(
m_key
+
":sum"
);
if
(
graphItem
!=
null
)
{
graphItem
.
setValue
(
min
,
sum
);
}
graphItem
=
m_metrics
.
get
(
m_key
+
":count"
);
if
(
graphItem
!=
null
)
{
graphItem
.
setValue
(
min
,
count
);
}
graphItem
=
m_metrics
.
get
(
m_key
+
":avg"
);
if
(
graphItem
!=
null
)
{
graphItem
.
setValue
(
min
,
avg
);
int
min
=
point
.
getId
();
long
count
=
point
.
getCount
();
double
sum
=
point
.
getSum
();
double
avg
=
point
.
getAvg
();
GraphItem
graphItem
=
m_metrics
.
get
(
m_key
+
":sum"
);
if
(
graphItem
!=
null
)
{
graphItem
.
setValue
(
min
,
sum
);
}
graphItem
=
m_metrics
.
get
(
m_key
+
":count"
);
if
(
graphItem
!=
null
)
{
graphItem
.
setValue
(
min
,
count
);
}
graphItem
=
m_metrics
.
get
(
m_key
+
":avg"
);
if
(
graphItem
!=
null
)
{
graphItem
.
setValue
(
min
,
avg
);
}
}
}
@Override
public
void
visitMetricReport
(
MetricReport
metricReport
)
{
super
.
visitMetricReport
(
metricReport
);
}
public
static
class
GraphItem
{
private
transient
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy/MM/dd HH:mm"
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/metric/Model.java
浏览文件 @
3a7ee76c
...
...
@@ -16,6 +16,8 @@ public class Model extends AbstractReportModel<Action, Context> {
private
String
m_group
;
private
String
m_channel
;
public
Model
(
Context
ctx
)
{
super
(
ctx
);
}
...
...
@@ -59,6 +61,14 @@ public class Model extends AbstractReportModel<Action, Context> {
return
m_group
;
}
public
String
getChannel
()
{
return
m_channel
;
}
public
void
setChannel
(
String
channel
)
{
m_channel
=
channel
;
}
public
void
setGroup
(
String
group
)
{
m_group
=
group
;
}
...
...
cat-home/src/main/java/com/dianping/cat/report/page/model/event/CompositeEventService.java
浏览文件 @
3a7ee76c
...
...
@@ -3,7 +3,6 @@ package com.dianping.cat.report.page.model.event;
import
java.util.List
;
import
com.dianping.cat.consumer.event.model.entity.EventReport
;
import
com.dianping.cat.helper.CatString
;
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
;
...
...
@@ -25,16 +24,6 @@ public class CompositeEventService extends BaseCompositeModelService<EventReport
return
null
;
}
EventReportMerger
merger
=
new
EventReportMerger
(
new
EventReport
(
request
.
getDomain
()));
String
ip
=
request
.
getProperty
(
"ip"
);
merger
.
setIp
(
ip
);
if
(
ip
.
equals
(
CatString
.
ALL_IP
))
{
merger
.
setAllIp
(
true
);
}
String
all
=
request
.
getProperty
(
"all"
);
if
(
"true"
.
equals
(
all
))
{
merger
.
setAllName
(
true
);
merger
.
setType
(
request
.
getProperty
(
"type"
));
}
for
(
ModelResponse
<
EventReport
>
response
:
responses
)
{
EventReport
model
=
response
.
getModel
();
if
(
model
!=
null
)
{
...
...
cat-home/src/main/java/com/dianping/cat/report/page/model/event/EventReportMerger.java
浏览文件 @
3a7ee76c
...
...
@@ -10,18 +10,6 @@ import com.dianping.cat.consumer.event.model.transform.DefaultMerger;
import
com.dianping.cat.helper.CatString
;
public
class
EventReportMerger
extends
DefaultMerger
{
private
boolean
m_allIp
=
false
;
private
Machine
m_allMachines
;
private
boolean
m_allName
=
false
;
private
EventName
m_allNames
;
private
String
m_ip
;
private
String
m_type
;
public
EventReportMerger
(
EventReport
eventReport
)
{
super
(
eventReport
);
...
...
@@ -29,11 +17,11 @@ public class EventReportMerger extends DefaultMerger {
}
@Override
p
rotected
void
mergeMachine
(
Machine
old
,
Machine
machine
)
{
p
ublic
void
mergeMachine
(
Machine
old
,
Machine
machine
)
{
}
@Override
p
rotected
void
mergeName
(
EventName
old
,
EventName
other
)
{
p
ublic
void
mergeName
(
EventName
old
,
EventName
other
)
{
old
.
setTotalCount
(
old
.
getTotalCount
()
+
other
.
getTotalCount
());
old
.
setFailCount
(
old
.
getFailCount
()
+
other
.
getFailCount
());
...
...
@@ -51,7 +39,7 @@ public class EventReportMerger extends DefaultMerger {
}
@Override
p
rotected
void
mergeRange
(
Range
old
,
Range
range
)
{
p
ublic
void
mergeRange
(
Range
old
,
Range
range
)
{
old
.
setCount
(
old
.
getCount
()
+
range
.
getCount
());
old
.
setFails
(
old
.
getFails
()
+
range
.
getFails
());
}
...
...
@@ -69,7 +57,7 @@ public class EventReportMerger extends DefaultMerger {
}
@Override
p
rotected
void
mergeType
(
EventType
old
,
EventType
other
)
{
p
ublic
void
mergeType
(
EventType
old
,
EventType
other
)
{
old
.
setTotalCount
(
old
.
getTotalCount
()
+
other
.
getTotalCount
());
old
.
setFailCount
(
old
.
getFailCount
()
+
other
.
getFailCount
());
...
...
@@ -86,65 +74,14 @@ public class EventReportMerger extends DefaultMerger {
}
}
public
EventReportMerger
setAllIp
(
boolean
allIp
)
{
m_allIp
=
allIp
;
return
this
;
}
public
EventReportMerger
setAllName
(
boolean
allName
)
{
m_allName
=
allName
;
return
this
;
}
public
EventReportMerger
setIp
(
String
ip
)
{
m_ip
=
ip
;
return
this
;
}
public
EventReportMerger
setType
(
String
type
)
{
m_type
=
type
;
return
this
;
}
@Override
public
void
visitMachine
(
Machine
machine
)
{
if
(
m_allIp
)
{
visitMachineChildren
(
m_allMachines
,
machine
);
}
else
{
super
.
visitMachine
(
machine
);
}
}
@Override
public
void
visitName
(
EventName
name
)
{
if
(
m_allName
)
{
visitNameChildren
(
m_allNames
,
name
);
}
else
{
super
.
visitName
(
name
);
}
}
@Override
public
void
visitEventReport
(
EventReport
eventReport
)
{
EventReport
report
=
getEventReport
();
if
(
m_allIp
)
{
m_allMachines
=
report
.
findOrCreateMachine
(
CatString
.
ALL_IP
);
}
if
(
m_allName
)
{
m_allNames
=
report
.
findOrCreateMachine
(
m_ip
).
findOrCreateType
(
m_type
).
findOrCreateName
(
"ALL"
);
}
super
.
visitEventReport
(
eventReport
);
EventReport
report
=
getEventReport
();
report
.
getDomainNames
().
addAll
(
eventReport
.
getDomainNames
());
report
.
getIps
().
addAll
(
eventReport
.
getIps
());
}
@Override
public
void
visitType
(
EventType
type
)
{
if
(!
m_allName
||
m_allName
&&
m_type
.
equals
(
type
.
getId
()))
{
super
.
visitType
(
type
);
}
}
}
cat-home/src/main/java/com/dianping/cat/report/page/model/transaction/CompositeTransactionService.java
浏览文件 @
3a7ee76c
...
...
@@ -3,7 +3,6 @@ package com.dianping.cat.report.page.model.transaction;
import
java.util.List
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
import
com.dianping.cat.helper.CatString
;
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
;
...
...
@@ -25,16 +24,7 @@ public class CompositeTransactionService extends BaseCompositeModelService<Trans
return
null
;
}
TransactionReportMerger
merger
=
new
TransactionReportMerger
(
new
TransactionReport
(
request
.
getDomain
()));
String
ip
=
request
.
getProperty
(
"ip"
);
merger
.
setIp
(
ip
);
if
(
ip
.
equals
(
CatString
.
ALL_IP
))
{
merger
.
setAllIp
(
true
);
}
String
all
=
request
.
getProperty
(
"all"
);
if
(
"true"
.
equals
(
all
))
{
merger
.
setAllName
(
true
);
merger
.
setType
(
request
.
getProperty
(
"type"
));
}
for
(
ModelResponse
<
TransactionReport
>
response
:
responses
)
{
if
(
response
!=
null
)
{
TransactionReport
model
=
response
.
getModel
();
...
...
cat-home/src/main/java/com/dianping/cat/report/page/model/transaction/TransactionReportMerger.java
浏览文件 @
3a7ee76c
...
...
@@ -11,17 +11,6 @@ import com.dianping.cat.consumer.transaction.model.transform.DefaultMerger;
import
com.dianping.cat.helper.CatString
;
public
class
TransactionReportMerger
extends
DefaultMerger
{
private
boolean
m_allIp
=
false
;
private
Machine
m_allMachines
;
private
boolean
m_allName
=
false
;
private
TransactionName
m_allNames
;
private
String
m_ip
;
private
String
m_type
;
public
TransactionReportMerger
(
TransactionReport
transactionReport
)
{
super
(
transactionReport
);
...
...
@@ -30,16 +19,17 @@ public class TransactionReportMerger extends DefaultMerger {
}
@Override
p
rotected
void
mergeDuration
(
Duration
old
,
Duration
duration
)
{
p
ublic
void
mergeDuration
(
Duration
old
,
Duration
duration
)
{
old
.
setCount
(
old
.
getCount
()
+
duration
.
getCount
());
old
.
setValue
(
duration
.
getValue
());
}
@Override
p
rotected
void
mergeMachine
(
Machine
old
,
Machine
machine
)
{
p
ublic
void
mergeMachine
(
Machine
old
,
Machine
machine
)
{
}
@Override
p
rotected
void
mergeName
(
TransactionName
old
,
TransactionName
other
)
{
p
ublic
void
mergeName
(
TransactionName
old
,
TransactionName
other
)
{
old
.
setTotalCount
(
old
.
getTotalCount
()
+
other
.
getTotalCount
());
old
.
setFailCount
(
old
.
getFailCount
()
+
other
.
getFailCount
());
...
...
@@ -75,7 +65,7 @@ public class TransactionReportMerger extends DefaultMerger {
}
@Override
p
rotected
void
mergeRange
(
Range
old
,
Range
range
)
{
p
ublic
void
mergeRange
(
Range
old
,
Range
range
)
{
old
.
setCount
(
old
.
getCount
()
+
range
.
getCount
());
old
.
setFails
(
old
.
getFails
()
+
range
.
getFails
());
old
.
setSum
(
old
.
getSum
()
+
range
.
getSum
());
...
...
@@ -85,20 +75,8 @@ public class TransactionReportMerger extends DefaultMerger {
}
}
public
Machine
mergesForAllMachine
(
TransactionReport
report
)
{
Machine
machine
=
new
Machine
(
CatString
.
ALL_IP
);
for
(
Machine
m
:
report
.
getMachines
().
values
())
{
if
(!
m
.
getIp
().
equals
(
CatString
.
ALL_IP
))
{
visitMachineChildren
(
machine
,
m
);
}
}
return
machine
;
}
@Override
p
rotected
void
mergeType
(
TransactionType
old
,
TransactionType
other
)
{
p
ublic
void
mergeType
(
TransactionType
old
,
TransactionType
other
)
{
old
.
setTotalCount
(
old
.
getTotalCount
()
+
other
.
getTotalCount
());
old
.
setFailCount
(
old
.
getFailCount
()
+
other
.
getFailCount
());
...
...
@@ -132,27 +110,14 @@ public class TransactionReportMerger extends DefaultMerger {
}
}
public
TransactionReportMerger
setAllIp
(
boolean
allIp
)
{
m_allIp
=
allIp
;
return
this
;
}
public
TransactionReportMerger
setAllName
(
boolean
allName
)
{
m_allName
=
allName
;
return
this
;
}
public
TransactionReportMerger
setIp
(
String
ip
)
{
m_ip
=
ip
;
return
this
;
}
public
TransactionReportMerger
setType
(
String
type
)
{
m_type
=
type
;
return
this
;
@Override
public
void
visitTransactionReport
(
TransactionReport
transactionReport
)
{
super
.
visitTransactionReport
(
transactionReport
);
getTransactionReport
().
getDomainNames
().
addAll
(
transactionReport
.
getDomainNames
());
getTransactionReport
().
getIps
().
addAll
(
transactionReport
.
getIps
());
}
p
rotected
double
std
(
long
count
,
double
avg
,
double
sum2
,
double
max
)
{
p
ublic
double
std
(
long
count
,
double
avg
,
double
sum2
,
double
max
)
{
double
value
=
sum2
/
count
-
avg
*
avg
;
if
(
value
<=
0
||
count
<=
1
)
{
...
...
@@ -163,47 +128,17 @@ public class TransactionReportMerger extends DefaultMerger {
return
Math
.
sqrt
(
value
);
}
}
public
Machine
mergesForAllMachine
(
TransactionReport
report
)
{
Machine
machine
=
new
Machine
(
CatString
.
ALL_IP
);
@Override
public
void
visitMachine
(
Machine
machine
)
{
if
(
m_allIp
)
{
visitMachineChildren
(
m_allMachines
,
machine
);
}
else
{
super
.
visitMachine
(
machine
);
}
}
@Override
public
void
visitName
(
TransactionName
name
)
{
if
(
m_allName
)
{
visitNameChildren
(
m_allNames
,
name
);
}
else
{
super
.
visitName
(
name
);
}
}
@Override
public
void
visitTransactionReport
(
TransactionReport
transactionReport
)
{
TransactionReport
report
=
getTransactionReport
();
if
(
m_allIp
)
{
m_allMachines
=
report
.
findOrCreateMachine
(
CatString
.
ALL_IP
);
}
if
(
m_allName
)
{
m_allNames
=
report
.
findOrCreateMachine
(
m_ip
).
findOrCreateType
(
m_type
).
findOrCreateName
(
"ALL"
);
for
(
Machine
m
:
report
.
getMachines
().
values
())
{
if
(!
m
.
getIp
().
equals
(
CatString
.
ALL_IP
))
{
visitMachineChildren
(
machine
,
m
);
}
}
super
.
visitTransactionReport
(
transactionReport
);
report
.
getDomainNames
().
addAll
(
transactionReport
.
getDomainNames
());
report
.
getIps
().
addAll
(
transactionReport
.
getIps
());
return
machine
;
}
@Override
public
void
visitType
(
TransactionType
type
)
{
if
(!
m_allName
||
m_allName
&&
m_type
.
equals
(
type
.
getId
()))
{
super
.
visitType
(
type
);
}
}
}
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Handler.java
浏览文件 @
3a7ee76c
...
...
@@ -135,7 +135,6 @@ public class Handler implements PageHandler<Context> {
if
(
m_service
.
isEligable
(
request
))
{
ModelResponse
<
TransactionReport
>
response
=
m_service
.
invoke
(
request
);
TransactionReport
report
=
response
.
getModel
();
calculateTps
(
payload
,
report
);
if
(
payload
.
getPeriod
().
isLast
())
{
Date
start
=
new
Date
(
payload
.
getDate
());
...
...
@@ -149,7 +148,13 @@ public class Handler implements PageHandler<Context> {
domainNames
.
addAll
(
domains
);
}
if
(
CatString
.
ALL_IP
.
equalsIgnoreCase
(
ipAddress
))
{
MergeAllMachine
all
=
new
MergeAllMachine
();
all
.
visitTransactionReport
(
report
);
report
=
all
.
getReport
();
}
calculateTps
(
payload
,
report
);
return
report
;
}
else
{
throw
new
RuntimeException
(
"Internal error: no eligable transaction service registered for "
+
request
+
"!"
);
...
...
@@ -171,12 +176,24 @@ public class Handler implements PageHandler<Context> {
if
(
name
==
null
||
name
.
length
()
==
0
)
{
request
.
setProperty
(
"name"
,
"*"
);
request
.
setProperty
(
"all"
,
"true"
);
name
=
"ALL"
;
name
=
CatString
.
ALL_NAME
;
}
ModelResponse
<
TransactionReport
>
response
=
m_service
.
invoke
(
request
);
TransactionReport
report
=
response
.
getModel
();
TransactionType
t
=
report
.
getMachines
().
get
(
ip
).
findType
(
type
);
if
(
CatString
.
ALL_IP
.
equalsIgnoreCase
(
ipAddress
))
{
MergeAllMachine
all
=
new
MergeAllMachine
();
all
.
visitTransactionReport
(
report
);
report
=
all
.
getReport
();
}
if
(
CatString
.
ALL_NAME
.
equalsIgnoreCase
(
name
))
{
MergeAllName
all
=
new
MergeAllName
();
all
.
visitTransactionReport
(
report
);
report
=
all
.
getReport
();
}
TransactionType
t
=
report
.
getMachines
().
get
(
ip
).
findType
(
type
);
if
(
t
!=
null
)
{
TransactionName
n
=
t
.
findName
(
name
);
if
(
n
!=
null
)
{
...
...
cat-home/src/main/java/com/dianping/cat/report/page/transaction/HistoryGraphs.java
浏览文件 @
3a7ee76c
...
...
@@ -44,10 +44,46 @@ public class HistoryGraphs {
}
}
public
Map
<
String
,
double
[]>
buildGraphDatasForHour
(
Date
start
,
Date
end
,
String
type
,
String
name
,
List
<
Graph
>
graphs
)
{
private
HistoryGraphItem
buildAvg
(
List
<
Map
<
String
,
double
[]>>
datas
,
Date
start
,
int
size
,
long
step
,
String
name
)
{
HistoryGraphItem
item
=
new
HistoryGraphItem
();
item
.
setStart
(
start
);
item
.
setSize
(
size
);
item
.
setStep
(
step
);
item
.
setTitles
(
name
+
" Response Time (ms)"
);
for
(
Map
<
String
,
double
[]>
data
:
datas
)
{
double
[]
sum
=
data
.
get
(
"sum"
);
double
[]
totalCount
=
data
.
get
(
"total_count"
);
double
[]
avg
=
new
double
[
sum
.
length
];
for
(
int
i
=
0
;
i
<
sum
.
length
;
i
++)
{
if
(
totalCount
[
i
]
>
0
)
{
avg
[
i
]
=
sum
[
i
]
/
totalCount
[
i
];
}
}
item
.
addValue
(
avg
);
}
return
item
;
}
private
HistoryGraphItem
buildFail
(
List
<
Map
<
String
,
double
[]>>
datas
,
Date
start
,
int
size
,
long
step
,
String
name
)
{
HistoryGraphItem
item
=
new
HistoryGraphItem
();
item
.
setStart
(
start
);
item
.
setSize
(
size
);
item
.
setStep
(
step
);
item
.
setTitles
(
name
+
" Error (count)"
);
for
(
Map
<
String
,
double
[]>
data
:
datas
)
{
item
.
addValue
(
data
.
get
(
"failure_count"
));
}
return
item
;
}
public
Map
<
String
,
double
[]>
buildGraphDatasForDaily
(
Date
start
,
Date
end
,
String
type
,
String
name
,
List
<
Dailygraph
>
graphs
)
{
Map
<
String
,
double
[]>
result
=
new
HashMap
<
String
,
double
[]>();
int
size
=
(
int
)
((
end
.
getTime
()
-
start
.
getTime
())
*
12
/
TimeUtil
.
ONE_HOUR
);
int
size
=
(
int
)
((
end
.
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_DAY
);
double
[]
total_count
=
new
double
[
size
];
double
[]
failure_count
=
new
double
[
size
];
double
[]
sum
=
new
double
[
size
];
...
...
@@ -59,30 +95,30 @@ public class HistoryGraphs {
}
if
(!
StringUtils
.
isEmpty
(
type
)
&&
StringUtils
.
isEmpty
(
name
))
{
for
(
G
raph
graph
:
graphs
)
{
int
indexOfperiod
=
(
int
)
((
graph
.
getPeriod
().
getTime
()
-
start
.
getTime
())
*
12
/
TimeUtil
.
ONE_HOUR
);
for
(
Dailyg
raph
graph
:
graphs
)
{
int
indexOfperiod
=
(
int
)
((
graph
.
getPeriod
().
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_DAY
);
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
))
{
appendArray
(
total_count
,
indexOfperiod
,
records
[
SummaryOrder
.
TOTAL_COUNT
.
ordinal
()],
12
);
appendArray
(
failure_count
,
indexOfperiod
,
records
[
SummaryOrder
.
FAILURE_COUNT
.
ordinal
()],
12
);
appendArray
(
sum
,
indexOfperiod
,
records
[
SummaryOrder
.
SUM
.
ordinal
()],
12
);
total_count
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
SummaryOrder
.
TOTAL_COUNT
.
ordinal
()]
);
failure_count
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
SummaryOrder
.
FAILURE_COUNT
.
ordinal
()]
);
sum
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
SummaryOrder
.
SUM
.
ordinal
()]
);
}
}
}
}
else
if
(!
StringUtils
.
isEmpty
(
type
)
&&
!
StringUtils
.
isEmpty
(
name
))
{
for
(
G
raph
graph
:
graphs
)
{
int
indexOfperiod
=
(
int
)
((
graph
.
getPeriod
().
getTime
()
-
start
.
getTime
())
*
12
/
TimeUtil
.
ONE_HOUR
);
for
(
Dailyg
raph
graph
:
graphs
)
{
int
indexOfperiod
=
(
int
)
((
graph
.
getPeriod
().
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_DAY
);
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
))
{
appendArray
(
total_count
,
indexOfperiod
,
records
[
DetailOrder
.
TOTAL_COUNT
.
ordinal
()],
12
);
appendArray
(
failure_count
,
indexOfperiod
,
records
[
DetailOrder
.
FAILURE_COUNT
.
ordinal
()],
12
);
appendArray
(
sum
,
indexOfperiod
,
records
[
DetailOrder
.
SUM
.
ordinal
()],
12
);
total_count
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
DetailOrder
.
TOTAL_COUNT
.
ordinal
()]
);
failure_count
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
DetailOrder
.
FAILURE_COUNT
.
ordinal
()]
);
sum
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
DetailOrder
.
SUM
.
ordinal
()]
);
}
}
}
...
...
@@ -94,10 +130,10 @@ public class HistoryGraphs {
return
result
;
}
public
Map
<
String
,
double
[]>
buildGraphDatasFor
Daily
(
Date
start
,
Date
end
,
String
type
,
String
name
,
List
<
Dailyg
raph
>
graphs
)
{
public
Map
<
String
,
double
[]>
buildGraphDatasFor
Hour
(
Date
start
,
Date
end
,
String
type
,
String
name
,
List
<
G
raph
>
graphs
)
{
Map
<
String
,
double
[]>
result
=
new
HashMap
<
String
,
double
[]>();
int
size
=
(
int
)
((
end
.
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_DAY
);
int
size
=
(
int
)
((
end
.
getTime
()
-
start
.
getTime
())
*
12
/
TimeUtil
.
ONE_HOUR
);
double
[]
total_count
=
new
double
[
size
];
double
[]
failure_count
=
new
double
[
size
];
double
[]
sum
=
new
double
[
size
];
...
...
@@ -109,30 +145,30 @@ public class HistoryGraphs {
}
if
(!
StringUtils
.
isEmpty
(
type
)
&&
StringUtils
.
isEmpty
(
name
))
{
for
(
Dailyg
raph
graph
:
graphs
)
{
int
indexOfperiod
=
(
int
)
((
graph
.
getPeriod
().
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_DAY
);
for
(
G
raph
graph
:
graphs
)
{
int
indexOfperiod
=
(
int
)
((
graph
.
getPeriod
().
getTime
()
-
start
.
getTime
())
*
12
/
TimeUtil
.
ONE_HOUR
);
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
()]
);
sum
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
SummaryOrder
.
SUM
.
ordinal
()]
);
appendArray
(
total_count
,
indexOfperiod
,
records
[
SummaryOrder
.
TOTAL_COUNT
.
ordinal
()],
12
);
appendArray
(
failure_count
,
indexOfperiod
,
records
[
SummaryOrder
.
FAILURE_COUNT
.
ordinal
()],
12
);
appendArray
(
sum
,
indexOfperiod
,
records
[
SummaryOrder
.
SUM
.
ordinal
()],
12
);
}
}
}
}
else
if
(!
StringUtils
.
isEmpty
(
type
)
&&
!
StringUtils
.
isEmpty
(
name
))
{
for
(
Dailyg
raph
graph
:
graphs
)
{
int
indexOfperiod
=
(
int
)
((
graph
.
getPeriod
().
getTime
()
-
start
.
getTime
())
/
TimeUtil
.
ONE_DAY
);
for
(
G
raph
graph
:
graphs
)
{
int
indexOfperiod
=
(
int
)
((
graph
.
getPeriod
().
getTime
()
-
start
.
getTime
())
*
12
/
TimeUtil
.
ONE_HOUR
);
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
()]
);
sum
[
indexOfperiod
]
=
Double
.
valueOf
(
records
[
DetailOrder
.
SUM
.
ordinal
()]
);
appendArray
(
total_count
,
indexOfperiod
,
records
[
DetailOrder
.
TOTAL_COUNT
.
ordinal
()],
12
);
appendArray
(
failure_count
,
indexOfperiod
,
records
[
DetailOrder
.
FAILURE_COUNT
.
ordinal
()],
12
);
appendArray
(
sum
,
indexOfperiod
,
records
[
DetailOrder
.
SUM
.
ordinal
()],
12
);
}
}
}
...
...
@@ -144,28 +180,6 @@ public class HistoryGraphs {
return
result
;
}
private
HistoryGraphItem
buildAvg
(
List
<
Map
<
String
,
double
[]>>
datas
,
Date
start
,
int
size
,
long
step
,
String
name
)
{
HistoryGraphItem
item
=
new
HistoryGraphItem
();
item
.
setStart
(
start
);
item
.
setSize
(
size
);
item
.
setStep
(
step
);
item
.
setTitles
(
name
+
" Response Time (ms)"
);
for
(
Map
<
String
,
double
[]>
data
:
datas
)
{
double
[]
sum
=
data
.
get
(
"sum"
);
double
[]
totalCount
=
data
.
get
(
"total_count"
);
double
[]
avg
=
new
double
[
sum
.
length
];
for
(
int
i
=
0
;
i
<
sum
.
length
;
i
++)
{
if
(
totalCount
[
i
]
>
0
)
{
avg
[
i
]
=
sum
[
i
]
/
totalCount
[
i
];
}
}
item
.
addValue
(
avg
);
}
return
item
;
}
private
HistoryGraphItem
buildTotal
(
List
<
Map
<
String
,
double
[]>>
datas
,
Date
start
,
int
size
,
long
step
,
String
name
)
{
HistoryGraphItem
item
=
new
HistoryGraphItem
();
...
...
@@ -181,20 +195,6 @@ public class HistoryGraphs {
return
item
;
}
private
HistoryGraphItem
buildFail
(
List
<
Map
<
String
,
double
[]>>
datas
,
Date
start
,
int
size
,
long
step
,
String
name
)
{
HistoryGraphItem
item
=
new
HistoryGraphItem
();
item
.
setStart
(
start
);
item
.
setSize
(
size
);
item
.
setStep
(
step
);
item
.
setTitles
(
name
+
" Error (count)"
);
for
(
Map
<
String
,
double
[]>
data
:
datas
)
{
item
.
addValue
(
data
.
get
(
"failure_count"
));
}
return
item
;
}
public
void
buildTrendGraph
(
Model
model
,
Payload
payload
)
{
Date
start
=
payload
.
getHistoryStartDate
();
Date
end
=
payload
.
getHistoryEndDate
();
...
...
cat-home/src/main/java/com/dianping/cat/report/page/transaction/MergeAllMachine.java
0 → 100644
浏览文件 @
3a7ee76c
package
com.dianping.cat.report.page.transaction
;
import
com.dianping.cat.consumer.transaction.model.entity.Duration
;
import
com.dianping.cat.consumer.transaction.model.entity.Machine
;
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.consumer.transaction.model.transform.BaseVisitor
;
import
com.dianping.cat.helper.CatString
;
import
com.dianping.cat.report.page.model.transaction.TransactionReportMerger
;
public
class
MergeAllMachine
extends
BaseVisitor
{
public
TransactionReport
m_report
;
public
String
m_currentType
;
public
String
m_currentName
;
public
Integer
m_currentRange
;
public
Integer
m_currentDuration
;
public
TransactionReportMerger
m_merger
=
new
TransactionReportMerger
(
new
TransactionReport
());
public
TransactionReport
getReport
()
{
return
m_report
;
}
@Override
public
void
visitDuration
(
Duration
duration
)
{
m_currentDuration
=
duration
.
getValue
();
Duration
temp
=
m_report
.
findOrCreateMachine
(
CatString
.
ALL_IP
).
findOrCreateType
(
m_currentType
)
.
findOrCreateName
(
m_currentName
).
findOrCreateDuration
(
m_currentDuration
);
m_merger
.
mergeDuration
(
temp
,
duration
);
super
.
visitDuration
(
duration
);
}
@Override
public
void
visitMachine
(
Machine
machine
)
{
m_report
.
findOrCreateMachine
(
CatString
.
ALL_IP
);
super
.
visitMachine
(
machine
);
}
@Override
public
void
visitName
(
TransactionName
name
)
{
m_currentName
=
name
.
getId
();
TransactionName
temp
=
m_report
.
findOrCreateMachine
(
CatString
.
ALL_IP
).
findOrCreateType
(
m_currentType
)
.
findOrCreateName
(
m_currentName
);
m_merger
.
mergeName
(
temp
,
name
);
super
.
visitName
(
name
);
}
@Override
public
void
visitRange
(
Range
range
)
{
m_currentRange
=
range
.
getValue
();
Range
temp
=
m_report
.
findOrCreateMachine
(
CatString
.
ALL_IP
).
findOrCreateType
(
m_currentType
)
.
findOrCreateName
(
m_currentName
).
findOrCreateRange
(
m_currentRange
);
m_merger
.
mergeRange
(
temp
,
range
);
super
.
visitRange
(
range
);
}
@Override
public
void
visitTransactionReport
(
TransactionReport
transactionReport
)
{
m_report
=
new
TransactionReport
(
transactionReport
.
getDomain
());
m_report
.
setStartTime
(
transactionReport
.
getStartTime
());
m_report
.
setEndTime
(
transactionReport
.
getEndTime
());
m_report
.
getDomainNames
().
addAll
(
transactionReport
.
getDomainNames
());
m_report
.
getIps
().
addAll
(
transactionReport
.
getIps
());
super
.
visitTransactionReport
(
transactionReport
);
}
@Override
public
void
visitType
(
TransactionType
type
)
{
m_currentType
=
type
.
getId
();
TransactionType
temp
=
m_report
.
findOrCreateMachine
(
CatString
.
ALL_IP
).
findOrCreateType
(
m_currentType
);
m_merger
.
mergeType
(
temp
,
type
);
super
.
visitType
(
type
);
}
}
cat-home/src/main/java/com/dianping/cat/report/page/transaction/MergeAllName.java
0 → 100644
浏览文件 @
3a7ee76c
package
com.dianping.cat.report.page.transaction
;
import
com.dianping.cat.consumer.transaction.model.entity.Duration
;
import
com.dianping.cat.consumer.transaction.model.entity.Machine
;
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.consumer.transaction.model.transform.BaseVisitor
;
import
com.dianping.cat.helper.CatString
;
import
com.dianping.cat.report.page.model.transaction.TransactionReportMerger
;
public
class
MergeAllName
extends
BaseVisitor
{
public
TransactionReport
m_report
;
public
String
m_currentIp
;
public
String
m_currentType
;
public
String
m_currentName
;
public
Integer
m_currentRange
;
public
Integer
m_currentDuration
;
public
TransactionReportMerger
m_merger
=
new
TransactionReportMerger
(
new
TransactionReport
());
public
TransactionReport
getReport
()
{
return
m_report
;
}
@Override
public
void
visitDuration
(
Duration
duration
)
{
m_currentDuration
=
duration
.
getValue
();
Duration
temp
=
m_report
.
findOrCreateMachine
(
m_currentIp
).
findOrCreateType
(
m_currentType
)
.
findOrCreateName
(
m_currentName
).
findOrCreateDuration
(
m_currentDuration
);
m_merger
.
mergeDuration
(
temp
,
duration
);
Duration
all
=
m_report
.
findOrCreateMachine
(
m_currentIp
).
findOrCreateType
(
m_currentType
)
.
findOrCreateName
(
CatString
.
ALL_NAME
).
findOrCreateDuration
(
m_currentDuration
);
m_merger
.
mergeDuration
(
all
,
duration
);
super
.
visitDuration
(
duration
);
}
@Override
public
void
visitMachine
(
Machine
machine
)
{
m_currentIp
=
machine
.
getIp
();
m_report
.
findOrCreateMachine
(
m_currentIp
);
super
.
visitMachine
(
machine
);
}
@Override
public
void
visitName
(
TransactionName
name
)
{
m_currentName
=
name
.
getId
();
TransactionName
temp
=
m_report
.
findOrCreateMachine
(
m_currentIp
).
findOrCreateType
(
m_currentType
)
.
findOrCreateName
(
m_currentName
);
m_merger
.
mergeName
(
temp
,
name
);
TransactionName
all
=
m_report
.
findOrCreateMachine
(
m_currentIp
).
findOrCreateType
(
m_currentType
)
.
findOrCreateName
(
CatString
.
ALL_NAME
);
m_merger
.
mergeName
(
all
,
name
);
m_merger
.
mergeName
(
temp
,
name
);
super
.
visitName
(
name
);
}
@Override
public
void
visitRange
(
Range
range
)
{
m_currentRange
=
range
.
getValue
();
Range
temp
=
m_report
.
findOrCreateMachine
(
m_currentIp
).
findOrCreateType
(
m_currentType
)
.
findOrCreateName
(
m_currentName
).
findOrCreateRange
(
m_currentRange
);
m_merger
.
mergeRange
(
temp
,
range
);
Range
all
=
m_report
.
findOrCreateMachine
(
m_currentIp
).
findOrCreateType
(
m_currentType
)
.
findOrCreateName
(
CatString
.
ALL_NAME
).
findOrCreateRange
(
m_currentRange
);
m_merger
.
mergeRange
(
all
,
range
);
super
.
visitRange
(
range
);
}
@Override
public
void
visitTransactionReport
(
TransactionReport
transactionReport
)
{
m_report
=
new
TransactionReport
(
transactionReport
.
getDomain
());
m_report
.
setStartTime
(
transactionReport
.
getStartTime
());
m_report
.
setEndTime
(
transactionReport
.
getEndTime
());
m_report
.
getDomainNames
().
addAll
(
transactionReport
.
getDomainNames
());
m_report
.
getIps
().
addAll
(
transactionReport
.
getIps
());
super
.
visitTransactionReport
(
transactionReport
);
}
@Override
public
void
visitType
(
TransactionType
type
)
{
m_currentType
=
type
.
getId
();
TransactionType
temp
=
m_report
.
findOrCreateMachine
(
m_currentIp
).
findOrCreateType
(
m_currentType
);
m_merger
.
mergeType
(
temp
,
type
);
super
.
visitType
(
type
);
}
}
cat-home/src/main/java/com/dianping/cat/report/task/event/HistoryEventReportMerger.java
浏览文件 @
3a7ee76c
...
...
@@ -11,7 +11,7 @@ public class HistoryEventReportMerger extends EventReportMerger {
}
@Override
p
rotected
void
mergeName
(
EventName
old
,
EventName
other
)
{
p
ublic
void
mergeName
(
EventName
old
,
EventName
other
)
{
old
.
getRanges
().
clear
();
other
.
getRanges
().
clear
();
super
.
mergeName
(
old
,
other
);
...
...
cat-home/src/main/java/com/dianping/cat/report/task/health/HealthReportBuilder.java
浏览文件 @
3a7ee76c
...
...
@@ -31,6 +31,7 @@ import com.dianping.cat.report.page.model.event.EventReportMerger;
import
com.dianping.cat.report.page.model.heartbeat.HeartbeatReportMerger
;
import
com.dianping.cat.report.page.model.problem.ProblemReportMerger
;
import
com.dianping.cat.report.page.model.transaction.TransactionReportMerger
;
import
com.dianping.cat.report.page.transaction.MergeAllMachine
;
import
com.dianping.cat.report.task.TaskHelper
;
import
com.dianping.cat.report.task.health.HealthServiceCollector.ServiceInfo
;
import
com.dianping.cat.report.task.spi.AbstractReportBuilder
;
...
...
@@ -136,7 +137,6 @@ public class HealthReportBuilder extends AbstractReportBuilder implements Report
try
{
List
<
Report
>
reports
=
m_reportDao
.
findAllByPeriodDomainTypeName
(
reportPeriod
,
domain
,
1
,
"event"
,
ReportEntity
.
READSET_FULL
);
merger
.
setAllIp
(
true
);
for
(
Report
report
:
reports
)
{
String
xml
=
report
.
getContent
();
...
...
@@ -147,6 +147,10 @@ public class HealthReportBuilder extends AbstractReportBuilder implements Report
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
com
.
dianping
.
cat
.
report
.
page
.
event
.
MergeAllMachine
all
=
new
com
.
dianping
.
cat
.
report
.
page
.
event
.
MergeAllMachine
();
all
.
visitEventReport
(
eventReport
);
eventReport
=
all
.
getReport
();
eventReport
.
setStartTime
(
reportPeriod
);
eventReport
.
setEndTime
(
new
Date
(
reportPeriod
.
getTime
()
+
TimeUtil
.
ONE_HOUR
));
...
...
@@ -200,7 +204,6 @@ public class HealthReportBuilder extends AbstractReportBuilder implements Report
private
TransactionReport
queryTransactionReport
(
String
domain
,
Date
reportPeriod
)
{
TransactionReportMerger
merger
=
new
TransactionReportMerger
(
new
TransactionReport
(
domain
));
TransactionReport
transactionReport
=
merger
.
getTransactionReport
();
merger
.
setAllIp
(
true
);
try
{
List
<
Report
>
reports
=
m_reportDao
.
findAllByPeriodDomainTypeName
(
reportPeriod
,
domain
,
1
,
"transaction"
,
ReportEntity
.
READSET_FULL
);
...
...
@@ -215,6 +218,9 @@ public class HealthReportBuilder extends AbstractReportBuilder implements Report
m_logger
.
error
(
domain
+
" "
+
reportPeriod
,
e
);
Cat
.
logError
(
e
);
}
MergeAllMachine
all
=
new
MergeAllMachine
();
all
.
visitTransactionReport
(
transactionReport
);
transactionReport
=
all
.
getReport
();
transactionReport
.
setStartTime
(
reportPeriod
);
transactionReport
.
setEndTime
(
new
Date
(
reportPeriod
.
getTime
()
+
TimeUtil
.
ONE_HOUR
));
...
...
cat-home/src/main/java/com/dianping/cat/report/task/matrix/MatrixMerger.java
浏览文件 @
3a7ee76c
...
...
@@ -6,6 +6,7 @@ import java.util.Set;
import
com.dainping.cat.consumer.dal.report.Report
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.consumer.matrix.MatrixReportFilter
;
import
com.dianping.cat.consumer.matrix.model.entity.MatrixReport
;
import
com.dianping.cat.consumer.matrix.model.transform.DefaultSaxParser
;
import
com.dianping.cat.report.page.model.matrix.MatrixReportMerger
;
...
...
@@ -28,11 +29,14 @@ public class MatrixMerger implements ReportMerger<MatrixReport> {
}
}
MatrixReport
matrixReport
=
merger
.
getMatrixReport
();
matrixReport
.
getDomainNames
().
addAll
(
domains
);
Date
date
=
matrixReport
.
getStartTime
();
matrixReport
.
setStartTime
(
TaskHelper
.
todayZero
(
date
));
Date
end
=
new
Date
(
TaskHelper
.
tomorrowZero
(
date
).
getTime
()
-
1000
);
matrixReport
.
getDomainNames
().
addAll
(
domains
);
matrixReport
.
setStartTime
(
TaskHelper
.
todayZero
(
date
));
matrixReport
.
setEndTime
(
end
);
new
MatrixReportFilter
(
500
).
visitMatrixReport
(
matrixReport
);
return
matrixReport
;
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/transaction/HistoryTransactionReportMerger.java
浏览文件 @
3a7ee76c
...
...
@@ -11,7 +11,7 @@ public class HistoryTransactionReportMerger extends TransactionReportMerger {
}
@Override
p
rotected
void
mergeName
(
TransactionName
old
,
TransactionName
other
)
{
p
ublic
void
mergeName
(
TransactionName
old
,
TransactionName
other
)
{
old
.
getDurations
().
clear
();
old
.
getRanges
().
clear
();
...
...
cat-home/src/main/java/com/dianping/cat/system/alarm/threshold/ThresholdRuleManager.java
浏览文件 @
3a7ee76c
...
...
@@ -207,7 +207,7 @@ public class ThresholdRuleManager implements Initializable {
ThresholdTemplate
template
=
merger
.
getThresholdTemplate
();
return
template
;
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
Cat
.
logError
(
newContent
,
e
);
}
}
return
baseTemplate
;
...
...
cat-home/src/main/webapp/jsp/report/crossHistoryProject.jsp
浏览文件 @
3a7ee76c
...
...
@@ -46,7 +46,7 @@
<table
class=
'cross'
>
<c:if
test=
"
${
!
empty
model
.
projectInfo
.
callProjectsInfo
}
"
>
<tr>
<th
class=
"left"
>
Type
</th>
<th
class=
"left"
>
Type
(本项目调用其他Pigeon服务)
</th>
<th
class=
"left"
><a
href=
"?op=history&domain=${model.domain}&reportType=${model.reportType}&date=${model.date}&ip=${model.ipAddress}&serviceSort=${model.serviceSort}&callSort=name${model.customDate}"
>
RemoteProject
</a></th>
<th><a
href=
"?op=history&domain=${model.domain}&reportType=${model.reportType}&date=${model.date}&ip=${model.ipAddress}&serviceSort=${model.serviceSort}&callSort=total${model.customDate}"
>
Total
</a></th>
<th><a
href=
"?op=history&domain=${model.domain}&reportType=${model.reportType}&date=${model.date}&ip=${model.ipAddress}&serviceSort=${model.serviceSort}&callSort=failure${model.customDate}"
>
Failure
</a></th>
...
...
@@ -69,7 +69,7 @@
<tr><td>
&
nbsp
</td></tr>
<c:if
test=
"
${
!
empty
model
.
projectInfo
.
serviceProjectsInfo
}
"
>
<tr>
<th
class=
"left"
>
Type
</th>
<th
class=
"left"
>
Type
(从服务端看,Pigeon服务数据)
</th>
<th
class=
"left"
><a
href=
"?op=history&domain=${model.domain}&reportType=${model.reportType}&date=${model.date}&ip=${model.ipAddress}&callSort=${model.callSort}&serviceSort=name${model.customDate}"
>
RemoteProject
</a></th>
<th><a
href=
"?op=history&domain=${model.domain}&reportType=${model.reportType}&date=${model.date}&ip=${model.ipAddress}&callSort=${model.callSort}&serviceSort=total${model.customDate}"
>
Total
</a></th>
<th><a
href=
"?op=history&domain=${model.domain}&reportType=${model.reportType}&date=${model.date}&ip=${model.ipAddress}&callSort=${model.callSort}&serviceSort=failure${model.customDate}"
>
Failure
</a></th>
...
...
cat-home/src/main/webapp/jsp/report/event.jsp
浏览文件 @
3a7ee76c
...
...
@@ -57,23 +57,21 @@
<c:choose>
<c:when
test=
"
${
empty
payload
.
type
}
"
>
<tr>
<th><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=type"
>
Type
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=total"
>
Total Count
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=failure"
>
Failure Count
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=failurePercent"
>
Failure%
</a></th>
<th>
Type
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=total"
>
Total Count
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=failure"
>
Failure Count
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=failurePercent"
>
Failure%
</a></th>
<th
class=
"right"
>
Sample Link
</th>
<th
class=
"right"
>
T
PS
</th>
<th
class=
"right"
>
Q
PS
</th>
</tr>
<c:forEach
var=
"item"
items=
"
${
model
.
displayTypeReport
.
results
}
"
varStatus=
"status"
>
<c:set
var=
"e"
value=
"
${
item
.
detail
}
"
/>
<c:set
var=
"lastIndex"
value=
"
${
status
.
index
}
"
/>
<tr
class=
"${status.index mod 2 != 0 ? 'odd' : 'even'}"
>
<td
style=
"text-align: left"
><a
<td
style=
"text-align: left"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=type"
><a
href=
"?op=graphs&domain=${model.domain}&date=${model.date}&type=${item.type}&ip=${model.ipAddress}"
class=
"graph_link"
data-status=
"${status.index}"
>
[:: show ::]
</a>
<a
href=
"?domain=${report.domain}&date=${model.date}&ip=${model.ipAddress}&type=${item.type}"
>
${item.type}
</a></td>
<td>
${w:format(e.totalCount,'#,###,###,###,##0')}
</td>
<td>
${e.failCount}
</td>
...
...
@@ -82,26 +80,22 @@
href=
"${model.logViewBaseUri}/${empty e.failMessageUrl ? e.successMessageUrl : e.failMessageUrl}?domain=${model.domain}"
>
Log View
</a></td>
<td>
${w:format(e.tps,'0.0')}
</td>
</tr>
<tr
class=
"graphs"
>
<td
colspan=
"7"
><div
id=
"${status.index}"
style=
"display: none"
></div></td>
</tr>
</c:forEach>
</c:when>
<c:otherwise>
<tr>
<th><a
href=
"?op=graphs&domain=${model.domain}&date=${model.date}&type=${payload.type}"
<th><a
href=
"?op=graphs&domain=${model.domain}&date=${model.date}&type=${payload.type}&ip=${model.ipAddress}"
class=
"graph_link"
data-status=
"-1"
>
[:: show ::]
</a>
<a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=type"
>
Name
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total"
>
Total Count
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=failure"
>
Failure Count
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=failurePercent"
>
Failure%
</a></th>
<a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=type"
>
Name
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total"
>
Total Count
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=failure"
>
Failure Count
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=failurePercent"
>
Failure%
</a></th>
<th
class=
"right"
>
Sample Link
</th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total"
>
TPS
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total"
>
Percent%
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total"
>
QPS
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total"
>
Percent%
</a></th>
</tr>
<tr
class=
"graphs"
>
<td
colspan=
"7"
><div
id=
"-1"
style=
"display: none"
></div></td>
...
...
@@ -111,9 +105,13 @@
<c:set
var=
"e"
value=
"
${
item
.
detail
}
"
/>
<c:set
var=
"lastIndex"
value=
"
${
status
.
index
}
"
/>
<tr
class=
"${status.index mod 2 != 0 ? 'odd' : 'even'}"
>
<td
style=
"text-align: left"
><a
<td
style=
"text-align: left"
>
<c:choose>
<c:when
test=
"
${
status
.
index
>
0
}
"
>
<a
href=
"?op=graphs&domain=${report.domain}&ip=${model.ipAddress}&date=${model.date}&type=${payload.type}&name=${e.id}"
class=
"graph_link"
data-status=
"${status.index}"
>
[:: show ::]
</a>
${e.id}
</td>
class=
"graph_link"
data-status=
"${status.index}"
>
[:: show ::]
</a>
</c:when></c:choose>
${e.id}
</td>
<td>
${w:format(e.totalCount,'#,###,###,###,##0')}
</td>
<td>
${e.failCount}
</td>
<td>
${w:format(e.failPercent/100,'0.00%')}
</td>
...
...
cat-home/src/main/webapp/jsp/report/eventHistoryReport.jsp
浏览文件 @
3a7ee76c
...
...
@@ -42,7 +42,7 @@
<th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&sort=total${model.customDate}"
>
Total Count
</a></th>
<th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&sort=failure${model.customDate}"
>
Failure Count
</a></th>
<th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&sort=failurePercent${model.customDate}"
>
Failure%
</a></th>
<th
class=
"right"
>
Sample Link
</th><th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&sort=total${model.customDate}"
>
T
PS
</a></th>
<th
class=
"right"
>
Sample Link
</th><th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&sort=total${model.customDate}"
>
Q
PS
</a></th>
</tr>
<c:forEach
var=
"item"
items=
"
${
model
.
displayTypeReport
.
results
}
"
varStatus=
"status"
>
...
...
@@ -67,7 +67,7 @@
<th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&type=${payload.type}&sort=total${model.customDate}"
>
Total Count
</a></th>
<th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&type=${payload.type}&sort=failure${model.customDate}"
>
Failure Count
</a></th>
<th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&type=${payload.type}&sort=failurePercent${model.customDate}"
>
Failure%
</a></th>
<th
class=
"right"
>
Sample Link
</th><th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&type=${payload.type}&sort=type${model.customDate}"
>
T
PS
</a></th>
<th
class=
"right"
>
Sample Link
</th><th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&type=${payload.type}&sort=type${model.customDate}"
>
Q
PS
</a></th>
<th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&type=${payload.type}&sort=type${model.customDate}"
>
Percent%
</a></th>
</tr>
...
...
cat-home/src/main/webapp/jsp/report/metric.jsp
浏览文件 @
3a7ee76c
...
...
@@ -24,7 +24,7 @@
margin
:
4px
auto
;
}
.row-fluid
.span2
{
width
:
9
%
;
width
:
12
%
;
}
</style>
<script
type=
"text/javascript"
>
...
...
@@ -34,12 +34,8 @@
graph
(
document
.
getElementById
(
'
${item.title}
'
),
data
);
</c:forEach>
/*
<c:forEach
var=
"item"
items=
"
${
model
.
display
.
conversionRates
}
"
varStatus=
"status"
>
var data = ${item.jsonString};
graph(document.getElementById('${item.title}'), data);
</c:forEach>
*/
var
id
=
"
channel
"
+
'
${model.channel}
'
;
$
(
'
#
'
+
id
).
addClass
(
"
active
"
);
});
</script>
...
...
@@ -61,9 +57,13 @@
<div
class=
"span2"
>
<div
class=
"well sidebar-nav"
>
<ul
class=
"nav nav-list"
>
<li
class=
"nav-header active"
><a
href=
"#"
>
团购
</a></li>
<li><a
href=
"?date=${model.date}&group=${model.group}&channel=1"
>
团800
</a></li>
<li><a
href=
"#"
>
搜索引擎
</a></li>
<li
id=
"channel"
><a
href=
"?date=${model.date}&group=${model.group}"
><strong>
团购ALL
</strong></a></li>
<li
>
</li>
<li
id=
"channel1"
><a
href=
"?date=${model.date}&group=${model.group}&channel=1"
>
渠道:搜索引擎
</a></li>
<li
id=
"channel2"
><a
href=
"?date=${model.date}&group=${model.group}&channel=2"
>
渠道:微博推广
</a></li>
<li
id=
"channel3"
><a
href=
"?date=${model.date}&group=${model.group}&channel=3"
>
渠道:腾讯推广
</a></li>
<li
id=
"channel4"
><a
href=
"?date=${model.date}&group=${model.group}&channel=4"
>
渠道:内部引流
</a></li>
<li
id=
"channel5"
><a
href=
"?date=${model.date}&group=${model.group}&channel=5"
>
渠道:团800
</a></li>
</ul>
</div>
<!--/.well -->
</div>
<!--/span-->
...
...
@@ -72,12 +72,6 @@
<div
style=
"float:left;"
id=
"${item.title}"
class=
"graph"
></div>
</c:forEach>
</div>
<%-- <div class="span10 offset1">
<h3 class='text-center'>页面实时转化率</h3>
<c:forEach var="item" items="${model.display.conversionRates}" varStatus="status">
<div style="float:left;" id="${item.title}" class="graph"></div>
</c:forEach>
</div> --%>
<table
class=
"footer"
>
<tr>
<td>
[ end ]
</td>
...
...
cat-home/src/main/webapp/jsp/report/transaction.jsp
浏览文件 @
3a7ee76c
...
...
@@ -58,7 +58,7 @@
<th
class=
"right"
>
Sample Link
</th><th
class=
"right"
>
Min(ms)
</th><th
class=
"right"
>
Max(ms)
</th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&sort=avg"
>
Avg
</a>
(ms)
</th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&sort=95line"
>
95Line
</a>
(ms)
</th>
<th
class=
"right"
>
Std(ms)
</th><th
class=
"right"
>
T
PS
</th></tr>
<th
class=
"right"
>
Std(ms)
</th><th
class=
"right"
>
Q
PS
</th></tr>
<c:forEach
var=
"item"
items=
"
${
model
.
displayTypeReport
.
results
}
"
varStatus=
"status"
>
<c:set
var=
"e"
value=
"
${
item
.
detail
}
"
/>
<c:set
var=
"lastIndex"
value=
"
${
status
.
index
}
"
/>
...
...
@@ -95,7 +95,7 @@
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&type=${payload.type}&sort=avg&queryname=${model.queryName}"
>
Avg
</a>
(ms)
</th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&type=${payload.type}&sort=95line&queryname=${model.queryName}"
>
95Line
</a>
(ms)
</th>
<th
class=
"right"
>
Std(ms)
</th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total&queryname=${model.queryName}"
>
T
PS
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total&queryname=${model.queryName}"
>
Q
PS
</a></th>
<th
class=
"right"
><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total&queryname=${model.queryName}"
>
Percent%
</a></th></tr>
<tr
class=
"graphs"
><td
colspan=
"12"
><div
id=
"-1"
style=
"display:none"
></div></td></tr>
<c:forEach
var=
"item"
items=
"
${
model
.
displayNameReport
.
results
}
"
varStatus=
"status"
>
...
...
cat-home/src/main/webapp/jsp/report/transactionHistoryReport.jsp
浏览文件 @
3a7ee76c
...
...
@@ -49,7 +49,7 @@
<th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&sort=avg${model.customDate}"
>
Avg
</a>
(ms)
</th>
<th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&sort=95line${model.customDate}"
>
95Line
</a>
(ms)
</th>
<th
class=
"right"
>
Std(ms)
</th>
<th
class=
"right"
>
T
PS
</th>
<th
class=
"right"
>
Q
PS
</th>
</tr>
<c:forEach
var=
"item"
items=
"
${
model
.
displayTypeReport
.
results
}
"
varStatus=
"status"
>
...
...
@@ -100,7 +100,7 @@
<th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&type=${payload.type}&sort=avg${model.customDate}&queryname=${model.queryName}"
>
Avg
</a>
(ms)
</th>
<th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&type=${payload.type}&sort=95line${model.customDate}&queryname=${model.queryName}"
>
95Line
</a>
(ms)
</th>
<th
class=
"right"
>
Std(ms)
</th>
<th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&type=${payload.type}&sort=total${model.customDate}&queryname=${model.queryName}"
>
T
PS
</a></th>
<th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&type=${payload.type}&sort=total${model.customDate}&queryname=${model.queryName}"
>
Q
PS
</a></th>
<th
class=
"right"
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&type=${payload.type}&sort=total${model.customDate}&queryname=${model.queryName}"
>
Percent%
</a></th>
</tr>
<c:forEach
var=
"item"
items=
"
${
model
.
displayNameReport
.
results
}
"
...
...
cat-home/src/test/java/com/dianping/cat/demo/TestBusinessMessage.java
浏览文件 @
3a7ee76c
...
...
@@ -13,23 +13,23 @@ public class TestBusinessMessage {
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"/index"
);
Cat
.
logMetric
(
"order"
,
"quantity"
,
i
);
Cat
.
logMetric
(
"order"
,
"quantity"
,
i
,
"channel"
,
i
%
5
);
t
.
addData
(
"channel="
+
i
%
5
);
t
.
complete
();
}
for
(
int
i
=
0
;
i
<
900
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"/detail"
);
Cat
.
logMetric
(
"payment.pending"
,
"amount"
,
i
,
"channel"
,
i
%
5
);
t
.
addData
(
"channel="
+
i
%
5
);
t
.
complete
();
}
for
(
int
i
=
0
;
i
<
500
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"/order/submitOrder"
);
Cat
.
logMetric
(
"payment.success"
,
"amount"
,
i
,
"channel"
,
i
%
5
);
t
.
addData
(
"channel="
+
i
%
5
);
t
.
complete
();
}
Thread
.
sleep
(
10000
);
}
}
...
...
cat-home/src/test/java/com/dianping/cat/report/page/event/EventReportMergerTest.java
浏览文件 @
3a7ee76c
...
...
@@ -6,8 +6,6 @@ import org.unidal.webres.helper.Files;
import
com.dianping.cat.consumer.event.model.entity.EventReport
;
import
com.dianping.cat.consumer.event.model.transform.DefaultDomParser
;
import
com.dianping.cat.consumer.event.model.transform.DefaultXmlBuilder
;
import
com.dianping.cat.helper.CatString
;
import
com.dianping.cat.report.page.model.event.EventReportMerger
;
public
class
EventReportMergerTest
{
...
...
@@ -28,57 +26,4 @@ public class EventReportMergerTest {
Assert
.
assertEquals
(
"Source report is changed!"
,
newXml
.
replaceAll
(
"\\s*"
,
""
),
reportNew
.
toString
().
replaceAll
(
"\\s*"
,
""
));
}
@Test
public
void
testMergeAllIp
()
throws
Exception
{
String
oldXml
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"EventReportOld.xml"
),
"utf-8"
);
String
newXml
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"EventReportNew.xml"
),
"utf-8"
);
EventReport
reportOld
=
new
DefaultDomParser
().
parse
(
oldXml
);
EventReport
reportNew
=
new
DefaultDomParser
().
parse
(
newXml
);
String
expected
=
Files
.
forIO
()
.
readFrom
(
getClass
().
getResourceAsStream
(
"EventReportMergeAllResult.xml"
),
"utf-8"
);
EventReportMerger
merger
=
new
EventReportMerger
(
new
EventReport
(
reportOld
.
getDomain
()));
merger
.
setAllIp
(
true
);
reportOld
.
accept
(
merger
);
reportNew
.
accept
(
merger
);
String
actual
=
new
DefaultXmlBuilder
().
buildXml
(
merger
.
getEventReport
());
Assert
.
assertEquals
(
"Check the merge result!"
,
expected
.
replaceAll
(
"\\s*"
,
""
),
actual
.
replaceAll
(
"\\s*"
,
""
));
Assert
.
assertEquals
(
"Source report is changed!"
,
oldXml
.
replaceAll
(
"\\s*"
,
""
),
reportOld
.
toString
().
replaceAll
(
"\\s*"
,
""
));
Assert
.
assertEquals
(
"Source report is changed!"
,
newXml
.
replaceAll
(
"\\s*"
,
""
),
reportNew
.
toString
().
replaceAll
(
"\\s*"
,
""
));
}
@Test
public
void
testMergeAllIpAllName
()
throws
Exception
{
String
oldXml
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"EventReportOld.xml"
),
"utf-8"
);
String
newXml
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"EventReportNew.xml"
),
"utf-8"
);
EventReport
reportOld
=
new
DefaultDomParser
().
parse
(
oldXml
);
EventReport
reportNew
=
new
DefaultDomParser
().
parse
(
newXml
);
String
expected
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"EventReportMergeAllIpAllName.xml"
),
"utf-8"
);
EventReportMerger
merger
=
new
EventReportMerger
(
new
EventReport
(
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
.
getEventReport
());
Assert
.
assertEquals
(
"Check the merge result!"
,
expected
.
replaceAll
(
"\\s*"
,
""
),
actual
.
replaceAll
(
"\\s*"
,
""
));
Assert
.
assertEquals
(
"Source report is changed!"
,
oldXml
.
replaceAll
(
"\\s*"
,
""
),
reportOld
.
toString
().
replaceAll
(
"\\s*"
,
""
));
Assert
.
assertEquals
(
"Source report is changed!"
,
newXml
.
replaceAll
(
"\\s*"
,
""
),
reportNew
.
toString
().
replaceAll
(
"\\s*"
,
""
));
}
}
cat-home/src/test/java/com/dianping/cat/report/page/transaction/TransactionReportMergerTest.java
浏览文件 @
3a7ee76c
...
...
@@ -6,8 +6,6 @@ import org.unidal.webres.helper.Files;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
import
com.dianping.cat.consumer.transaction.model.transform.DefaultDomParser
;
import
com.dianping.cat.consumer.transaction.model.transform.DefaultXmlBuilder
;
import
com.dianping.cat.helper.CatString
;
import
com.dianping.cat.report.page.model.transaction.TransactionReportMerger
;
public
class
TransactionReportMergerTest
{
...
...
@@ -29,52 +27,4 @@ public class TransactionReportMergerTest {
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"
,
""
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录