Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
3954d7df
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,发现更多精彩内容 >>
提交
3954d7df
编写于
7月 10, 2013
作者:
H
Hao Zhu
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #108 from youyong205/biz
Biz
上级
37c07efb
77202540
变更
40
隐藏空白更改
内联
并排
Showing
40 changed file
with
730 addition
and
843 deletion
+730
-843
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/advanced/MetricAnalyzer.java
...va/com/dianping/cat/consumer/advanced/MetricAnalyzer.java
+12
-4
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
...m/dianping/cat/consumer/build/ComponentsConfigurator.java
+1
-1
cat-consumer-advanced/src/main/resources/META-INF/plexus/components.xml
...dvanced/src/main/resources/META-INF/plexus/components.xml
+3
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/core/problem/LongExecutionProblemHandler.java
...at/consumer/core/problem/LongExecutionProblemHandler.java
+31
-5
cat-consumer/src/main/java/com/dianping/cat/consumer/core/problem/ProblemType.java
...a/com/dianping/cat/consumer/core/problem/ProblemType.java
+2
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionDelegate.java
...ianping/cat/consumer/transaction/TransactionDelegate.java
+5
-4
cat-core/src/main/java/com/dianping/cat/service/DefaultReportService.java
...n/java/com/dianping/cat/service/DefaultReportService.java
+8
-28
cat-core/src/main/java/com/dianping/cat/task/TaskManager.java
...core/src/main/java/com/dianping/cat/task/TaskManager.java
+38
-15
cat-core/src/main/resources/META-INF/dal/jdbc/report-dal.xml
cat-core/src/main/resources/META-INF/dal/jdbc/report-dal.xml
+0
-25
cat-home/src/main/java/com/dianping/cat/report/baseline/BaselineConfigManager.java
...m/dianping/cat/report/baseline/BaselineConfigManager.java
+3
-3
cat-home/src/main/java/com/dianping/cat/report/baseline/BaselineService.java
...ava/com/dianping/cat/report/baseline/BaselineService.java
+2
-5
cat-home/src/main/java/com/dianping/cat/report/baseline/impl/DefaultBaselineService.java
...ping/cat/report/baseline/impl/DefaultBaselineService.java
+52
-20
cat-home/src/main/java/com/dianping/cat/report/page/problem/Handler.java
...in/java/com/dianping/cat/report/page/problem/Handler.java
+12
-25
cat-home/src/main/java/com/dianping/cat/report/page/problem/LongConfig.java
...java/com/dianping/cat/report/page/problem/LongConfig.java
+59
-0
cat-home/src/main/java/com/dianping/cat/report/page/problem/Model.java
...main/java/com/dianping/cat/report/page/problem/Model.java
+0
-30
cat-home/src/main/java/com/dianping/cat/report/page/problem/Payload.java
...in/java/com/dianping/cat/report/page/problem/Payload.java
+53
-28
cat-home/src/main/java/com/dianping/cat/report/page/problem/ProblemStatistics.java
...m/dianping/cat/report/page/problem/ProblemStatistics.java
+19
-21
cat-home/src/main/java/com/dianping/cat/report/task/cross/CrossReportBuilder.java
...om/dianping/cat/report/task/cross/CrossReportBuilder.java
+20
-22
cat-home/src/main/java/com/dianping/cat/report/task/event/EventGraphCreator.java
...com/dianping/cat/report/task/event/EventGraphCreator.java
+1
-3
cat-home/src/main/java/com/dianping/cat/report/task/event/EventReportBuilder.java
...om/dianping/cat/report/task/event/EventReportBuilder.java
+48
-50
cat-home/src/main/java/com/dianping/cat/report/task/heartbeat/HeartbeatGraphCreator.java
...ping/cat/report/task/heartbeat/HeartbeatGraphCreator.java
+1
-3
cat-home/src/main/java/com/dianping/cat/report/task/matrix/MatrixReportBuilder.java
.../dianping/cat/report/task/matrix/MatrixReportBuilder.java
+22
-23
cat-home/src/main/java/com/dianping/cat/report/task/metric/MetricAlert.java
...java/com/dianping/cat/report/task/metric/MetricAlert.java
+57
-46
cat-home/src/main/java/com/dianping/cat/report/task/metric/MetricBaselineReportBuilder.java
...g/cat/report/task/metric/MetricBaselineReportBuilder.java
+12
-9
cat-home/src/main/java/com/dianping/cat/report/task/metric/MetricPointParser.java
...om/dianping/cat/report/task/metric/MetricPointParser.java
+21
-21
cat-home/src/main/java/com/dianping/cat/report/task/problem/ProblemGraphCreator.java
...dianping/cat/report/task/problem/ProblemGraphCreator.java
+1
-3
cat-home/src/main/java/com/dianping/cat/report/task/problem/ProblemReportBuilder.java
...ianping/cat/report/task/problem/ProblemReportBuilder.java
+50
-51
cat-home/src/main/java/com/dianping/cat/report/task/spi/GraphCreator.java
...n/java/com/dianping/cat/report/task/spi/GraphCreator.java
+0
-14
cat-home/src/main/java/com/dianping/cat/report/task/sql/SqlReportBuilder.java
...va/com/dianping/cat/report/task/sql/SqlReportBuilder.java
+21
-22
cat-home/src/main/java/com/dianping/cat/report/task/state/StateReportBuilder.java
...om/dianping/cat/report/task/state/StateReportBuilder.java
+23
-24
cat-home/src/main/java/com/dianping/cat/report/task/thread/TaskProducer.java
...ava/com/dianping/cat/report/task/thread/TaskProducer.java
+0
-199
cat-home/src/main/java/com/dianping/cat/report/task/transaction/TransactionGraphCreator.java
.../cat/report/task/transaction/TransactionGraphCreator.java
+1
-3
cat-home/src/main/java/com/dianping/cat/report/task/transaction/TransactionReportBuilder.java
...cat/report/task/transaction/TransactionReportBuilder.java
+36
-37
cat-home/src/main/webapp/css/body.css
cat-home/src/main/webapp/css/body.css
+16
-0
cat-home/src/main/webapp/jsp/report/dependency/dependencyDashboard.jsp
...main/webapp/jsp/report/dependency/dependencyDashboard.jsp
+5
-5
cat-home/src/main/webapp/jsp/report/metric.jsp
cat-home/src/main/webapp/jsp/report/metric.jsp
+1
-1
cat-home/src/main/webapp/jsp/report/problem/problemHistoryReport.jsp
...c/main/webapp/jsp/report/problem/problemHistoryReport.jsp
+14
-47
cat-home/src/main/webapp/jsp/report/problem/problemQuery.jsp
cat-home/src/main/webapp/jsp/report/problem/problemQuery.jsp
+61
-0
cat-home/src/main/webapp/jsp/report/problem/problemStatics.jsp
...ome/src/main/webapp/jsp/report/problem/problemStatics.jsp
+13
-46
cat-home/src/test/java/com/dianping/cat/AllTests.java
cat-home/src/test/java/com/dianping/cat/AllTests.java
+6
-0
未找到文件。
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/advanced/MetricAnalyzer.java
浏览文件 @
3954d7df
...
...
@@ -31,8 +31,11 @@ import com.dianping.cat.message.Message;
import
com.dianping.cat.message.Metric
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.spi.MessageTree
;
import
com.dianping.cat.service.ReportConstants
;
import
com.dianping.cat.storage.Bucket
;
import
com.dianping.cat.storage.BucketManager
;
import
com.dianping.cat.task.TaskManager
;
import
com.dianping.cat.task.TaskManager.TaskProlicy
;
public
class
MetricAnalyzer
extends
AbstractMessageAnalyzer
<
MetricReport
>
implements
LogEnabled
{
public
static
final
String
ID
=
"metric"
;
...
...
@@ -52,9 +55,12 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
@Inject
private
ABTestCodec
m_codec
;
@Inject
private
TaskManager
m_taskManager
;
// key is project line,such as tuangou
private
Map
<
String
,
MetricReport
>
m_reports
=
new
HashMap
<
String
,
MetricReport
>();
@Override
public
void
doCheckpoint
(
boolean
atEnd
)
{
storeReports
(
atEnd
);
...
...
@@ -65,7 +71,6 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
m_logger
=
logger
;
}
public
MetricReport
getReport
(
String
product
)
{
MetricReport
report
=
m_reports
.
get
(
product
);
...
...
@@ -166,7 +171,8 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
if
(
config
!=
null
)
{
long
current
=
metric
.
getTimestamp
()
/
1000
/
60
;
int
min
=
(
int
)
(
current
%
(
60
));
MetricItem
metricItem
=
report
.
findOrCreateMetricItem
(
name
);
String
key
=
m_configManager
.
buildMetricKey
(
domain
,
"Metric"
,
name
);
MetricItem
metricItem
=
report
.
findOrCreateMetricItem
(
key
);
Map
<
String
,
String
>
abtests
=
parseABTests
(
type
);
metricItem
.
addDomain
(
domain
).
setType
(
status
);
...
...
@@ -245,7 +251,7 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
long
current
=
transaction
.
getTimestamp
()
/
1000
/
60
;
int
min
=
(
int
)
(
current
%
(
60
));
double
sum
=
transaction
.
getDurationInMicros
();
MetricItem
metricItem
=
report
.
findOrCreateMetricItem
(
name
);
MetricItem
metricItem
=
report
.
findOrCreateMetricItem
(
key
);
Map
<
String
,
String
>
abtests
=
parseABtests
(
transaction
);
metricItem
.
addDomain
(
domain
).
setType
(
"C"
);
...
...
@@ -300,6 +306,8 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
Cat
.
getProducer
().
logError
(
e
);
}
}
//for create baseline for metric
m_taskManager
.
createTask
(
period
,
ReportConstants
.
CAT
,
ID
,
TaskProlicy
.
DAILY
);
}
}
catch
(
Exception
e
)
{
Cat
.
getProducer
().
logError
(
e
);
...
...
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
浏览文件 @
3954d7df
...
...
@@ -58,7 +58,7 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
MessageAnalyzer
.
class
,
MetricAnalyzer
.
ID
,
MetricAnalyzer
.
class
).
is
(
PER_LOOKUP
)
//
.
req
(
BucketManager
.
class
,
BusinessReportDao
.
class
,
MetricConfigManager
.
class
)
//
.
req
(
ProductLineConfigManager
.
class
,
ABTestCodec
.
class
));
.
req
(
ProductLineConfigManager
.
class
,
ABTestCodec
.
class
,
TaskManager
.
class
));
all
.
add
(
C
(
Module
.
class
,
CatConsumerAdvancedModule
.
ID
,
CatConsumerAdvancedModule
.
class
));
...
...
cat-consumer-advanced/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
3954d7df
...
...
@@ -135,6 +135,9 @@
<requirement>
<role>
com.dianping.cat.abtest.spi.internal.ABTestCodec
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.task.TaskManager
</role>
</requirement>
</requirements>
</component>
<component>
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/core/problem/LongExecutionProblemHandler.java
浏览文件 @
3954d7df
...
...
@@ -18,24 +18,30 @@ import com.dianping.cat.message.spi.MessageTree;
public
class
LongExecutionProblemHandler
extends
ProblemHandler
implements
Initializable
{
public
static
final
String
ID
=
"long-execution"
;
@Inject
private
ServerConfigManager
m_configManager
;
private
int
m_defaultCacheThreshold
=
10
;
private
int
[]
m_defaultLongServiceDuration
=
{
50
,
100
,
500
,
1000
,
3000
,
5000
};
private
int
[]
m_defaultLongSqlDuration
=
{
100
,
500
,
1000
,
3000
};
private
int
[]
m_defaultLongSqlDuration
=
{
100
,
500
,
1000
,
3000
,
5000
};
private
int
[]
m_defaultLongUrlDuration
=
{
1000
,
2000
,
3000
,
5000
};
private
int
[]
m_defalutLongCallDuration
=
{
100
,
500
,
1000
,
3000
,
5000
};
private
int
[]
m_defaultLongCacheDuration
=
{
10
,
50
,
100
,
500
};
private
Map
<
String
,
Integer
>
m_longServiceThresholds
=
new
HashMap
<
String
,
Integer
>();
private
Map
<
String
,
Integer
>
m_longSqlThresholds
=
new
HashMap
<
String
,
Integer
>();
private
Map
<
String
,
Integer
>
m_longUrlThresholds
=
new
HashMap
<
String
,
Integer
>();
private
Map
<
String
,
Integer
>
m_longCallThresholds
=
new
HashMap
<
String
,
Integer
>();
private
Map
<
String
,
Integer
>
m_longCacheThresholds
=
new
HashMap
<
String
,
Integer
>();
public
int
computeLongDuration
(
long
duration
,
String
domain
,
int
[]
defaultLongDuration
,
Map
<
String
,
Integer
>
longThresholds
)
{
int
[]
messageDuration
=
defaultLongDuration
;
...
...
@@ -95,8 +101,10 @@ public class LongExecutionProblemHandler extends ProblemHandler implements Initi
private
int
processLongCache
(
Machine
machine
,
Transaction
transaction
,
MessageTree
tree
,
int
count
)
{
long
duration
=
((
Transaction
)
transaction
).
getDurationInMillis
();
long
nomarizeDuration
=
computeLongDuration
(
duration
,
tree
.
getDomain
(),
m_defaultLongCacheDuration
,
m_longCacheThresholds
);
if
(
duration
>
m_defaultCacheThreshold
)
{
if
(
nomarizeDuration
>
0
)
{
String
type
=
ProblemType
.
LONG_CACHE
.
getName
();
String
status
=
transaction
.
getName
();
...
...
@@ -134,6 +142,22 @@ public class LongExecutionProblemHandler extends ProblemHandler implements Initi
return
count
;
}
private
int
processLongCall
(
Machine
machine
,
Transaction
transaction
,
MessageTree
tree
,
int
count
)
{
long
duration
=
transaction
.
getDurationInMillis
();
String
domain
=
tree
.
getDomain
();
long
nomarizeDuration
=
computeLongDuration
(
duration
,
domain
,
m_defalutLongCallDuration
,
m_longCallThresholds
);
if
(
nomarizeDuration
>
0
)
{
String
type
=
ProblemType
.
LONG_CALL
.
getName
();
String
status
=
transaction
.
getName
();
Entry
entry
=
findOrCreateEntry
(
machine
,
type
,
status
);
updateEntry
(
tree
,
entry
,
(
int
)
nomarizeDuration
);
count
++;
}
return
count
;
}
private
int
processLongSql
(
Machine
machine
,
Transaction
transaction
,
MessageTree
tree
,
int
count
)
{
long
duration
=
transaction
.
getDurationInMillis
();
String
domain
=
tree
.
getDomain
();
...
...
@@ -181,6 +205,8 @@ public class LongExecutionProblemHandler extends ProblemHandler implements Initi
count
=
processLongCache
(
machine
,
transaction
,
tree
,
count
);
}
else
if
(
transactionType
.
equals
(
"SQL"
))
{
count
=
processLongSql
(
machine
,
transaction
,
tree
,
count
);
}
else
if
(
transactionType
.
equals
(
"Call"
)
||
transactionType
.
equals
(
"PigeonCall"
))
{
count
=
processLongCall
(
machine
,
transaction
,
tree
,
count
);
}
List
<
Message
>
messageList
=
transaction
.
getChildren
();
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/core/problem/ProblemType.java
浏览文件 @
3954d7df
...
...
@@ -9,6 +9,8 @@ public enum ProblemType {
LONG_SQL
(
"long-sql"
),
LONG_CALL
(
"long-call"
),
LONG_URL
(
"long-url"
),
LONG_SERVICE
(
"long-service"
),
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionDelegate.java
浏览文件 @
3954d7df
...
...
@@ -20,7 +20,7 @@ public class TransactionDelegate implements ReportDelegate<TransactionReport> {
@Inject
private
TaskManager
m_taskManager
;
@Override
public
void
afterLoad
(
Map
<
String
,
TransactionReport
>
reports
)
{
}
...
...
@@ -34,9 +34,11 @@ public class TransactionDelegate implements ReportDelegate<TransactionReport> {
domainNames
.
addAll
(
reports
.
keySet
());
}
TransactionReport
all
=
createAggregatedTypeReport
(
reports
);
if
(
reports
.
size
()
>
0
)
{
TransactionReport
all
=
createAggregatedTypeReport
(
reports
);
reports
.
put
(
all
.
getDomain
(),
all
);
reports
.
put
(
all
.
getDomain
(),
all
);
}
}
@Override
...
...
@@ -65,7 +67,6 @@ public class TransactionDelegate implements ReportDelegate<TransactionReport> {
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
return
all
;
}
...
...
cat-core/src/main/java/com/dianping/cat/service/DefaultReportService.java
浏览文件 @
3954d7df
...
...
@@ -188,27 +188,17 @@ public class DefaultReportService<T> extends ContainerHolder implements ReportSe
long
startTime
=
request
.
getStartTime
();
String
name
=
request
.
getReportName
();
ReportDelegate
<
T
>
delegate
=
lookup
(
ReportDelegate
.
class
,
name
);
T
result
=
delegate
.
makeReport
(
domain
,
startTime
,
ReportConstants
.
HOUR
);
try
{
List
<
MonthlyReport
>
reports
=
m_monthlyReportDao
.
findAllByPeriodDomainName
(
new
Date
(
startTime
),
domain
,
name
,
MonthlyReport
report
=
m_monthlyReportDao
.
findReportByDomainNamePeriod
(
new
Date
(
startTime
),
domain
,
name
,
MonthlyReportEntity
.
READSET_FULL
);
for
(
MonthlyReport
report
:
reports
)
{
try
{
String
xml
=
report
.
getContent
();
T
model
=
delegate
.
parseXml
(
xml
);
result
=
delegate
.
mergeReport
(
result
,
model
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
String
xml
=
report
.
getContent
();
return
delegate
.
parseXml
(
xml
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
return
result
;
return
delegate
.
makeReport
(
domain
,
startTime
,
ReportConstants
.
DAY
*
30
);
}
@Override
...
...
@@ -222,27 +212,17 @@ public class DefaultReportService<T> extends ContainerHolder implements ReportSe
long
startTime
=
request
.
getStartTime
();
String
name
=
request
.
getReportName
();
ReportDelegate
<
T
>
delegate
=
lookup
(
ReportDelegate
.
class
,
name
);
T
result
=
delegate
.
makeReport
(
domain
,
startTime
,
ReportConstants
.
HOUR
);
try
{
List
<
WeeklyReport
>
reports
=
m_weeklyReportDao
.
findAllByPeriodDomainName
(
new
Date
(
startTime
),
domain
,
name
,
WeeklyReport
report
=
m_weeklyReportDao
.
findReportByDomainNamePeriod
(
new
Date
(
startTime
),
domain
,
name
,
WeeklyReportEntity
.
READSET_FULL
);
String
xml
=
report
.
getContent
();
for
(
WeeklyReport
report
:
reports
)
{
try
{
String
xml
=
report
.
getContent
();
T
model
=
delegate
.
parseXml
(
xml
);
result
=
delegate
.
mergeReport
(
result
,
model
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
return
delegate
.
parseXml
(
xml
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
return
result
;
return
delegate
.
makeReport
(
domain
,
startTime
,
ReportConstants
.
WEEK
);
}
@Override
...
...
cat-core/src/main/java/com/dianping/cat/task/TaskManager.java
浏览文件 @
3954d7df
...
...
@@ -128,29 +128,29 @@ public class TaskManager {
}
},
HOULY
{
HOULY
{
@Override
public
boolean
shouldCreateHourlyTask
()
{
return
true
;
}
public
boolean
shouldCreateHourlyTask
()
{
return
true
;
}
@Override
public
boolean
shouldCreateDailyTask
()
{
return
false
;
}
public
boolean
shouldCreateDailyTask
()
{
return
false
;
}
@Override
public
boolean
shouldCreateWeeklyTask
()
{
return
false
;
}
public
boolean
shouldCreateWeeklyTask
()
{
return
false
;
}
@Override
public
boolean
shouldCreateMonthTask
()
{
return
false
;
}
public
boolean
shouldCreateMonthTask
()
{
return
false
;
}
},
ALL_EXCLUED_HOURLY
{
...
...
@@ -174,6 +174,29 @@ public class TaskManager {
public
boolean
shouldCreateMonthTask
()
{
return
true
;
}
},
DAILY
{
@Override
public
boolean
shouldCreateHourlyTask
()
{
return
false
;
}
@Override
public
boolean
shouldCreateDailyTask
()
{
return
true
;
}
@Override
public
boolean
shouldCreateWeeklyTask
()
{
return
false
;
}
@Override
public
boolean
shouldCreateMonthTask
()
{
return
false
;
}
};
}
...
...
cat-core/src/main/resources/META-INF/dal/jdbc/report-dal.xml
浏览文件 @
3954d7df
...
...
@@ -531,18 +531,6 @@
<entity
name=
"monthreport"
table=
"monthreport"
alias=
"m"
class-name=
"MonthlyReport"
>
<member
name=
"creation-date"
insert-expr=
"NOW()"
/>
<query-defs>
<query
name=
"find-all-by-period-domain-name"
type=
"SELECT"
multiple=
"true"
>
<param
name=
"period"
/>
<param
name=
"domain"
/>
<param
name=
"name"
/>
<statement>
<![CDATA[
SELECT <FIELDS/>
FROM
<TABLE/>
WHERE
<FIELD
name=
'period'
/>
= ${period}
AND
<FIELD
name=
'domain'
/>
= ${domain}
AND
<FIELD
name=
'name'
/>
= ${name}
]]>
</statement>
</query>
<query
name=
"find-report-by-domain-name-period"
type=
"SELECT"
>
<param
name=
"period"
/>
<param
name=
"domain"
/>
...
...
@@ -561,19 +549,6 @@
<entity
name=
"weeklyreport"
table=
"weeklyreport"
alias=
"w"
class-name=
"WeeklyReport"
>
<member
name=
"creation-date"
insert-expr=
"NOW()"
/>
<query-defs>
<query
name=
"find-all-by-period-domain-name"
type=
"SELECT"
multiple=
"true"
>
<param
name=
"period"
/>
<param
name=
"domain"
/>
<param
name=
"name"
/>
<statement>
<![CDATA[
SELECT <FIELDS/>
FROM
<TABLE/>
WHERE
<FIELD
name=
'period'
/>
= ${period}
AND
<FIELD
name=
'domain'
/>
= ${domain}
AND
<FIELD
name=
'name'
/>
= ${name}
]]>
</statement>
</query>
<query
name=
"find-report-by-domain-name-period"
type=
"SELECT"
>
<param
name=
"period"
/>
<param
name=
"domain"
/>
...
...
cat-home/src/main/java/com/dianping/cat/report/baseline/BaselineConfigManager.java
浏览文件 @
3954d7df
...
...
@@ -6,15 +6,15 @@ public class BaselineConfigManager {
public
BaselineConfig
queryBaseLineConfig
(
String
key
)
{
BaselineConfig
config
=
new
BaselineConfig
();
Integer
[]
days
=
{
-
6
,
-
13
,
-
1
,
-
2
,
-
3
};
Double
[]
weights
=
{
1.0
,
1.0
,
1.0
,
1.0
,
1.0
};
Integer
[]
days
=
{
-
21
,
-
14
,
-
7
,
0
};
Double
[]
weights
=
{
1.0
,
1.0
,
1.0
,
1.0
};
config
.
setDays
(
Arrays
.
asList
(
days
));
config
.
setId
(
1
);
config
.
setKey
(
key
);
config
.
setLowerLimit
(
0.2
);
config
.
setMinValue
(
100
);
config
.
setTargetDate
(
1
);
config
.
setTargetDate
(
7
);
config
.
setUpperLimit
(
5
);
config
.
setWeights
(
Arrays
.
asList
(
weights
));
return
config
;
...
...
cat-home/src/main/java/com/dianping/cat/report/baseline/BaselineService.java
浏览文件 @
3954d7df
package
com.dianping.cat.report.baseline
;
import
java.io.IOException
;
import
java.util.Date
;
import
org.unidal.dal.jdbc.DalException
;
import
com.dianping.cat.home.dal.report.Baseline
;
public
interface
BaselineService
{
public
double
[]
queryDailyBaseline
(
String
reportName
,
String
key
,
Date
reportPeriod
)
throws
DalException
,
IOException
;
public
double
[]
queryDailyBaseline
(
String
reportName
,
String
key
,
Date
reportPeriod
);
public
double
[]
queryHourlyBaseline
(
String
reportName
,
String
key
,
Date
reportPeriod
)
throws
DalException
,
IOException
;
public
double
[]
queryHourlyBaseline
(
String
reportName
,
String
key
,
Date
reportPeriod
);
public
void
insertBaseline
(
Baseline
baseline
);
}
cat-home/src/main/java/com/dianping/cat/report/baseline/impl/DefaultBaselineService.java
浏览文件 @
3954d7df
...
...
@@ -7,9 +7,14 @@ import java.io.DataOutputStream;
import
java.io.IOException
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
import
org.unidal.dal.jdbc.DalException
;
import
org.unidal.dal.jdbc.DalNotFoundException
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.Cat
;
...
...
@@ -20,38 +25,54 @@ import com.dianping.cat.home.dal.report.BaselineEntity;
import
com.dianping.cat.report.baseline.BaselineService
;
import
com.dianping.cat.report.task.TaskHelper
;
public
class
DefaultBaselineService
implements
BaselineService
{
public
class
DefaultBaselineService
implements
BaselineService
,
LogEnabled
{
@Inject
private
BaselineDao
m_baselineDao
;
private
Map
<
String
,
Map
<
String
,
Baseline
>>
m_baselineMap
=
new
HashMap
<
String
,
Map
<
String
,
Baseline
>>();
private
Map
<
String
,
Map
<
String
,
Baseline
>>
m_baselines
=
new
HashMap
<
String
,
Map
<
String
,
Baseline
>>();
private
Map
<
String
,
Baseline
>
m_baselineMaps
=
new
LinkedHashMap
<
String
,
Baseline
>(
1000
)
{
private
static
final
long
serialVersionUID
=
1L
;
@Override
protected
boolean
removeEldestEntry
(
Entry
<
String
,
Baseline
>
eldest
)
{
return
true
;
}
};
private
Logger
m_logger
;
@Override
public
double
[]
queryDailyBaseline
(
String
reportName
,
String
key
,
Date
reportPeriod
)
throws
DalException
,
IOException
{
public
double
[]
queryDailyBaseline
(
String
reportName
,
String
key
,
Date
reportPeriod
)
{
double
[]
result
=
new
double
[
24
*
60
];
Baseline
baseline
=
queryFromMap
(
reportName
,
key
,
reportPeriod
);
if
(
baseline
==
null
)
{
baseline
=
m_baselineDao
.
findByReportNameKeyTime
(
reportPeriod
,
reportName
,
key
,
BaselineEntity
.
READSET_FULL
);
addBaselineToMap
(
m_baselineMap
,
baseline
,
reportName
,
key
);
try
{
baseline
=
m_baselineDao
.
findByReportNameKeyTime
(
reportPeriod
,
reportName
,
key
,
BaselineEntity
.
READSET_FULL
);
addBaselineToMap
(
baseline
,
reportName
,
key
);
result
=
parse
(
baseline
.
getData
());
return
result
;
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
result
=
parse
(
baseline
.
getData
());
return
result
;
}
private
void
addBaselineToMap
(
Map
<
String
,
Map
<
String
,
Baseline
>>
allBaselineMap
,
Baseline
baseline
,
String
reportName
,
String
key
)
{
Map
<
String
,
Baseline
>
baselineMap
=
m_baselineMap
.
get
(
reportName
);
private
void
addBaselineToMap
(
Baseline
baseline
,
String
reportName
,
String
key
)
{
Map
<
String
,
Baseline
>
baselineMap
=
m_baselines
.
get
(
reportName
);
if
(
baselineMap
==
null
)
{
baselineMap
=
new
HashMap
<
String
,
Baseline
>();
m_baseline
Map
.
put
(
reportName
,
baselineMap
);
m_baseline
s
.
put
(
reportName
,
baselineMap
);
}
baselineMap
.
put
(
key
,
baseline
);
}
private
Baseline
queryFromMap
(
String
reportName
,
String
key
,
Date
reportPeriod
)
{
Map
<
String
,
Baseline
>
baselineMap
=
m_baseline
Map
.
get
(
reportName
);
Map
<
String
,
Baseline
>
baselineMap
=
m_baseline
s
.
get
(
reportName
);
if
(
baselineMap
==
null
)
{
return
null
;
}
...
...
@@ -63,17 +84,23 @@ public class DefaultBaselineService implements BaselineService {
}
@Override
public
double
[]
queryHourlyBaseline
(
String
reportName
,
String
key
,
Date
reportPeriod
)
throws
DalException
,
IOException
{
public
double
[]
queryHourlyBaseline
(
String
reportName
,
String
key
,
Date
reportPeriod
)
{
double
[]
result
=
new
double
[
60
];
Date
today
=
TaskHelper
.
todayZero
(
reportPeriod
);
int
hour
=
(
int
)
((
reportPeriod
.
getTime
()
-
today
.
getTime
())
/
TimeUtil
.
ONE_HOUR
);
Baseline
baseline
=
m_baselineDao
.
findByReportNameKeyTime
(
today
,
reportName
,
key
,
BaselineEntity
.
READSET_FULL
);
double
[]
dayResult
=
parse
(
baseline
.
getData
());
for
(
int
i
=
0
;
i
<
60
;
i
++)
{
result
[
i
]
=
dayResult
[
hour
*
60
+
i
];
try
{
Baseline
baseline
=
m_baselineDao
.
findByReportNameKeyTime
(
today
,
reportName
,
key
,
BaselineEntity
.
READSET_FULL
);
double
[]
dayResult
=
parse
(
baseline
.
getData
());
for
(
int
i
=
0
;
i
<
60
;
i
++)
{
result
[
i
]
=
dayResult
[
hour
*
60
+
i
];
}
return
result
;
}
catch
(
DalNotFoundException
e
)
{
m_logger
.
warn
(
"base line cant't be fonund!"
+
reportName
+
" "
+
key
+
" "
+
reportPeriod
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
return
result
;
return
null
;
}
@Override
...
...
@@ -92,8 +119,8 @@ public class DefaultBaselineService implements BaselineService {
double
[]
result
;
ByteArrayInputStream
input
=
new
ByteArrayInputStream
(
datas
);
DataInputStream
dataInput
=
new
DataInputStream
(
input
);
int
size
=
dataInput
.
readInt
();
result
=
new
double
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
result
[
i
]
=
dataInput
.
readDouble
();
...
...
@@ -112,4 +139,9 @@ public class DefaultBaselineService implements BaselineService {
return
out
.
toByteArray
();
}
@Override
public
void
enableLogging
(
Logger
logger
)
{
m_logger
=
logger
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/problem/Handler.java
浏览文件 @
3954d7df
...
...
@@ -72,11 +72,11 @@ public class Handler implements PageHandler<Context> {
private
ProblemReport
getHourlyReport
(
Payload
payload
,
String
type
)
{
ProblemReport
report
=
getHourlyReportInternal
(
payload
,
type
);
if
(
"FrontEnd"
.
equals
(
payload
.
getDomain
()))
{
//ModelPeriod period = payload.getPeriod();
//
ModelPeriod period = payload.getPeriod();
//if (period == ModelPeriod.CURRENT || period == ModelPeriod.LAST) {
report
=
buildFrontEndByRule
(
report
);
//}
//
if (period == ModelPeriod.CURRENT || period == ModelPeriod.LAST) {
report
=
buildFrontEndByRule
(
report
);
//
}
}
return
report
;
}
...
...
@@ -89,7 +89,7 @@ public class Handler implements PageHandler<Context> {
private
ProblemReport
getHourlyReportInternal
(
Payload
payload
,
String
type
)
{
String
domain
=
payload
.
getDomain
();
ModelRequest
request
=
new
ModelRequest
(
domain
,
payload
.
getDate
())
//
.
setProperty
(
"type"
,
type
);
.
setProperty
(
"type"
,
type
);
if
(!
CatString
.
ALL
.
equals
(
payload
.
getIpAddress
()))
{
request
.
setProperty
(
"ip"
,
payload
.
getIpAddress
());
}
...
...
@@ -141,10 +141,12 @@ public class Handler implements PageHandler<Context> {
ProblemReport
report
=
null
;
ProblemStatistics
problemStatistics
=
new
ProblemStatistics
();
String
ip
=
model
.
getIpAddress
();
int
urlThreshold
=
payload
.
getLongTime
();
int
sqlThreshold
=
payload
.
getSqlLongTime
();
int
serviceThreshold
=
payload
.
getSeviceLongTime
();
LongConfig
longConfig
=
new
LongConfig
();
longConfig
.
setSqlThreshold
(
payload
.
getSqlThreshold
()).
setUrlThreshold
(
payload
.
getUrlThreshold
())
.
setServiceThreshold
(
payload
.
getServiceThreshold
());
longConfig
.
setCacheThreshold
(
payload
.
getCacheThreshold
()).
setCallThreshold
(
payload
.
getCallThreshold
());
problemStatistics
.
setLongConfig
(
longConfig
);
switch
(
payload
.
getAction
())
{
case
VIEW:
report
=
getHourlyReport
(
payload
,
VIEW
);
...
...
@@ -154,20 +156,16 @@ public class Handler implements PageHandler<Context> {
}
else
{
problemStatistics
.
setIp
(
ip
);
}
problemStatistics
.
setSqlThreshold
(
sqlThreshold
).
setUrlThreshold
(
urlThreshold
)
.
setServiceThreshold
(
serviceThreshold
);
problemStatistics
.
visitProblemReport
(
report
);
model
.
setAllStatistics
(
problemStatistics
);
break
;
case
HISTORY:
report
=
showSummarizeReport
(
model
,
payload
);
if
(
ip
.
equals
(
CatString
.
ALL
))
{
problemStatistics
.
setAllIp
(
true
).
setSqlThreshold
(
sqlThreshold
).
setUrlThreshold
(
urlThreshold
)
.
setServiceThreshold
(
serviceThreshold
);
problemStatistics
.
setAllIp
(
true
);
problemStatistics
.
visitProblemReport
(
report
);
}
else
{
problemStatistics
.
setIp
(
ip
).
setSqlThreshold
(
sqlThreshold
).
setUrlThreshold
(
urlThreshold
)
.
setServiceThreshold
(
serviceThreshold
);
problemStatistics
.
setIp
(
ip
);
problemStatistics
.
visitProblemReport
(
report
);
}
model
.
setReport
(
report
);
...
...
@@ -210,10 +208,6 @@ public class Handler implements PageHandler<Context> {
private
void
normalize
(
Model
model
,
Payload
payload
)
{
setDefaultThreshold
(
model
,
payload
);
model
.
setPage
(
ReportPage
.
PROBLEM
);
model
.
setThreshold
(
payload
.
getLongTime
());
model
.
setSqlThreshold
(
payload
.
getSqlLongTime
());
model
.
setServiceThreshold
(
payload
.
getSeviceLongTime
());
m_normalizePayload
.
normalize
(
model
,
payload
);
}
...
...
@@ -225,10 +219,6 @@ public class Handler implements PageHandler<Context> {
int
longUrlTime
=
d
.
getUrlThreshold
()
==
null
?
m_manager
.
getLongUrlDefaultThreshold
()
:
d
.
getUrlThreshold
()
.
intValue
();
if
(
payload
.
getRealLongTime
()
==
0
)
{
payload
.
setLongTime
(
longUrlTime
);
}
if
(
longUrlTime
!=
500
&&
longUrlTime
!=
1000
&&
longUrlTime
!=
2000
&&
longUrlTime
!=
3000
&&
longUrlTime
!=
4000
&&
longUrlTime
!=
5000
)
{
double
sec
=
(
double
)
(
longUrlTime
)
/
(
double
)
1000
;
...
...
@@ -239,9 +229,6 @@ public class Handler implements PageHandler<Context> {
}
int
longSqlTime
=
d
.
getSqlThreshold
();
if
(
payload
.
getSqlLongTime
()
==
0
)
{
payload
.
setSqlLongTime
(
longSqlTime
);
}
if
(
longSqlTime
!=
100
&&
longSqlTime
!=
500
&&
longSqlTime
!=
1000
)
{
double
sec
=
(
double
)
(
longSqlTime
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/problem/LongConfig.java
0 → 100644
浏览文件 @
3954d7df
package
com.dianping.cat.report.page.problem
;
public
class
LongConfig
{
private
int
m_sqlThreshold
=
50
;
private
int
m_urlThreshold
=
1000
;
private
int
m_serviceThreshold
=
50
;
private
int
m_cacheThreshold
=
10
;
private
int
m_callThreshold
=
50
;
public
int
getCacheThreshold
()
{
return
m_cacheThreshold
;
}
public
int
getCallThreshold
()
{
return
m_callThreshold
;
}
public
int
getServiceThreshold
()
{
return
m_serviceThreshold
;
}
public
int
getSqlThreshold
()
{
return
m_sqlThreshold
;
}
public
int
getUrlThreshold
()
{
return
m_urlThreshold
;
}
public
LongConfig
setCacheThreshold
(
int
cacheThreshold
)
{
m_cacheThreshold
=
cacheThreshold
;
return
this
;
}
public
LongConfig
setCallThreshold
(
int
callThreshold
)
{
m_callThreshold
=
callThreshold
;
return
this
;
}
public
LongConfig
setServiceThreshold
(
int
serviceThreshold
)
{
m_serviceThreshold
=
serviceThreshold
;
return
this
;
}
public
LongConfig
setSqlThreshold
(
int
sqlThreshold
)
{
m_sqlThreshold
=
sqlThreshold
;
return
this
;
}
public
LongConfig
setUrlThreshold
(
int
urlThreshold
)
{
m_urlThreshold
=
urlThreshold
;
return
this
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/problem/Model.java
浏览文件 @
3954d7df
...
...
@@ -35,16 +35,10 @@ public class Model extends AbstractReportModel<Action, Context> {
private
ProblemReport
m_report
;
private
int
m_sqlThreshold
;
private
int
m_serviceThreshold
;
private
String
m_threadId
;
private
ThreadLevelInfo
m_threadLevelInfo
;
private
int
m_threshold
;
public
Model
(
Context
ctx
)
{
super
(
ctx
);
}
...
...
@@ -151,14 +145,6 @@ public class Model extends AbstractReportModel<Action, Context> {
return
m_report
;
}
public
int
getServiceThreshold
()
{
return
m_serviceThreshold
;
}
public
int
getSqlThreshold
()
{
return
m_sqlThreshold
;
}
public
String
getThreadId
()
{
return
m_threadId
;
}
...
...
@@ -167,10 +153,6 @@ public class Model extends AbstractReportModel<Action, Context> {
return
m_threadLevelInfo
;
}
public
int
getThreshold
()
{
return
m_threshold
;
}
public
void
setAllStatistics
(
ProblemStatistics
allStatistics
)
{
m_allStatistics
=
allStatistics
;
}
...
...
@@ -223,14 +205,6 @@ public class Model extends AbstractReportModel<Action, Context> {
m_report
=
report
;
}
public
void
setServiceThreshold
(
int
serviceLongTime
)
{
m_serviceThreshold
=
serviceLongTime
;
}
public
void
setSqlThreshold
(
int
sqlThreshold
)
{
m_sqlThreshold
=
sqlThreshold
;
}
public
void
setThreadId
(
String
threadId
)
{
m_threadId
=
threadId
;
}
...
...
@@ -239,8 +213,4 @@ public class Model extends AbstractReportModel<Action, Context> {
m_threadLevelInfo
=
threadLevelInfo
;
}
public
void
setThreshold
(
int
threshold
)
{
m_threshold
=
threshold
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/problem/Payload.java
浏览文件 @
3954d7df
...
...
@@ -16,17 +16,23 @@ public class Payload extends AbstractReportPayload<Action> {
@FieldMeta
(
"linkCount"
)
private
int
m_linkCount
;
@FieldMeta
(
"
t
hreshold"
)
private
int
m_
longTime
;
@FieldMeta
(
"
urlT
hreshold"
)
private
int
m_
urlThreshold
=
1000
;
@FieldMeta
(
"minute"
)
private
int
m_minute
;
@FieldMeta
(
"sqlThreshold"
)
private
int
m_sql
LongTime
;
private
int
m_sql
Threshold
=
100
;
@FieldMeta
(
"serviceThreshold"
)
private
int
m_seviceLongTime
;
private
int
m_serviceThreshold
=
50
;
@FieldMeta
(
"cacheThreshold"
)
private
int
m_cacheThreshold
=
10
;
@FieldMeta
(
"callThreshold"
)
private
int
m_callThreshold
=
50
;
@FieldMeta
(
"status"
)
private
String
m_status
;
...
...
@@ -41,6 +47,16 @@ public class Payload extends AbstractReportPayload<Action> {
super
(
ReportPage
.
PROBLEM
);
}
public
String
getQueryString
(){
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"&urlThreshold="
).
append
(
m_urlThreshold
);
sb
.
append
(
"&sqlThreshold="
).
append
(
m_sqlThreshold
);
sb
.
append
(
"&serviceThreshold="
).
append
(
m_serviceThreshold
);
sb
.
append
(
"&cacheThreshold="
).
append
(
m_cacheThreshold
);
sb
.
append
(
"&callThreshold="
).
append
(
m_callThreshold
);
return
sb
.
toString
();
}
@Override
public
Action
getAction
()
{
return
m_action
;
...
...
@@ -57,27 +73,44 @@ public class Payload extends AbstractReportPayload<Action> {
return
m_linkCount
;
}
public
int
getLongTime
()
{
if
(
m_longTime
==
0
)
{
m_longTime
=
1000
;
}
return
m_longTime
;
public
int
getSqlThreshold
()
{
return
m_sqlThreshold
;
}
public
int
getMinute
()
{
return
m_minute
;
public
void
setSqlThreshold
(
int
sqlThreshold
)
{
m_sqlThreshold
=
sqlThreshold
;
}
public
int
getServiceThreshold
()
{
return
m_serviceThreshold
;
}
public
void
setServiceThreshold
(
int
serviceThreshold
)
{
m_serviceThreshold
=
serviceThreshold
;
}
public
int
get
RealLongTime
()
{
return
m_
longTime
;
public
int
get
CacheThreshold
()
{
return
m_
cacheThreshold
;
}
public
int
getSeviceLongTime
(
)
{
return
m_seviceLongTime
;
public
void
setCacheThreshold
(
int
cacheThreshold
)
{
m_cacheThreshold
=
cacheThreshold
;
}
public
int
getSqlLongTime
()
{
return
m_sqlLongTime
;
public
int
getCallThreshold
()
{
return
m_callThreshold
;
}
public
void
setCallThreshold
(
int
callThreshold
)
{
m_callThreshold
=
callThreshold
;
}
public
int
getUrlThreshold
()
{
return
m_urlThreshold
;
}
public
int
getMinute
()
{
return
m_minute
;
}
public
String
getStatus
()
{
...
...
@@ -104,22 +137,14 @@ public class Payload extends AbstractReportPayload<Action> {
m_linkCount
=
linkSize
;
}
public
void
set
LongTime
(
int
longTime
)
{
m_
longTime
=
longTime
;
public
void
set
UrlThreshold
(
int
longTime
)
{
m_
urlThreshold
=
longTime
;
}
public
void
setMinute
(
int
minute
)
{
m_minute
=
minute
;
}
public
void
setSeviceLongTime
(
int
seviceLongTime
)
{
m_seviceLongTime
=
seviceLongTime
;
}
public
void
setSqlLongTime
(
int
sqlLongTime
)
{
m_sqlLongTime
=
sqlLongTime
;
}
public
void
setStatus
(
String
status
)
{
m_status
=
status
;
}
...
...
cat-home/src/main/java/com/dianping/cat/report/page/problem/ProblemStatistics.java
浏览文件 @
3954d7df
...
...
@@ -26,30 +26,38 @@ public class ProblemStatistics extends BaseVisitor {
private
String
m_ip
=
""
;
private
List
<
String
>
m_ips
;
private
int
m_sqlThreshold
=
100
;
private
int
m_urlThreshold
=
1000
;
private
int
m_serviceThreshold
=
50
;
private
LongConfig
m_longConfig
=
new
LongConfig
();
private
List
<
Duration
>
getDurationsByType
(
String
type
,
Entry
entry
)
{
List
<
Duration
>
durations
=
new
ArrayList
<
Duration
>();
if
(
ProblemType
.
LONG_URL
.
getName
().
equals
(
type
))
{
for
(
java
.
util
.
Map
.
Entry
<
Integer
,
Duration
>
temp
:
entry
.
getDurations
().
entrySet
())
{
if
(
temp
.
getKey
()
>=
m_
urlThreshold
)
{
if
(
temp
.
getKey
()
>=
m_
longConfig
.
getUrlThreshold
()
)
{
durations
.
add
(
temp
.
getValue
());
}
}
}
else
if
(
ProblemType
.
LONG_SQL
.
getName
().
equals
(
type
))
{
for
(
java
.
util
.
Map
.
Entry
<
Integer
,
Duration
>
temp
:
entry
.
getDurations
().
entrySet
())
{
if
(
temp
.
getKey
()
>=
m_
sqlThreshold
)
{
if
(
temp
.
getKey
()
>=
m_
longConfig
.
getSqlThreshold
()
)
{
durations
.
add
(
temp
.
getValue
());
}
}
}
else
if
(
ProblemType
.
LONG_SERVICE
.
getName
().
equals
(
type
))
{
for
(
java
.
util
.
Map
.
Entry
<
Integer
,
Duration
>
temp
:
entry
.
getDurations
().
entrySet
())
{
if
(
temp
.
getKey
()
>=
m_serviceThreshold
)
{
if
(
temp
.
getKey
()
>=
m_longConfig
.
getServiceThreshold
())
{
durations
.
add
(
temp
.
getValue
());
}
}
}
else
if
(
ProblemType
.
LONG_CALL
.
getName
().
equals
(
type
))
{
for
(
java
.
util
.
Map
.
Entry
<
Integer
,
Duration
>
temp
:
entry
.
getDurations
().
entrySet
())
{
if
(
temp
.
getKey
()
>=
m_longConfig
.
getCallThreshold
())
{
durations
.
add
(
temp
.
getValue
());
}
}
}
else
if
(
ProblemType
.
LONG_CACHE
.
getName
().
equals
(
type
))
{
for
(
java
.
util
.
Map
.
Entry
<
Integer
,
Duration
>
temp
:
entry
.
getDurations
().
entrySet
())
{
if
(
temp
.
getKey
()
>=
m_longConfig
.
getCacheThreshold
())
{
durations
.
add
(
temp
.
getValue
());
}
}
...
...
@@ -81,18 +89,8 @@ public class ProblemStatistics extends BaseVisitor {
m_ips
=
ips
;
}
public
ProblemStatistics
setServiceThreshold
(
int
serviceThreshold
)
{
m_serviceThreshold
=
serviceThreshold
;
return
this
;
}
public
ProblemStatistics
setSqlThreshold
(
int
sqlThreshold
)
{
m_sqlThreshold
=
sqlThreshold
;
return
this
;
}
public
ProblemStatistics
setUrlThreshold
(
int
urlThreshold
)
{
m_urlThreshold
=
urlThreshold
;
public
ProblemStatistics
setLongConfig
(
LongConfig
config
)
{
m_longConfig
=
config
;
return
this
;
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/cross/CrossReportBuilder.java
浏览文件 @
3954d7df
...
...
@@ -42,26 +42,6 @@ public class CrossReportBuilder implements ReportTaskBuilder {
throw
new
RuntimeException
(
"Cross report don't support HourReport!"
);
}
private
CrossReport
queryDailyReportsByDuration
(
String
domain
,
Date
start
,
Date
end
)
{
long
startTime
=
start
.
getTime
();
long
endTime
=
end
.
getTime
();
CrossReportMerger
merger
=
new
CrossReportMerger
(
new
CrossReport
(
domain
));
for
(;
startTime
<
endTime
;
startTime
+=
TimeUtil
.
ONE_DAY
)
{
try
{
CrossReport
reportModel
=
m_reportService
.
queryCrossReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_DAY
));
reportModel
.
accept
(
merger
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
CrossReport
crossReport
=
merger
.
getCrossReport
();
crossReport
.
setStartTime
(
start
);
crossReport
.
setEndTime
(
end
);
return
crossReport
;
}
@Override
public
boolean
buildMonthlyTask
(
String
name
,
String
domain
,
Date
period
)
{
CrossReport
crossReport
=
queryDailyReportsByDuration
(
domain
,
period
,
TaskHelper
.
nextMonthStart
(
period
));
...
...
@@ -74,7 +54,6 @@ public class CrossReportBuilder implements ReportTaskBuilder {
report
.
setName
(
name
);
report
.
setPeriod
(
period
);
report
.
setType
(
1
);
return
m_reportService
.
insertMonthlyReport
(
report
);
}
...
...
@@ -92,10 +71,29 @@ public class CrossReportBuilder implements ReportTaskBuilder {
report
.
setName
(
name
);
report
.
setPeriod
(
period
);
report
.
setType
(
1
);
return
m_reportService
.
insertWeeklyReport
(
report
);
}
private
CrossReport
queryDailyReportsByDuration
(
String
domain
,
Date
start
,
Date
end
)
{
long
startTime
=
start
.
getTime
();
long
endTime
=
end
.
getTime
();
CrossReportMerger
merger
=
new
CrossReportMerger
(
new
CrossReport
(
domain
));
for
(;
startTime
<
endTime
;
startTime
+=
TimeUtil
.
ONE_DAY
)
{
try
{
CrossReport
reportModel
=
m_reportService
.
queryCrossReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_DAY
));
reportModel
.
accept
(
merger
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
CrossReport
crossReport
=
merger
.
getCrossReport
();
crossReport
.
setStartTime
(
start
);
crossReport
.
setEndTime
(
end
);
return
crossReport
;
}
private
CrossReport
queryHourlyReportsByDuration
(
String
name
,
String
domain
,
Date
period
,
Date
endDate
)
{
Set
<
String
>
domainSet
=
m_reportService
.
queryAllDomainNames
(
period
,
endDate
,
"cross"
);
long
startTime
=
period
.
getTime
();
...
...
cat-home/src/main/java/com/dianping/cat/report/task/event/EventGraphCreator.java
浏览文件 @
3954d7df
...
...
@@ -17,10 +17,9 @@ 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.core.dal.Graph
;
import
com.dianping.cat.report.task.spi.GraphCreator
;
import
com.dianping.cat.report.task.spi.GraphLine
;
public
class
EventGraphCreator
implements
GraphCreator
<
EventReport
>
{
public
class
EventGraphCreator
{
private
long
[]
arrayAdd
(
long
[]
src
,
long
added
[])
{
int
size
=
added
.
length
;
...
...
@@ -63,7 +62,6 @@ public class EventGraphCreator implements GraphCreator<EventReport> {
return
value
;
}
@Override
public
List
<
Graph
>
splitReportToGraphs
(
Date
reportPeriod
,
String
domainName
,
String
reportName
,
EventReport
eventReport
)
{
Set
<
String
>
ips
=
eventReport
.
getIps
();
...
...
cat-home/src/main/java/com/dianping/cat/report/task/event/EventReportBuilder.java
浏览文件 @
3954d7df
...
...
@@ -41,19 +41,6 @@ public class EventReportBuilder implements ReportTaskBuilder {
@Inject
private
EventMerger
m_eventMerger
;
private
void
buildEventDailyGraph
(
EventReport
report
)
{
DailyEventGraphCreator
creator
=
new
DailyEventGraphCreator
();
List
<
DailyGraph
>
graphs
=
creator
.
buildDailygraph
(
report
);
for
(
DailyGraph
graph
:
graphs
)
{
try
{
m_dailyGraphDao
.
insert
(
graph
);
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
}
}
}
@Override
public
boolean
buildDailyTask
(
String
name
,
String
domain
,
Date
period
)
{
try
{
...
...
@@ -71,7 +58,6 @@ public class EventReportBuilder implements ReportTaskBuilder {
report
.
setName
(
name
);
report
.
setPeriod
(
period
);
report
.
setType
(
1
);
return
m_reportService
.
insertDailyReport
(
report
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
...
...
@@ -79,6 +65,33 @@ public class EventReportBuilder implements ReportTaskBuilder {
}
}
private
void
buildEventDailyGraph
(
EventReport
report
)
{
DailyEventGraphCreator
creator
=
new
DailyEventGraphCreator
();
List
<
DailyGraph
>
graphs
=
creator
.
buildDailygraph
(
report
);
for
(
DailyGraph
graph
:
graphs
)
{
try
{
m_dailyGraphDao
.
insert
(
graph
);
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
}
}
}
private
List
<
Graph
>
buildHourlyGraphs
(
String
name
,
String
domain
,
Date
period
)
throws
DalException
{
List
<
Graph
>
graphs
=
new
ArrayList
<
Graph
>();
List
<
EventReport
>
reports
=
new
ArrayList
<
EventReport
>();
long
startTime
=
period
.
getTime
();
EventReport
report
=
m_reportService
.
queryEventReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_HOUR
));
reports
.
add
(
report
);
EventReport
eventReport
=
m_eventMerger
.
mergeForGraph
(
domain
,
reports
);
graphs
=
m_eventGraphCreator
.
splitReportToGraphs
(
period
,
domain
,
name
,
eventReport
);
return
graphs
;
}
@Override
public
boolean
buildHourlyTask
(
String
name
,
String
domain
,
Date
period
)
{
try
{
...
...
@@ -95,26 +108,6 @@ public class EventReportBuilder implements ReportTaskBuilder {
return
true
;
}
private
EventReport
queryDailyReportsByDuration
(
String
domain
,
Date
start
,
Date
end
)
{
long
startTime
=
start
.
getTime
();
long
endTime
=
end
.
getTime
();
EventReportMerger
merger
=
new
EventReportMerger
(
new
EventReport
(
domain
));
for
(;
startTime
<
endTime
;
startTime
+=
TimeUtil
.
ONE_DAY
)
{
try
{
EventReport
reportModel
=
m_reportService
.
queryEventReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_DAY
));
reportModel
.
accept
(
merger
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
EventReport
eventReport
=
merger
.
getEventReport
();
eventReport
.
setStartTime
(
start
);
eventReport
.
setEndTime
(
end
);
return
eventReport
;
}
@Override
public
boolean
buildMonthlyTask
(
String
name
,
String
domain
,
Date
period
)
{
EventReport
eventReport
=
queryDailyReportsByDuration
(
domain
,
period
,
TaskHelper
.
nextMonthStart
(
period
));
...
...
@@ -127,7 +120,6 @@ public class EventReportBuilder implements ReportTaskBuilder {
report
.
setName
(
name
);
report
.
setPeriod
(
period
);
report
.
setType
(
1
);
return
m_reportService
.
insertMonthlyReport
(
report
);
}
...
...
@@ -145,10 +137,30 @@ public class EventReportBuilder implements ReportTaskBuilder {
report
.
setName
(
name
);
report
.
setPeriod
(
period
);
report
.
setType
(
1
);
return
m_reportService
.
insertWeeklyReport
(
report
);
}
private
EventReport
queryDailyReportsByDuration
(
String
domain
,
Date
start
,
Date
end
)
{
long
startTime
=
start
.
getTime
();
long
endTime
=
end
.
getTime
();
EventReportMerger
merger
=
new
EventReportMerger
(
new
EventReport
(
domain
));
for
(;
startTime
<
endTime
;
startTime
+=
TimeUtil
.
ONE_DAY
)
{
try
{
EventReport
reportModel
=
m_reportService
.
queryEventReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_DAY
));
reportModel
.
accept
(
merger
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
EventReport
eventReport
=
merger
.
getEventReport
();
eventReport
.
setStartTime
(
start
);
eventReport
.
setEndTime
(
end
);
return
eventReport
;
}
private
EventReport
queryHourlyReportsByDuration
(
String
name
,
String
domain
,
Date
start
,
Date
end
)
throws
DalException
{
Set
<
String
>
domainSet
=
m_reportService
.
queryAllDomainNames
(
start
,
end
,
"event"
);
...
...
@@ -165,18 +177,4 @@ public class EventReportBuilder implements ReportTaskBuilder {
return
m_eventMerger
.
mergeForDaily
(
domain
,
reports
,
domainSet
);
}
private
List
<
Graph
>
buildHourlyGraphs
(
String
name
,
String
domain
,
Date
period
)
throws
DalException
{
List
<
Graph
>
graphs
=
new
ArrayList
<
Graph
>();
List
<
EventReport
>
reports
=
new
ArrayList
<
EventReport
>();
long
startTime
=
period
.
getTime
();
EventReport
report
=
m_reportService
.
queryEventReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_HOUR
));
reports
.
add
(
report
);
EventReport
eventReport
=
m_eventMerger
.
mergeForGraph
(
domain
,
reports
);
graphs
=
m_eventGraphCreator
.
splitReportToGraphs
(
period
,
domain
,
name
,
eventReport
);
return
graphs
;
}
}
cat-home/src/main/java/com/dianping/cat/report/task/heartbeat/HeartbeatGraphCreator.java
浏览文件 @
3954d7df
...
...
@@ -16,10 +16,9 @@ import com.dianping.cat.consumer.heartbeat.model.entity.HeartbeatReport;
import
com.dianping.cat.consumer.heartbeat.model.entity.Period
;
import
com.dianping.cat.core.dal.Graph
;
import
com.dianping.cat.report.task.TaskHelper
;
import
com.dianping.cat.report.task.spi.GraphCreator
;
import
com.dianping.cat.report.task.spi.GraphLine
;
public
class
HeartbeatGraphCreator
implements
GraphCreator
<
HeartbeatReport
>
{
public
class
HeartbeatGraphCreator
{
private
void
cacheHeartbeatColumn
(
Map
<
String
,
GraphLine
>
detailCache
,
int
minute
,
Number
value
,
String
key
)
{
GraphLine
detailLine
=
detailCache
.
get
(
key
);
...
...
@@ -31,7 +30,6 @@ public class HeartbeatGraphCreator implements GraphCreator<HeartbeatReport> {
detailLine
.
minuteNumbers
[
minute
]
=
value
.
doubleValue
();
}
@Override
public
List
<
Graph
>
splitReportToGraphs
(
Date
reportPeriod
,
String
domainName
,
String
reportName
,
HeartbeatReport
heartbeatReport
)
{
Set
<
String
>
ips
=
heartbeatReport
.
getIps
();
...
...
cat-home/src/main/java/com/dianping/cat/report/task/matrix/MatrixReportBuilder.java
浏览文件 @
3954d7df
...
...
@@ -42,27 +42,6 @@ public class MatrixReportBuilder implements ReportTaskBuilder {
throw
new
RuntimeException
(
"Matrix report don't support hourly report!"
);
}
private
MatrixReport
queryDailyReportsByDuration
(
String
domain
,
Date
start
,
Date
end
)
{
long
startTime
=
start
.
getTime
();
long
endTime
=
end
.
getTime
();
MatrixReportMerger
merger
=
new
MatrixReportMerger
(
new
MatrixReport
(
domain
));
for
(;
startTime
<
endTime
;
startTime
+=
TimeUtil
.
ONE_DAY
)
{
try
{
MatrixReport
reportModel
=
m_reportService
.
queryMatrixReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_DAY
));
reportModel
.
accept
(
merger
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
MatrixReport
matrixReport
=
merger
.
getMatrixReport
();
matrixReport
.
setStartTime
(
start
);
matrixReport
.
setEndTime
(
end
);
return
matrixReport
;
}
@Override
public
boolean
buildMonthlyTask
(
String
name
,
String
domain
,
Date
period
)
{
MatrixReport
matrixReport
=
queryDailyReportsByDuration
(
domain
,
period
,
TaskHelper
.
nextMonthStart
(
period
));
...
...
@@ -75,7 +54,6 @@ public class MatrixReportBuilder implements ReportTaskBuilder {
report
.
setName
(
name
);
report
.
setPeriod
(
period
);
report
.
setType
(
1
);
return
m_reportService
.
insertMonthlyReport
(
report
);
}
...
...
@@ -93,10 +71,31 @@ public class MatrixReportBuilder implements ReportTaskBuilder {
report
.
setName
(
name
);
report
.
setPeriod
(
period
);
report
.
setType
(
1
);
return
m_reportService
.
insertWeeklyReport
(
report
);
}
private
MatrixReport
queryDailyReportsByDuration
(
String
domain
,
Date
start
,
Date
end
)
{
long
startTime
=
start
.
getTime
();
long
endTime
=
end
.
getTime
();
MatrixReportMerger
merger
=
new
MatrixReportMerger
(
new
MatrixReport
(
domain
));
for
(;
startTime
<
endTime
;
startTime
+=
TimeUtil
.
ONE_DAY
)
{
try
{
MatrixReport
reportModel
=
m_reportService
.
queryMatrixReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_DAY
));
reportModel
.
accept
(
merger
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
MatrixReport
matrixReport
=
merger
.
getMatrixReport
();
matrixReport
.
setStartTime
(
start
);
matrixReport
.
setEndTime
(
end
);
return
matrixReport
;
}
private
MatrixReport
queryHourlyReportByDuration
(
String
name
,
String
domain
,
Date
start
,
Date
end
)
{
Set
<
String
>
domainSet
=
m_reportService
.
queryAllDomainNames
(
start
,
end
,
"matrix"
);
long
startTime
=
start
.
getTime
();
...
...
cat-home/src/main/java/com/dianping/cat/report/task/metric/MetricAlert.java
浏览文件 @
3954d7df
package
com.dianping.cat.report.task.metric
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.
Map
;
import
java.util.
Set
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
...
...
@@ -52,13 +50,15 @@ public class MetricAlert implements Task, LogEnabled {
@Inject
(
type
=
ModelService
.
class
,
value
=
"metric"
)
protected
ModelService
<
MetricReport
>
m_service
;
@Inject
protected
MetricPointParser
m_parser
;
private
Logger
m_logger
;
private
static
final
long
TEN_SECONDS
=
10
*
TimeUtil
.
ONE_MINUTE
;
private
static
final
String
METRIC
=
"metric"
;
private
static
final
long
TEN_SECONDS
=
10
*
1000
;
private
static
final
int
DURATION_IN_MINUTE
=
1
;
...
...
@@ -76,8 +76,9 @@ public class MetricAlert implements Task, LogEnabled {
Transaction
t
=
Cat
.
newTransaction
(
"MetricAlert"
,
"Redo"
);
long
current
=
System
.
currentTimeMillis
();
try
{
Date
reportPeriod
=
new
Date
(
new
Date
().
getTime
()
-
DURATION
-
TEN_SECONDS
);
metricAlert
(
reportPeriod
);
Date
date
=
new
Date
(
System
.
currentTimeMillis
()
-
DURATION
-
TEN_SECONDS
);
metricAlert
(
date
);
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
...
...
@@ -97,53 +98,63 @@ public class MetricAlert implements Task, LogEnabled {
}
}
protected
void
metricAlert
(
Date
reportPeriod
)
{
Map
<
String
,
MetricItemConfig
>
metricConfigMap
=
m_metricConfigManager
.
getMetricConfig
().
getMetricItemConfigs
();
Map
<
String
,
MetricReport
>
metricReportMap
=
new
HashMap
<
String
,
MetricReport
>();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
reportPeriod
);
int
minute
=
calendar
.
get
(
Calendar
.
MINUTE
);
for
(
String
metricID
:
metricConfigMap
.
keySet
())
{
MetricItemConfig
metricConfig
=
metricConfigMap
.
get
(
metricID
);
String
domain
=
metricConfig
.
getDomain
();
String
productLine
=
m_productLineConfigManager
.
queryProductLineByDomain
(
domain
);
for
(
MetricType
type
:
MetricType
.
values
())
{
String
key
=
metricID
+
":"
+
type
;
BaselineConfig
baselineConfig
=
m_baselineConfigManager
.
queryBaseLineConfig
(
key
);
double
[]
baseline
=
null
;
try
{
baseline
=
m_baselineService
.
queryHourlyBaseline
(
"metric"
,
key
,
reportPeriod
);
}
catch
(
Exception
e
)
{
continue
;
}
MetricReport
report
=
metricReportMap
.
get
(
productLine
);
if
(
report
==
null
){
report
=
queryMetricReport
(
productLine
);
metricReportMap
.
put
(
productLine
,
report
);
private
List
<
Integer
>
check
(
double
[]
realDatas
,
double
[]
baseLineDatas
,
BaselineConfig
config
)
{
int
size
=
realDatas
.
length
;
for
(
int
i
=
0
;
i
<=
size
;
i
++)
{
}
return
null
;
}
protected
void
metricAlert
(
Date
date
)
{
long
current
=
date
.
getTime
()
/
1000
/
60
;
int
minute
=
(
int
)
(
current
%
(
60
));
Set
<
String
>
productLines
=
m_productLineConfigManager
.
queryProductLines
().
keySet
();
for
(
String
productLine
:
productLines
)
{
MetricReport
report
=
queryMetricReport
(
productLine
);
for
(
MetricItem
item
:
report
.
getMetricItems
().
values
())
{
String
key
=
item
.
getId
();
MetricItemConfig
metricConfig
=
m_metricConfigManager
.
queryMetricItemConfig
(
key
);
List
<
Integer
>
alerts
=
new
ArrayList
<
Integer
>();
if
(
metricConfig
.
isShowCount
())
{
alerts
.
addAll
(
buildAlertInfo
(
date
,
MetricType
.
COUNT
,
item
,
key
));
}
double
[]
datas
=
extractDatasFromReport
(
report
,
metricConfig
,
type
);
if
(
datas
==
null
)
{
continue
;
if
(
metricConfig
.
isShowAvg
())
{
alerts
.
addAll
(
buildAlertInfo
(
date
,
MetricType
.
AVG
,
item
,
key
));
}
List
<
Integer
>
alertList
=
checkData
(
baseline
,
datas
,
minute
,
baselineConfig
);
for
(
int
alertItem
:
alertList
)
{
m_logger
.
info
(
"ALERT:"
+
key
+
","
+
reportPeriod
+
", minute:"
+
alertItem
);
if
(
metricConfig
.
isShowSum
())
{
alerts
.
addAll
(
buildAlertInfo
(
date
,
MetricType
.
SUM
,
item
,
key
));
}
if
(
alerts
.
size
()
>
0
)
{
String
alertInfo
=
buildAlertInfo
(
alerts
,
minute
);
m_logger
.
info
(
alertInfo
);
}
}
}
}
private
double
[]
extractDatasFromReport
(
MetricReport
report
,
MetricItemConfig
metricConfig
,
MetricType
type
)
{
try
{
MetricItem
reportItem
=
report
.
getMetricItems
().
get
(
metricConfig
.
getMetricKey
());
double
[]
datas
=
m_parser
.
getOneHourData
(
reportItem
,
type
);
return
datas
;
}
catch
(
NullPointerException
e
)
{
return
null
;
private
String
buildAlertInfo
(
List
<
Integer
>
alerts
,
int
minute
)
{
return
null
;
}
private
List
<
Integer
>
buildAlertInfo
(
Date
date
,
MetricType
type
,
MetricItem
item
,
String
key
)
{
String
baseLineKey
=
key
+
":"
+
type
;
double
[]
baseline
=
m_baselineService
.
queryHourlyBaseline
(
METRIC
,
baseLineKey
,
date
);
if
(
baseline
!=
null
)
{
double
[]
realDatas
=
extractDatasFromReport
(
item
,
type
);
BaselineConfig
baselineConfig
=
m_baselineConfigManager
.
queryBaseLineConfig
(
baseLineKey
);
return
check
(
baseline
,
realDatas
,
baselineConfig
);
}
return
new
ArrayList
<
Integer
>();
}
private
double
[]
extractDatasFromReport
(
MetricItem
item
,
MetricType
type
)
{
return
m_parser
.
queryOneHourData
(
item
,
type
);
}
private
MetricReport
queryMetricReport
(
String
product
)
{
...
...
cat-home/src/main/java/com/dianping/cat/report/task/metric/MetricBaselineReportBuilder.java
浏览文件 @
3954d7df
...
...
@@ -49,9 +49,9 @@ public class MetricBaselineReportBuilder implements ReportTaskBuilder {
@Override
public
boolean
buildDailyTask
(
String
reportName
,
String
domain
,
Date
reportPeriod
)
{
Map
<
String
,
MetricReport
>
report
Map
=
new
HashMap
<
String
,
MetricReport
>();
Map
<
String
,
MetricReport
>
report
s
=
new
HashMap
<
String
,
MetricReport
>();
for
(
String
metricID
:
m_configManager
.
getMetricConfig
().
getMetricItemConfigs
().
keySet
())
{
buildDailyReportInternal
(
report
Map
,
reportName
,
metricID
,
reportPeriod
);
buildDailyReportInternal
(
report
s
,
reportName
,
metricID
,
reportPeriod
);
}
return
true
;
}
...
...
@@ -69,22 +69,25 @@ public class MetricBaselineReportBuilder implements ReportTaskBuilder {
List
<
Double
>
weights
=
baselineConfig
.
getWeights
();
Date
targetDate
=
new
Date
(
reportPeriod
.
getTime
()
+
baselineConfig
.
getTargetDate
()
*
TimeUtil
.
ONE_DAY
);
List
<
double
[]>
values
=
new
ArrayList
<
double
[]>();
for
(
Integer
day
:
days
)
{
List
<
MetricItem
>
reports
=
new
ArrayList
<
MetricItem
>();
Date
relatedHour
=
new
Date
(
reportPeriod
.
getTime
()
+
day
*
TimeUtil
.
ONE_DAY
);
Date
currentDate
=
new
Date
(
reportPeriod
.
getTime
()
+
day
*
TimeUtil
.
ONE_DAY
);
for
(
int
i
=
0
;
i
<
24
;
i
++)
{
Date
hourEnd
=
new
Date
(
relatedHour
.
getTime
()
+
TimeUtil
.
ONE_HOUR
);
String
metricReportKey
=
productLine
+
":"
+
relatedHour
.
getTime
();
Date
start
=
new
Date
(
currentDate
.
getTime
()
+
i
*
TimeUtil
.
ONE_HOUR
);
Date
end
=
new
Date
(
start
.
getTime
()
+
TimeUtil
.
ONE_HOUR
);
String
metricReportKey
=
productLine
+
":"
+
start
.
getTime
();
MetricReport
report
=
reportMap
.
get
(
metricReportKey
);
if
(
report
==
null
)
{
report
=
m_reportService
.
queryMetricReport
(
productLine
,
relatedHour
,
hourE
nd
);
report
=
m_reportService
.
queryMetricReport
(
productLine
,
start
,
e
nd
);
reportMap
.
put
(
metricReportKey
,
report
);
}
MetricItem
reportItem
=
report
.
getMetricItems
().
get
(
metricKey
);
relatedHour
=
hourEnd
;
MetricItem
reportItem
=
report
.
findOrCreateMetricItem
(
metricKey
);
reports
.
add
(
reportItem
);
}
double
[]
oneDayValue
=
m_parser
.
get
OneDayData
(
reports
,
type
);
double
[]
oneDayValue
=
m_parser
.
query
OneDayData
(
reports
,
type
);
values
.
add
(
oneDayValue
);
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/metric/MetricPointParser.java
浏览文件 @
3954d7df
...
...
@@ -10,43 +10,43 @@ public class MetricPointParser {
private
static
final
int
POINT_NUMBER
=
60
;
public
double
[]
getOneHourData
(
MetricItem
report
,
MetricType
type
)
{
public
double
[]
queryOneHourData
(
MetricItem
item
,
MetricType
type
)
{
double
[]
result
=
new
double
[
POINT_NUMBER
];
Map
<
Integer
,
Point
>
map
=
report
.
getAbtests
().
get
(
"-1"
).
getGroups
().
get
(
""
).
getPoints
();
Map
<
Integer
,
Point
>
map
=
item
.
getAbtests
().
get
(
"-1"
).
getGroups
().
get
(
""
).
getPoints
();
for
(
Integer
minute
:
map
.
keySet
())
{
if
(
minute
>=
0
&&
minute
<
POINT_NUMBER
)
{
Point
point
=
map
.
get
(
minute
);
if
(
type
==
MetricType
.
AVG
)
{
result
[
minute
]
=
point
.
getAvg
();
}
else
if
(
type
==
MetricType
.
COUNT
)
{
result
[
minute
]
=
(
double
)
point
.
getCount
();
}
else
if
(
type
==
MetricType
.
SUM
)
{
result
[
minute
]
=
point
.
getSum
();
}
Point
point
=
map
.
get
(
minute
);
if
(
type
==
MetricType
.
AVG
)
{
result
[
minute
]
=
point
.
getAvg
();
}
else
if
(
type
==
MetricType
.
COUNT
)
{
result
[
minute
]
=
(
double
)
point
.
getCount
();
}
else
if
(
type
==
MetricType
.
SUM
)
{
result
[
minute
]
=
point
.
getSum
();
}
}
return
result
;
}
public
double
[]
getOneDayData
(
List
<
MetricItem
>
reports
,
MetricType
type
)
{
double
[]
values
=
new
double
[
24
*
POINT_NUMBER
];
for
(
int
i
=
0
;
i
<
24
*
POINT_NUMBER
;
i
++)
{
public
double
[]
queryOneDayData
(
List
<
MetricItem
>
items
,
MetricType
type
)
{
int
size
=
items
.
size
();
double
[]
values
=
new
double
[
24
*
POINT_NUMBER
];
for
(
int
i
=
0
;
i
<
24
*
POINT_NUMBER
;
i
++)
{
values
[
i
]
=
-
1
;
}
int
hour
=
0
;
for
(
MetricItem
report
:
reports
)
{
for
(
int
hour
=
0
;
hour
<
size
;
hour
++)
{
MetricItem
item
=
items
.
get
(
hour
);
try
{
double
[]
oneHourValues
=
getOneHourData
(
report
,
type
);
for
(
int
minute
=
0
;
minute
<
60
;
minute
++)
{
double
[]
oneHourValues
=
queryOneHourData
(
item
,
type
);
for
(
int
minute
=
0
;
minute
<
60
;
minute
++)
{
int
index
=
hour
*
60
+
minute
;
values
[
index
]
=
oneHourValues
[
minute
];
}
}
catch
(
NullPointerException
e
)
{
// Do Nothing
}
hour
++;
}
return
values
;
}
}
cat-home/src/main/java/com/dianping/cat/report/task/problem/ProblemGraphCreator.java
浏览文件 @
3954d7df
...
...
@@ -16,12 +16,10 @@ import com.dianping.cat.consumer.problem.model.entity.ProblemReport;
import
com.dianping.cat.consumer.problem.model.entity.Segment
;
import
com.dianping.cat.core.dal.Graph
;
import
com.dianping.cat.report.task.TaskHelper
;
import
com.dianping.cat.report.task.spi.GraphCreator
;
import
com.dianping.cat.report.task.spi.GraphLine
;
public
class
ProblemGraphCreator
implements
GraphCreator
<
ProblemReport
>
{
public
class
ProblemGraphCreator
{
@Override
public
List
<
Graph
>
splitReportToGraphs
(
Date
reportPeriod
,
String
reportDomain
,
String
reportName
,
ProblemReport
report
)
{
Set
<
String
>
ips
=
report
.
getIps
();
...
...
cat-home/src/main/java/com/dianping/cat/report/task/problem/ProblemReportBuilder.java
浏览文件 @
3954d7df
...
...
@@ -40,21 +40,6 @@ public class ProblemReportBuilder implements ReportTaskBuilder {
@Inject
private
ProblemMerger
m_problemMerger
;
private
void
buildProblemDailyGraph
(
ProblemReport
report
)
{
try
{
ProblemDailyGraphCreator
creator
=
new
ProblemDailyGraphCreator
();
creator
.
visitProblemReport
(
report
);
List
<
DailyGraph
>
graphs
=
creator
.
buildDailyGraph
();
for
(
DailyGraph
temp
:
graphs
)
{
m_dailyGraphDao
.
insert
(
temp
);
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
@Override
public
boolean
buildDailyTask
(
String
name
,
String
domain
,
Date
period
)
{
try
{
...
...
@@ -79,6 +64,20 @@ public class ProblemReportBuilder implements ReportTaskBuilder {
}
}
private
List
<
Graph
>
buildHourlyGraphs
(
String
name
,
String
domain
,
Date
period
)
throws
DalException
{
List
<
Graph
>
graphs
=
new
ArrayList
<
Graph
>();
List
<
ProblemReport
>
reports
=
new
ArrayList
<
ProblemReport
>();
long
startTime
=
period
.
getTime
();
ProblemReport
report
=
m_reportService
.
queryProblemReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_HOUR
));
reports
.
add
(
report
);
ProblemReport
problemReport
=
m_problemMerger
.
mergeForGraph
(
domain
,
reports
);
graphs
=
m_problemGraphCreator
.
splitReportToGraphs
(
period
,
domain
,
name
,
problemReport
);
return
graphs
;
}
@Override
public
boolean
buildHourlyTask
(
String
name
,
String
domain
,
Date
period
)
{
try
{
...
...
@@ -95,26 +94,6 @@ public class ProblemReportBuilder implements ReportTaskBuilder {
return
true
;
}
private
ProblemReport
queryDailyReportsByDuration
(
String
domain
,
Date
start
,
Date
end
)
{
long
startTime
=
start
.
getTime
();
long
endTime
=
end
.
getTime
();
ProblemReportMerger
merger
=
new
ProblemReportMerger
(
new
ProblemReport
(
domain
));
for
(;
startTime
<
endTime
;
startTime
+=
TimeUtil
.
ONE_DAY
)
{
try
{
ProblemReport
reportModel
=
m_reportService
.
queryProblemReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_DAY
));
reportModel
.
accept
(
merger
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
ProblemReport
problemReport
=
merger
.
getProblemReport
();
problemReport
.
setStartTime
(
start
);
problemReport
.
setEndTime
(
end
);
return
problemReport
;
}
@Override
public
boolean
buildMonthlyTask
(
String
name
,
String
domain
,
Date
period
)
{
ProblemReport
problemReport
=
queryDailyReportsByDuration
(
domain
,
period
,
TaskHelper
.
nextMonthStart
(
period
));
...
...
@@ -127,10 +106,24 @@ public class ProblemReportBuilder implements ReportTaskBuilder {
report
.
setName
(
name
);
report
.
setPeriod
(
period
);
report
.
setType
(
1
);
return
m_reportService
.
insertMonthlyReport
(
report
);
}
private
void
buildProblemDailyGraph
(
ProblemReport
report
)
{
try
{
ProblemDailyGraphCreator
creator
=
new
ProblemDailyGraphCreator
();
creator
.
visitProblemReport
(
report
);
List
<
DailyGraph
>
graphs
=
creator
.
buildDailyGraph
();
for
(
DailyGraph
temp
:
graphs
)
{
m_dailyGraphDao
.
insert
(
temp
);
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
@Override
public
boolean
buildWeeklyTask
(
String
name
,
String
domain
,
Date
period
)
{
ProblemReport
problemReport
=
queryDailyReportsByDuration
(
domain
,
period
,
new
Date
(
period
.
getTime
()
...
...
@@ -145,10 +138,30 @@ public class ProblemReportBuilder implements ReportTaskBuilder {
report
.
setName
(
name
);
report
.
setPeriod
(
period
);
report
.
setType
(
1
);
return
m_reportService
.
insertWeeklyReport
(
report
);
}
private
ProblemReport
queryDailyReportsByDuration
(
String
domain
,
Date
start
,
Date
end
)
{
long
startTime
=
start
.
getTime
();
long
endTime
=
end
.
getTime
();
ProblemReportMerger
merger
=
new
ProblemReportMerger
(
new
ProblemReport
(
domain
));
for
(;
startTime
<
endTime
;
startTime
+=
TimeUtil
.
ONE_DAY
)
{
try
{
ProblemReport
reportModel
=
m_reportService
.
queryProblemReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_DAY
));
reportModel
.
accept
(
merger
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
ProblemReport
problemReport
=
merger
.
getProblemReport
();
problemReport
.
setStartTime
(
start
);
problemReport
.
setEndTime
(
end
);
return
problemReport
;
}
private
ProblemReport
queryHourlyReportsByDuration
(
String
name
,
String
domain
,
Date
start
,
Date
end
)
throws
DalException
{
Set
<
String
>
domainSet
=
m_reportService
.
queryAllDomainNames
(
start
,
end
,
"problem"
);
...
...
@@ -164,18 +177,4 @@ public class ProblemReportBuilder implements ReportTaskBuilder {
}
return
m_problemMerger
.
mergeForDaily
(
domain
,
reports
,
domainSet
);
}
private
List
<
Graph
>
buildHourlyGraphs
(
String
name
,
String
domain
,
Date
period
)
throws
DalException
{
List
<
Graph
>
graphs
=
new
ArrayList
<
Graph
>();
List
<
ProblemReport
>
reports
=
new
ArrayList
<
ProblemReport
>();
long
startTime
=
period
.
getTime
();
ProblemReport
report
=
m_reportService
.
queryProblemReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_HOUR
));
reports
.
add
(
report
);
ProblemReport
problemReport
=
m_problemMerger
.
mergeForGraph
(
domain
,
reports
);
graphs
=
m_problemGraphCreator
.
splitReportToGraphs
(
period
,
domain
,
name
,
problemReport
);
return
graphs
;
}
}
cat-home/src/main/java/com/dianping/cat/report/task/spi/GraphCreator.java
已删除
100644 → 0
浏览文件 @
37c07efb
/**
*
*/
package
com.dianping.cat.report.task.spi
;
import
java.util.Date
;
import
java.util.List
;
import
com.dianping.cat.core.dal.Graph
;
public
interface
GraphCreator
<
E
>
{
public
List
<
Graph
>
splitReportToGraphs
(
Date
reportPeriod
,
String
reportDomain
,
String
reportName
,
E
report
);
}
cat-home/src/main/java/com/dianping/cat/report/task/sql/SqlReportBuilder.java
浏览文件 @
3954d7df
...
...
@@ -47,26 +47,6 @@ public class SqlReportBuilder implements ReportTaskBuilder {
throw
new
RuntimeException
(
"Sql report don't support HourReport!"
);
}
private
SqlReport
queryDailyReportsByDuration
(
String
domain
,
Date
start
,
Date
end
)
{
long
startTime
=
start
.
getTime
();
long
endTime
=
end
.
getTime
();
SqlReportMerger
merger
=
new
SqlReportMerger
(
new
SqlReport
(
domain
));
for
(;
startTime
<
endTime
;
startTime
+=
TimeUtil
.
ONE_DAY
)
{
try
{
SqlReport
reportModel
=
m_reportService
.
querySqlReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_DAY
));
reportModel
.
accept
(
merger
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
SqlReport
sqlReport
=
merger
.
getSqlReport
();
sqlReport
.
setStartTime
(
start
);
sqlReport
.
setEndTime
(
end
);
return
sqlReport
;
}
@Override
public
boolean
buildMonthlyTask
(
String
name
,
String
domain
,
Date
period
)
{
SqlReport
sqlReport
=
queryDailyReportsByDuration
(
domain
,
period
,
TaskHelper
.
nextMonthStart
(
period
));
...
...
@@ -79,7 +59,6 @@ public class SqlReportBuilder implements ReportTaskBuilder {
report
.
setName
(
name
);
report
.
setPeriod
(
period
);
report
.
setType
(
1
);
return
m_reportService
.
insertMonthlyReport
(
report
);
}
...
...
@@ -96,10 +75,30 @@ public class SqlReportBuilder implements ReportTaskBuilder {
report
.
setName
(
name
);
report
.
setPeriod
(
period
);
report
.
setType
(
1
);
return
m_reportService
.
insertWeeklyReport
(
report
);
}
private
SqlReport
queryDailyReportsByDuration
(
String
domain
,
Date
start
,
Date
end
)
{
long
startTime
=
start
.
getTime
();
long
endTime
=
end
.
getTime
();
SqlReportMerger
merger
=
new
SqlReportMerger
(
new
SqlReport
(
domain
));
for
(;
startTime
<
endTime
;
startTime
+=
TimeUtil
.
ONE_DAY
)
{
try
{
SqlReport
reportModel
=
m_reportService
.
querySqlReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_DAY
));
reportModel
.
accept
(
merger
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
SqlReport
sqlReport
=
merger
.
getSqlReport
();
sqlReport
.
setStartTime
(
start
);
sqlReport
.
setEndTime
(
end
);
return
sqlReport
;
}
private
SqlReport
queryHourlyReportsByDuration
(
String
name
,
String
domain
,
Date
start
,
Date
end
)
{
Set
<
String
>
domainSet
=
m_reportService
.
queryAllDomainNames
(
start
,
end
,
"sql"
);
long
startTime
=
start
.
getTime
();
...
...
cat-home/src/main/java/com/dianping/cat/report/task/state/StateReportBuilder.java
浏览文件 @
3954d7df
...
...
@@ -41,27 +41,6 @@ public class StateReportBuilder implements ReportTaskBuilder {
throw
new
RuntimeException
(
"State report don't support HourReport!"
);
}
private
StateReport
queryDailyReportsByDuration
(
String
domain
,
Date
start
,
Date
end
)
{
long
startTime
=
start
.
getTime
();
long
endTime
=
end
.
getTime
();
StateReportMerger
merger
=
new
StateReportMerger
(
new
StateReport
(
domain
));
for
(;
startTime
<
endTime
;
startTime
+=
TimeUtil
.
ONE_DAY
)
{
try
{
StateReport
reportModel
=
m_reportService
.
queryStateReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_DAY
));
reportModel
.
accept
(
merger
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
StateReport
stateReport
=
merger
.
getStateReport
();
stateReport
.
setStartTime
(
start
);
stateReport
.
setEndTime
(
end
);
return
stateReport
;
}
@Override
public
boolean
buildMonthlyTask
(
String
name
,
String
domain
,
Date
period
)
{
StateReport
stateReport
=
queryDailyReportsByDuration
(
domain
,
period
,
TaskHelper
.
nextMonthStart
(
period
));
...
...
@@ -74,7 +53,6 @@ public class StateReportBuilder implements ReportTaskBuilder {
report
.
setName
(
name
);
report
.
setPeriod
(
period
);
report
.
setType
(
1
);
return
m_reportService
.
insertMonthlyReport
(
report
);
}
...
...
@@ -94,10 +72,31 @@ public class StateReportBuilder implements ReportTaskBuilder {
report
.
setName
(
name
);
report
.
setPeriod
(
period
);
report
.
setType
(
1
);
return
m_reportService
.
insertWeeklyReport
(
report
);
}
private
StateReport
queryDailyReportsByDuration
(
String
domain
,
Date
start
,
Date
end
)
{
long
startTime
=
start
.
getTime
();
long
endTime
=
end
.
getTime
();
StateReportMerger
merger
=
new
StateReportMerger
(
new
StateReport
(
domain
));
for
(;
startTime
<
endTime
;
startTime
+=
TimeUtil
.
ONE_DAY
)
{
try
{
StateReport
reportModel
=
m_reportService
.
queryStateReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_DAY
));
reportModel
.
accept
(
merger
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
StateReport
stateReport
=
merger
.
getStateReport
();
stateReport
.
setStartTime
(
start
);
stateReport
.
setEndTime
(
end
);
return
stateReport
;
}
private
StateReport
queryHourlyReportsByDuration
(
String
name
,
String
domain
,
Date
period
,
Date
endDate
)
{
long
startTime
=
period
.
getTime
();
long
endTime
=
endDate
.
getTime
();
...
...
@@ -111,9 +110,9 @@ public class StateReportBuilder implements ReportTaskBuilder {
reportModel
.
accept
(
merger
);
}
StateReport
stateReport
=
merger
.
getStateReport
();
stateReport
.
setStartTime
(
period
);
stateReport
.
setEndTime
(
endDate
);
return
stateReport
;
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/thread/TaskProducer.java
已删除
100644 → 0
浏览文件 @
37c07efb
package
com.dianping.cat.report.task.thread
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.Set
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
org.unidal.dal.jdbc.DalException
;
import
org.unidal.dal.jdbc.DalNotFoundException
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
import
com.dianping.cat.consumer.advanced.MetricConfigManager
;
import
com.dianping.cat.core.dal.Task
;
import
com.dianping.cat.core.dal.TaskDao
;
import
com.dianping.cat.core.dal.TaskEntity
;
import
com.dianping.cat.helper.CatString
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.report.service.ReportService
;
import
com.dianping.cat.report.task.TaskHelper
;
import
com.dianping.cat.report.task.spi.ReportFacade
;
public
class
TaskProducer
implements
org
.
unidal
.
helper
.
Threads
.
Task
,
Initializable
{
@Inject
private
ReportService
m_reportService
;
@Inject
private
TaskDao
m_taskDao
;
@Inject
private
MetricConfigManager
m_configManager
;
private
Set
<
String
>
m_dailyReportNameSet
=
new
HashSet
<
String
>();
private
Set
<
String
>
m_graphReportNameSet
=
new
HashSet
<
String
>();
private
static
final
String
STATE
=
"state"
;
private
long
m_currentDay
;
private
void
createDailyReportTasks
(
Date
date
)
{
generateReportTasks
(
date
,
new
Date
(
date
.
getTime
()
+
TimeUtil
.
ONE_DAY
),
ReportFacade
.
TYPE_DAILY
);
}
private
void
createMonthReportTasks
(
Date
date
)
{
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
date
);
int
dayOfMonth
=
cal
.
get
(
Calendar
.
DAY_OF_MONTH
);
if
(
dayOfMonth
==
1
)
{
Calendar
monthEnd
=
Calendar
.
getInstance
();
monthEnd
.
setTime
(
date
);
monthEnd
.
add
(
Calendar
.
MONTH
,
1
);
generateReportTasks
(
date
,
monthEnd
.
getTime
(),
ReportFacade
.
TYPE_WEEK
);
}
}
private
void
generateDailyMetricBaselineTasks
(
Date
date
)
{
try
{
m_taskDao
.
findByDomainNameTypePeriod
(
"metricBaseline"
,
""
,
ReportFacade
.
TYPE_DAILY
,
date
,
TaskEntity
.
READSET_FULL
);
}
catch
(
DalNotFoundException
e
)
{
insertTask
(
""
,
"metricBaseline"
,
ReportFacade
.
TYPE_DAILY
,
date
);
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
}
}
private
void
createWeeklyReportTasks
(
Date
date
)
{
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
date
);
int
dayOfWeek
=
cal
.
get
(
Calendar
.
DAY_OF_WEEK
);
if
(
dayOfWeek
==
7
)
{
generateReportTasks
(
date
,
new
Date
(
date
.
getTime
()
+
TimeUtil
.
ONE_DAY
*
7
),
ReportFacade
.
TYPE_WEEK
);
}
}
private
void
creatReportTask
(
Date
date
)
{
generateDailyMetricBaselineTasks
(
date
);
createDailyReportTasks
(
date
);
createWeeklyReportTasks
(
date
);
createMonthReportTasks
(
date
);
}
private
void
generateReportTasks
(
Date
start
,
Date
end
,
int
reportType
)
{
Set
<
String
>
domainSet
=
queryDomainSet
(
start
,
end
);
for
(
String
domain
:
domainSet
)
{
for
(
String
name
:
m_dailyReportNameSet
)
{
insertTask
(
domain
,
name
,
reportType
,
start
);
}
}
insertTask
(
CatString
.
CAT
,
STATE
,
reportType
,
start
);
}
@Override
public
String
getName
()
{
return
"Task-Producer"
;
}
@Override
public
void
initialize
()
throws
InitializationException
{
m_dailyReportNameSet
.
add
(
"event"
);
m_dailyReportNameSet
.
add
(
"transaction"
);
m_dailyReportNameSet
.
add
(
"problem"
);
m_dailyReportNameSet
.
add
(
"matrix"
);
m_dailyReportNameSet
.
add
(
"cross"
);
m_dailyReportNameSet
.
add
(
"sql"
);
m_dailyReportNameSet
.
add
(
"health"
);
m_graphReportNameSet
.
add
(
"transaction"
);
m_graphReportNameSet
.
add
(
"event"
);
m_graphReportNameSet
.
add
(
"problem"
);
m_graphReportNameSet
.
add
(
"heartbeat"
);
}
private
void
insertTask
(
String
domain
,
String
reportName
,
int
taskType
,
Date
taskPeriod
)
{
try
{
m_taskDao
.
findByDomainNameTypePeriod
(
reportName
,
domain
,
taskType
,
taskPeriod
,
TaskEntity
.
READSET_FULL
);
}
catch
(
DalNotFoundException
e
)
{
Task
task
=
m_taskDao
.
createLocal
();
task
.
setCreationDate
(
new
Date
());
task
.
setProducer
(
NetworkInterfaceManager
.
INSTANCE
.
getLocalHostAddress
());
task
.
setReportDomain
(
domain
);
task
.
setReportName
(
reportName
);
task
.
setReportPeriod
(
taskPeriod
);
task
.
setStatus
(
1
);
task
.
setTaskType
(
taskType
);
try
{
m_taskDao
.
insert
(
task
);
}
catch
(
Exception
ex
)
{
Cat
.
logError
(
ex
);
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
private
Set
<
String
>
queryDomainSet
(
Date
start
,
Date
end
)
{
return
m_reportService
.
queryAllDomainNames
(
start
,
end
,
"transaction"
);
}
@Override
public
void
run
()
{
boolean
active
=
true
;
while
(
active
)
{
Date
currentDay
=
TimeUtil
.
getCurrentDay
();
if
(
currentDay
.
getTime
()
>
m_currentDay
)
{
Calendar
cal
=
Calendar
.
getInstance
();
int
minute
=
cal
.
get
(
Calendar
.
MINUTE
);
Date
yesterday
=
TaskHelper
.
yesterdayZero
(
new
Date
());
Transaction
t
=
Cat
.
newTransaction
(
"System"
,
"CreateTask"
);
try
{
// Daily report should created after last day reports all insert to database
if
(
minute
>
6
)
{
creatReportTask
(
yesterday
);
}
else
{
try
{
Thread
.
sleep
((
7
-
minute
)
*
TimeUtil
.
ONE_MINUTE
);
}
catch
(
InterruptedException
e
)
{
active
=
false
;
}
creatReportTask
(
yesterday
);
}
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
}
finally
{
t
.
complete
();
}
m_currentDay
=
currentDay
.
getTime
();
}
try
{
Thread
.
sleep
(
5
*
TimeUtil
.
ONE_MINUTE
);
}
catch
(
InterruptedException
e
)
{
active
=
false
;
}
}
}
@Override
public
void
shutdown
()
{
}
}
cat-home/src/main/java/com/dianping/cat/report/task/transaction/TransactionGraphCreator.java
浏览文件 @
3954d7df
...
...
@@ -17,10 +17,9 @@ 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.core.dal.Graph
;
import
com.dianping.cat.report.task.spi.GraphCreator
;
import
com.dianping.cat.report.task.spi.GraphLine
;
public
class
TransactionGraphCreator
implements
GraphCreator
<
TransactionReport
>
{
public
class
TransactionGraphCreator
{
private
double
[]
arrayAdd
(
double
[]
src
,
double
added
[])
{
int
size
=
added
.
length
;
...
...
@@ -95,7 +94,6 @@ public class TransactionGraphCreator implements GraphCreator<TransactionReport>
return
value
;
}
@Override
public
List
<
Graph
>
splitReportToGraphs
(
Date
reportPeriod
,
String
reportDomain
,
String
reportName
,
TransactionReport
report
)
{
Set
<
String
>
ips
=
report
.
getIps
();
...
...
cat-home/src/main/java/com/dianping/cat/report/task/transaction/TransactionReportBuilder.java
浏览文件 @
3954d7df
...
...
@@ -64,7 +64,6 @@ public class TransactionReportBuilder implements ReportTaskBuilder, LogEnabled {
report
.
setName
(
name
);
report
.
setPeriod
(
period
);
report
.
setType
(
1
);
return
m_reportService
.
insertDailyReport
(
report
);
}
catch
(
Exception
e
)
{
m_logger
.
error
(
e
.
getMessage
(),
e
);
...
...
@@ -86,6 +85,19 @@ public class TransactionReportBuilder implements ReportTaskBuilder, LogEnabled {
}
}
private
List
<
Graph
>
buildHourlyGraphs
(
String
name
,
String
domain
,
Date
period
)
throws
DalException
{
List
<
Graph
>
graphs
=
new
ArrayList
<
Graph
>();
List
<
TransactionReport
>
reports
=
new
ArrayList
<
TransactionReport
>();
long
startTime
=
period
.
getTime
();
TransactionReport
report
=
m_reportService
.
queryTransactionReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_HOUR
));
reports
.
add
(
report
);
TransactionReport
transactionReport
=
m_transactionMerger
.
mergeForGraph
(
domain
,
reports
);
graphs
=
m_transactionGraphCreator
.
splitReportToGraphs
(
period
,
domain
,
name
,
transactionReport
);
return
graphs
;
}
@Override
public
boolean
buildHourlyTask
(
String
name
,
String
domain
,
Date
period
)
{
try
{
...
...
@@ -103,29 +115,6 @@ public class TransactionReportBuilder implements ReportTaskBuilder, LogEnabled {
return
true
;
}
private
TransactionReport
queryDailyReportsByDuration
(
String
domain
,
Date
start
,
Date
end
)
{
long
startTime
=
start
.
getTime
();
long
endTime
=
end
.
getTime
();
TransactionReportMerger
merger
=
new
TransactionReportMerger
(
new
TransactionReport
(
domain
));
for
(;
startTime
<
endTime
;
startTime
+=
TimeUtil
.
ONE_DAY
)
{
try
{
TransactionReport
reportModel
=
m_reportService
.
queryTransactionReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_DAY
));
reportModel
.
accept
(
merger
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
TransactionReport
transactionReport
=
merger
.
getTransactionReport
();
transactionReport
.
setStartTime
(
start
);
transactionReport
.
setEndTime
(
end
);
new
TransactionReportUrlFilter
().
visitTransactionReport
(
transactionReport
);
return
transactionReport
;
}
@Override
public
boolean
buildMonthlyTask
(
String
name
,
String
domain
,
Date
period
)
{
TransactionReport
transactionReport
=
queryDailyReportsByDuration
(
domain
,
period
,
...
...
@@ -166,6 +155,29 @@ public class TransactionReportBuilder implements ReportTaskBuilder, LogEnabled {
m_logger
=
logger
;
}
private
TransactionReport
queryDailyReportsByDuration
(
String
domain
,
Date
start
,
Date
end
)
{
long
startTime
=
start
.
getTime
();
long
endTime
=
end
.
getTime
();
TransactionReportMerger
merger
=
new
TransactionReportMerger
(
new
TransactionReport
(
domain
));
for
(;
startTime
<
endTime
;
startTime
+=
TimeUtil
.
ONE_DAY
)
{
try
{
TransactionReport
reportModel
=
m_reportService
.
queryTransactionReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_DAY
));
reportModel
.
accept
(
merger
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
TransactionReport
transactionReport
=
merger
.
getTransactionReport
();
transactionReport
.
setStartTime
(
start
);
transactionReport
.
setEndTime
(
end
);
new
TransactionReportUrlFilter
().
visitTransactionReport
(
transactionReport
);
return
transactionReport
;
}
private
TransactionReport
queryHourlyReportsByDuration
(
String
name
,
String
domain
,
Date
start
,
Date
endDate
)
throws
DalException
{
Set
<
String
>
domainSet
=
m_reportService
.
queryAllDomainNames
(
start
,
endDate
,
"transaction"
);
...
...
@@ -181,17 +193,4 @@ public class TransactionReportBuilder implements ReportTaskBuilder, LogEnabled {
}
return
m_transactionMerger
.
mergeForDaily
(
domain
,
reports
,
domainSet
);
}
private
List
<
Graph
>
buildHourlyGraphs
(
String
name
,
String
domain
,
Date
period
)
throws
DalException
{
List
<
Graph
>
graphs
=
new
ArrayList
<
Graph
>();
List
<
TransactionReport
>
reports
=
new
ArrayList
<
TransactionReport
>();
long
startTime
=
period
.
getTime
();
TransactionReport
report
=
m_reportService
.
queryTransactionReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeUtil
.
ONE_HOUR
));
reports
.
add
(
report
);
TransactionReport
transactionReport
=
m_transactionMerger
.
mergeForGraph
(
domain
,
reports
);
graphs
=
m_transactionGraphCreator
.
splitReportToGraphs
(
period
,
domain
,
name
,
transactionReport
);
return
graphs
;
}
}
cat-home/src/main/webapp/css/body.css
浏览文件 @
3954d7df
...
...
@@ -264,10 +264,21 @@ a.long-url {
background-color
:
blue
;
}
a
.long-url
{
background-color
:
#5599CC
;
}
a
.long-sql
{
background-color
:
#6699CC
;
}
a
.long-call
{
background-color
:
#6688BB
;
}
a
.long-cache
{
background-color
:
#6677AA
;
}
a
.url
{
background-color
:
#cc0000
;
}
...
...
@@ -382,6 +393,11 @@ a.abtest-heartbeat{
margin
:
4px
auto
;
}
.metricGraph
{
width
:
560px
;
height
:
300px
;
}
.pieChart
{
text-align
:
left
;
width
:
700px
;
...
...
cat-home/src/main/webapp/jsp/report/dependency/dependencyDashboard.jsp
浏览文件 @
3954d7df
...
...
@@ -63,11 +63,11 @@
"
3
"
:
'
#b94a48
'
,
"
4
"
:
'
#772fbf
'
},
legendMap
:{
"
1
"
:
"
good
"
,
"
2
"
:
"
warning
"
,
"
3
"
:
"
error
"
},
legendMap
:{
"
1
"
:
"
good
"
,
"
2
"
:
"
warning
"
,
"
3
"
:
"
error
"
},
paddingInside
:
20
,
col
:
3
,
colInside
:
4
...
...
cat-home/src/main/webapp/jsp/report/metric.jsp
浏览文件 @
3954d7df
...
...
@@ -64,7 +64,7 @@
<c:forEach
var=
"item"
items=
"
${
model
.
display
.
lineCharts
}
"
varStatus=
"status"
>
<div
style=
"float:left;"
>
<h5
class=
"text-center text-error"
>
${item.title}
</h5>
<div
id=
"${item.title}"
class=
"
g
raph"
></div>
<div
id=
"${item.title}"
class=
"
metricG
raph"
></div>
</div>
</c:forEach>
</div>
...
...
cat-home/src/main/webapp/jsp/report/problem/problemHistoryReport.jsp
浏览文件 @
3954d7df
...
...
@@ -7,7 +7,7 @@
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.report.page.problem.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.report.page.problem.Model"
scope=
"request"
/>
<a:historyReport
title=
"History Report"
navUrlPrefix=
"
threshold=${model.threshold}&sqlThreshold=${model.sqlThreshold}&ip=${model.ipAddress
}"
>
<a:historyReport
title=
"History Report"
navUrlPrefix=
"
ip=${model.ipAddress}${payload.queryString
}"
>
<jsp:attribute
name=
"subtitle"
>
From ${w:format(payload.historyStartDate,'yyyy-MM-dd HH:mm:ss')} to ${w:format(payload.historyDisplayEndDate,'yyyy-MM-dd HH:mm:ss')}
</jsp:attribute>
<jsp:body>
...
...
@@ -18,74 +18,41 @@
<tr
style=
"text-align:left"
>
<th>
Machines:
[
<c:choose>
<c:when
test=
"
${
model
.
ipAddress
eq
'All'
}
"
>
<a
href=
"?op=history&domain=${model.domain}&date=${model.date}
&threshold=${model.threshold}&sqlThreshold=${model.sqlThreshold
}&ip=All&reportType=${model.reportType}${model.customDate}"
<a
href=
"?op=history&domain=${model.domain}&date=${model.date}
${payload.queryString
}&ip=All&reportType=${model.reportType}${model.customDate}"
class=
"current"
>
All
</a>
</c:when>
<c:otherwise>
<a
href=
"?op=history&domain=${model.domain}&date=${model.date}
&threshold=${model.threshold}&sqlThreshold=${model.sqlThreshold
}&ip=All&reportType=${model.reportType}${model.customDate}"
>
All
</a>
<a
href=
"?op=history&domain=${model.domain}&date=${model.date}
${payload.queryString
}&ip=All&reportType=${model.reportType}${model.customDate}"
>
All
</a>
</c:otherwise>
</c:choose>
]
<c:forEach
var=
"ip"
items=
"
${
model
.
ips
}
"
>
[
<c:choose>
<c:when
test=
"
${
model
.
ipAddress
eq
ip
}
"
>
<a
href=
"?op=history&domain=${model.domain}&ip=${ip}&date=${model.date}
&threshold=${model.threshold}&sqlThreshold=${model.sqlThreshold
}&reportType=${model.reportType}${model.customDate}"
<a
href=
"?op=history&domain=${model.domain}&ip=${ip}&date=${model.date}
${payload.queryString
}&reportType=${model.reportType}${model.customDate}"
class=
"current"
>
${ip}
</a>
</c:when>
<c:otherwise>
<a
href=
"?op=history&domain=${model.domain}&ip=${ip}&date=${model.date}
&threshold=${model.threshold}&sqlThreshold=${model.sqlThreshold
}&reportType=${model.reportType}${model.customDate}"
>
${ip}
</a>
<a
href=
"?op=history&domain=${model.domain}&ip=${ip}&date=${model.date}
${payload.queryString
}&reportType=${model.reportType}${model.customDate}"
>
${ip}
</a>
</c:otherwise>
</c:choose>
]
</c:forEach>
</th>
<th>
long-url
<input
id=
"thresholdInput"
style=
"display: none"
value=
"${model.threshold}"
>
<select
class=
"input-small"
size=
"1"
id=
"p_longUrl"
>
${model.defaultThreshold}
<option
value=
"500"
>
0.5 Sec
</option>
<option
value=
"1000"
>
1.0 Sec
</option>
<option
value=
"1500"
>
1.5 Sec
</option>
<option
value=
"2000"
>
2.0 Sec
</option>
<option
value=
"3000"
>
3.0 Sec
</option>
<option
value=
"5000"
>
5.0 Sec
</option>
</select>
long-sql
<select
size=
"1"
id=
"p_longSql"
class=
"input-small"
>
${model.defaultSqlThreshold}
<option
value=
"100"
>
100 ms
</option>
<option
value=
"500"
>
500 ms
</option>
<option
value=
"1000"
>
1000 ms
</option>
<option
value=
"2000"
>
3000 ms
</option>
</select>
long-service
<select
size=
"1"
id=
"p_longService"
class=
"input-small"
>
${model.defaultSqlThreshold}
<option
value=
"100"
>
50 ms
</option>
<option
value=
"200"
>
100 ms
</option>
<option
value=
"200"
>
500 ms
</option>
<option
value=
"1000"
>
1000 ms
</option>
<option
value=
"2000"
>
3000 ms
</option>
<option
value=
"5000"
>
5000 ms
</option>
</select>
</th></tr>
<tr><th>
<%@ include
file=
"problemQuery.jsp"
%></th>
<script>
var
threshold
=
'
${model.threshold}
'
;
$
(
"
#p_longUrl
"
).
val
(
threshold
)
;
var
sqlThreshold
=
'
${model.sqlThreshold}
'
;
$
(
"
#p_longSql
"
).
val
(
sqlThreshold
)
;
var
serviceThreshold
=
'
${model.serviceThreshold}
'
;
$
(
"
#p_longService
"
).
val
(
serviceThreshold
)
;
function
longTimeChange
(
date
,
domain
,
ip
){
var
customDate
=
'
${model.customDate}
'
;
var
reportType
=
'
${model.reportType}
'
;
var
long
t
ime
=
$
(
"
#p_longUrl
"
).
val
();
var
long
UrlT
ime
=
$
(
"
#p_longUrl
"
).
val
();
var
longSqlTime
=
$
(
"
#p_longSql
"
).
val
();
var
longServiceTime
=
$
(
"
#p_longService
"
).
val
();
window
.
location
.
href
=
"
?op=history&domain=
"
+
domain
+
"
&ip=
"
+
ip
+
"
&date=
"
+
date
+
"
&threshold=
"
+
longtime
+
"
&sqlThreshold=
"
+
longSqlTime
+
'
&reportType=
'
+
reportType
+
customDate
+
"
&serviceThreshold=
"
+
longServiceTime
;
var
longCacheTime
=
$
(
"
#p_longCache
"
).
val
();
var
longCallTime
=
$
(
"
#p_longCall
"
).
val
();
window
.
location
.
href
=
"
?op=history&domain=
"
+
domain
+
"
&ip=
"
+
ip
+
"
&date=
"
+
date
+
"
&urlThreshold=
"
+
longUrlTime
+
"
&sqlThreshold=
"
+
longSqlTime
+
'
&reportType=
'
+
reportType
+
customDate
+
"
&serviceThreshold=
"
+
longServiceTime
+
"
&cacheThreshold=
"
+
longCacheTime
+
"
&callThreshold=
"
+
longCallTime
;
}
</script><input
class=
"btn btn-primary btn-small"
value=
"Refresh"
onclick=
"longTimeChange('${model.date}','${model.domain}','${model.ipAddress}')"
type=
"submit"
>
</th>
</script>
</tr>
</table>
...
...
cat-home/src/main/webapp/jsp/report/problem/problemQuery.jsp
0 → 100644
浏览文件 @
3954d7df
<%@ page
contentType=
"text/html; charset=utf-8"
%>
<div>
Long-url
<select
class=
"input-small"
size=
"1"
id=
"p_longUrl"
>
${model.defaultThreshold}
<option
value=
"500"
>
0.5 Sec
</option>
<option
value=
"1000"
>
1.0 Sec
</option>
<option
value=
"1500"
>
1.5 Sec
</option>
<option
value=
"2000"
>
2.0 Sec
</option>
<option
value=
"3000"
>
3.0 Sec
</option>
<option
value=
"5000"
>
5.0 Sec
</option>
</select>
Long-sql
<select
size=
"1"
id=
"p_longSql"
class=
"input-small"
>
${model.defaultSqlThreshold}
<option
value=
"100"
>
100 ms
</option>
<option
value=
"500"
>
500 ms
</option>
<option
value=
"1000"
>
1000 ms
</option>
<option
value=
"2000"
>
3000 ms
</option>
<option
value=
"2000"
>
5000 ms
</option>
</select>
Long-service
<select
size=
"1"
id=
"p_longService"
class=
"input-small"
>
${model.defaultSqlThreshold}
<option
value=
"100"
>
50 ms
</option>
<option
value=
"200"
>
100 ms
</option>
<option
value=
"200"
>
500 ms
</option>
<option
value=
"1000"
>
1000 ms
</option>
<option
value=
"2000"
>
3000 ms
</option>
<option
value=
"5000"
>
5000 ms
</option>
</select>
Long-cache
<select
size=
"1"
id=
"p_longCache"
class=
"input-small"
>
<option
value=
"10"
>
10 ms
</option>
<option
value=
"50"
>
50 ms
</option>
<option
value=
"100"
>
100 ms
</option>
<option
value=
"1000"
>
500 ms
</option>
</select>
Long-call
<select
size=
"1"
id=
"p_longCall"
class=
"input-small"
>
<option
value=
"100"
>
50 ms
</option>
<option
value=
"200"
>
100 ms
</option>
<option
value=
"200"
>
500 ms
</option>
<option
value=
"1000"
>
1000 ms
</option>
<option
value=
"2000"
>
3000 ms
</option>
<option
value=
"5000"
>
5000 ms
</option>
</select>
<input
class=
"btn btn-primary btn-small"
value=
"Refresh"
onclick=
"longTimeChange('${model.date}','${model.domain}','${model.ipAddress}')"
type=
"submit"
></div>
<script>
var
urlThreshold
=
'
${payload.urlThreshold}
'
;
$
(
"
#p_longUrl
"
).
val
(
urlThreshold
)
;
var
sqlThreshold
=
'
${payload.sqlThreshold}
'
;
$
(
"
#p_longSql
"
).
val
(
sqlThreshold
)
;
var
serviceThreshold
=
'
${payload.serviceThreshold}
'
;
$
(
"
#p_longService
"
).
val
(
serviceThreshold
)
;
var
cacheThreshold
=
'
${payload.cacheThreshold}
'
;
$
(
"
#p_longCache
"
).
val
(
cacheThreshold
)
;
var
callThreshold
=
'
${payload.callThreshold}
'
;
$
(
"
#p_longCall
"
).
val
(
callThreshold
)
;
</script>
cat-home/src/main/webapp/jsp/report/problem/problemStatics.jsp
浏览文件 @
3954d7df
...
...
@@ -10,7 +10,7 @@
<c:set
var=
"report"
value=
"
${
model
.
report
}
"
/>
<a:report
title=
"Problem Report"
navUrlPrefix=
"op=${payload.action.name}&domain=${model.domain}&ip=${model.ipAddress}
&threshold=${model.threshold}&sqlThreshold=${model.sqlThreshold
}"
navUrlPrefix=
"op=${payload.action.name}&domain=${model.domain}&ip=${model.ipAddress}
${payload.queryString
}"
timestamp=
"
${
w:
format
(
model
.
creatTime
,
'yyyy-MM-dd HH:mm:ss'
)
}
"
>
<jsp:attribute
name=
"subtitle"
>
From ${w:format(report.startTime,'yyyy-MM-dd HH:mm:ss')} to ${w:format(report.endTime,'yyyy-MM-dd HH:mm:ss')}
</jsp:attribute>
...
...
@@ -23,72 +23,39 @@
<tr
style=
"text-align:left"
>
<th>
Machines:
[
<c:choose>
<c:when
test=
"
${
model
.
ipAddress
eq
'All'
}
"
>
<a
href=
"?domain=${model.domain}&date=${model.date}
&threshold=${model.threshold
}"
<a
href=
"?domain=${model.domain}&date=${model.date}
${payload.queryString
}"
class=
"current"
>
All
</a>
</c:when>
<c:otherwise>
<a
href=
"?domain=${model.domain}&date=${model.date}
&threshold=${model.threshold
}"
>
All
</a>
<a
href=
"?domain=${model.domain}&date=${model.date}
${payload.queryString
}"
>
All
</a>
</c:otherwise>
</c:choose>
]
<c:forEach
var=
"ip"
items=
"
${
model
.
ips
}
"
>
[
<c:choose>
<c:when
test=
"
${
model
.
ipAddress
eq
ip
}
"
>
<a
href=
"?op=view&domain=${model.domain}&ip=${ip}&date=${model.date}
&threshold=${model.threshold}&sqlThreshold=${model.sqlThreshold
}"
<a
href=
"?op=view&domain=${model.domain}&ip=${ip}&date=${model.date}
${payload.queryString
}"
class=
"current"
>
${ip}
</a>
</c:when>
<c:otherwise>
<a
href=
"?op=view&domain=${model.domain}&ip=${ip}&date=${model.date}
&threshold=${model.threshold}&sqlThreshold=${model.sqlThreshold
}"
>
${ip}
</a>
<a
href=
"?op=view&domain=${model.domain}&ip=${ip}&date=${model.date}
${payload.queryString
}"
>
${ip}
</a>
</c:otherwise>
</c:choose>
]
</c:forEach>
</th><th>
long-url
<input
id=
"thresholdInput"
style=
"display: none"
value=
"${model.threshold}"
>
<select
class=
"input-small"
size=
"1"
id=
"p_longUrl"
>
${model.defaultThreshold}
<option
value=
"500"
>
0.5 Sec
</option>
<option
value=
"1000"
>
1.0 Sec
</option>
<option
value=
"1500"
>
1.5 Sec
</option>
<option
value=
"2000"
>
2.0 Sec
</option>
<option
value=
"3000"
>
3.0 Sec
</option>
<option
value=
"5000"
>
5.0 Sec
</option>
</select>
long-sql
<select
size=
"1"
id=
"p_longSql"
class=
"input-small"
>
${model.defaultSqlThreshold}
<option
value=
"100"
>
100 ms
</option>
<option
value=
"500"
>
500 ms
</option>
<option
value=
"1000"
>
1000 ms
</option>
<option
value=
"2000"
>
3000 ms
</option>
</select>
long-service
<select
size=
"1"
id=
"p_longService"
class=
"input-small"
>
${model.defaultSqlThreshold}
<option
value=
"100"
>
50 ms
</option>
<option
value=
"200"
>
100 ms
</option>
<option
value=
"200"
>
500 ms
</option>
<option
value=
"1000"
>
1000 ms
</option>
<option
value=
"2000"
>
3000 ms
</option>
<option
value=
"5000"
>
5000 ms
</option>
</select>
</th></tr>
<tr><th>
<%@ include
file=
"problemQuery.jsp"
%>
<script>
var
threshold
=
'
${model.threshold}
'
;
$
(
"
#p_longUrl
"
).
val
(
threshold
)
;
var
sqlThreshold
=
'
${model.sqlThreshold}
'
;
$
(
"
#p_longSql
"
).
val
(
sqlThreshold
)
;
var
serviceThreshold
=
'
${model.serviceThreshold}
'
;
$
(
"
#p_longService
"
).
val
(
serviceThreshold
)
;
function
longTimeChange
(
date
,
domain
,
ip
){
var
long
t
ime
=
$
(
"
#p_longUrl
"
).
val
();
var
long
UrlT
ime
=
$
(
"
#p_longUrl
"
).
val
();
var
longSqlTime
=
$
(
"
#p_longSql
"
).
val
();
var
longServiceTime
=
$
(
"
#p_longService
"
).
val
();
window
.
location
.
href
=
"
?op=view&domain=
"
+
domain
+
"
&ip=
"
+
ip
+
"
&date=
"
+
date
+
"
&threshold=
"
+
longtime
+
"
&sqlThreshold=
"
+
longSqlTime
+
"
&serviceThreshold=
"
+
longServiceTime
;
var
longCacheTime
=
$
(
"
#p_longCache
"
).
val
();
var
longCallTime
=
$
(
"
#p_longCall
"
).
val
();
window
.
location
.
href
=
"
?op=view&domain=
"
+
domain
+
"
&ip=
"
+
ip
+
"
&date=
"
+
date
+
"
&urlThreshold=
"
+
longUrlTime
+
"
&sqlThreshold=
"
+
longSqlTime
+
"
&serviceThreshold=
"
+
longServiceTime
+
"
&cacheThreshold=
"
+
longCacheTime
+
"
&callThreshold=
"
+
longCallTime
;
}
</script>
<input
class=
'btn btn-primary btn-small'
value=
"Refresh"
onclick=
"longTimeChange('${model.date}','${model.domain}','${model.ipAddress}')"
type=
"submit"
>
</th>
</tr>
</table>
...
...
cat-home/src/test/java/com/dianping/cat/AllTests.java
浏览文件 @
3954d7df
...
...
@@ -4,6 +4,7 @@ import org.junit.runner.RunWith;
import
org.junit.runners.Suite
;
import
org.junit.runners.Suite.SuiteClasses
;
import
com.dianping.cat.report.baseline.BaselineCreatorTest
;
import
com.dianping.cat.report.graph.ValueTranslaterTest
;
import
com.dianping.cat.report.page.cross.CMDBTest
;
import
com.dianping.cat.report.page.cross.CrossReportMergerTest
;
...
...
@@ -97,6 +98,11 @@ DependencyReportMergerTest.class, GraphConfigManagerTest.class,
/* CMDB */
CMDBTest
.
class
,
/* BaseLine */
BaselineCreatorTest
.
class
,
MetricReportParseTest
.
class
,
/* jsError */
ParseTest
.
class
})
public
class
AllTests
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录