Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
eedd7f93
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,发现更多精彩内容 >>
提交
eedd7f93
编写于
9月 20, 2012
作者:
Y
youyong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify the cat checkpoint
上级
6122029a
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
212 addition
and
183 deletion
+212
-183
cat-consumer/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
...m/dianping/cat/consumer/build/ComponentsConfigurator.java
+1
-1
cat-consumer/src/main/java/com/dianping/cat/consumer/common/CommonAnalyzer.java
...java/com/dianping/cat/consumer/common/CommonAnalyzer.java
+43
-28
cat-consumer/src/main/java/com/dianping/cat/consumer/cross/CrossAnalyzer.java
...n/java/com/dianping/cat/consumer/cross/CrossAnalyzer.java
+16
-19
cat-consumer/src/main/java/com/dianping/cat/consumer/database/DatabaseAnalyzer.java
.../com/dianping/cat/consumer/database/DatabaseAnalyzer.java
+19
-25
cat-consumer/src/main/java/com/dianping/cat/consumer/dump/DumpUploader.java
...ain/java/com/dianping/cat/consumer/dump/DumpUploader.java
+3
-6
cat-consumer/src/main/java/com/dianping/cat/consumer/event/EventAnalyzer.java
...n/java/com/dianping/cat/consumer/event/EventAnalyzer.java
+16
-11
cat-consumer/src/main/java/com/dianping/cat/consumer/heartbeat/HeartbeatAnalyzer.java
...om/dianping/cat/consumer/heartbeat/HeartbeatAnalyzer.java
+15
-9
cat-consumer/src/main/java/com/dianping/cat/consumer/matrix/MatrixAnalyzer.java
...java/com/dianping/cat/consumer/matrix/MatrixAnalyzer.java
+19
-19
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/ProblemAnalyzer.java
...va/com/dianping/cat/consumer/problem/ProblemAnalyzer.java
+17
-13
cat-consumer/src/main/java/com/dianping/cat/consumer/sql/SqlAnalyzer.java
.../main/java/com/dianping/cat/consumer/sql/SqlAnalyzer.java
+15
-21
cat-consumer/src/main/java/com/dianping/cat/consumer/sql/SqlParseManager.java
...n/java/com/dianping/cat/consumer/sql/SqlParseManager.java
+1
-2
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionAnalyzer.java
...ianping/cat/consumer/transaction/TransactionAnalyzer.java
+21
-15
cat-core/src/main/java/com/dianping/cat/storage/dump/LocalMessageBucketManager.java
.../dianping/cat/storage/dump/LocalMessageBucketManager.java
+14
-11
cat-home/src/main/java/com/dianping/cat/report/page/cross/DomainManager.java
...ava/com/dianping/cat/report/page/cross/DomainManager.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/page/model/Handler.java
...main/java/com/dianping/cat/report/page/model/Handler.java
+11
-2
未找到文件。
cat-consumer/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
浏览文件 @
eedd7f93
...
...
@@ -29,7 +29,7 @@ import com.dianping.cat.consumer.problem.handler.DefaultProblemHandler;
import
com.dianping.cat.consumer.problem.handler.Handler
;
import
com.dianping.cat.consumer.problem.handler.LongExecutionHandler
;
import
com.dianping.cat.consumer.sql.SqlAnalyzer
;
import
com.dianping.cat.consumer.sql
parse
.SqlParseManager
;
import
com.dianping.cat.consumer.sql.SqlParseManager
;
import
com.dianping.cat.consumer.transaction.TransactionAnalyzer
;
import
com.dianping.cat.hadoop.hdfs.FileSystemManager
;
import
com.dianping.cat.message.spi.MessageCodec
;
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/common/CommonAnalyzer.java
浏览文件 @
eedd7f93
...
...
@@ -15,6 +15,8 @@ import com.dainping.cat.consumer.dal.report.TaskDao;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
import
com.dianping.cat.consumer.common.model.entity.CommonReport
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.spi.AbstractMessageAnalyzer
;
import
com.dianping.cat.message.spi.MessageTree
;
import
com.dianping.cat.storage.BucketManager
;
...
...
@@ -22,7 +24,7 @@ import com.site.dal.jdbc.DalException;
import
com.site.lookup.annotation.Inject
;
public
class
CommonAnalyzer
extends
AbstractMessageAnalyzer
<
CommonReport
>
implements
LogEnabled
{
private
Map
<
String
,
CommonReport
>
m_reports
=
new
HashMap
<
String
,
CommonReport
>();
@Inject
...
...
@@ -47,39 +49,52 @@ public class CommonAnalyzer extends AbstractMessageAnalyzer<CommonReport> implem
}
private
void
storeReport
()
{
for
(
CommonReport
report
:
m_reports
.
values
())
{
String
domain
=
report
.
getDomain
();
Set
<
String
>
ips
=
report
.
getIps
();
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"Checkpoint"
,
getClass
().
getSimpleName
());
for
(
String
ip
:
ips
)
{
Hostinfo
info
=
m_hostInfoDao
.
createLocal
();
t
.
setStatus
(
Message
.
SUCCESS
);
try
{
for
(
CommonReport
report
:
m_reports
.
values
())
{
String
domain
=
report
.
getDomain
();
Set
<
String
>
ips
=
report
.
getIps
();
for
(
String
ip
:
ips
)
{
try
{
Hostinfo
info
=
m_hostInfoDao
.
createLocal
();
info
.
setDomain
(
domain
);
info
.
setIp
(
ip
);
m_hostInfoDao
.
insert
(
info
);
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
t
.
setStatus
(
e
);
}
}
}
Date
period
=
new
Date
(
m_startTime
);
String
ip
=
NetworkInterfaceManager
.
INSTANCE
.
getLocalHostAddress
();
info
.
setDomain
(
domain
);
info
.
setIp
(
ip
);
// Create task for health report
for
(
String
domain
:
m_reports
.
keySet
())
{
try
{
m_hostInfoDao
.
insert
(
info
);
}
catch
(
DalException
e
)
{
Task
task
=
m_taskDao
.
createLocal
();
task
.
setCreationDate
(
new
Date
());
task
.
setProducer
(
ip
);
task
.
setReportDomain
(
domain
);
task
.
setReportName
(
"health"
);
task
.
setReportPeriod
(
period
);
task
.
setStatus
(
1
);
// status todo
m_taskDao
.
insert
(
task
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
t
.
setStatus
(
e
);
}
}
}
Date
period
=
new
Date
(
m_startTime
);
String
ip
=
NetworkInterfaceManager
.
INSTANCE
.
getLocalHostAddress
();
// Create task for health report
for
(
String
domain
:
m_reports
.
keySet
())
{
try
{
Task
task
=
m_taskDao
.
createLocal
();
task
.
setCreationDate
(
new
Date
());
task
.
setProducer
(
ip
);
task
.
setReportDomain
(
domain
);
task
.
setReportName
(
"health"
);
task
.
setReportPeriod
(
period
);
task
.
setStatus
(
1
);
// status todo
m_taskDao
.
insert
(
task
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
}
finally
{
t
.
complete
();
}
}
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/cross/CrossAnalyzer.java
浏览文件 @
eedd7f93
...
...
@@ -246,19 +246,25 @@ public class CrossAnalyzer extends AbstractMessageAnalyzer<CrossReport> implemen
DefaultXmlBuilder
builder
=
new
DefaultXmlBuilder
(
true
);
Bucket
<
String
>
reportBucket
=
null
;
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"Checkpoint"
,
getClass
().
getSimpleName
());
t
.
setStatus
(
Message
.
SUCCESS
);
try
{
reportBucket
=
m_bucketManager
.
getReportBucket
(
m_startTime
,
"cross"
);
for
(
CrossReport
report
:
m_reports
.
values
())
{
Set
<
String
>
domainNames
=
report
.
getDomainNames
();
domainNames
.
clear
();
domainNames
.
addAll
(
getDomains
());
String
xml
=
builder
.
buildXml
(
report
);
String
domain
=
report
.
getDomain
();
reportBucket
.
storeById
(
domain
,
xml
);
try
{
Set
<
String
>
domainNames
=
report
.
getDomainNames
();
domainNames
.
clear
();
domainNames
.
addAll
(
getDomains
());
String
xml
=
builder
.
buildXml
(
report
);
String
domain
=
report
.
getDomain
();
reportBucket
.
storeById
(
domain
,
xml
);
}
catch
(
Exception
e
)
{
Cat
.
getProducer
().
logError
(
e
);
t
.
setStatus
(
e
);
}
}
if
(
atEnd
&&
!
isLocalMode
())
{
...
...
@@ -280,22 +286,13 @@ public class CrossAnalyzer extends AbstractMessageAnalyzer<CrossReport> implemen
m_reportDao
.
insert
(
r
);
// Task task = m_taskDao.createLocal();
// task.setCreationDate(new Date());
// task.setProducer(ip);
// task.setReportDomain(domain);
// task.setReportName("cross");
// task.setReportPeriod(period);
// task.setStatus(1); // status todo
// m_taskDao.insert(task);
// m_logger.info("insert cross task:" + task.toString());
}
catch
(
Throwable
e
)
{
Cat
.
getProducer
().
logError
(
e
);
t
.
setStatus
(
e
);
}
}
}
t
.
setStatus
(
Message
.
SUCCESS
);
}
catch
(
Exception
e
)
{
Cat
.
getProducer
().
logError
(
e
);
t
.
setStatus
(
e
);
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/database/DatabaseAnalyzer.java
浏览文件 @
eedd7f93
...
...
@@ -19,7 +19,7 @@ import com.dianping.cat.consumer.database.model.entity.Method;
import
com.dianping.cat.consumer.database.model.entity.Table
;
import
com.dianping.cat.consumer.database.model.transform.DefaultSaxParser
;
import
com.dianping.cat.consumer.database.model.transform.DefaultXmlBuilder
;
import
com.dianping.cat.consumer.sql
parse
.SqlParseManager
;
import
com.dianping.cat.consumer.sql.SqlParseManager
;
import
com.dianping.cat.message.Event
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
...
...
@@ -180,19 +180,25 @@ public class DatabaseAnalyzer extends AbstractMessageAnalyzer<DatabaseReport> im
DefaultXmlBuilder
builder
=
new
DefaultXmlBuilder
(
true
);
Bucket
<
String
>
reportBucket
=
null
;
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"Checkpoint"
,
getClass
().
getSimpleName
());
t
.
setStatus
(
Message
.
SUCCESS
);
try
{
reportBucket
=
m_bucketManager
.
getReportBucket
(
m_startTime
,
"database"
);
for
(
DatabaseReport
report
:
m_reports
.
values
())
{
Set
<
String
>
domainNames
=
report
.
getDatabaseNames
();
domainNames
.
clear
();
domainNames
.
addAll
(
getDomains
());
String
xml
=
builder
.
buildXml
(
report
);
String
domain
=
report
.
getDatabase
();
reportBucket
.
storeById
(
domain
,
xml
);
try
{
Set
<
String
>
domainNames
=
report
.
getDatabaseNames
();
domainNames
.
clear
();
domainNames
.
addAll
(
getDomains
());
String
xml
=
builder
.
buildXml
(
report
);
String
domain
=
report
.
getDatabase
();
reportBucket
.
storeById
(
domain
,
xml
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
t
.
setStatus
(
e
);
}
}
if
(
atEnd
&&
!
isLocalMode
())
{
...
...
@@ -213,25 +219,14 @@ public class DatabaseAnalyzer extends AbstractMessageAnalyzer<DatabaseReport> im
r
.
setContent
(
xml
);
m_reportDao
.
insert
(
r
);
// Task task = m_taskDao.createLocal();
// task.setCreationDate(new Date());
// task.setProducer(ip);
// task.setReportDomain(domain);
// task.setReportName("database");
// task.setReportPeriod(period);
// task.setStatus(1); // status todo
// m_taskDao.insert(task);
// m_logger.info("insert database task:" + task.toString());
}
catch
(
Throwable
e
)
{
Cat
.
getProducer
().
logError
(
e
);
Cat
.
logError
(
e
);
t
.
setStatus
(
e
);
}
}
}
t
.
setStatus
(
Message
.
SUCCESS
);
}
catch
(
Exception
e
)
{
Cat
.
getProducer
().
logError
(
e
);
Cat
.
logError
(
e
);
t
.
setStatus
(
e
);
m_logger
.
error
(
String
.
format
(
"Error when storing database reports of %s!"
,
new
Date
(
m_startTime
)),
e
);
}
finally
{
...
...
@@ -241,7 +236,6 @@ public class DatabaseAnalyzer extends AbstractMessageAnalyzer<DatabaseReport> im
m_bucketManager
.
closeBucket
(
reportBucket
);
}
}
}
private
DatabaseItem
buildDataBaseItem
(
String
domain
,
Transaction
t
)
{
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/dump/DumpUploader.java
浏览文件 @
eedd7f93
...
...
@@ -3,10 +3,8 @@ package com.dianping.cat.consumer.dump;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
import
org.apache.hadoop.fs.FSDataOutputStream
;
...
...
@@ -141,8 +139,7 @@ public class DumpUploader implements Initializable, LogEnabled {
MessageProducer
cat
=
Cat
.
getProducer
();
String
ip
=
NetworkInterfaceManager
.
INSTANCE
.
getLocalHostAddress
();
String
ts
=
new
SimpleDateFormat
(
"mmss"
).
format
(
new
Date
());
Transaction
root
=
cat
.
newTransaction
(
"System"
,
"Dump-"
+
ip
+
"-"
+
ts
);
Transaction
root
=
cat
.
newTransaction
(
"System"
,
"Dump-"
+
ip
);
Collections
.
sort
(
paths
);
...
...
@@ -195,7 +192,7 @@ public class DumpUploader implements Initializable, LogEnabled {
// the path has two depth
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
final
List
<
String
>
directionPaths
=
new
ArrayList
<
String
>();
Scanners
.
forDir
().
scan
(
baseDir
,
new
FileMatcher
()
{
@Override
public
Direction
matches
(
File
base
,
String
path
)
{
...
...
@@ -209,7 +206,7 @@ public class DumpUploader implements Initializable, LogEnabled {
for
(
String
path
:
directionPaths
)
{
try
{
File
file
=
new
File
(
baseDir
,
path
);
file
.
delete
();
}
catch
(
Exception
e
)
{
}
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/event/EventAnalyzer.java
浏览文件 @
eedd7f93
...
...
@@ -229,19 +229,25 @@ public class EventAnalyzer extends AbstractMessageAnalyzer<EventReport> implemen
DefaultXmlBuilder
builder
=
new
DefaultXmlBuilder
(
true
);
Bucket
<
String
>
reportBucket
=
null
;
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"Checkpoint"
,
getClass
().
getSimpleName
());
t
.
setStatus
(
Message
.
SUCCESS
);
try
{
reportBucket
=
m_bucketManager
.
getReportBucket
(
m_startTime
,
"event"
);
for
(
EventReport
report
:
m_reports
.
values
())
{
Set
<
String
>
domainNames
=
report
.
getDomainNames
();
domainNames
.
clear
();
domainNames
.
addAll
(
getDomains
());
String
xml
=
builder
.
buildXml
(
report
);
String
domain
=
report
.
getDomain
();
reportBucket
.
storeById
(
domain
,
xml
);
try
{
Set
<
String
>
domainNames
=
report
.
getDomainNames
();
domainNames
.
clear
();
domainNames
.
addAll
(
getDomains
());
String
xml
=
builder
.
buildXml
(
report
);
String
domain
=
report
.
getDomain
();
reportBucket
.
storeById
(
domain
,
xml
);
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
}
}
if
(
atEnd
&&
!
isLocalMode
())
{
...
...
@@ -272,12 +278,11 @@ public class EventAnalyzer extends AbstractMessageAnalyzer<EventReport> implemen
task
.
setStatus
(
1
);
// status todo
m_taskDao
.
insert
(
task
);
}
catch
(
Throwable
e
)
{
t
.
setStatus
(
e
);
Cat
.
getProducer
().
logError
(
e
);
}
}
}
t
.
setStatus
(
Message
.
SUCCESS
);
}
catch
(
Exception
e
)
{
Cat
.
getProducer
().
logError
(
e
);
t
.
setStatus
(
e
);
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/heartbeat/HeartbeatAnalyzer.java
浏览文件 @
eedd7f93
...
...
@@ -260,18 +260,24 @@ public class HeartbeatAnalyzer extends AbstractMessageAnalyzer<HeartbeatReport>
Bucket
<
String
>
reportBucket
=
null
;
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"Checkpoint"
,
getClass
().
getSimpleName
());
t
.
setStatus
(
Message
.
SUCCESS
);
try
{
reportBucket
=
m_bucketManager
.
getReportBucket
(
m_startTime
,
"heartbeat"
);
for
(
HeartbeatReport
report
:
m_reports
.
values
())
{
Set
<
String
>
domainNames
=
report
.
getDomainNames
();
domainNames
.
clear
();
domainNames
.
addAll
(
getDomains
());
String
xml
=
builder
.
buildXml
(
report
);
String
domain
=
report
.
getDomain
();
reportBucket
.
storeById
(
domain
,
xml
);
try
{
Set
<
String
>
domainNames
=
report
.
getDomainNames
();
domainNames
.
clear
();
domainNames
.
addAll
(
getDomains
());
String
xml
=
builder
.
buildXml
(
report
);
String
domain
=
report
.
getDomain
();
reportBucket
.
storeById
(
domain
,
xml
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
t
.
setStatus
(
e
);
}
}
if
(
atEnd
&&
!
isLocalMode
())
{
...
...
@@ -303,11 +309,11 @@ public class HeartbeatAnalyzer extends AbstractMessageAnalyzer<HeartbeatReport>
m_taskDao
.
insert
(
task
);
}
catch
(
Throwable
e
)
{
Cat
.
getProducer
().
logError
(
e
);
t
.
setStatus
(
e
);
}
}
}
t
.
setStatus
(
Message
.
SUCCESS
);
}
catch
(
Exception
e
)
{
Cat
.
getProducer
().
logError
(
e
);
t
.
setStatus
(
e
);
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/matrix/MatrixAnalyzer.java
浏览文件 @
eedd7f93
...
...
@@ -205,19 +205,30 @@ public class MatrixAnalyzer extends AbstractMessageAnalyzer<MatrixReport> implem
Bucket
<
String
>
reportBucket
=
null
;
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"Checkpoint"
,
getClass
().
getSimpleName
());
t
.
setStatus
(
Message
.
SUCCESS
);
try
{
reportBucket
=
m_bucketManager
.
getReportBucket
(
m_startTime
,
"matrix"
);
for
(
MatrixReport
report
:
m_reports
.
values
())
{
report
.
accept
(
new
MatrixReportFilter
(
50
));
Set
<
String
>
domainNames
=
report
.
getDomainNames
();
domainNames
.
clear
();
domainNames
.
addAll
(
getDomains
());
try
{
report
.
accept
(
new
MatrixReportFilter
(
50
));
Set
<
String
>
domainNames
=
report
.
getDomainNames
();
domainNames
.
clear
();
domainNames
.
addAll
(
getDomains
());
String
xml
=
builder
.
buildXml
(
report
);
String
domain
=
report
.
getDomain
();
String
xml
=
null
;
try
{
xml
=
builder
.
buildXml
(
report
);
}
catch
(
Exception
e
)
{
xml
=
builder
.
buildXml
(
report
);
}
String
domain
=
report
.
getDomain
();
reportBucket
.
storeById
(
domain
,
xml
);
reportBucket
.
storeById
(
domain
,
xml
);
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
}
}
if
(
atEnd
&&
!
isLocalMode
())
{
...
...
@@ -239,23 +250,12 @@ public class MatrixAnalyzer extends AbstractMessageAnalyzer<MatrixReport> implem
r
.
setContent
(
xml
);
m_reportDao
.
insert
(
r
);
//
// Task task = m_taskDao.createLocal();
// task.setCreationDate(new Date());
// task.setProducer(ip);
// task.setReportDomain(domain);
// task.setReportName("matrix");
// task.setReportPeriod(period);
// task.setStatus(1); // status todo
// m_taskDao.insert(task);
// m_logger.info("insert matrix task:" + task.toString());
}
catch
(
Throwable
e
)
{
t
.
setStatus
(
e
);
Cat
.
getProducer
().
logError
(
e
);
}
}
}
t
.
setStatus
(
Message
.
SUCCESS
);
}
catch
(
Exception
e
)
{
Cat
.
getProducer
().
logError
(
e
);
t
.
setStatus
(
e
);
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/ProblemAnalyzer.java
浏览文件 @
eedd7f93
...
...
@@ -165,23 +165,28 @@ public class ProblemAnalyzer extends AbstractMessageAnalyzer<ProblemReport> impl
}
private
void
storeReports
(
boolean
atEnd
)
{
DefaultXmlBuilder
builder
=
new
DefaultXmlBuilder
(
true
);
Bucket
<
String
>
reportBucket
=
null
;
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"Checkpoint"
,
getClass
().
getSimpleName
());
t
.
setStatus
(
Message
.
SUCCESS
);
try
{
reportBucket
=
m_bucketManager
.
getReportBucket
(
m_startTime
,
"problem"
);
for
(
ProblemReport
report
:
m_reports
.
values
())
{
Set
<
String
>
domainNames
=
report
.
getDomainNames
();
domainNames
.
clear
();
domainNames
.
addAll
(
getDomains
());
String
xml
=
builder
.
buildXml
(
report
);
String
domain
=
report
.
getDomain
();
reportBucket
.
storeById
(
domain
,
xml
);
try
{
Set
<
String
>
domainNames
=
report
.
getDomainNames
();
domainNames
.
clear
();
domainNames
.
addAll
(
getDomains
());
String
xml
=
builder
.
buildXml
(
report
);
String
domain
=
report
.
getDomain
();
reportBucket
.
storeById
(
domain
,
xml
);
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
Cat
.
getProducer
().
logError
(
e
);
}
}
if
(
atEnd
&&
!
isLocalMode
())
{
...
...
@@ -212,15 +217,14 @@ public class ProblemAnalyzer extends AbstractMessageAnalyzer<ProblemReport> impl
task
.
setStatus
(
1
);
m_taskDao
.
insert
(
task
);
}
catch
(
Throwable
e
)
{
t
.
setStatus
(
e
);
Cat
.
getProducer
().
logError
(
e
);
}
}
}
t
.
setStatus
(
Message
.
SUCCESS
);
}
catch
(
Exception
e
)
{
Cat
.
getProducer
().
logError
(
e
);
t
.
setStatus
(
e
);
Cat
.
getProducer
().
logError
(
e
);
m_logger
.
error
(
String
.
format
(
"Error when storing problem reports to %s!"
,
new
Date
(
m_startTime
)),
e
);
}
finally
{
t
.
complete
();
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/sql/SqlAnalyzer.java
浏览文件 @
eedd7f93
...
...
@@ -19,7 +19,6 @@ import com.dianping.cat.consumer.sql.model.entity.SqlReport;
import
com.dianping.cat.consumer.sql.model.entity.Table
;
import
com.dianping.cat.consumer.sql.model.transform.DefaultSaxParser
;
import
com.dianping.cat.consumer.sql.model.transform.DefaultXmlBuilder
;
import
com.dianping.cat.consumer.sqlparse.SqlParseManager
;
import
com.dianping.cat.message.Event
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
...
...
@@ -185,18 +184,24 @@ public class SqlAnalyzer extends AbstractMessageAnalyzer<SqlReport> implements L
Bucket
<
String
>
reportBucket
=
null
;
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"Checkpoint"
,
getClass
().
getSimpleName
());
t
.
setStatus
(
Message
.
SUCCESS
);
try
{
reportBucket
=
m_bucketManager
.
getReportBucket
(
m_startTime
,
"sql"
);
for
(
SqlReport
report
:
m_reports
.
values
())
{
Set
<
String
>
domainNames
=
report
.
getDomainNames
();
domainNames
.
clear
();
domainNames
.
addAll
(
getDomains
());
String
xml
=
builder
.
buildXml
(
report
);
String
domain
=
report
.
getDomain
();
reportBucket
.
storeById
(
domain
,
xml
);
try
{
Set
<
String
>
domainNames
=
report
.
getDomainNames
();
domainNames
.
clear
();
domainNames
.
addAll
(
getDomains
());
String
xml
=
builder
.
buildXml
(
report
);
String
domain
=
report
.
getDomain
();
reportBucket
.
storeById
(
domain
,
xml
);
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
Cat
.
getProducer
().
logError
(
e
);
}
}
if
(
atEnd
&&
!
isLocalMode
())
{
...
...
@@ -217,23 +222,12 @@ public class SqlAnalyzer extends AbstractMessageAnalyzer<SqlReport> implements L
r
.
setContent
(
xml
);
m_reportDao
.
insert
(
r
);
// Task task = m_taskDao.createLocal();
// task.setCreationDate(new Date());
// task.setProducer(ip);
// task.setReportDomain(domain);
// task.setReportName("sql");
// task.setReportPeriod(period);
// task.setStatus(1); // status todo
// m_taskDao.insert(task);
// m_logger.info("insert sql task:" + task.toString());
}
catch
(
Throwable
e
)
{
t
.
setStatus
(
e
);
Cat
.
getProducer
().
logError
(
e
);
}
}
}
t
.
setStatus
(
Message
.
SUCCESS
);
}
catch
(
Exception
e
)
{
Cat
.
getProducer
().
logError
(
e
);
t
.
setStatus
(
e
);
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/sql
parse
/SqlParseManager.java
→
cat-consumer/src/main/java/com/dianping/cat/consumer/sql/SqlParseManager.java
浏览文件 @
eedd7f93
package
com.dianping.cat.consumer.sql
parse
;
package
com.dianping.cat.consumer.sql
;
import
java.util.HashMap
;
import
java.util.HashSet
;
...
...
@@ -15,7 +15,6 @@ import com.site.dal.jdbc.DalException;
import
com.site.lookup.annotation.Inject
;
public
class
SqlParseManager
{
@Inject
private
SqltableDao
m_sqltableDao
;
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionAnalyzer.java
浏览文件 @
eedd7f93
...
...
@@ -53,9 +53,11 @@ public class TransactionAnalyzer extends AbstractMessageAnalyzer<TransactionRepo
private
void
clearAllDuration
(
TransactionReport
report
)
{
Collection
<
Machine
>
machines
=
report
.
getMachines
().
values
();
for
(
Machine
machine
:
machines
)
{
for
(
TransactionType
type
:
machine
.
getTypes
().
values
())
{
type
.
getAllDurations
().
clear
();
for
(
TransactionName
name
:
type
.
getNames
().
values
())
{
name
.
getAllDurations
().
clear
();
}
...
...
@@ -104,9 +106,7 @@ public class TransactionAnalyzer extends AbstractMessageAnalyzer<TransactionRepo
if
(
report
==
null
)
{
report
=
new
TransactionReport
(
domain
);
}
// report.accept(new TransactionReportFilter());
report
.
getDomainNames
().
addAll
(
m_reports
.
keySet
());
report
.
accept
(
new
StatisticsComputer
());
set95Line
(
report
);
return
report
;
...
...
@@ -319,24 +319,30 @@ public class TransactionAnalyzer extends AbstractMessageAnalyzer<TransactionRepo
}
private
void
storeReports
(
boolean
atEnd
)
{
// DefaultXmlBuilder builder = new DefaultXmlBuilder(true);
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"Checkpoint"
,
getClass
().
getSimpleName
());
Bucket
<
String
>
reportBucket
=
null
;
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"Checkpoint"
,
getClass
().
getSimpleName
());
t
.
setStatus
(
Message
.
SUCCESS
);
try
{
reportBucket
=
m_bucketManager
.
getReportBucket
(
m_startTime
,
"transaction"
);
for
(
TransactionReport
report
:
m_reports
.
values
())
{
Set
<
String
>
domainNames
=
report
.
getDomainNames
();
domainNames
.
clear
();
domainNames
.
addAll
(
getDomains
());
set95Line
(
report
);
clearAllDuration
(
report
);
String
xml
=
new
TransactionReportFilter
(
50
).
buildXml
(
report
);
String
domain
=
report
.
getDomain
();
reportBucket
.
storeById
(
domain
,
xml
);
try
{
Set
<
String
>
domainNames
=
report
.
getDomainNames
();
domainNames
.
clear
();
domainNames
.
addAll
(
getDomains
());
set95Line
(
report
);
clearAllDuration
(
report
);
String
xml
=
new
TransactionReportFilter
(
50
).
buildXml
(
report
);
String
domain
=
report
.
getDomain
();
reportBucket
.
storeById
(
domain
,
xml
);
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
Cat
.
getProducer
().
logError
(
e
);
}
}
if
(
atEnd
&&
!
isLocalMode
())
{
...
...
@@ -367,11 +373,11 @@ public class TransactionAnalyzer extends AbstractMessageAnalyzer<TransactionRepo
task
.
setStatus
(
1
);
// status todo
m_taskDao
.
insert
(
task
);
}
catch
(
Throwable
e
)
{
t
.
setStatus
(
e
);
Cat
.
getProducer
().
logError
(
e
);
}
}
}
t
.
setStatus
(
Message
.
SUCCESS
);
}
catch
(
Exception
e
)
{
Cat
.
getProducer
().
logError
(
e
);
t
.
setStatus
(
e
);
...
...
cat-core/src/main/java/com/dianping/cat/storage/dump/LocalMessageBucketManager.java
浏览文件 @
eedd7f93
...
...
@@ -124,7 +124,7 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
Threads
.
forGroup
(
"Cat"
).
start
(
new
BlockDumper
());
Threads
.
forGroup
(
"Cat"
).
start
(
new
IdleChecker
());
Threads
.
forGroup
(
"Cat"
).
start
(
new
OldMessage
Upload
er
());
Threads
.
forGroup
(
"Cat"
).
start
(
new
OldMessage
Mov
er
());
}
@Override
...
...
@@ -138,7 +138,6 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
MessageId
id
=
MessageId
.
parse
(
messageId
);
final
String
path
=
m_pathBuilder
.
getPath
(
new
Date
(
id
.
getTimestamp
()),
""
);
final
File
dir
=
new
File
(
m_baseDir
,
path
);
// final String key = "-" + id.getDomain() + "-";
final
String
key
=
id
.
getDomain
()
+
'-'
+
id
.
getIpAddress
();
final
List
<
String
>
paths
=
new
ArrayList
<
String
>();
...
...
@@ -211,8 +210,6 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
@Override
public
void
storeMessage
(
MessageTree
tree
)
throws
IOException
{
MessageId
id
=
MessageId
.
parse
(
tree
.
getMessageId
());
// <callee domain> - <caller domain> - <callee ip>
// String name = tree.getDomain() + "-" + id.getDomain() + "-" + tree.getIpAddress();
String
localIp
=
NetworkInterfaceManager
.
INSTANCE
.
getLocalHostAddress
();
String
name
=
id
.
getDomain
()
+
'-'
+
id
.
getIpAddress
()
+
'-'
+
localIp
;
String
dataFile
=
m_pathBuilder
.
getPath
(
new
Date
(
id
.
getTimestamp
()),
name
);
...
...
@@ -276,22 +273,28 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
if
(
path
.
indexOf
(
"draft"
)
>
-
1
||
path
.
indexOf
(
"outbox"
)
>
-
1
)
{
return
false
;
}
long
current
=
System
.
currentTimeMillis
();
long
currentHour
=
current
-
current
%
ONE_HOUR
;
long
lastHour
=
currentHour
-
ONE_HOUR
;
long
nextHour
=
currentHour
+
ONE_HOUR
;
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMdd/HH"
);
String
currentHourStr
=
sdf
.
format
(
new
Date
(
currentHour
));
String
lastHourStr
=
sdf
.
format
(
new
Date
(
lastHour
));
String
nextHourStr
=
sdf
.
format
(
new
Date
(
nextHour
));
int
indexOf
=
path
.
indexOf
(
currentHourStr
);
int
indexOf2
=
path
.
indexOf
(
lastHourStr
);
if
(
indexOf
>
-
1
||
indexOf2
>
-
1
)
{
int
indexOfLast
=
path
.
indexOf
(
lastHourStr
);
int
indexOfNext
=
path
.
indexOf
(
nextHourStr
);
if
(
indexOf
>
-
1
||
indexOfLast
>
-
1
||
indexOfNext
>
-
1
)
{
return
false
;
}
return
true
;
}
private
void
uploadOld
()
{
private
void
moverOldMessages
()
{
final
List
<
String
>
paths
=
new
ArrayList
<
String
>();
Scanners
.
forDir
().
scan
(
m_baseDir
,
new
FileMatcher
()
{
...
...
@@ -334,18 +337,18 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
}
}
class
OldMessage
Upload
er
implements
Task
{
class
OldMessage
Mov
er
implements
Task
{
@Override
public
void
run
()
{
while
(
true
)
{
try
{
uploadOld
();
moverOldMessages
();
}
catch
(
Throwable
e
)
{
Cat
.
logError
(
e
);
}
try
{
Thread
.
sleep
(
60
*
1000L
);
Thread
.
sleep
(
2
*
60
*
1000L
);
}
catch
(
InterruptedException
e
)
{
// ignore
}
...
...
@@ -354,7 +357,7 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
@Override
public
String
getName
()
{
return
"
MessageUpload-Clean
"
;
return
"
LocalMessageBucketManager-OldMessageMover
"
;
}
@Override
...
...
cat-home/src/main/java/com/dianping/cat/report/page/cross/DomainManager.java
浏览文件 @
eedd7f93
...
...
@@ -74,7 +74,7 @@ public class DomainManager implements Initializable {
addIps
.
add
(
hostinfo
.
getIp
());
m_ipDomains
.
put
(
hostinfo
.
getIp
(),
hostinfo
.
getDomain
());
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
//ignore
}
}
for
(
String
ip
:
addIps
)
{
...
...
cat-home/src/main/java/com/dianping/cat/report/page/model/Handler.java
浏览文件 @
eedd7f93
...
...
@@ -89,9 +89,18 @@ public class Handler extends ContainerHolder implements PageHandler<Context> {
String
report
=
payload
.
getReport
();
String
ipAddress
=
payload
.
getIpAddress
();
if
(
"transaction"
.
equals
(
report
))
{
TransactionReportFilter
filter
=
new
TransactionReportFilter
(
payload
.
getType
(),
payload
.
getName
(),
ipAddress
);
try
{
TransactionReportFilter
filter
=
new
TransactionReportFilter
(
payload
.
getType
(),
payload
.
getName
(),
ipAddress
);
return
filter
.
buildXml
((
IEntity
<?>)
dataModel
);
}
catch
(
Exception
e
)
{
TransactionReportFilter
filter
=
new
TransactionReportFilter
(
payload
.
getType
(),
payload
.
getName
(),
ipAddress
);
return
filter
.
buildXml
((
IEntity
<?>)
dataModel
);
}
return
filter
.
buildXml
((
IEntity
<?>)
dataModel
);
}
else
if
(
"event"
.
equals
(
report
))
{
EventReportFilter
filter
=
new
EventReportFilter
(
payload
.
getType
(),
payload
.
getName
(),
ipAddress
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录