Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
4eb20042
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,发现更多精彩内容 >>
提交
4eb20042
编写于
12月 12, 2013
作者:
Y
youyong205
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify the graph creator
上级
8dc7b909
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
106 addition
and
105 deletion
+106
-105
cat-home/src/main/java/com/dianping/cat/report/task/TaskHelper.java
...rc/main/java/com/dianping/cat/report/task/TaskHelper.java
+16
-16
cat-home/src/main/java/com/dianping/cat/report/task/abtest/ABTestReportBuilder.java
.../dianping/cat/report/task/abtest/ABTestReportBuilder.java
+52
-52
cat-home/src/main/java/com/dianping/cat/report/task/event/EventGraphCreator.java
...com/dianping/cat/report/task/event/EventGraphCreator.java
+25
-27
cat-home/src/main/java/com/dianping/cat/report/task/heartbeat/HeartbeatGraphCreator.java
...ping/cat/report/task/heartbeat/HeartbeatGraphCreator.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/task/heartbeat/HeartbeatReportBuilder.java
...ing/cat/report/task/heartbeat/HeartbeatReportBuilder.java
+2
-2
cat-home/src/main/java/com/dianping/cat/report/task/problem/ProblemGraphCreator.java
...dianping/cat/report/task/problem/ProblemGraphCreator.java
+9
-4
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/TaskHelper.java
浏览文件 @
4eb20042
...
...
@@ -83,37 +83,33 @@ public class TaskHelper {
return
buf
.
toString
();
}
public
static
Date
todayZero
(
Date
period
)
{
if
(
period
==
null
)
{
period
=
new
Date
();
}
public
static
Date
nextMonthStart
(
Date
period
)
{
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
period
);
cal
.
add
(
Calendar
.
MONTH
,
1
);
cal
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
cal
.
set
(
Calendar
.
MINUTE
,
0
);
cal
.
set
(
Calendar
.
SECOND
,
0
);
cal
.
set
(
Calendar
.
MILLISECOND
,
0
);
return
cal
.
getTime
();
}
public
static
Date
tomorrowZero
(
Date
period
)
{
if
(
period
==
null
)
{
period
=
new
Date
();
}
public
static
Date
thisHour
(
Date
period
)
{
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
period
);
cal
.
add
(
Calendar
.
DAY_OF_YEAR
,
1
);
cal
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
cal
.
set
(
Calendar
.
MINUTE
,
0
);
cal
.
set
(
Calendar
.
SECOND
,
0
);
cal
.
set
(
Calendar
.
MILLISECOND
,
0
);
return
cal
.
getTime
();
}
public
static
Date
yesterdayZero
(
Date
period
)
{
public
static
Date
todayZero
(
Date
period
)
{
if
(
period
==
null
)
{
period
=
new
Date
();
}
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
period
);
cal
.
add
(
Calendar
.
DAY_OF_YEAR
,
-
1
);
cal
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
cal
.
set
(
Calendar
.
MINUTE
,
0
);
cal
.
set
(
Calendar
.
SECOND
,
0
);
...
...
@@ -121,24 +117,28 @@ public class TaskHelper {
return
cal
.
getTime
();
}
public
static
Date
thisHour
(
Date
period
)
{
public
static
Date
tomorrowZero
(
Date
period
)
{
if
(
period
==
null
)
{
period
=
new
Date
();
}
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
period
);
cal
.
add
(
Calendar
.
DAY_OF_YEAR
,
1
);
cal
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
cal
.
set
(
Calendar
.
MINUTE
,
0
);
cal
.
set
(
Calendar
.
SECOND
,
0
);
cal
.
set
(
Calendar
.
MILLISECOND
,
0
);
return
cal
.
getTime
();
}
public
static
Date
nextMonthStart
(
Date
period
)
{
public
static
Date
yesterdayZero
(
Date
period
)
{
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
period
);
cal
.
add
(
Calendar
.
MONTH
,
1
);
cal
.
add
(
Calendar
.
DAY_OF_YEAR
,
-
1
);
cal
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
cal
.
set
(
Calendar
.
MINUTE
,
0
);
cal
.
set
(
Calendar
.
SECOND
,
0
);
cal
.
set
(
Calendar
.
MILLISECOND
,
0
);
return
cal
.
getTime
();
}
}
cat-home/src/main/java/com/dianping/cat/report/task/abtest/ABTestReportBuilder.java
浏览文件 @
4eb20042
...
...
@@ -40,6 +40,11 @@ public class ABTestReportBuilder implements ReportTaskBuilder, Initializable {
private
Calendar
m_calendar
=
Calendar
.
getInstance
();
@Override
public
boolean
buildDailyTask
(
String
name
,
String
domain
,
Date
period
)
{
throw
new
UnsupportedOperationException
(
"ABTest report don't support daily report!"
);
}
@Override
public
boolean
buildHourlyTask
(
String
name
,
String
domain
,
Date
period
)
{
List
<
AbtestRun
>
runs
=
m_abtestService
.
getAbtestRunByStatus
(
AbtestStatus
.
RUNNING
);
...
...
@@ -53,22 +58,33 @@ public class ABTestReportBuilder implements ReportTaskBuilder, Initializable {
return
true
;
}
private
Date
resetTime
(
String
period
,
Date
time
)
{
m_calendar
.
setTime
(
time
);
m_calendar
.
set
(
Calendar
.
MINUTE
,
0
);
m_calendar
.
set
(
Calendar
.
SECOND
,
0
);
m_calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
private
void
buildHourlyTaskInternal
(
Date
period
,
Set
<
String
>
productLineSet
)
{
MetricReportForABTestVisitor
visitor
=
new
MetricReportForABTestVisitor
();
if
(
period
.
equals
(
"day"
))
{
m_calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
for
(
String
productLine
:
productLineSet
)
{
MetricReport
metricReport
=
m_reportService
.
queryMetricReport
(
productLine
,
period
,
new
Date
(
period
.
getTime
()
+
TimeUtil
.
ONE_HOUR
));
metricReport
.
accept
(
visitor
);
}
return
m_calendar
.
getTime
();
}
Map
<
Integer
,
AbtestReport
>
result
=
visitor
.
getReportMap
();
@Override
public
boolean
buildDailyTask
(
String
name
,
String
domain
,
Date
period
)
{
throw
new
UnsupportedOperationException
(
"ABTest report don't support daily report!"
);
for
(
AbtestReport
report
:
result
.
values
())
{
if
(
report
.
getRunId
()
!=
-
1
)
{
com
.
dianping
.
cat
.
home
.
dal
.
abtest
.
AbtestReport
_report
=
new
com
.
dianping
.
cat
.
home
.
dal
.
abtest
.
AbtestReport
();
_report
.
setRunId
(
report
.
getRunId
());
_report
.
setPeriod
(
period
);
_report
.
setContent
(
report
.
toString
());
try
{
m_abtestReportDao
.
insert
(
_report
);
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
}
}
}
}
@Override
...
...
@@ -81,26 +97,6 @@ public class ABTestReportBuilder implements ReportTaskBuilder, Initializable {
throw
new
UnsupportedOperationException
(
"ABTest line report don't support weekly report!"
);
}
@Override
public
void
initialize
()
throws
InitializationException
{
Date
now
=
resetTime
(
"hour"
,
new
Date
());
List
<
AbtestRun
>
runs
=
m_abtestService
.
getAbtestRunByStatus
(
AbtestStatus
.
RUNNING
);
for
(
AbtestRun
run
:
runs
)
{
Set
<
String
>
productLineSet
=
getProductLinesByRunID
(
run
);
Date
period
=
getLatestPeriod
(
now
,
run
.
getId
());
m_calendar
.
setTime
(
period
);
while
(!
period
.
after
(
now
))
{
buildHourlyTaskInternal
(
period
,
productLineSet
);
m_calendar
.
add
(
Calendar
.
HOUR
,
1
);
period
=
m_calendar
.
getTime
();
}
}
}
private
Date
getLatestPeriod
(
Date
now
,
int
runId
)
{
com
.
dianping
.
cat
.
home
.
dal
.
abtest
.
AbtestReport
latestReport
=
null
;
Date
period
=
null
;
...
...
@@ -137,32 +133,36 @@ public class ABTestReportBuilder implements ReportTaskBuilder, Initializable {
return
productLineSet
;
}
private
void
buildHourlyTaskInternal
(
Date
period
,
Set
<
String
>
productLineSet
)
{
MetricReportForABTestVisitor
visitor
=
new
MetricReportForABTestVisitor
();
@Override
public
void
initialize
()
throws
InitializationException
{
Date
now
=
resetTime
(
"hour"
,
new
Date
());
List
<
AbtestRun
>
runs
=
m_abtestService
.
getAbtestRunByStatus
(
AbtestStatus
.
RUNNING
);
for
(
String
productLine
:
productLineSet
)
{
MetricReport
metricReport
=
m_reportService
.
queryMetricReport
(
productLine
,
period
,
new
Date
(
period
.
getTime
()
+
TimeUtil
.
ONE_HOUR
));
for
(
AbtestRun
run
:
runs
)
{
Set
<
String
>
productLineSet
=
getProductLinesByRunID
(
run
);
Date
period
=
getLatestPeriod
(
now
,
run
.
getId
(
));
metricReport
.
accept
(
visitor
);
}
m_calendar
.
setTime
(
period
);
Map
<
Integer
,
AbtestReport
>
result
=
visitor
.
getReportMap
();
while
(!
period
.
after
(
now
))
{
buildHourlyTaskInternal
(
period
,
productLineSet
);
for
(
AbtestReport
report
:
result
.
values
())
{
if
(
report
.
getRunId
()
!=
-
1
)
{
com
.
dianping
.
cat
.
home
.
dal
.
abtest
.
AbtestReport
_report
=
new
com
.
dianping
.
cat
.
home
.
dal
.
abtest
.
AbtestReport
();
m_calendar
.
add
(
Calendar
.
HOUR
,
1
);
period
=
m_calendar
.
getTime
();
}
}
}
_report
.
setRunId
(
report
.
getRunId
());
_report
.
setPeriod
(
period
);
_report
.
setContent
(
report
.
toString
());
private
Date
resetTime
(
String
period
,
Date
time
)
{
m_calendar
.
setTime
(
time
);
m_calendar
.
set
(
Calendar
.
MINUTE
,
0
);
m_calendar
.
set
(
Calendar
.
SECOND
,
0
);
m_calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
try
{
m_abtestReportDao
.
insert
(
_report
);
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
}
}
if
(
period
.
equals
(
"day"
))
{
m_calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
}
return
m_calendar
.
getTime
();
}
}
cat-home/src/main/java/com/dianping/cat/report/task/event/EventGraphCreator.java
浏览文件 @
4eb20042
...
...
@@ -21,7 +21,7 @@ import com.dianping.cat.core.dal.Graph;
import
com.dianping.cat.report.task.spi.GraphLine
;
public
class
EventGraphCreator
{
private
List
<
Graph
>
m_graphs
=
new
ArrayList
<
Graph
>();
private
EventReport
m_report
;
...
...
@@ -32,8 +32,8 @@ public class EventGraphCreator {
return
m_graphs
;
}
private
class
EventReportVisitor
extends
BaseVisitor
{
private
class
EventReportVisitor
extends
BaseVisitor
{
String
m_currentIp
;
...
...
@@ -78,8 +78,8 @@ public class EventGraphCreator {
return
sb
.
toString
();
}
private
void
buildContent
(
StringBuilder
content
,
String
key
,
GraphLine
graphLine
)
{
content
.
append
(
key
).
append
(
'\t'
);
private
void
buildContent
(
StringBuilder
content
,
EventType
type
,
GraphLine
graphLine
)
{
content
.
append
(
type
.
getId
()
).
append
(
'\t'
);
content
.
append
(
arrayToString
(
graphLine
.
totalCounts
)).
append
(
'\t'
);
content
.
append
(
arrayToString
(
graphLine
.
failCounts
)).
append
(
'\n'
);
}
...
...
@@ -91,12 +91,12 @@ public class EventGraphCreator {
content
.
append
(
arrayToString
(
graphLine
.
failCounts
)).
append
(
'\n'
);
}
private
void
buildContent
(
StringBuilder
content
,
EventType
type
,
GraphLine
graphLine
)
{
content
.
append
(
type
.
getId
()
).
append
(
'\t'
);
private
void
buildContent
(
StringBuilder
content
,
String
key
,
GraphLine
graphLine
)
{
content
.
append
(
key
).
append
(
'\t'
);
content
.
append
(
arrayToString
(
graphLine
.
totalCounts
)).
append
(
'\t'
);
content
.
append
(
arrayToString
(
graphLine
.
failCounts
)).
append
(
'\n'
);
}
private
Graph
buildGraph
(
String
ip
)
{
Graph
graph
=
new
Graph
();
graph
.
setIp
(
ip
);
...
...
@@ -123,6 +123,23 @@ public class EventGraphCreator {
}
}
@Override
public
void
visitEventReport
(
EventReport
eventReport
)
{
Graph
allGraph
=
buildGraph
(
"all"
);
m_graphs
.
add
(
allGraph
);
m_allDetailContent
=
new
StringBuilder
();
m_allSummaryContent
=
new
StringBuilder
();
super
.
visitEventReport
(
eventReport
);
for
(
Entry
<
String
,
GraphLine
>
entry
:
m_allDetails
.
entrySet
())
{
buildContent
(
m_allDetailContent
,
entry
.
getKey
(),
entry
.
getValue
());
}
for
(
Entry
<
String
,
GraphLine
>
entry
:
m_allSummaries
.
entrySet
())
{
buildContent
(
m_allSummaryContent
,
entry
.
getKey
(),
entry
.
getValue
());
}
allGraph
.
setDetailContent
(
m_allDetailContent
.
toString
());
allGraph
.
setSummaryContent
(
m_allSummaryContent
.
toString
());
}
@Override
public
void
visitMachine
(
Machine
machine
)
{
m_currentIp
=
machine
.
getIp
();
...
...
@@ -165,23 +182,6 @@ public class EventGraphCreator {
m_currentIndex
++;
}
@Override
public
void
visitEventReport
(
EventReport
eventReport
)
{
Graph
allGraph
=
buildGraph
(
"all"
);
m_graphs
.
add
(
allGraph
);
m_allDetailContent
=
new
StringBuilder
();
m_allSummaryContent
=
new
StringBuilder
();
super
.
visitEventReport
(
eventReport
);
for
(
Entry
<
String
,
GraphLine
>
entry
:
m_allDetails
.
entrySet
())
{
buildContent
(
m_allDetailContent
,
entry
.
getKey
(),
entry
.
getValue
());
}
for
(
Entry
<
String
,
GraphLine
>
entry
:
m_allSummaries
.
entrySet
())
{
buildContent
(
m_allSummaryContent
,
entry
.
getKey
(),
entry
.
getValue
());
}
allGraph
.
setDetailContent
(
m_allDetailContent
.
toString
());
allGraph
.
setSummaryContent
(
m_allSummaryContent
.
toString
());
}
@Override
public
void
visitType
(
EventType
type
)
{
// TYPE, TOTAL_COUNT, FAILURE_COUNT, MIN, MAX, SUM, SUM2
...
...
@@ -204,6 +204,4 @@ public class EventGraphCreator {
}
}
}
cat-home/src/main/java/com/dianping/cat/report/task/heartbeat/HeartbeatGraphCreator.java
浏览文件 @
4eb20042
...
...
@@ -187,7 +187,7 @@ public class HeartbeatGraphCreator {
public
void
visitDisk
(
Disk
disk
)
{
String
key
=
"Disk "
+
disk
.
getPath
();
Number
value
=
disk
.
getFree
();
cacheHeartbeatColumn
(
key
,
value
);
super
.
visitDisk
(
disk
);
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/heartbeat/HeartbeatReportBuilder.java
浏览文件 @
4eb20042
...
...
@@ -57,8 +57,8 @@ public class HeartbeatReportBuilder implements ReportTaskBuilder {
}
private
List
<
Graph
>
qeueryHourlyGraphs
(
String
name
,
String
domain
,
Date
period
)
throws
DalException
{
HeartbeatReport
heartbeatReport
=
m_reportService
.
queryHeartbeatReport
(
domain
,
period
,
new
Date
(
period
.
getTime
()
+
TimeUtil
.
ONE_HOUR
));
HeartbeatReport
heartbeatReport
=
m_reportService
.
queryHeartbeatReport
(
domain
,
period
,
new
Date
(
period
.
getTime
()
+
TimeUtil
.
ONE_HOUR
));
return
m_heartbeatGraphCreator
.
buildGraph
(
heartbeatReport
);
}
}
cat-home/src/main/java/com/dianping/cat/report/task/problem/ProblemGraphCreator.java
浏览文件 @
4eb20042
...
...
@@ -72,6 +72,7 @@ public class ProblemGraphCreator {
Graph
graph
=
buildGraph
(
machine
.
getIp
());
StringBuilder
summaryBuilder
=
new
StringBuilder
();
for
(
Entry
<
String
,
GraphLine
>
summaryEntry
:
m_summaryCache
.
entrySet
())
{
GraphLine
summaryLine
=
summaryEntry
.
getValue
();
summaryBuilder
.
append
(
summaryEntry
.
getKey
());
...
...
@@ -82,7 +83,9 @@ public class ProblemGraphCreator {
summaryBuilder
.
append
(
"\n"
);
}
graph
.
setSummaryContent
(
summaryBuilder
.
toString
());
StringBuilder
detailBuilder
=
new
StringBuilder
();
for
(
Entry
<
String
,
GraphLine
>
detailEntry
:
m_detailCache
.
entrySet
())
{
GraphLine
detailLine
=
detailEntry
.
getValue
();
detailBuilder
.
append
(
detailEntry
.
getKey
());
...
...
@@ -93,7 +96,6 @@ public class ProblemGraphCreator {
detailBuilder
.
append
(
"\n"
);
}
graph
.
setDetailContent
(
detailBuilder
.
toString
());
graph
.
setCreationDate
(
new
Date
());
m_graphs
.
add
(
graph
);
}
...
...
@@ -102,8 +104,8 @@ public class ProblemGraphCreator {
public
void
visitProblemReport
(
ProblemReport
problemReport
)
{
super
.
visitProblemReport
(
problemReport
);
Graph
allGraph
=
buildGraph
(
"all"
);
StringBuilder
summaryBuilder
=
new
StringBuilder
();
for
(
Entry
<
String
,
GraphLine
>
summaryEntry
:
m_allSummaryCache
.
entrySet
())
{
GraphLine
summaryLine
=
summaryEntry
.
getValue
();
summaryBuilder
.
append
(
summaryEntry
.
getKey
());
...
...
@@ -116,6 +118,7 @@ public class ProblemGraphCreator {
allGraph
.
setSummaryContent
(
summaryBuilder
.
toString
());
StringBuilder
detailBuilder
=
new
StringBuilder
();
for
(
Entry
<
String
,
GraphLine
>
detailEntry
:
m_allDetailCache
.
entrySet
())
{
GraphLine
detailLine
=
detailEntry
.
getValue
();
detailBuilder
.
append
(
detailEntry
.
getKey
());
...
...
@@ -127,7 +130,6 @@ public class ProblemGraphCreator {
}
allGraph
.
setDetailContent
(
detailBuilder
.
toString
());
allGraph
.
setCreationDate
(
new
Date
());
m_graphs
.
add
(
allGraph
);
}
...
...
@@ -136,8 +138,8 @@ public class ProblemGraphCreator {
int
minute
=
segment
.
getId
();
int
count
=
segment
.
getMessages
().
size
();
String
summaryKey
=
m_type
;
GraphLine
summaryLine
=
m_summaryCache
.
get
(
summaryKey
);
if
(
summaryLine
==
null
)
{
summaryLine
=
new
GraphLine
();
summaryLine
.
minuteCounts
=
new
int
[
60
];
...
...
@@ -147,6 +149,7 @@ public class ProblemGraphCreator {
summaryLine
.
minuteCounts
[
minute
]
=
summaryLine
.
minuteCounts
[
minute
]
+
count
;
GraphLine
allSummaryLine
=
m_allSummaryCache
.
get
(
summaryKey
);
if
(
allSummaryLine
==
null
)
{
allSummaryLine
=
new
GraphLine
();
allSummaryLine
.
minuteCounts
=
new
int
[
60
];
...
...
@@ -157,6 +160,7 @@ public class ProblemGraphCreator {
String
detailKey
=
m_type
+
"\t"
+
m_status
;
GraphLine
detailLine
=
m_detailCache
.
get
(
detailKey
);
if
(
detailLine
==
null
)
{
detailLine
=
new
GraphLine
();
detailLine
.
minuteCounts
=
new
int
[
60
];
...
...
@@ -166,6 +170,7 @@ public class ProblemGraphCreator {
detailLine
.
minuteCounts
[
minute
]
=
detailLine
.
minuteCounts
[
minute
]
+
count
;
GraphLine
allDetailLine
=
m_allDetailCache
.
get
(
detailKey
);
if
(
allDetailLine
==
null
)
{
allDetailLine
=
new
GraphLine
();
allDetailLine
.
minuteCounts
=
new
int
[
60
];
...
...
cat-home/src/main/java/com/dianping/cat/report/task/transaction/TransactionGraphCreator.java
浏览文件 @
4eb20042
...
...
@@ -33,8 +33,6 @@ public class TransactionGraphCreator {
return
m_graphs
;
}
public
class
TransactionReportVisitor
extends
BaseVisitor
{
String
m_currentIp
;
...
...
@@ -123,7 +121,7 @@ public class TransactionGraphCreator {
content
.
append
(
arrayToString
(
graphLine
.
sums
)).
append
(
'\t'
);
content
.
append
(
type
.
getSum2
()).
append
(
'\t'
).
append
(
'\n'
);
}
private
Graph
buildGraph
(
String
ip
)
{
Graph
graph
=
new
Graph
();
graph
.
setIp
(
ip
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录