Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
7f595a7b
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,发现更多精彩内容 >>
提交
7f595a7b
编写于
7月 09, 2013
作者:
Y
yong.you
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify the task package and transaction domains
上级
c5647d3f
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
29 addition
and
232 deletion
+29
-232
cat-consumer/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
...m/dianping/cat/consumer/build/ComponentsConfigurator.java
+1
-2
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionAnalyzer.java
...ianping/cat/consumer/transaction/TransactionAnalyzer.java
+1
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionDelegate.java
...ianping/cat/consumer/transaction/TransactionDelegate.java
+5
-19
cat-consumer/src/main/resources/META-INF/plexus/components.xml
...onsumer/src/main/resources/META-INF/plexus/components.xml
+1
-1
cat-core/src/main/java/com/dianping/cat/service/DefaultReportManager.java
...n/java/com/dianping/cat/service/DefaultReportManager.java
+13
-1
cat-core/src/main/java/com/dianping/cat/service/ReportManager.java
...src/main/java/com/dianping/cat/service/ReportManager.java
+3
-0
cat-home/src/main/java/com/dianping/cat/CatHomeModule.java
cat-home/src/main/java/com/dianping/cat/CatHomeModule.java
+1
-1
cat-home/src/main/java/com/dianping/cat/build/TaskComponentConfigurator.java
...ava/com/dianping/cat/build/TaskComponentConfigurator.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/task/DefaultTaskConsumer.java
...ava/com/dianping/cat/report/task/DefaultTaskConsumer.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/task/TaskConsumer.java
.../main/java/com/dianping/cat/report/task/TaskConsumer.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/task/cross/CrossReportBuilder.java
...om/dianping/cat/report/task/cross/CrossReportBuilder.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/task/thread/TaskProducer.java
...ava/com/dianping/cat/report/task/thread/TaskProducer.java
+0
-203
cat-home/src/test/java/com/dianping/cat/report/task/TaskConsumerTest.java
...t/java/com/dianping/cat/report/task/TaskConsumerTest.java
+0
-1
未找到文件。
cat-consumer/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
浏览文件 @
7f595a7b
...
...
@@ -33,7 +33,6 @@ import com.dianping.cat.core.config.ConfigDao;
import
com.dianping.cat.core.dal.HostinfoDao
;
import
com.dianping.cat.core.dal.HourlyReportDao
;
import
com.dianping.cat.core.dal.ProjectDao
;
import
com.dianping.cat.core.dal.TaskDao
;
import
com.dianping.cat.message.spi.core.MessageConsumer
;
import
com.dianping.cat.service.DefaultReportManager
;
import
com.dianping.cat.service.ReportDelegate
;
...
...
@@ -108,7 +107,7 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
.
req
(
ReportDelegate
.
class
,
ID
)
//
.
req
(
BucketManager
.
class
,
HourlyReportDao
.
class
)
//
.
config
(
E
(
"name"
).
value
(
ID
)));
all
.
add
(
C
(
ReportDelegate
.
class
,
ID
,
TransactionDelegate
.
class
).
req
(
Task
Dao
.
class
));
all
.
add
(
C
(
ReportDelegate
.
class
,
ID
,
TransactionDelegate
.
class
).
req
(
Task
Manager
.
class
));
return
all
;
}
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionAnalyzer.java
浏览文件 @
7f595a7b
...
...
@@ -52,6 +52,7 @@ public class TransactionAnalyzer extends AbstractMessageAnalyzer<TransactionRepo
public
TransactionReport
getReport
(
String
domain
)
{
TransactionReport
report
=
m_reportManager
.
getHourlyReport
(
getStartTime
(),
domain
,
false
);
report
.
getDomainNames
().
addAll
(
m_reportManager
.
getDomains
(
getStartTime
()));
report
.
accept
(
new
TransactionStatisticsComputer
());
return
report
;
}
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionDelegate.java
浏览文件 @
7f595a7b
...
...
@@ -9,19 +9,18 @@ import java.util.Set;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
import
com.dianping.cat.consumer.transaction.model.transform.DefaultSaxParser
;
import
com.dianping.cat.core.dal.Task
;
import
com.dianping.cat.core.dal.TaskDao
;
import
com.dianping.cat.service.ReportConstants
;
import
com.dianping.cat.service.ReportDelegate
;
import
com.dianping.cat.task.TaskManager
;
import
com.dianping.cat.task.TaskManager.TaskProlicy
;
public
class
TransactionDelegate
implements
ReportDelegate
<
TransactionReport
>
{
@Inject
private
Task
Dao
m_taskDao
;
private
Task
Manager
m_taskManager
;
@Override
public
void
afterLoad
(
Map
<
String
,
TransactionReport
>
reports
)
{
}
...
...
@@ -102,19 +101,6 @@ public class TransactionDelegate implements ReportDelegate<TransactionReport> {
@Override
public
boolean
createHourlyTask
(
TransactionReport
report
)
{
try
{
Task
task
=
m_taskDao
.
createLocal
();
task
.
setCreationDate
(
new
Date
());
task
.
setProducer
(
NetworkInterfaceManager
.
INSTANCE
.
getLocalHostAddress
());
task
.
setReportDomain
(
report
.
getDomain
());
task
.
setReportName
(
"transaction"
);
task
.
setReportPeriod
(
report
.
getStartTime
());
task
.
setStatus
(
1
);
m_taskDao
.
insert
(
task
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
return
false
;
return
m_taskManager
.
createTask
(
report
.
getStartTime
(),
report
.
getDomain
(),
"transaction"
,
TaskProlicy
.
ALL
);
}
}
cat-consumer/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
7f595a7b
...
...
@@ -75,7 +75,7 @@
<implementation>
com.dianping.cat.consumer.transaction.TransactionDelegate
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.
core.dal.TaskDao
</role>
<role>
com.dianping.cat.
task.TaskManager
</role>
</requirement>
</requirements>
</component>
...
...
cat-core/src/main/java/com/dianping/cat/service/DefaultReportManager.java
浏览文件 @
7f595a7b
...
...
@@ -6,8 +6,10 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
...
...
@@ -60,6 +62,17 @@ public class DefaultReportManager<T> implements ReportManager<T>, LogEnabled {
m_logger
=
logger
;
}
@Override
public
Set
<
String
>
getDomains
(
long
startTime
)
{
Map
<
String
,
T
>
reports
=
m_map
.
get
(
startTime
);
if
(
reports
==
null
)
{
return
new
HashSet
<
String
>();
}
else
{
return
reports
.
keySet
();
}
}
@Override
public
T
getHourlyReport
(
long
startTime
,
String
domain
,
boolean
createIfNotExist
)
{
Map
<
String
,
T
>
reports
=
m_map
.
get
(
startTime
);
...
...
@@ -197,7 +210,6 @@ public class DefaultReportManager<T> implements ReportManager<T>, LogEnabled {
r
.
setContent
(
xml
);
m_reportDao
.
insert
(
r
);
m_reportDelegate
.
createHourlyTask
(
report
);
}
catch
(
Throwable
e
)
{
t
.
setStatus
(
e
);
...
...
cat-core/src/main/java/com/dianping/cat/service/ReportManager.java
浏览文件 @
7f595a7b
package
com.dianping.cat.service
;
import
java.util.Map
;
import
java.util.Set
;
import
com.dianping.cat.service.DefaultReportManager.StoragePolicy
;
...
...
@@ -8,6 +9,8 @@ public interface ReportManager<T> {
public
void
cleanup
();
public
void
initialize
();
public
Set
<
String
>
getDomains
(
long
startTime
);
public
T
getHourlyReport
(
long
startTime
,
String
domain
,
boolean
createIfNotExist
);
...
...
cat-home/src/main/java/com/dianping/cat/CatHomeModule.java
浏览文件 @
7f595a7b
...
...
@@ -12,7 +12,7 @@ import com.dianping.cat.consumer.CatConsumerModule;
import
com.dianping.cat.consumer.core.aggregation.AggregationConfigManager
;
import
com.dianping.cat.message.spi.core.MessageConsumer
;
import
com.dianping.cat.message.spi.core.TcpSocketReceiver
;
import
com.dianping.cat.report.task.
thread.
DefaultTaskConsumer
;
import
com.dianping.cat.report.task.DefaultTaskConsumer
;
import
com.dianping.cat.report.view.DomainNavManager
;
import
com.dianping.cat.system.alarm.AlarmRuleCreator
;
import
com.dianping.cat.system.alarm.AlarmTask
;
...
...
cat-home/src/main/java/com/dianping/cat/build/TaskComponentConfigurator.java
浏览文件 @
7f595a7b
...
...
@@ -21,6 +21,7 @@ import com.dianping.cat.report.baseline.impl.DefaultBaselineCreator;
import
com.dianping.cat.report.baseline.impl.DefaultBaselineService
;
import
com.dianping.cat.report.page.dependency.graph.TopologyGraphBuilder
;
import
com.dianping.cat.report.service.ReportService
;
import
com.dianping.cat.report.task.DefaultTaskConsumer
;
import
com.dianping.cat.report.task.cross.CrossReportBuilder
;
import
com.dianping.cat.report.task.dependency.DependencyReportBuilder
;
import
com.dianping.cat.report.task.event.EventGraphCreator
;
...
...
@@ -38,7 +39,6 @@ import com.dianping.cat.report.task.spi.ReportFacade;
import
com.dianping.cat.report.task.sql.SqlMerger
;
import
com.dianping.cat.report.task.sql.SqlReportBuilder
;
import
com.dianping.cat.report.task.state.StateReportBuilder
;
import
com.dianping.cat.report.task.thread.DefaultTaskConsumer
;
import
com.dianping.cat.report.task.transaction.TransactionGraphCreator
;
import
com.dianping.cat.report.task.transaction.TransactionMerger
;
import
com.dianping.cat.report.task.transaction.TransactionReportBuilder
;
...
...
cat-home/src/main/java/com/dianping/cat/report/task/
thread/
DefaultTaskConsumer.java
→
cat-home/src/main/java/com/dianping/cat/report/task/DefaultTaskConsumer.java
浏览文件 @
7f595a7b
/**
*
*/
package
com.dianping.cat.report.task
.thread
;
package
com.dianping.cat.report.task
;
import
java.util.Date
;
import
java.util.concurrent.locks.LockSupport
;
...
...
cat-home/src/main/java/com/dianping/cat/report/task/
thread/
TaskConsumer.java
→
cat-home/src/main/java/com/dianping/cat/report/task/TaskConsumer.java
浏览文件 @
7f595a7b
package
com.dianping.cat.report.task
.thread
;
package
com.dianping.cat.report.task
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
...
...
cat-home/src/main/java/com/dianping/cat/report/task/cross/CrossReportBuilder.java
浏览文件 @
7f595a7b
...
...
@@ -110,7 +110,7 @@ public class CrossReportBuilder implements ReportBuilder {
Date
date
=
new
Date
(
startTime
);
CrossReport
reportModel
=
m_reportService
.
queryCrossReport
(
domain
,
date
,
new
Date
(
date
.
getTime
()
+
TimeUtil
.
ONE_HOUR
));
reportModel
.
accept
(
merger
);
}
CrossReport
crossReport
=
merger
.
getCrossReport
();
...
...
cat-home/src/main/java/com/dianping/cat/report/task/thread/TaskProducer.java
已删除
100644 → 0
浏览文件 @
c5647d3f
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.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
{
Set
<
String
>
groups
=
m_configManager
.
getMetricConfig
().
getMetricItemConfigs
().
keySet
();
for
(
String
group
:
groups
)
{
try
{
m_taskDao
.
findByDomainNameTypePeriod
(
"metricBaseline"
,
group
,
ReportFacade
.
TYPE_DAILY
,
date
,
TaskEntity
.
READSET_FULL
);
}
catch
(
DalNotFoundException
e
)
{
insertTask
(
group
,
"metricBaseline"
,
ReportFacade
.
TYPE_DAILY
,
date
);
}
}
}
catch
(
Exception
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/test/java/com/dianping/cat/report/task/TaskConsumerTest.java
浏览文件 @
7f595a7b
...
...
@@ -9,7 +9,6 @@ import junit.framework.Assert;
import
org.junit.Test
;
import
com.dianping.cat.core.dal.Task
;
import
com.dianping.cat.report.task.thread.TaskConsumer
;
public
class
TaskConsumerTest
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录