Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
1430e1be
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,发现更多精彩内容 >>
提交
1430e1be
编写于
11月 16, 2012
作者:
Y
youyong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify the cat
上级
ebdfc146
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
110 addition
and
33 deletion
+110
-33
cat-core/src/main/java/com/dianping/cat/message/io/TcpSocketReceiver.java
...n/java/com/dianping/cat/message/io/TcpSocketReceiver.java
+2
-1
cat-core/src/main/java/com/dianping/cat/storage/dump/LocalMessageBucketManager.java
.../dianping/cat/storage/dump/LocalMessageBucketManager.java
+10
-4
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
...n/java/com/dianping/cat/build/ComponentsConfigurator.java
+2
-2
cat-home/src/main/java/com/dianping/cat/report/task/cross/CrossReportBuilder.java
...om/dianping/cat/report/task/cross/CrossReportBuilder.java
+81
-6
cat-home/src/main/java/com/dianping/cat/report/task/thread/TaskConsumer.java
...ava/com/dianping/cat/report/task/thread/TaskConsumer.java
+2
-2
cat-home/src/main/java/com/dianping/cat/report/task/thread/TaskProducer.java
...ava/com/dianping/cat/report/task/thread/TaskProducer.java
+1
-1
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+6
-0
script/Cat.sql
script/Cat.sql
+6
-17
未找到文件。
cat-core/src/main/java/com/dianping/cat/message/io/TcpSocketReceiver.java
浏览文件 @
1430e1be
...
...
@@ -195,7 +195,8 @@ public class TcpSocketReceiver implements LogEnabled {
int
length
=
buffer
.
readInt
();
buffer
.
resetReaderIndex
();
if
(
buffer
.
readableBytes
()
<
length
)
{
if
(
buffer
.
readableBytes
()
<
length
+
4
)
{
return
null
;
}
...
...
cat-core/src/main/java/com/dianping/cat/storage/dump/LocalMessageBucketManager.java
浏览文件 @
1430e1be
...
...
@@ -61,6 +61,8 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
private
int
m_total
;
private
long
m_totalSize
=
0
;
private
Logger
m_logger
;
private
BlockingQueue
<
MessageBlock
>
m_messageBlocks
=
new
LinkedBlockingQueue
<
MessageBlock
>(
1000
);
...
...
@@ -151,7 +153,7 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
}
private
boolean
isFit
(
String
path
)
{
private
boolean
shouldMove
(
String
path
)
{
if
(
path
.
indexOf
(
"draft"
)
>
-
1
||
path
.
indexOf
(
"outbox"
)
>
-
1
)
{
return
false
;
}
...
...
@@ -259,7 +261,7 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
@Override
public
Direction
matches
(
File
base
,
String
path
)
{
if
(
new
File
(
base
,
path
).
isFile
())
{
if
(
isFit
(
path
))
{
if
(
shouldMove
(
path
))
{
paths
.
add
(
path
);
}
}
...
...
@@ -317,6 +319,10 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
DefaultMessageTree
defaultTree
=
(
DefaultMessageTree
)
tree
;
ChannelBuffer
buf
=
defaultTree
.
getBuf
();
int
size
=
buf
.
readableBytes
();
m_totalSize
+=
size
;
MessageBlock
bolck
=
bucket
.
storeMessage
(
buf
,
id
);
if
(
bolck
!=
null
)
{
...
...
@@ -332,9 +338,9 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
m_total
++;
if
(
m_total
%
100000
==
0
)
{
m_logger
.
info
(
"Encode the message number "
+
m_total
);
m_logger
.
info
(
"Encode the message number: "
+
m_total
+
" Size:"
+
m_totalSize
*
1.0
/
1024
/
1024
/
1024
+
"GB"
);
}
}
class
BlockDumper
implements
Task
{
...
...
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
浏览文件 @
1430e1be
...
...
@@ -125,8 +125,8 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
.
req
(
TaskDao
.
class
,
ReportDao
.
class
,
DailyreportDao
.
class
));
all
.
add
(
C
(
HealthReportBuilder
.
class
)
//
.
req
(
GraphDao
.
class
,
ReportDao
.
class
,
DailyreportDao
.
class
,
//
HealthServiceCollector
.
class
));
.
req
(
GraphDao
.
class
,
ReportDao
.
class
,
DailyreportDao
.
class
)
//
.
req
(
WeeklyreportDao
.
class
,
MonthreportDao
.
class
,
HealthServiceCollector
.
class
));
all
.
add
(
C
(
ReportFacade
.
class
)
//
.
req
(
TransactionReportBuilder
.
class
,
EventReportBuilder
.
class
,
ProblemReportBuilder
.
class
,
//
...
...
cat-home/src/main/java/com/dianping/cat/report/task/cross/CrossReportBuilder.java
浏览文件 @
1430e1be
package
com.dianping.cat.report.task.cross
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -8,7 +9,14 @@ import com.dainping.cat.consumer.dal.report.Report;
import
com.dainping.cat.consumer.dal.report.ReportEntity
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
import
com.dianping.cat.consumer.cross.model.entity.CrossReport
;
import
com.dianping.cat.consumer.cross.model.transform.DefaultSaxParser
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.home.dal.report.Dailyreport
;
import
com.dianping.cat.home.dal.report.DailyreportEntity
;
import
com.dianping.cat.home.dal.report.Monthreport
;
import
com.dianping.cat.home.dal.report.Weeklyreport
;
import
com.dianping.cat.report.page.model.cross.CrossReportMerger
;
import
com.dianping.cat.report.task.TaskHelper
;
import
com.dianping.cat.report.task.spi.AbstractReportBuilder
;
import
com.dianping.cat.report.task.spi.ReportBuilder
;
...
...
@@ -74,13 +82,80 @@ public class CrossReportBuilder extends AbstractReportBuilder implements ReportB
}
@Override
public
boolean
buildWeeklyReport
(
String
reportName
,
String
reportDomain
,
Date
reportPeriod
)
{
return
false
;
}
public
boolean
buildWeeklyReport
(
String
reportName
,
String
reportDomain
,
Date
reportPeriod
)
{
Date
start
=
reportPeriod
;
Date
end
=
new
Date
(
start
.
getTime
()
+
TimeUtil
.
ONE_DAY
*
7
);
CrossReport
crossReport
=
buildMergedDailyReport
(
reportDomain
,
start
,
end
);
Weeklyreport
report
=
m_weeklyreportDao
.
createLocal
();
String
content
=
crossReport
.
toString
();
report
.
setContent
(
content
);
report
.
setCreationDate
(
new
Date
());
report
.
setDomain
(
reportDomain
);
report
.
setIp
(
NetworkInterfaceManager
.
INSTANCE
.
getLocalHostAddress
());
report
.
setName
(
reportName
);
report
.
setPeriod
(
reportPeriod
);
report
.
setType
(
1
);
try
{
m_weeklyreportDao
.
insert
(
report
);
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
return
false
;
}
return
true
;
}
@Override
public
boolean
buildMonthReport
(
String
reportName
,
String
reportDomain
,
Date
reportPeriod
)
{
return
false
;
}
public
boolean
buildMonthReport
(
String
reportName
,
String
reportDomain
,
Date
reportPeriod
)
{
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
reportPeriod
);
cal
.
add
(
Calendar
.
MONTH
,
1
);
Date
start
=
reportPeriod
;
Date
end
=
cal
.
getTime
();
CrossReport
crossReport
=
buildMergedDailyReport
(
reportDomain
,
start
,
end
);
Monthreport
report
=
m_monthreportDao
.
createLocal
();
report
.
setContent
(
crossReport
.
toString
());
report
.
setCreationDate
(
new
Date
());
report
.
setDomain
(
reportDomain
);
report
.
setIp
(
NetworkInterfaceManager
.
INSTANCE
.
getLocalHostAddress
());
report
.
setName
(
reportName
);
report
.
setPeriod
(
reportPeriod
);
report
.
setType
(
1
);
try
{
m_monthreportDao
.
insert
(
report
);
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
return
false
;
}
return
true
;
}
private
CrossReport
buildMergedDailyReport
(
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
{
Dailyreport
dailyreport
=
m_dailyReportDao
.
findByNameDomainPeriod
(
new
Date
(
startTime
),
domain
,
"cross"
,
DailyreportEntity
.
READSET_FULL
);
String
xml
=
dailyreport
.
getContent
();
CrossReport
reportModel
=
DefaultSaxParser
.
parse
(
xml
);
reportModel
.
accept
(
merger
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
CrossReport
crossReport
=
merger
.
getCrossReport
();
crossReport
.
setStartTime
(
start
);
crossReport
.
setEndTime
(
end
);
return
crossReport
;
}
}
cat-home/src/main/java/com/dianping/cat/report/task/thread/TaskConsumer.java
浏览文件 @
1430e1be
...
...
@@ -71,11 +71,11 @@ public abstract class TaskConsumer implements com.site.helper.Threads.Task {
updateDoingToDone
(
task
);
}
}
t
.
addData
(
task
.
toString
());
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Throwable
e
)
{
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
t
.
setStatus
(
e
);
}
finally
{
t
.
complete
();
}
...
...
cat-home/src/main/java/com/dianping/cat/report/task/thread/TaskProducer.java
浏览文件 @
1430e1be
...
...
@@ -228,7 +228,7 @@ public class TaskProducer implements com.site.helper.Threads.Task, Initializable
m_dailyReportNameSet
.
add
(
"health"
);
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
add
(
Calendar
.
MONTH
,
-
2
);
cal
.
add
(
Calendar
.
MONTH
,
-
3
);
cal
.
set
(
cal
.
get
(
Calendar
.
YEAR
),
cal
.
get
(
Calendar
.
MONTH
),
0
,
0
,
0
,
0
);
cal
.
set
(
Calendar
.
MILLISECOND
,
0
);
...
...
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
1430e1be
...
...
@@ -314,6 +314,12 @@
<requirement>
<role>
com.dianping.cat.home.dal.report.DailyreportDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.home.dal.report.WeeklyreportDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.home.dal.report.MonthreportDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.report.task.health.HealthServiceCollector
</role>
</requirement>
...
...
script/Cat.sql
浏览文件 @
1430e1be
...
...
@@ -2,7 +2,7 @@ CREATE TABLE `dailygraph` (
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`name`
varchar
(
20
)
NOT
NULL
COMMENT
'报表名称'
,
`ip`
varchar
(
20
)
NULL
COMMENT
'报表来自于哪台cat-client机器ip, 空串表示合并同domain所有ip'
,
`domain`
varchar
(
2
0
)
NOT
NULL
COMMENT
'报表处理的Domain信息'
,
`domain`
varchar
(
5
0
)
NOT
NULL
COMMENT
'报表处理的Domain信息'
,
`period`
datetime
NOT
NULL
COMMENT
'报表时间段'
,
`type`
tinyint
(
4
)
NOT
NULL
COMMENT
'报表数据格式, 1/xml, 2/json, 3/csv, 默认3'
,
`detail_content`
mediumtext
NOT
NULL
COMMENT
'详细绘图内容'
,
...
...
@@ -16,7 +16,7 @@ CREATE TABLE `dailyreport` (
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`name`
varchar
(
20
)
NOT
NULL
COMMENT
'报表名称, transaction, problem...'
,
`ip`
varchar
(
20
)
NOT
NULL
COMMENT
'报表来自于哪台cat-consumer机器'
,
`domain`
varchar
(
2
0
)
NOT
NULL
COMMENT
'报表处理的Domain信息'
,
`domain`
varchar
(
5
0
)
NOT
NULL
COMMENT
'报表处理的Domain信息'
,
`period`
datetime
NOT
NULL
COMMENT
'报表时间段'
,
`type`
tinyint
(
4
)
NOT
NULL
COMMENT
'报表数据格式, 1/xml, 2/json, 默认1'
,
`content`
mediumtext
NOT
NULL
COMMENT
'报表内容'
,
...
...
@@ -29,7 +29,7 @@ CREATE TABLE `weeklyreport` (
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`name`
varchar
(
20
)
NOT
NULL
COMMENT
'报表名称, transaction, problem...'
,
`ip`
varchar
(
20
)
NOT
NULL
COMMENT
'报表来自于哪台cat-consumer机器'
,
`domain`
varchar
(
2
0
)
NOT
NULL
COMMENT
'报表处理的Domain信息'
,
`domain`
varchar
(
5
0
)
NOT
NULL
COMMENT
'报表处理的Domain信息'
,
`period`
datetime
NOT
NULL
COMMENT
'报表时间段'
,
`type`
tinyint
(
4
)
NOT
NULL
COMMENT
'报表数据格式, 1/xml, 2/json, 默认1'
,
`content`
mediumtext
NOT
NULL
COMMENT
'报表内容'
,
...
...
@@ -42,7 +42,7 @@ CREATE TABLE `monthreport` (
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`name`
varchar
(
20
)
NOT
NULL
COMMENT
'报表名称, transaction, problem...'
,
`ip`
varchar
(
20
)
NOT
NULL
COMMENT
'报表来自于哪台cat-consumer机器'
,
`domain`
varchar
(
2
0
)
NOT
NULL
COMMENT
'报表处理的Domain信息'
,
`domain`
varchar
(
5
0
)
NOT
NULL
COMMENT
'报表处理的Domain信息'
,
`period`
datetime
NOT
NULL
COMMENT
'报表时间段'
,
`type`
tinyint
(
4
)
NOT
NULL
COMMENT
'报表数据格式, 1/xml, 2/json, 默认1'
,
`content`
mediumtext
NOT
NULL
COMMENT
'报表内容'
,
...
...
@@ -68,7 +68,7 @@ CREATE TABLE `graph` (
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`name`
varchar
(
20
)
NOT
NULL
COMMENT
'报表名称'
,
`ip`
varchar
(
20
)
NULL
COMMENT
'报表来自于哪台cat-client机器ip, NULL表示合并同domain所有ip'
,
`domain`
varchar
(
2
0
)
NOT
NULL
COMMENT
'报表处理的Domain信息'
,
`domain`
varchar
(
5
0
)
NOT
NULL
COMMENT
'报表处理的Domain信息'
,
`period`
datetime
NOT
NULL
COMMENT
'报表时间段'
,
`type`
tinyint
(
4
)
NOT
NULL
COMMENT
'报表数据格式, 1/xml, 2/json, 3/csv, 默认3'
,
`detail_content`
mediumtext
NOT
NULL
COMMENT
'详细绘图内容'
,
...
...
@@ -99,17 +99,6 @@ CREATE TABLE `location` (
UNIQUE
KEY
`transaction_date_lat_lng`
(
`transaction_date`
,
`lat`
,
`lng`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
COMMENT
=
'用于热点图地理位置表'
;
CREATE
TABLE
`monthreport`
(
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`name`
varchar
(
50
)
DEFAULT
NULL
,
`domain`
varchar
(
100
)
DEFAULT
NULL
,
`period`
datetime
DEFAULT
NULL
,
`content`
mediumtext
,
`creation_date`
datetime
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
),
UNIQUE
KEY
`name_2`
(
`name`
,
`domain`
,
`period`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
;
CREATE
TABLE
`report`
(
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
...
...
@@ -179,7 +168,7 @@ CREATE TABLE `task` (
`consumer`
varchar
(
20
)
NULL
COMMENT
'任务执行者ip'
,
`failure_count`
tinyint
(
4
)
NOT
NULL
COMMENT
'任务失败次数'
,
`report_name`
varchar
(
20
)
NOT
NULL
COMMENT
'报表名称, transaction, problem...'
,
`report_domain`
varchar
(
2
0
)
NOT
NULL
COMMENT
'报表处理的Domain信息'
,
`report_domain`
varchar
(
5
0
)
NOT
NULL
COMMENT
'报表处理的Domain信息'
,
`report_period`
datetime
NOT
NULL
COMMENT
'报表时间'
,
`status`
tinyint
(
4
)
NOT
NULL
COMMENT
'执行状态: 1/todo, 2/doing, 3/done 4/failed'
,
`task_type`
tinyint
(
4
)
NOT
NULL
DEFAULT
'1'
COMMENT
'0表示小时任务,1表示天任务'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录