Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
1a55f336
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,发现更多精彩内容 >>
提交
1a55f336
编写于
10月 30, 2014
作者:
L
leon.li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add backend of high load sql module
上级
9e7eb432
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
270 addition
and
13 deletion
+270
-13
cat-consumer/src/main/java/com/dianping/cat/consumer/state/StateDelegate.java
...n/java/com/dianping/cat/consumer/state/StateDelegate.java
+3
-2
cat-core/src/main/java/com/dianping/cat/Constants.java
cat-core/src/main/java/com/dianping/cat/Constants.java
+2
-0
cat-home/src/main/java/com/dianping/cat/build/TaskComponentConfigurator.java
...ava/com/dianping/cat/build/TaskComponentConfigurator.java
+7
-0
cat-home/src/main/java/com/dianping/cat/report/task/highload/HighLoadSqlUpdater.java
...dianping/cat/report/task/highload/HighLoadSqlUpdater.java
+197
-0
cat-home/src/main/java/com/dianping/cat/report/task/highload/HighLoadUpdater.java
...om/dianping/cat/report/task/highload/HighLoadUpdater.java
+31
-0
cat-home/src/main/java/com/dianping/cat/report/task/highload/TransactionHighLoadUpdater.java
.../cat/report/task/highload/TransactionHighLoadUpdater.java
+7
-0
cat-home/src/main/java/com/dianping/cat/report/task/overload/CapacityUpdateTask.java
...dianping/cat/report/task/overload/CapacityUpdateTask.java
+9
-11
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+14
-0
未找到文件。
cat-consumer/src/main/java/com/dianping/cat/consumer/state/StateDelegate.java
浏览文件 @
1a55f336
...
@@ -44,7 +44,7 @@ public class StateDelegate implements ReportDelegate<StateReport> {
...
@@ -44,7 +44,7 @@ public class StateDelegate implements ReportDelegate<StateReport> {
String
domain
=
report
.
getDomain
();
String
domain
=
report
.
getDomain
();
m_taskManager
.
createTask
(
startTime
,
domain
,
StateAnalyzer
.
ID
,
TaskProlicy
.
ALL_EXCLUED_HOURLY
);
m_taskManager
.
createTask
(
startTime
,
domain
,
StateAnalyzer
.
ID
,
TaskProlicy
.
ALL_EXCLUED_HOURLY
);
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
REPORT_SERVICE
,
TaskProlicy
.
ALL
);
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
REPORT_SERVICE
,
TaskProlicy
.
ALL
);
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
REPORT_BUG
,
TaskProlicy
.
ALL
);
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
REPORT_BUG
,
TaskProlicy
.
ALL
);
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
REPORT_HEAVY
,
TaskProlicy
.
ALL
);
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
REPORT_HEAVY
,
TaskProlicy
.
ALL
);
...
@@ -52,11 +52,12 @@ public class StateDelegate implements ReportDelegate<StateReport> {
...
@@ -52,11 +52,12 @@ public class StateDelegate implements ReportDelegate<StateReport> {
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
REPORT_UTILIZATION
,
TaskProlicy
.
ALL
);
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
REPORT_UTILIZATION
,
TaskProlicy
.
ALL
);
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
REPORT_NET_TOPOLOGY
,
TaskProlicy
.
HOULY
);
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
REPORT_NET_TOPOLOGY
,
TaskProlicy
.
HOULY
);
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
REPORT_DATABASE_CAPACITY
,
TaskProlicy
.
ALL
);
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
REPORT_DATABASE_CAPACITY
,
TaskProlicy
.
ALL
);
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
HIGH_LOAD_SQL
,
TaskProlicy
.
DAILY
);
Calendar
cal
=
Calendar
.
getInstance
();
Calendar
cal
=
Calendar
.
getInstance
();
int
hour
=
cal
.
get
(
Calendar
.
HOUR_OF_DAY
);
int
hour
=
cal
.
get
(
Calendar
.
HOUR_OF_DAY
);
// for daily report aggreation done
// for daily report aggreation done
if
(
hour
>=
4
)
{
if
(
hour
>=
4
)
{
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
REPORT_NOTIFY
,
TaskProlicy
.
DAILY
);
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
REPORT_NOTIFY
,
TaskProlicy
.
DAILY
);
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
REPORT_ROUTER
,
TaskProlicy
.
DAILY
);
m_taskManager
.
createTask
(
startTime
,
domain
,
Constants
.
REPORT_ROUTER
,
TaskProlicy
.
DAILY
);
...
...
cat-core/src/main/java/com/dianping/cat/Constants.java
浏览文件 @
1a55f336
...
@@ -41,4 +41,6 @@ public class Constants {
...
@@ -41,4 +41,6 @@ public class Constants {
public
static
final
String
REPORT_NOTIFY
=
"dailyNotify"
;
public
static
final
String
REPORT_NOTIFY
=
"dailyNotify"
;
public
static
final
String
HIGH_LOAD_SQL
=
"highLoadSql"
;
}
}
cat-home/src/main/java/com/dianping/cat/build/TaskComponentConfigurator.java
浏览文件 @
1a55f336
...
@@ -12,6 +12,7 @@ import com.dianping.cat.config.app.AppConfigManager;
...
@@ -12,6 +12,7 @@ import com.dianping.cat.config.app.AppConfigManager;
import
com.dianping.cat.config.app.AppDataService
;
import
com.dianping.cat.config.app.AppDataService
;
import
com.dianping.cat.consumer.metric.MetricConfigManager
;
import
com.dianping.cat.consumer.metric.MetricConfigManager
;
import
com.dianping.cat.consumer.metric.ProductLineConfigManager
;
import
com.dianping.cat.consumer.metric.ProductLineConfigManager
;
import
com.dianping.cat.consumer.transaction.TransactionAnalyzer
;
import
com.dianping.cat.core.dal.DailyGraphDao
;
import
com.dianping.cat.core.dal.DailyGraphDao
;
import
com.dianping.cat.core.dal.DailyReportDao
;
import
com.dianping.cat.core.dal.DailyReportDao
;
import
com.dianping.cat.core.dal.GraphDao
;
import
com.dianping.cat.core.dal.GraphDao
;
...
@@ -35,6 +36,7 @@ import com.dianping.cat.report.baseline.BaselineService;
...
@@ -35,6 +36,7 @@ import com.dianping.cat.report.baseline.BaselineService;
import
com.dianping.cat.report.baseline.impl.DefaultBaselineCreator
;
import
com.dianping.cat.report.baseline.impl.DefaultBaselineCreator
;
import
com.dianping.cat.report.baseline.impl.DefaultBaselineService
;
import
com.dianping.cat.report.baseline.impl.DefaultBaselineService
;
import
com.dianping.cat.report.page.dependency.graph.TopologyGraphBuilder
;
import
com.dianping.cat.report.page.dependency.graph.TopologyGraphBuilder
;
import
com.dianping.cat.report.page.model.spi.ModelService
;
import
com.dianping.cat.report.page.network.nettopology.NetGraphBuilder
;
import
com.dianping.cat.report.page.network.nettopology.NetGraphBuilder
;
import
com.dianping.cat.report.page.transaction.TransactionMergeManager
;
import
com.dianping.cat.report.page.transaction.TransactionMergeManager
;
import
com.dianping.cat.report.service.ReportServiceManager
;
import
com.dianping.cat.report.service.ReportServiceManager
;
...
@@ -50,6 +52,7 @@ import com.dianping.cat.report.task.event.EventReportBuilder;
...
@@ -50,6 +52,7 @@ import com.dianping.cat.report.task.event.EventReportBuilder;
import
com.dianping.cat.report.task.heartbeat.HeartbeatGraphCreator
;
import
com.dianping.cat.report.task.heartbeat.HeartbeatGraphCreator
;
import
com.dianping.cat.report.task.heartbeat.HeartbeatReportBuilder
;
import
com.dianping.cat.report.task.heartbeat.HeartbeatReportBuilder
;
import
com.dianping.cat.report.task.heavy.HeavyReportBuilder
;
import
com.dianping.cat.report.task.heavy.HeavyReportBuilder
;
import
com.dianping.cat.report.task.highload.HighLoadSqlUpdater
;
import
com.dianping.cat.report.task.matrix.MatrixReportBuilder
;
import
com.dianping.cat.report.task.matrix.MatrixReportBuilder
;
import
com.dianping.cat.report.task.metric.MetricBaselineReportBuilder
;
import
com.dianping.cat.report.task.metric.MetricBaselineReportBuilder
;
import
com.dianping.cat.report.task.metric.MetricPointParser
;
import
com.dianping.cat.report.task.metric.MetricPointParser
;
...
@@ -182,6 +185,10 @@ public class TaskComponentConfigurator extends AbstractResourceConfigurator {
...
@@ -182,6 +185,10 @@ public class TaskComponentConfigurator extends AbstractResourceConfigurator {
.
req
(
CapacityUpdater
.
class
,
WeeklyCapacityUpdater
.
ID
,
"m_weeklyUpdater"
)
.
req
(
CapacityUpdater
.
class
,
WeeklyCapacityUpdater
.
ID
,
"m_weeklyUpdater"
)
.
req
(
CapacityUpdater
.
class
,
MonthlyCapacityUpdater
.
ID
,
"m_monthlyUpdater"
));
.
req
(
CapacityUpdater
.
class
,
MonthlyCapacityUpdater
.
ID
,
"m_monthlyUpdater"
));
all
.
add
(
C
(
ReportTaskBuilder
.
class
,
HighLoadSqlUpdater
.
ID
,
HighLoadSqlUpdater
.
class
)
//
.
req
(
ModelService
.
class
,
TransactionAnalyzer
.
ID
)
//
.
req
(
ReportServiceManager
.
class
));
all
.
add
(
C
(
ReportRender
.
class
,
ReportRenderImpl
.
class
));
all
.
add
(
C
(
ReportRender
.
class
,
ReportRenderImpl
.
class
));
all
.
add
(
C
(
AppDataComparisonRender
.
class
));
all
.
add
(
C
(
AppDataComparisonRender
.
class
));
...
...
cat-home/src/main/java/com/dianping/cat/report/task/highload/HighLoadSqlUpdater.java
0 → 100644
浏览文件 @
1a55f336
package
com.dianping.cat.report.task.highload
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Constants
;
import
com.dianping.cat.consumer.transaction.TransactionAnalyzer
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionName
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
import
com.dianping.cat.helper.TimeHelper
;
import
com.dianping.cat.report.page.model.spi.ModelService
;
import
com.dianping.cat.report.page.transaction.DisplayNames
;
import
com.dianping.cat.report.page.transaction.DisplayNames.TransactionNameModel
;
import
com.dianping.cat.report.service.ReportServiceManager
;
import
com.dianping.cat.service.ModelRequest
;
import
com.dianping.cat.service.ModelResponse
;
public
class
HighLoadSqlUpdater
extends
TransactionHighLoadUpdater
{
@Inject
(
type
=
ModelService
.
class
,
value
=
TransactionAnalyzer
.
ID
)
private
ModelService
<
TransactionReport
>
m_transactionService
;
@Inject
private
ReportServiceManager
m_reportService
;
public
static
final
String
ID
=
Constants
.
HIGH_LOAD_SQL
;
@Override
public
boolean
buildDailyTask
(
String
name
,
String
domain
,
Date
period
)
{
try
{
List
<
HighLoadSQL
>
sqls
=
generateHighLoadSqls
();
return
true
;
}
catch
(
Exception
ex
)
{
Cat
.
logError
(
ex
);
return
false
;
}
}
private
List
<
HighLoadSQL
>
generateHighLoadSqls
()
{
Set
<
String
>
domains
=
queryDomains
();
Heap
heap
=
new
Heap
();
for
(
String
domain
:
domains
)
{
try
{
TransactionReport
report
=
m_reportService
.
queryTransactionReport
(
domain
,
TimeHelper
.
getYesterday
(),
TimeHelper
.
getCurrentDay
());
DisplayNames
displayNames
=
new
DisplayNames
();
displayNames
.
display
(
""
,
getType
(),
"All"
,
report
,
""
);
for
(
TransactionNameModel
nameModel
:
displayNames
.
getResults
())
{
HighLoadSQL
sql
=
new
HighLoadSQL
(
domain
,
nameModel
.
getDetail
());
heap
.
add
(
sql
);
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
return
heap
.
getSqls
();
}
@Override
public
String
getID
()
{
return
ID
;
}
@Override
public
String
getType
()
{
return
"SQL"
;
}
private
Set
<
String
>
queryDomains
()
{
Set
<
String
>
domains
=
new
HashSet
<
String
>();
ModelRequest
request
=
new
ModelRequest
(
"cat"
,
System
.
currentTimeMillis
());
if
(
m_transactionService
.
isEligable
(
request
))
{
ModelResponse
<
TransactionReport
>
response
=
m_transactionService
.
invoke
(
request
);
domains
.
addAll
(
response
.
getModel
().
getDomainNames
());
}
return
domains
;
}
public
class
Heap
{
private
final
int
m_size
=
100
;
private
HighLoadSQL
[]
m_sqls
=
new
HighLoadSQL
[
m_size
];
public
void
add
(
HighLoadSQL
sql
)
{
int
nextIndex
=
findNextValidIndex
();
if
(
nextIndex
==
m_size
)
{
if
(
isBigger
(
sql
,
m_sqls
[
0
]))
{
m_sqls
[
0
]
=
sql
;
heapAdjust
(
0
,
m_size
-
1
);
}
}
else
{
m_sqls
[
nextIndex
]
=
sql
;
if
(
nextIndex
==
m_size
-
1
)
{
sort
();
}
}
}
private
int
findNextValidIndex
()
{
int
i
;
for
(
i
=
0
;
i
<
m_size
&&
m_sqls
[
i
]
!=
null
;
i
++)
{
}
return
i
;
}
public
List
<
HighLoadSQL
>
getSqls
()
{
return
Arrays
.
asList
(
m_sqls
);
}
private
void
heapAdjust
(
int
startIndex
,
int
endIndex
)
{
int
currentIndex
=
startIndex
;
int
tmpIndex
=
2
*
currentIndex
+
1
;
while
(
tmpIndex
<=
endIndex
)
{
if
(
m_sqls
[
tmpIndex
+
1
]
!=
null
&&
isBigger
(
m_sqls
[
tmpIndex
+
1
],
m_sqls
[
tmpIndex
]))
{
tmpIndex
=
tmpIndex
+
1
;
}
if
(
isBigger
(
m_sqls
[
currentIndex
],
m_sqls
[
tmpIndex
]))
{
swap
(
currentIndex
,
tmpIndex
);
currentIndex
=
tmpIndex
;
tmpIndex
=
2
*
currentIndex
+
1
;
}
else
{
break
;
}
}
}
private
boolean
isBigger
(
HighLoadSQL
sql1
,
HighLoadSQL
sql2
)
{
TransactionName
name1
=
sql1
.
getName
();
TransactionName
name2
=
sql2
.
getName
();
return
name1
.
getTotalCount
()
*
name1
.
getAvg
()
-
name2
.
getTotalCount
()
*
name2
.
getAvg
()
>
0
?
true
:
false
;
}
private
void
sort
()
{
int
currentIndex
=
(
m_size
-
1
)
/
2
;
for
(;
currentIndex
>=
0
;
currentIndex
--)
{
heapAdjust
(
currentIndex
,
m_size
);
}
for
(
int
i
=
m_size
-
1
;
i
>
0
;
i
--)
{
swap
(
0
,
i
);
heapAdjust
(
0
,
i
-
1
);
}
}
private
void
swap
(
int
index1
,
int
index2
)
{
HighLoadSQL
tmpNode
=
m_sqls
[
index1
];
m_sqls
[
index1
]
=
m_sqls
[
index2
];
m_sqls
[
index2
]
=
tmpNode
;
}
}
public
class
HighLoadSQL
{
private
String
m_domain
;
private
TransactionName
m_name
;
public
HighLoadSQL
(
String
domain
,
TransactionName
name
)
{
m_domain
=
domain
;
m_name
=
name
;
}
public
String
getDomain
()
{
return
m_domain
;
}
public
TransactionName
getName
()
{
return
m_name
;
}
public
void
setDomain
(
String
domain
)
{
m_domain
=
domain
;
}
public
void
setName
(
TransactionName
name
)
{
m_name
=
name
;
}
}
}
\ No newline at end of file
cat-home/src/main/java/com/dianping/cat/report/task/highload/HighLoadUpdater.java
0 → 100644
浏览文件 @
1a55f336
package
com.dianping.cat.report.task.highload
;
import
java.util.Date
;
import
com.dianping.cat.report.task.spi.ReportTaskBuilder
;
public
abstract
class
HighLoadUpdater
implements
ReportTaskBuilder
{
@Override
public
boolean
buildDailyTask
(
String
name
,
String
domain
,
Date
period
)
{
throw
new
RuntimeException
(
getID
()
+
" don't support daily update"
);
}
@Override
public
boolean
buildHourlyTask
(
String
name
,
String
domain
,
Date
period
)
{
throw
new
RuntimeException
(
getID
()
+
" don't support hourly update"
);
}
@Override
public
boolean
buildMonthlyTask
(
String
name
,
String
domain
,
Date
period
)
{
throw
new
RuntimeException
(
getID
()
+
" don't support monthly update"
);
}
@Override
public
boolean
buildWeeklyTask
(
String
name
,
String
domain
,
Date
period
)
{
throw
new
RuntimeException
(
getID
()
+
" don't support weekly update"
);
}
public
abstract
String
getID
();
}
cat-home/src/main/java/com/dianping/cat/report/task/highload/TransactionHighLoadUpdater.java
0 → 100644
浏览文件 @
1a55f336
package
com.dianping.cat.report.task.highload
;
public
abstract
class
TransactionHighLoadUpdater
extends
HighLoadUpdater
{
public
abstract
String
getType
();
}
cat-home/src/main/java/com/dianping/cat/report/task/overload/CapacityUpdateTask.java
浏览文件 @
1a55f336
...
@@ -13,8 +13,6 @@ import com.dianping.cat.report.task.spi.ReportTaskBuilder;
...
@@ -13,8 +13,6 @@ import com.dianping.cat.report.task.spi.ReportTaskBuilder;
public
class
CapacityUpdateTask
implements
ReportTaskBuilder
,
LogEnabled
{
public
class
CapacityUpdateTask
implements
ReportTaskBuilder
,
LogEnabled
{
public
static
final
String
ID
=
Constants
.
REPORT_DATABASE_CAPACITY
;
public
static
final
String
ID
=
Constants
.
REPORT_DATABASE_CAPACITY
;
@Inject
(
type
=
CapacityUpdater
.
class
,
value
=
HourlyCapacityUpdater
.
ID
)
@Inject
(
type
=
CapacityUpdater
.
class
,
value
=
HourlyCapacityUpdater
.
ID
)
...
@@ -81,19 +79,19 @@ public class CapacityUpdateTask implements ReportTaskBuilder, LogEnabled {
...
@@ -81,19 +79,19 @@ public class CapacityUpdateTask implements ReportTaskBuilder, LogEnabled {
}
}
public
void
setHourlyUpdater
(
CapacityUpdater
hourlyUpdater
)
{
public
void
setHourlyUpdater
(
CapacityUpdater
hourlyUpdater
)
{
m_hourlyUpdater
=
hourlyUpdater
;
m_hourlyUpdater
=
hourlyUpdater
;
}
}
public
void
setDailyUpdater
(
CapacityUpdater
dailyUpdater
)
{
public
void
setDailyUpdater
(
CapacityUpdater
dailyUpdater
)
{
m_dailyUpdater
=
dailyUpdater
;
m_dailyUpdater
=
dailyUpdater
;
}
}
public
void
setWeeklyUpdater
(
CapacityUpdater
weeklyUpdater
)
{
public
void
setWeeklyUpdater
(
CapacityUpdater
weeklyUpdater
)
{
m_weeklyUpdater
=
weeklyUpdater
;
m_weeklyUpdater
=
weeklyUpdater
;
}
}
public
void
setMonthlyUpdater
(
CapacityUpdater
monthlyUpdater
)
{
public
void
setMonthlyUpdater
(
CapacityUpdater
monthlyUpdater
)
{
m_monthlyUpdater
=
monthlyUpdater
;
m_monthlyUpdater
=
monthlyUpdater
;
}
}
}
}
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
1a55f336
...
@@ -1439,6 +1439,20 @@
...
@@ -1439,6 +1439,20 @@
</requirement>
</requirement>
</requirements>
</requirements>
</component>
</component>
<component>
<role>
com.dianping.cat.report.task.spi.ReportTaskBuilder
</role>
<role-hint>
highLoadSql
</role-hint>
<implementation>
com.dianping.cat.report.task.highload.HighLoadSqlUpdater
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.report.page.model.spi.ModelService
</role>
<role-hint>
transaction
</role-hint>
</requirement>
<requirement>
<role>
com.dianping.cat.report.service.ReportServiceManager
</role>
</requirement>
</requirements>
</component>
<component>
<component>
<role>
com.dianping.cat.report.task.notify.ReportRender
</role>
<role>
com.dianping.cat.report.task.notify.ReportRender
</role>
<implementation>
com.dianping.cat.report.task.notify.ReportRenderImpl
</implementation>
<implementation>
com.dianping.cat.report.task.notify.ReportRenderImpl
</implementation>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录