Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
1fea6433
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,体验更适合开发者的 AI 搜索 >>
提交
1fea6433
编写于
9月 28, 2018
作者:
L
leon.li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enhance transaction & event report
上级
1e29a466
变更
31
展开全部
隐藏空白更改
内联
并排
Showing
31 changed file
with
2027 addition
and
919 deletion
+2027
-919
cat-alarm/pom.xml
cat-alarm/pom.xml
+134
-129
cat-client/src/main/java/com/dianping/cat/analyzer/TransactionAggregator.java
...java/com/dianping/cat/analyzer/TransactionAggregator.java
+21
-1
cat-client/src/main/java/com/dianping/cat/configuration/ClientConfigManager.java
...a/com/dianping/cat/configuration/ClientConfigManager.java
+2
-0
cat-client/src/main/java/com/dianping/cat/configuration/DefaultClientConfigManager.java
...ianping/cat/configuration/DefaultClientConfigManager.java
+44
-0
cat-client/src/main/java/com/dianping/cat/configuration/ProblemLongType.java
.../java/com/dianping/cat/configuration/ProblemLongType.java
+86
-0
cat-client/src/main/java/com/dianping/cat/message/internal/DefaultMessageManager.java
.../dianping/cat/message/internal/DefaultMessageManager.java
+1
-0
cat-client/src/main/java/com/dianping/cat/message/internal/NullMessageManager.java
...com/dianping/cat/message/internal/NullMessageManager.java
+7
-0
cat-client/src/main/java/com/dianping/cat/message/spi/MessageManager.java
...ain/java/com/dianping/cat/message/spi/MessageManager.java
+3
-0
cat-client/src/test/java/com/dianping/cat/opensource/OpensourceTest.java
...test/java/com/dianping/cat/opensource/OpensourceTest.java
+1
-3
cat-consumer/src/main/java/com/dianping/cat/consumer/GraphTrendUtil.java
...c/main/java/com/dianping/cat/consumer/GraphTrendUtil.java
+4
-8
cat-consumer/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
...m/dianping/cat/consumer/build/ComponentsConfigurator.java
+1
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/event/EventAnalyzer.java
...n/java/com/dianping/cat/consumer/event/EventAnalyzer.java
+212
-64
cat-consumer/src/main/java/com/dianping/cat/consumer/event/EventDelegate.java
...n/java/com/dianping/cat/consumer/event/EventDelegate.java
+17
-8
cat-consumer/src/main/java/com/dianping/cat/consumer/event/EventReportCountFilter.java
...m/dianping/cat/consumer/event/EventReportCountFilter.java
+99
-12
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionAnalyzer.java
...ianping/cat/consumer/transaction/TransactionAnalyzer.java
+309
-223
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionDelegate.java
...ianping/cat/consumer/transaction/TransactionDelegate.java
+20
-10
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionReportCountFilter.java
...at/consumer/transaction/TransactionReportCountFilter.java
+115
-12
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionReportMerger.java
...ing/cat/consumer/transaction/TransactionReportMerger.java
+279
-180
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionStatisticsComputer.java
...t/consumer/transaction/TransactionStatisticsComputer.java
+169
-19
cat-consumer/src/main/java/com/dianping/cat/consumer/util/InvidStringBuilder.java
...va/com/dianping/cat/consumer/util/InvidStringBuilder.java
+38
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/util/StringUtils.java
...main/java/com/dianping/cat/consumer/util/StringUtils.java
+204
-0
cat-consumer/src/main/resources/META-INF/dal/model/event-report-model.xml
.../main/resources/META-INF/dal/model/event-report-model.xml
+46
-41
cat-consumer/src/main/resources/META-INF/dal/model/transaction-report-model.xml
...resources/META-INF/dal/model/transaction-report-model.xml
+116
-102
cat-consumer/src/main/resources/META-INF/plexus/components.xml
...onsumer/src/main/resources/META-INF/plexus/components.xml
+27
-3
cat-consumer/src/test/java/com/dianping/cat/consumer/AllTests.java
...mer/src/test/java/com/dianping/cat/consumer/AllTests.java
+0
-3
cat-consumer/src/test/java/com/dianping/cat/consumer/transaction/TransactionReportFilterTest.java
...cat/consumer/transaction/TransactionReportFilterTest.java
+0
-38
cat-core/src/main/java/com/dianping/cat/config/server/ServerConfigManager.java
...a/com/dianping/cat/config/server/ServerConfigManager.java
+12
-0
cat-home/src/main/java/com/dianping/cat/report/page/event/task/EventReportBuilder.java
...anping/cat/report/page/event/task/EventReportBuilder.java
+19
-7
cat-home/src/main/java/com/dianping/cat/report/page/logview/util/JdbcRefParser.java
.../dianping/cat/report/page/logview/util/JdbcRefParser.java
+0
-39
cat-home/src/main/java/com/dianping/cat/report/page/transaction/task/TransactionReportBuilder.java
...eport/page/transaction/task/TransactionReportBuilder.java
+29
-17
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+12
-0
未找到文件。
cat-alarm/pom.xml
浏览文件 @
1fea6433
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<parent>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<parent>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
parent
</artifactId>
<version>
1.4.6
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
cat-alarm
</artifactId>
<name>
cat-alarm
</name>
<packaging>
jar
</packaging>
<dependencies>
<dependency>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
parent
</artifactId>
<version>
1.4.6
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
cat-alarm
</artifactId>
<name>
cat-alarm
</name>
<packaging>
jar
</packaging>
<dependencies>
<dependency>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
cat-client
</artifactId>
</dependency>
<dependency>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
cat-core
</artifactId>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
foundation-service
</artifactId>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
web-framework
</artifactId>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
dal-jdbc
</artifactId>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
servlet-api
</artifactId>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
log4j
</groupId>
<artifactId>
log4j
</artifactId>
<optional>
true
</optional>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.freemarker
</groupId>
<artifactId>
freemarker
</artifactId>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
test-framework
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
commons-lang
</groupId>
<artifactId>
commons-lang
</artifactId>
</dependency>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
</dependency>
<dependency>
<groupId>
commons-codec
</groupId>
<artifactId>
commons-codec
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpmime
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.unidal.maven.plugins
</groupId>
<artifactId>
codegen-maven-plugin
</artifactId>
<executions>
<execution>
<id>
generate data model
</id>
<phase>
generate-sources
</phase>
<goals>
<goal>
dal-model
</goal>
</goals>
<configuration>
<manifest>
${basedir}/src/main/resources/META-INF/dal/model/server-alarm-rule-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/model/sender-config-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/model/alert-policy-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/model/monitor-rules-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/model/alert-receiver-manifest.xml,
</manifest>
</configuration>
</execution>
<execution>
<id>
generate dal jdbc model
</id>
<phase>
generate-sources
</phase>
<goals>
<goal>
dal-jdbc
</goal>
</goals>
<configuration>
<manifest>
${basedir}/src/main/resources/META-INF/dal/jdbc/alarm-manifest.xml,
</manifest>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>
org.unidal.maven.plugins
</groupId>
<artifactId>
plexus-maven-plugin
</artifactId>
<executions>
<execution>
<id>
generate plexus component descriptor
</id>
<phase>
process-classes
</phase>
<goals>
<goal>
plexus
</goal>
</goals>
<configuration>
<className>
com.dianping.cat.build.ComponentsConfigurator
</className>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>
utf-8
</project.build.sourceEncoding>
</properties>
<artifactId>
cat-client
</artifactId>
</dependency>
<dependency>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
cat-core
</artifactId>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
foundation-service
</artifactId>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
web-framework
</artifactId>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
dal-jdbc
</artifactId>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
servlet-api
</artifactId>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
log4j
</groupId>
<artifactId>
log4j
</artifactId>
<optional>
true
</optional>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.freemarker
</groupId>
<artifactId>
freemarker
</artifactId>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
test-framework
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
commons-lang
</groupId>
<artifactId>
commons-lang
</artifactId>
</dependency>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
</dependency>
<dependency>
<groupId>
commons-codec
</groupId>
<artifactId>
commons-codec
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpmime
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.unidal.maven.plugins
</groupId>
<artifactId>
codegen-maven-plugin
</artifactId>
<executions>
<execution>
<id>
generate data model
</id>
<phase>
generate-sources
</phase>
<goals>
<goal>
dal-model
</goal>
</goals>
<configuration>
<manifest>
${basedir}/src/main/resources/META-INF/dal/model/server-alarm-rule-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/model/sender-config-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/model/alert-policy-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/model/monitor-rules-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/model/alert-receiver-manifest.xml,
</manifest>
</configuration>
</execution>
<execution>
<id>
generate dal jdbc model
</id>
<phase>
generate-sources
</phase>
<goals>
<goal>
dal-jdbc
</goal>
</goals>
<configuration>
<manifest>
${basedir}/src/main/resources/META-INF/dal/jdbc/alarm-manifest.xml,
</manifest>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>
org.unidal.maven.plugins
</groupId>
<artifactId>
plexus-maven-plugin
</artifactId>
<executions>
<execution>
<id>
generate plexus component descriptor
</id>
<phase>
process-classes
</phase>
<goals>
<goal>
plexus
</goal>
</goals>
<configuration>
<className>
com.dianping.cat.build.ComponentsConfigurator
</className>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>
utf-8
</project.build.sourceEncoding>
</properties>
</project>
cat-client/src/main/java/com/dianping/cat/analyzer/TransactionAggregator.java
浏览文件 @
1fea6433
...
...
@@ -8,6 +8,8 @@ import java.util.concurrent.atomic.AtomicLong;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.CatConstants
;
import
com.dianping.cat.configuration.ClientConfigManager
;
import
com.dianping.cat.configuration.ProblemLongType
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.spi.MessageTree
;
...
...
@@ -124,7 +126,25 @@ public class TransactionAggregator {
}
private
int
checkAndGetLongThreshold
(
String
type
,
int
duration
)
{
// todo
ClientConfigManager
config
=
Cat
.
getManager
().
getConfigManager
();
ProblemLongType
longType
=
ProblemLongType
.
findByMessageType
(
type
);
if
(
longType
!=
null
)
{
switch
(
longType
)
{
case
LONG_CACHE:
return
config
.
getLongThresholdByDuration
(
ProblemLongType
.
LONG_CACHE
.
getName
(),
duration
);
case
LONG_CALL:
return
config
.
getLongThresholdByDuration
(
ProblemLongType
.
LONG_CALL
.
getName
(),
duration
);
case
LONG_SERVICE:
return
config
.
getLongThresholdByDuration
(
ProblemLongType
.
LONG_SERVICE
.
getName
(),
duration
);
case
LONG_SQL:
return
config
.
getLongThresholdByDuration
(
ProblemLongType
.
LONG_SQL
.
getName
(),
duration
);
case
LONG_URL:
return
config
.
getLongThresholdByDuration
(
ProblemLongType
.
LONG_URL
.
getName
(),
duration
);
case
LONG_MQ:
return
config
.
getLongThresholdByDuration
(
ProblemLongType
.
LONG_MQ
.
getName
(),
duration
);
}
}
return
-
1
;
}
...
...
cat-client/src/main/java/com/dianping/cat/configuration/ClientConfigManager.java
浏览文件 @
1fea6433
...
...
@@ -33,4 +33,6 @@ public interface ClientConfigManager {
public
void
refreshConfig
();
public
int
getLongThresholdByDuration
(
String
key
,
int
duration
);
}
\ No newline at end of file
cat-client/src/main/java/com/dianping/cat/configuration/DefaultClientConfigManager.java
浏览文件 @
1fea6433
...
...
@@ -3,11 +3,14 @@ package com.dianping.cat.configuration;
import
java.io.File
;
import
java.io.InputStream
;
import
java.util.Collections
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
import
com.site.helper.JsonBuilder
;
import
com.site.helper.Splitters
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
...
...
@@ -40,6 +43,8 @@ public class DefaultClientConfigManager implements LogEnabled, ClientConfigManag
private
AtomicTreeParser
m_atomicTreeParser
=
new
AtomicTreeParser
();
private
Map
<
String
,
List
<
Integer
>>
m_longConfigs
=
new
LinkedHashMap
<
String
,
List
<
Integer
>>();
private
Logger
m_logger
;
@Override
...
...
@@ -263,9 +268,48 @@ public class DefaultClientConfigManager implements LogEnabled, ClientConfigManag
String
matchTypes
=
routerConfig
.
getValue
(
"matchTransactionTypes"
);
m_atomicTreeParser
.
init
(
startTypes
,
matchTypes
);
for
(
ProblemLongType
longType
:
ProblemLongType
.
values
())
{
final
String
name
=
longType
.
getName
();
String
propertyName
=
name
+
"s"
;
String
values
=
routerConfig
.
getValue
(
propertyName
);
if
(
values
!=
null
)
{
List
<
String
>
valueStrs
=
Splitters
.
by
(
','
).
trim
().
split
(
values
);
List
<
Integer
>
thresholds
=
new
LinkedList
<
Integer
>();
for
(
String
valueStr
:
valueStrs
)
{
try
{
thresholds
.
add
(
Integer
.
parseInt
(
valueStr
));
}
catch
(
Exception
e
)
{
// ignore
}
}
if
(!
thresholds
.
isEmpty
())
{
m_longConfigs
.
put
(
name
,
thresholds
);
}
}
}
}
catch
(
Exception
e
)
{
m_logger
.
warn
(
"error when connect cat server config url "
+
url
);
}
}
@Override
public
int
getLongThresholdByDuration
(
String
key
,
int
duration
)
{
List
<
Integer
>
values
=
m_longConfigs
.
get
(
key
);
if
(
values
!=
null
)
{
for
(
int
i
=
values
.
size
()
-
1
;
i
>=
0
;
i
--)
{
int
userThreshold
=
values
.
get
(
i
);
if
(
duration
>=
userThreshold
)
{
return
userThreshold
;
}
}
}
return
-
1
;
}
}
cat-client/src/main/java/com/dianping/cat/configuration/ProblemLongType.java
0 → 100644
浏览文件 @
1fea6433
package
com.dianping.cat.configuration
;
public
enum
ProblemLongType
{
LONG_CACHE
(
"long-cache"
,
25
)
{
@Override
protected
boolean
checkLongType
(
String
type
)
{
return
type
.
startsWith
(
"Squirrel."
)
||
type
.
startsWith
(
"Cellar."
)
||
type
.
startsWith
(
"Cache."
);
}
},
LONG_CALL
(
"long-call"
,
100
)
{
@Override
protected
boolean
checkLongType
(
String
type
)
{
return
"PigeonCall"
.
equals
(
type
)
||
"OctoCall"
.
equals
(
type
)
||
"Call"
.
equals
(
type
);
}
},
LONG_SERVICE
(
"long-service"
,
100
)
{
@Override
protected
boolean
checkLongType
(
String
type
)
{
return
"PigeonService"
.
equals
(
type
)
||
"OctoService"
.
equals
(
type
)
||
"Service"
.
equals
(
type
);
}
},
LONG_SQL
(
"long-sql"
,
100
)
{
@Override
protected
boolean
checkLongType
(
String
type
)
{
return
"SQL"
.
equals
(
type
);
}
},
LONG_URL
(
"long-url"
,
1000
)
{
@Override
protected
boolean
checkLongType
(
String
type
)
{
return
"URL"
.
equals
(
type
);
}
},
LONG_MQ
(
"long-mq"
,
100
)
{
@Override
protected
boolean
checkLongType
(
String
type
)
{
return
"MtmqRecvMessage"
.
equals
(
type
)
||
"MafkaRecvMessage"
.
equals
(
type
);
}
};
private
String
m_name
;
private
int
m_threshold
;
protected
abstract
boolean
checkLongType
(
String
type
);
public
static
ProblemLongType
findByName
(
String
name
)
{
for
(
ProblemLongType
longType
:
values
())
{
if
(
longType
.
getName
().
equals
(
name
))
{
return
longType
;
}
}
throw
new
RuntimeException
(
"Error long type "
+
name
);
}
public
static
ProblemLongType
findByMessageType
(
String
type
)
{
for
(
ProblemLongType
longType
:
values
())
{
if
(
longType
.
checkLongType
(
type
))
{
return
longType
;
}
}
return
null
;
}
private
ProblemLongType
(
String
name
,
int
threshold
)
{
m_name
=
name
;
m_threshold
=
threshold
;
}
public
String
getName
()
{
return
m_name
;
}
public
int
getThreshold
()
{
return
m_threshold
;
}
}
cat-client/src/main/java/com/dianping/cat/message/internal/DefaultMessageManager.java
浏览文件 @
1fea6433
...
...
@@ -124,6 +124,7 @@ public class DefaultMessageManager extends ContainerHolder implements MessageMan
}
}
@Override
public
ClientConfigManager
getConfigManager
()
{
return
m_configManager
;
}
...
...
cat-client/src/main/java/com/dianping/cat/message/internal/NullMessageManager.java
浏览文件 @
1fea6433
...
...
@@ -5,6 +5,7 @@ import org.codehaus.plexus.logging.Logger;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
com.dianping.cat.configuration.ClientConfigManager
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.spi.MessageManager
;
...
...
@@ -91,4 +92,10 @@ public class NullMessageManager implements MessageManager, Initializable, LogEna
public
String
getDomain
()
{
return
NullMessageTree
.
NULL_MESSAGE_TREE
.
getDomain
();
}
@Override
public
ClientConfigManager
getConfigManager
()
{
return
null
;
}
}
cat-client/src/main/java/com/dianping/cat/message/spi/MessageManager.java
浏览文件 @
1fea6433
package
com.dianping.cat.message.spi
;
import
com.dianping.cat.configuration.ClientConfigManager
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
...
...
@@ -103,4 +104,6 @@ public interface MessageManager {
*/
public
String
getDomain
();
public
ClientConfigManager
getConfigManager
();
}
\ No newline at end of file
cat-client/src/test/java/com/dianping/cat/opensource/OpensourceTest.java
浏览文件 @
1fea6433
...
...
@@ -36,10 +36,8 @@ public class OpensourceTest {
@Test
public
void
testEvent
()
throws
Exception
{
//Transaction t = Cat.newTransaction("Parent3", "name22");
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
Cat
.
logEvent
(
"JavaClient1
3"
,
"Bucket_"
);
Cat
.
logEvent
(
"JavaClient1
"
,
"Bucket_"
+
String
.
valueOf
(
i
%
10
)
);
Thread
.
sleep
(
5
);
}
//t.complete();
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/GraphTrendUtil.java
浏览文件 @
1fea6433
...
...
@@ -2,11 +2,11 @@ package com.dianping.cat.consumer;
import
org.codehaus.plexus.util.StringUtils
;
import
com.dianping.cat.Cat
;
public
class
GraphTrendUtil
{
public
static
final
String
GRAPH_SPLITTER
=
";"
;
public
static
final
char
GRAPH_CHAR_SPLITTER
=
';'
;
public
static
Double
[]
parseToDouble
(
String
str
,
int
length
)
{
Double
[]
result
=
new
Double
[
length
];
...
...
@@ -18,7 +18,6 @@ public class GraphTrendUtil {
result
[
i
]
=
Double
.
parseDouble
(
strs
[
i
]);
}
catch
(
Exception
e
)
{
result
[
i
]
=
0.0
;
Cat
.
logError
(
e
);
}
}
}
else
{
...
...
@@ -28,7 +27,7 @@ public class GraphTrendUtil {
}
return
result
;
}
public
static
Long
[]
parseToLong
(
String
str
,
int
length
)
{
Long
[]
result
=
new
Long
[
length
];
...
...
@@ -40,7 +39,6 @@ public class GraphTrendUtil {
result
[
i
]
=
Long
.
parseLong
(
strs
[
i
]);
}
catch
(
Exception
e
)
{
result
[
i
]
=
0L
;
Cat
.
logError
(
e
);
}
}
}
else
{
...
...
@@ -50,6 +48,4 @@ public class GraphTrendUtil {
}
return
result
;
}
}
cat-consumer/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
浏览文件 @
1fea6433
...
...
@@ -83,6 +83,7 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
addAll
(
defineBusinessComponents
());
all
.
add
(
A
(
AtomicMessageConfigManager
.
class
));
all
.
add
(
A
(
ServerConfigManager
.
class
));
all
.
add
(
A
(
TpValueStatisticConfigManager
.
class
));
all
.
add
(
A
(
AllReportConfigManager
.
class
));
all
.
add
(
C
(
Module
.
class
,
CatConsumerModule
.
ID
,
CatConsumerModule
.
class
));
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/event/EventAnalyzer.java
浏览文件 @
1fea6433
package
com.dianping.cat.consumer.event
;
import
java.util.List
;
import
java.util.Set
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
import
org.unidal.helper.Threads
;
import
org.unidal.lookup.annotation.Inject
;
import
org.unidal.lookup.annotation.Named
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.CatConstants
;
import
com.dianping.cat.analysis.AbstractMessageAnalyzer
;
import
com.dianping.cat.analysis.MessageAnalyzer
;
import
com.dianping.cat.config.
server.ServerFilter
ConfigManager
;
import
com.dianping.cat.config.
AtomicMessage
ConfigManager
;
import
com.dianping.cat.consumer.event.model.entity.EventName
;
import
com.dianping.cat.consumer.event.model.entity.EventReport
;
import
com.dianping.cat.consumer.event.model.entity.EventType
;
import
com.dianping.cat.consumer.event.model.entity.Machine
;
import
com.dianping.cat.consumer.event.model.entity.Range
;
import
com.dianping.cat.consumer.event.model.entity.StatusCode
;
import
com.dianping.cat.helper.TimeHelper
;
import
com.dianping.cat.message.Event
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.spi.MessageTree
;
import
com.dianping.cat.report.DefaultReportManager.StoragePolicy
;
import
com.dianping.cat.report.ReportManager
;
...
...
@@ -29,10 +36,16 @@ public class EventAnalyzer extends AbstractMessageAnalyzer<EventReport> implemen
private
ReportManager
<
EventReport
>
m_reportManager
;
@Inject
private
ServerFilterConfigManager
m_serverFilter
ConfigManager
;
private
AtomicMessageConfigManager
m_atomicMessage
ConfigManager
;
private
EventTpsStatisticsComputer
m_computer
=
new
EventTpsStatisticsComputer
();
private
int
m_typeCountLimit
=
100
;
private
int
m_statusCodeCountLimit
=
100
;
private
long
m_nextClearTime
;
@Override
public
synchronized
void
doCheckpoint
(
boolean
atEnd
)
{
if
(
atEnd
&&
!
isLocalMode
())
{
...
...
@@ -42,11 +55,6 @@ public class EventAnalyzer extends AbstractMessageAnalyzer<EventReport> implemen
}
}
@Override
public
void
enableLogging
(
Logger
logger
)
{
m_logger
=
logger
;
}
@Override
public
EventReport
getReport
(
String
domain
)
{
long
period
=
getStartTime
();
...
...
@@ -60,14 +68,145 @@ public class EventAnalyzer extends AbstractMessageAnalyzer<EventReport> implemen
}
else
if
(
period
<
current
)
{
report
.
accept
(
m_computer
.
setDuration
(
3600
));
}
// report.getIps().addAll(report.getMachines().keySet());
return
report
;
}
@Override
public
void
enableLogging
(
Logger
logger
)
{
m_logger
=
logger
;
}
private
EventType
findOrCreateType
(
Machine
machine
,
String
type
)
{
EventType
eventType
=
machine
.
findType
(
type
);
if
(
eventType
==
null
)
{
int
size
=
machine
.
getTypes
().
size
();
if
(
size
>
m_typeCountLimit
)
{
eventType
=
machine
.
findOrCreateType
(
CatConstants
.
OTHERS
);
}
else
{
eventType
=
machine
.
findOrCreateType
(
type
);
}
}
return
eventType
;
}
private
EventName
findOrCreateName
(
EventType
type
,
String
name
,
String
domain
)
{
EventName
eventName
=
type
.
findName
(
name
);
if
(
eventName
==
null
)
{
int
size
=
type
.
getNames
().
size
();
if
(
size
>
m_atomicMessageConfigManager
.
getMaxNameThreshold
(
domain
))
{
eventName
=
type
.
findOrCreateName
(
CatConstants
.
OTHERS
);
}
else
{
eventName
=
type
.
findOrCreateName
(
name
);
}
}
return
eventName
;
}
private
StatusCode
findOrCreateStatusCode
(
EventName
name
,
String
codeName
)
{
StatusCode
code
=
name
.
findStatusCode
(
codeName
);
if
(
code
==
null
)
{
int
size
=
name
.
getStatusCodes
().
size
();
if
(
size
>
m_statusCodeCountLimit
)
{
code
=
name
.
findOrCreateStatusCode
(
CatConstants
.
OTHERS
);
}
else
{
code
=
name
.
findOrCreateStatusCode
(
codeName
);
}
}
return
code
;
}
private
void
cleanUpReports
()
{
String
minute
=
TimeHelper
.
getMinuteStr
();
Transaction
t
=
Cat
.
newTransaction
(
"CleanUpEventReports"
,
minute
);
try
{
Set
<
String
>
domains
=
m_reportManager
.
getDomains
(
m_startTime
);
for
(
String
domain
:
domains
)
{
Transaction
tran
=
Cat
.
newTransaction
(
"CleanUpEvent"
,
minute
);
tran
.
addData
(
"domain"
,
domain
);
EventReportCountFilter
visitor
=
new
EventReportCountFilter
(
m_serverConfigManager
.
getMaxTypeThreshold
(),
m_atomicMessageConfigManager
.
getMaxNameThreshold
(
domain
),
m_serverConfigManager
.
getTypeNameLengthLimit
());
try
{
EventReport
report
=
m_reportManager
.
getHourlyReport
(
m_startTime
,
domain
,
false
);
visitor
.
visitEventReport
(
report
);
tran
.
setSuccessStatus
();
}
catch
(
Exception
e
)
{
try
{
EventReport
report
=
m_reportManager
.
getHourlyReport
(
m_startTime
,
domain
,
false
);
visitor
.
visitEventReport
(
report
);
tran
.
setSuccessStatus
();
}
catch
(
Exception
re
)
{
tran
.
setStatus
(
re
);
Cat
.
logError
(
re
);
}
}
finally
{
tran
.
complete
();
}
}
t
.
setSuccessStatus
();
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
finally
{
t
.
complete
();
}
}
private
String
formatStatus
(
String
status
)
{
if
(
status
.
length
()
>
128
)
{
return
status
.
substring
(
0
,
128
);
}
else
{
return
status
;
}
}
@Override
public
ReportManager
<
EventReport
>
getReportManager
()
{
return
m_reportManager
;
}
@Override
public
void
initialize
(
long
startTime
,
long
duration
,
long
extraTime
)
{
super
.
initialize
(
startTime
,
duration
,
extraTime
);
m_typeCountLimit
=
m_serverConfigManager
.
getMaxTypeThreshold
();
final
long
current
=
System
.
currentTimeMillis
();
if
(
startTime
<
current
)
{
m_nextClearTime
=
TimeHelper
.
getCurrentMinute
().
getTime
()
+
TimeHelper
.
ONE_MINUTE
*
2
;
}
else
{
m_nextClearTime
=
startTime
+
TimeHelper
.
ONE_MINUTE
*
2
;
}
}
@Override
public
boolean
isEligable
(
MessageTree
tree
)
{
List
<
Event
>
events
=
tree
.
getEvents
();
if
(
events
!=
null
&&
events
.
size
()
>
0
)
{
return
true
;
}
else
{
return
false
;
}
}
@Override
protected
void
loadReports
()
{
m_reportManager
.
loadHourlyReports
(
getStartTime
(),
StoragePolicy
.
FILE
,
m_index
);
...
...
@@ -76,77 +215,95 @@ public class EventAnalyzer extends AbstractMessageAnalyzer<EventReport> implemen
@Override
public
void
process
(
MessageTree
tree
)
{
String
domain
=
tree
.
getDomain
();
String
ip
=
tree
.
getIpAddress
();
EventReport
report
=
m_reportManager
.
getHourlyReport
(
getStartTime
(),
domain
,
true
);
List
<
Event
>
events
=
tree
.
findOrCreateEvents
();
if
(
m_serverFilterConfigManager
.
validateDomain
(
domain
))
{
EventReport
report
=
m_reportManager
.
getHourlyReport
(
getStartTime
(),
domain
,
true
);
String
ip
=
tree
.
getIpAddress
();
List
<
Event
>
events
=
tree
.
getEvents
();
for
(
Event
e
:
events
)
{
String
data
=
String
.
valueOf
(
e
.
getData
());
int
total
=
1
;
int
fail
=
0
;
boolean
batchData
=
data
.
length
()
>
0
&&
data
.
charAt
(
0
)
==
CatConstants
.
BATCH_FLAG
;
if
(
batchData
)
{
String
[]
tab
=
data
.
substring
(
1
).
split
(
CatConstants
.
SPLIT
);
total
=
Integer
.
parseInt
(
tab
[
0
]);
fail
=
Integer
.
parseInt
(
tab
[
1
]);
}
else
{
if
(!
e
.
isSuccess
())
{
fail
=
1
;
}
for
(
Event
event
:
events
)
{
String
data
=
String
.
valueOf
(
event
.
getData
());
int
total
=
1
;
int
fail
=
0
;
boolean
batchData
=
data
.
length
()
>
0
&&
data
.
charAt
(
0
)
==
CatConstants
.
BATCH_FLAG
;
if
(
batchData
)
{
String
[]
tab
=
data
.
substring
(
1
).
split
(
CatConstants
.
SPLIT
);
total
=
Integer
.
parseInt
(
tab
[
0
]);
fail
=
Integer
.
parseInt
(
tab
[
1
]);
}
else
{
if
(!
event
.
isSuccess
())
{
fail
=
1
;
}
processEvent
(
report
,
tree
,
e
,
ip
);
}
processEvent
(
report
,
tree
,
event
,
ip
,
total
,
fail
,
batchData
);
}
if
(
System
.
currentTimeMillis
()
>
m_nextClearTime
)
{
m_nextClearTime
=
m_nextClearTime
+
TimeHelper
.
ONE_MINUTE
;
Threads
.
forGroup
(
"cat"
).
start
(
new
Runnable
()
{
@Override
public
void
run
()
{
cleanUpReports
();
}
});
}
}
private
void
processEvent
(
EventReport
report
,
MessageTree
tree
,
Event
event
,
String
ip
)
{
int
count
=
1
;
EventType
type
=
report
.
findOrCreateMachine
(
ip
).
findOrCreateType
(
event
.
getType
());
EventName
name
=
type
.
findOrCreateName
(
event
.
getName
());
private
void
processEvent
(
EventReport
report
,
MessageTree
tree
,
Event
event
,
String
ip
,
int
total
,
int
fail
,
boolean
batchData
)
{
Machine
machine
=
report
.
findOrCreateMachine
(
ip
);
EventType
type
=
findOrCreateType
(
machine
,
event
.
getType
());
EventName
name
=
findOrCreateName
(
type
,
event
.
getName
(),
report
.
getDomain
());
String
messageId
=
tree
.
getMessageId
();
report
.
addIp
(
tree
.
getIpAddress
());
type
.
incTotalCount
(
count
);
name
.
incTotalCount
(
count
);
type
.
incTotalCount
(
total
);
name
.
incTotalCount
(
total
);
if
(
event
.
isSuccess
())
{
if
(
type
.
getSuccessMessageUrl
()
==
null
)
{
type
.
setSuccessMessageUrl
(
messageId
);
}
if
(
fail
>
0
)
{
type
.
incFailCount
(
fail
);
name
.
incFailCount
(
fail
);
}
if
(
type
.
getSuccessMessageUrl
()
==
null
)
{
type
.
setSuccessMessageUrl
(
messageId
);
}
if
(
name
.
getSuccessMessageUrl
()
==
null
)
{
if
(
name
.
getSuccessMessageUrl
()
==
null
)
{
name
.
setSuccessMessageUrl
(
messageId
);
}
if
(!
batchData
)
{
if
(
event
.
isSuccess
())
{
type
.
setSuccessMessageUrl
(
messageId
);
name
.
setSuccessMessageUrl
(
messageId
);
}
else
{
type
.
setSuccessMessageUrl
(
messageId
);
name
.
setSuccessMessageUrl
(
messageId
);
}
}
else
{
type
.
incFailCount
(
count
);
name
.
incFailCount
(
count
);
if
(
type
.
getFailMessageUrl
()
==
null
)
{
type
.
setFailMessageUrl
(
messageId
);
}
String
statusCode
=
formatStatus
(
event
.
getStatus
());
if
(
name
.
getFailMessageUrl
()
==
null
)
{
name
.
setFailMessageUrl
(
messageId
);
findOrCreateStatusCode
(
name
,
statusCode
).
incCount
();
}
}
type
.
setFailPercent
(
type
.
getFailCount
()
*
100.0
/
type
.
getTotalCount
());
name
.
setFailPercent
(
name
.
getFailCount
()
*
100.0
/
name
.
getTotalCount
());
processEventGrpah
(
name
,
event
,
count
);
processEventGrpah
(
name
,
event
,
total
,
fail
);
}
private
void
processEventGrpah
(
EventName
name
,
Event
t
,
int
count
)
{
long
current
=
t
.
getTimestamp
()
/
1000
/
60
;
private
void
processEventGrpah
(
EventName
name
,
Event
event
,
int
total
,
int
fail
)
{
long
current
=
even
t
.
getTimestamp
()
/
1000
/
60
;
int
min
=
(
int
)
(
current
%
(
60
));
Range
range
=
name
.
findOrCreateRange
(
min
);
range
.
incCount
(
count
);
if
(!
t
.
isSuccess
())
{
range
.
incFails
(
count
);
range
.
incCount
(
total
);
if
(
fail
>
0
)
{
range
.
incFails
(
fail
);
}
}
...
...
@@ -154,13 +311,4 @@ public class EventAnalyzer extends AbstractMessageAnalyzer<EventReport> implemen
m_reportManager
=
reportManager
;
}
@Override
public
boolean
isEligable
(
MessageTree
tree
)
{
if
(
tree
.
getEvents
().
size
()
>
0
)
{
return
true
;
}
else
{
return
false
;
}
}
}
cat-consumer/src/main/java/com/dianping/cat/consumer/event/EventDelegate.java
浏览文件 @
1fea6433
...
...
@@ -8,6 +8,8 @@ import org.unidal.lookup.annotation.Named;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Constants
;
import
com.dianping.cat.config.AtomicMessageConfigManager
;
import
com.dianping.cat.config.server.ServerConfigManager
;
import
com.dianping.cat.config.server.ServerFilterConfigManager
;
import
com.dianping.cat.consumer.config.AllReportConfigManager
;
import
com.dianping.cat.consumer.event.model.entity.EventReport
;
...
...
@@ -30,6 +32,12 @@ public class EventDelegate implements ReportDelegate<EventReport> {
@Inject
private
AllReportConfigManager
m_allManager
;
@Inject
private
ServerConfigManager
m_serverConfigManager
;
@Inject
private
AtomicMessageConfigManager
m_atomicMessageConfigManager
;
private
EventTpsStatisticsComputer
m_computer
=
new
EventTpsStatisticsComputer
();
@Override
...
...
@@ -38,11 +46,11 @@ public class EventDelegate implements ReportDelegate<EventReport> {
@Override
public
void
beforeSave
(
Map
<
String
,
EventReport
>
reports
)
{
// if (reports.size() > 0) {
// EventReport all = createAggregatedReport(reports);
//
// reports.put(all.getDomain(), all);
// }
// if (reports.size() > 0) {
// EventReport all = createAggregatedReport(reports);
//
// reports.put(all.getDomain(), all);
// }
}
@Override
...
...
@@ -54,7 +62,9 @@ public class EventDelegate implements ReportDelegate<EventReport> {
public
String
buildXml
(
EventReport
report
)
{
report
.
accept
(
m_computer
);
new
EventReportCountFilter
().
visitEventReport
(
report
);
new
EventReportCountFilter
(
m_serverConfigManager
.
getMaxTypeThreshold
(),
m_atomicMessageConfigManager
.
getMaxNameThreshold
(
report
.
getDomain
()),
m_serverConfigManager
.
getTypeNameLengthLimit
()).
visitEventReport
(
report
);
return
report
.
toString
();
}
...
...
@@ -89,8 +99,7 @@ public class EventDelegate implements ReportDelegate<EventReport> {
String
domain
=
report
.
getDomain
();
if
(
domain
.
equals
(
Constants
.
ALL
)
||
m_configManager
.
validateDomain
(
domain
))
{
return
m_taskManager
.
createTask
(
report
.
getStartTime
(),
domain
,
EventAnalyzer
.
ID
,
TaskProlicy
.
ALL_EXCLUED_HOURLY
);
return
m_taskManager
.
createTask
(
report
.
getStartTime
(),
domain
,
EventAnalyzer
.
ID
,
TaskProlicy
.
ALL_EXCLUED_HOURLY
);
}
else
{
return
true
;
}
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/event/EventReportCountFilter.java
浏览文件 @
1fea6433
...
...
@@ -8,13 +8,30 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Set
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.CatConstants
;
import
com.dianping.cat.consumer.event.model.entity.EventName
;
import
com.dianping.cat.consumer.event.model.entity.EventReport
;
import
com.dianping.cat.consumer.event.model.entity.EventType
;
import
com.dianping.cat.consumer.event.model.entity.Machine
;
import
com.dianping.cat.consumer.event.model.transform.BaseVisitor
;
import
com.dianping.cat.consumer.util.InvidStringBuilder
;
public
class
EventReportCountFilter
extends
BaseVisitor
{
private
int
m_maxItems
=
600
;
private
int
m_maxTypeLimit
;
private
int
m_maxNameLimit
;
private
String
m_domain
;
private
int
m_lengthLimit
;
public
EventReportCountFilter
(
int
typeLimit
,
int
nameLimit
,
int
lengthLimimt
)
{
m_maxTypeLimit
=
typeLimit
;
m_maxNameLimit
=
nameLimit
;
m_lengthLimit
=
lengthLimimt
;
}
private
void
mergeName
(
EventName
old
,
EventName
other
)
{
old
.
setTotalCount
(
old
.
getTotalCount
()
+
other
.
getTotalCount
());
...
...
@@ -31,6 +48,53 @@ public class EventReportCountFilter extends BaseVisitor {
}
}
private
void
mergeType
(
EventType
old
,
EventType
other
)
{
old
.
setTotalCount
(
old
.
getTotalCount
()
+
other
.
getTotalCount
());
old
.
setFailCount
(
old
.
getFailCount
()
+
other
.
getFailCount
());
if
(
old
.
getTotalCount
()
>
0
)
{
old
.
setFailPercent
(
old
.
getFailCount
()
*
100.0
/
old
.
getTotalCount
());
}
if
(
old
.
getSuccessMessageUrl
()
==
null
)
{
old
.
setSuccessMessageUrl
(
other
.
getSuccessMessageUrl
());
}
if
(
old
.
getFailMessageUrl
()
==
null
)
{
old
.
setFailMessageUrl
(
other
.
getFailMessageUrl
());
}
}
@Override
public
void
visitEventReport
(
EventReport
eventReport
)
{
m_domain
=
eventReport
.
getDomain
();
super
.
visitEventReport
(
eventReport
);
}
@Override
public
void
visitMachine
(
Machine
machine
)
{
final
Map
<
String
,
EventType
>
types
=
machine
.
getTypes
();
int
size
=
types
.
size
();
if
(
size
>
m_maxTypeLimit
)
{
Cat
.
logEvent
(
"TooManyEventType"
,
m_domain
);
List
<
EventType
>
all
=
new
ArrayList
<
EventType
>(
types
.
values
());
Collections
.
sort
(
all
,
new
EventTypeCompator
());
machine
.
getTypes
().
clear
();
for
(
int
i
=
0
;
i
<
m_maxTypeLimit
;
i
++)
{
machine
.
addType
(
all
.
get
(
i
));
}
EventType
other
=
machine
.
findOrCreateType
(
CatConstants
.
OTHERS
);
for
(
int
i
=
m_maxTypeLimit
;
i
<
size
;
i
++)
{
mergeType
(
other
,
all
.
get
(
i
));
}
}
super
.
visitMachine
(
machine
);
}
@Override
public
void
visitType
(
EventType
type
)
{
Map
<
String
,
EventName
>
eventNames
=
type
.
getNames
();
...
...
@@ -40,34 +104,43 @@ public class EventReportCountFilter extends BaseVisitor {
for
(
String
temp
:
names
)
{
int
length
=
temp
.
length
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
// invalidate char
if
(
temp
.
charAt
(
i
)
>
126
||
temp
.
charAt
(
i
)
<
32
)
{
invalidates
.
add
(
temp
);
break
;
if
(
length
>
m_lengthLimit
)
{
invalidates
.
add
(
temp
);
}
else
{
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
// invalidate char
if
(
temp
.
charAt
(
i
)
>
126
||
temp
.
charAt
(
i
)
<
32
)
{
invalidates
.
add
(
temp
);
break
;
}
}
}
}
for
(
String
name
:
invalidates
)
{
eventNames
.
remove
(
name
);
}
EventName
eventName
=
eventNames
.
remove
(
name
);
if
(
eventName
!=
null
)
{
eventName
.
setId
(
InvidStringBuilder
.
getValidString
(
name
));
eventNames
.
put
(
eventName
.
getId
(),
eventName
);
}
}
int
size
=
eventNames
.
size
();
if
(
size
>
m_maxItems
)
{
if
(
size
>
m_maxNameLimit
)
{
Cat
.
logEvent
(
"TooManyEventItem"
,
m_domain
+
":"
+
type
.
getId
());
List
<
EventName
>
all
=
new
ArrayList
<
EventName
>(
eventNames
.
values
());
Collections
.
sort
(
all
,
new
EventNameCompator
());
type
.
getNames
().
clear
();
for
(
int
i
=
0
;
i
<
m_max
Items
;
i
++)
{
for
(
int
i
=
0
;
i
<
m_max
NameLimit
;
i
++)
{
type
.
addName
(
all
.
get
(
i
));
}
EventName
other
=
type
.
findOrCreateName
(
"OTHERS"
);
EventName
other
=
type
.
findOrCreateName
(
CatConstants
.
OTHERS
);
for
(
int
i
=
m_max
Items
;
i
<
size
;
i
++)
{
for
(
int
i
=
m_max
NameLimit
;
i
<
size
;
i
++)
{
mergeName
(
other
,
all
.
get
(
i
));
}
}
...
...
@@ -86,4 +159,18 @@ public class EventReportCountFilter extends BaseVisitor {
}
}
}
private
static
class
EventTypeCompator
implements
Comparator
<
EventType
>
{
@Override
public
int
compare
(
EventType
o1
,
EventType
o2
)
{
if
(
o2
.
getTotalCount
()
>
o1
.
getTotalCount
())
{
return
1
;
}
else
if
(
o2
.
getTotalCount
()
<
o1
.
getTotalCount
())
{
return
-
1
;
}
else
{
return
0
;
}
}
}
}
\ No newline at end of file
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionAnalyzer.java
浏览文件 @
1fea6433
此差异已折叠。
点击以展开。
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionDelegate.java
浏览文件 @
1fea6433
package
com.dianping.cat.consumer.transaction
;
import
static
com
.
dianping
.
cat
.
Constants
.
ALL
;
import
java.util.Date
;
import
java.util.Map
;
...
...
@@ -10,6 +8,8 @@ import org.unidal.lookup.annotation.Named;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Constants
;
import
com.dianping.cat.config.AtomicMessageConfigManager
;
import
com.dianping.cat.config.server.ServerConfigManager
;
import
com.dianping.cat.config.server.ServerFilterConfigManager
;
import
com.dianping.cat.consumer.config.AllReportConfigManager
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
...
...
@@ -20,6 +20,8 @@ import com.dianping.cat.report.ReportDelegate;
import
com.dianping.cat.task.TaskManager
;
import
com.dianping.cat.task.TaskManager.TaskProlicy
;
import
static
com
.
dianping
.
cat
.
Constants
.
ALL
;
@Named
(
type
=
ReportDelegate
.
class
,
value
=
TransactionAnalyzer
.
ID
)
public
class
TransactionDelegate
implements
ReportDelegate
<
TransactionReport
>
{
...
...
@@ -32,6 +34,12 @@ public class TransactionDelegate implements ReportDelegate<TransactionReport> {
@Inject
private
AllReportConfigManager
m_transactionManager
;
@Inject
private
ServerConfigManager
m_serverConfigManager
;
@Inject
private
AtomicMessageConfigManager
m_atomicMessageConfigManager
;
private
TransactionStatisticsComputer
m_computer
=
new
TransactionStatisticsComputer
();
@Override
...
...
@@ -40,11 +48,11 @@ public class TransactionDelegate implements ReportDelegate<TransactionReport> {
@Override
public
void
beforeSave
(
Map
<
String
,
TransactionReport
>
reports
)
{
// if (reports.size() > 0) {
// TransactionReport all = createAggregatedReport(reports);
//
// reports.put(all.getDomain(), all);
// }
// if (reports.size() > 0) {
// TransactionReport all = createAggregatedReport(reports);
//
// reports.put(all.getDomain(), all);
// }
}
@Override
...
...
@@ -56,7 +64,9 @@ public class TransactionDelegate implements ReportDelegate<TransactionReport> {
public
String
buildXml
(
TransactionReport
report
)
{
report
.
accept
(
m_computer
);
new
TransactionReportCountFilter
().
visitTransactionReport
(
report
);
new
TransactionReportCountFilter
(
m_serverConfigManager
.
getMaxTypeThreshold
(),
m_atomicMessageConfigManager
.
getMaxNameThreshold
(
report
.
getDomain
()),
m_serverConfigManager
.
getTypeNameLengthLimit
()).
visitTransactionReport
(
report
);
return
report
.
toString
();
}
...
...
@@ -91,8 +101,8 @@ public class TransactionDelegate implements ReportDelegate<TransactionReport> {
String
domain
=
report
.
getDomain
();
if
(
domain
.
equals
(
Constants
.
ALL
)
||
m_configManager
.
validateDomain
(
domain
))
{
return
m_taskManager
.
createTask
(
report
.
getStartTime
(),
domain
,
TransactionAnalyzer
.
ID
,
TaskProlicy
.
ALL_EXCLUED_HOURLY
);
return
m_taskManager
.
createTask
(
report
.
getStartTime
(),
domain
,
TransactionAnalyzer
.
ID
,
TaskProlicy
.
ALL_EXCLUED_HOURLY
);
}
else
{
return
true
;
}
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionReportCountFilter.java
浏览文件 @
1fea6433
...
...
@@ -8,12 +8,30 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Set
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.CatConstants
;
import
com.dianping.cat.consumer.transaction.model.entity.Machine
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionName
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionType
;
import
com.dianping.cat.consumer.transaction.model.transform.BaseVisitor
;
import
com.dianping.cat.consumer.util.InvidStringBuilder
;
public
class
TransactionReportCountFilter
extends
BaseVisitor
{
private
int
m_maxItems
=
400
;
private
int
m_maxTypeLimit
;
private
int
m_maxNameLimit
;
private
String
m_domain
;
private
int
m_lengthLimit
=
256
;
public
TransactionReportCountFilter
(
int
typeLimit
,
int
nameLimit
,
int
lengthLimit
)
{
m_maxNameLimit
=
nameLimit
;
m_maxTypeLimit
=
typeLimit
;
m_lengthLimit
=
lengthLimit
;
}
private
void
mergeName
(
TransactionName
old
,
TransactionName
other
)
{
old
.
setTotalCount
(
old
.
getTotalCount
()
+
other
.
getTotalCount
());
...
...
@@ -24,6 +42,7 @@ public class TransactionReportCountFilter extends BaseVisitor {
}
if
(
other
.
getMax
()
>
old
.
getMax
())
{
old
.
setMax
(
other
.
getMax
());
old
.
setLongestMessageUrl
(
other
.
getLongestMessageUrl
());
}
old
.
setSum
(
old
.
getSum
()
+
other
.
getSum
());
old
.
setSum2
(
old
.
getSum2
()
+
other
.
getSum2
());
...
...
@@ -40,10 +59,71 @@ public class TransactionReportCountFilter extends BaseVisitor {
}
}
private
void
mergeType
(
TransactionType
old
,
TransactionType
other
)
{
old
.
setTotalCount
(
old
.
getTotalCount
()
+
other
.
getTotalCount
());
old
.
setFailCount
(
old
.
getFailCount
()
+
other
.
getFailCount
());
if
(
other
.
getMin
()
<
old
.
getMin
())
{
old
.
setMin
(
other
.
getMin
());
}
if
(
other
.
getMax
()
>
old
.
getMax
())
{
old
.
setMax
(
other
.
getMax
());
old
.
setLongestMessageUrl
(
other
.
getLongestMessageUrl
());
}
old
.
setSum
(
old
.
getSum
()
+
other
.
getSum
());
old
.
setSum2
(
old
.
getSum2
()
+
other
.
getSum2
());
old
.
setLine95Value
(
0
);
if
(
old
.
getTotalCount
()
>
0
)
{
old
.
setFailPercent
(
old
.
getFailCount
()
*
100.0
/
old
.
getTotalCount
());
old
.
setAvg
(
old
.
getSum
()
/
old
.
getTotalCount
());
}
if
(
old
.
getSuccessMessageUrl
()
==
null
)
{
old
.
setSuccessMessageUrl
(
other
.
getSuccessMessageUrl
());
}
if
(
old
.
getFailMessageUrl
()
==
null
)
{
old
.
setFailMessageUrl
(
other
.
getFailMessageUrl
());
}
}
public
void
setMaxItems
(
int
item
)
{
m_max
Items
=
item
;
m_max
NameLimit
=
item
;
}
@Override
public
void
visitMachine
(
Machine
machine
)
{
final
Map
<
String
,
TransactionType
>
types
=
machine
.
getTypes
();
int
size
=
types
.
size
();
if
(
size
>
m_maxTypeLimit
)
{
Cat
.
logEvent
(
"TooManyTransactionType"
,
m_domain
);
List
<
TransactionType
>
all
=
new
ArrayList
<
TransactionType
>(
types
.
values
());
Collections
.
sort
(
all
,
new
TransactionTypeCompator
());
machine
.
getTypes
().
clear
();
for
(
int
i
=
0
;
i
<
m_maxTypeLimit
;
i
++)
{
machine
.
addType
(
all
.
get
(
i
));
}
TransactionType
other
=
machine
.
findOrCreateType
(
CatConstants
.
OTHERS
);
for
(
int
i
=
m_maxTypeLimit
;
i
<
size
;
i
++)
{
mergeType
(
other
,
all
.
get
(
i
));
}
}
super
.
visitMachine
(
machine
);
}
@Override
public
void
visitTransactionReport
(
TransactionReport
transactionReport
)
{
m_domain
=
transactionReport
.
getDomain
();
super
.
visitTransactionReport
(
transactionReport
);
}
;
@Override
public
void
visitType
(
TransactionType
type
)
{
Map
<
String
,
TransactionName
>
transactionNames
=
type
.
getNames
();
...
...
@@ -53,34 +133,43 @@ public class TransactionReportCountFilter extends BaseVisitor {
for
(
String
temp
:
names
)
{
int
length
=
temp
.
length
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
// invalidate char
if
(
temp
.
charAt
(
i
)
>
126
||
temp
.
charAt
(
i
)
<
32
)
{
invalidates
.
add
(
temp
);
continue
;
if
(
length
>
m_lengthLimit
)
{
invalidates
.
add
(
temp
);
}
else
{
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
// invalidate char
if
(
temp
.
charAt
(
i
)
>
126
||
temp
.
charAt
(
i
)
<
32
)
{
invalidates
.
add
(
temp
);
break
;
}
}
}
}
for
(
String
name
:
invalidates
)
{
transactionNames
.
remove
(
name
);
TransactionName
transactionName
=
transactionNames
.
remove
(
name
);
String
validString
=
InvidStringBuilder
.
getValidString
(
name
);
transactionName
.
setId
(
validString
);
transactionNames
.
put
(
transactionName
.
getId
(),
transactionName
);
}
int
size
=
transactionNames
.
size
();
if
(
size
>
m_maxItems
)
{
if
(
size
>
m_maxNameLimit
)
{
Cat
.
logEvent
(
"TooManyTransactionName"
,
m_domain
+
":"
+
type
.
getId
());
List
<
TransactionName
>
all
=
new
ArrayList
<
TransactionName
>(
transactionNames
.
values
());
Collections
.
sort
(
all
,
new
TransactionNameCompator
());
type
.
getNames
().
clear
();
for
(
int
i
=
0
;
i
<
m_max
Items
;
i
++)
{
for
(
int
i
=
0
;
i
<
m_max
NameLimit
;
i
++)
{
type
.
addName
(
all
.
get
(
i
));
}
TransactionName
other
=
type
.
findOrCreateName
(
"OTHERS"
);
TransactionName
other
=
type
.
findOrCreateName
(
CatConstants
.
OTHERS
);
for
(
int
i
=
m_max
Items
;
i
<
size
;
i
++)
{
for
(
int
i
=
m_max
NameLimit
;
i
<
size
;
i
++)
{
mergeName
(
other
,
all
.
get
(
i
));
}
}
...
...
@@ -99,4 +188,18 @@ public class TransactionReportCountFilter extends BaseVisitor {
}
}
}
private
static
class
TransactionTypeCompator
implements
Comparator
<
TransactionType
>
{
@Override
public
int
compare
(
TransactionType
o1
,
TransactionType
o2
)
{
if
(
o2
.
getTotalCount
()
>
o1
.
getTotalCount
())
{
return
1
;
}
else
if
(
o2
.
getTotalCount
()
<
o1
.
getTotalCount
())
{
return
-
1
;
}
else
{
return
0
;
}
}
}
}
\ No newline at end of file
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionReportMerger.java
浏览文件 @
1fea6433
此差异已折叠。
点击以展开。
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionStatisticsComputer.java
浏览文件 @
1fea6433
package
com.dianping.cat.consumer.transaction
;
import
java.util.Comparator
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.TreeMap
;
import
com.dianping.cat.consumer.transaction.model.entity.AllDuration
;
import
com.dianping.cat.consumer.transaction.model.entity.Range
;
import
com.dianping.cat.consumer.transaction.model.entity.Range2
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionName
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionType
;
import
com.dianping.cat.consumer.transaction.model.transform.BaseVisitor
;
public
class
TransactionStatisticsComputer
extends
BaseVisitor
{
p
ublic
double
m_duration
=
3600
;
p
rivate
double
m_duration
=
3600
;
private
double
computeLineValue
(
Map
<
Integer
,
AllDuration
>
durations
,
double
percent
)
{
int
totalCount
=
0
;
Map
<
Integer
,
AllDuration
>
sorted
=
new
TreeMap
<
Integer
,
AllDuration
>(
TransactionComparator
.
DESC
);
private
boolean
m_clearAll
=
false
;
sorted
.
putAll
(
durations
);
private
int
m_maxDurationMinute
=
1
;
public
final
static
double
PERCENT_50
=
50.0
;
public
final
static
double
PERCENT_90
=
90.0
;
public
final
static
double
PERCENT_95
=
95.0
;
public
final
static
double
PERCENT_99
=
99.0
;
public
final
static
double
PERCENT_999
=
99.9
;
for
(
AllDuration
duration
:
durations
.
values
())
{
public
final
static
double
PERCENT_9999
=
99.99
;
public
TransactionStatisticsComputer
()
{
}
public
TransactionStatisticsComputer
(
boolean
clearAll
)
{
m_clearAll
=
clearAll
;
}
public
Map
<
Double
,
Integer
>
computeLineValue
(
Map
<
Integer
,
AllDuration
>
sorted
,
double
[]
percents
)
{
int
totalCount
=
0
;
for
(
AllDuration
duration
:
sorted
.
values
())
{
totalCount
+=
duration
.
getCount
();
}
int
remaining
=
(
int
)
(
totalCount
*
(
100
-
percent
)
/
100
);
Map
<
Double
,
Integer
>
lineValue
=
new
LinkedHashMap
<
Double
,
Integer
>();
Map
<
Double
,
Integer
>
remainings
=
new
LinkedHashMap
<>();
for
(
double
percent
:
percents
)
{
int
remaining
=
(
int
)
(
totalCount
*
(
100
-
percent
)
/
100
);
remainings
.
put
(
percent
,
remaining
);
lineValue
.
put
(
percent
,
0
);
}
for
(
Entry
<
Integer
,
AllDuration
>
entry
:
sorted
.
entrySet
())
{
remaining
-=
entry
.
getValue
().
getCount
();
int
count
=
entry
.
getValue
().
getCount
();
int
result
=
1
;
for
(
double
key
:
percents
)
{
if
(
lineValue
.
get
(
key
)
==
0
)
{
int
remaining
=
remainings
.
get
(
key
);
remaining
-=
count
;
if
(
remaining
<=
0
)
{
lineValue
.
put
(
key
,
entry
.
getKey
());
}
remainings
.
put
(
key
,
remaining
);
}
result
&=
lineValue
.
get
(
key
);
}
if
(
re
maining
<=
0
)
{
return
entry
.
getKey
()
;
if
(
re
sult
>
0
)
{
break
;
}
}
return
0.0
;
return
lineValue
;
}
public
int
getMaxDurationMinute
()
{
return
m_maxDurationMinute
;
}
public
TransactionStatisticsComputer
setDuration
(
double
duration
)
{
...
...
@@ -43,6 +91,18 @@ public class TransactionStatisticsComputer extends BaseVisitor {
return
this
;
}
public
void
setMaxDurationMinute
(
int
maxDurationMinute
)
{
m_maxDurationMinute
=
maxDurationMinute
;
}
public
Map
<
Integer
,
AllDuration
>
sortMap
(
Map
<
Integer
,
AllDuration
>
durations
)
{
Map
<
Integer
,
AllDuration
>
sorted
=
new
TreeMap
<
Integer
,
AllDuration
>(
TransactionComparator
.
DESC
);
sorted
.
putAll
(
durations
);
return
sorted
;
}
double
std
(
long
count
,
double
avg
,
double
sum2
,
double
max
)
{
double
value
=
sum2
/
count
-
avg
*
avg
;
...
...
@@ -71,14 +131,28 @@ public class TransactionStatisticsComputer extends BaseVisitor {
name
.
setAvg
(
avg
);
name
.
setStd
(
std
);
double
line95
=
computeLineValue
(
name
.
getAllDurations
(),
95
);
double
line999
=
computeLineValue
(
name
.
getAllDurations
(),
99.9
);
name
.
setLine95Value
(
line95
);
name
.
setLine99Value
(
line999
);
final
Map
<
Integer
,
AllDuration
>
allDurations
=
name
.
getAllDurations
();
if
(!
allDurations
.
isEmpty
())
{
final
Map
<
Integer
,
AllDuration
>
sourtMap
=
sortMap
(
allDurations
);
Map
<
Double
,
Integer
>
lineValues
=
computeLineValue
(
sourtMap
,
new
double
[]
{
PERCENT_50
,
PERCENT_90
,
PERCENT_95
,
PERCENT_99
,
PERCENT_999
,
PERCENT_9999
});
name
.
setLine50Value
(
lineValues
.
get
(
PERCENT_50
));
name
.
setLine90Value
(
lineValues
.
get
(
PERCENT_90
));
name
.
setLine95Value
(
lineValues
.
get
(
PERCENT_95
));
name
.
setLine99Value
(
lineValues
.
get
(
PERCENT_99
));
name
.
setLine999Value
(
lineValues
.
get
(
PERCENT_999
));
name
.
setLine9999Value
(
lineValues
.
get
(
PERCENT_9999
));
}
}
if
(
m_duration
>
0
)
{
name
.
setTps
(
name
.
getTotalCount
()
*
1.0
/
m_duration
);
}
if
(
m_clearAll
)
{
name
.
getAllDurations
().
clear
();
}
}
@Override
...
...
@@ -86,6 +160,69 @@ public class TransactionStatisticsComputer extends BaseVisitor {
if
(
range
.
getCount
()
>
0
)
{
range
.
setAvg
(
range
.
getSum
()
/
range
.
getCount
());
}
final
Map
<
Integer
,
AllDuration
>
allDurations
=
range
.
getAllDurations
();
if
(!
allDurations
.
isEmpty
()
&&
!
range
.
getClearDuration
())
{
final
Map
<
Integer
,
AllDuration
>
sourtMap
=
sortMap
(
allDurations
);
Map
<
Double
,
Integer
>
lineValues
=
computeLineValue
(
sourtMap
,
new
double
[]
{
PERCENT_50
,
PERCENT_90
,
PERCENT_95
,
PERCENT_99
,
PERCENT_999
,
PERCENT_9999
});
range
.
setLine50Value
(
lineValues
.
get
(
PERCENT_50
));
range
.
setLine90Value
(
lineValues
.
get
(
PERCENT_90
));
range
.
setLine95Value
(
lineValues
.
get
(
PERCENT_95
));
range
.
setLine99Value
(
lineValues
.
get
(
PERCENT_99
));
range
.
setLine999Value
(
lineValues
.
get
(
PERCENT_999
));
range
.
setLine9999Value
(
lineValues
.
get
(
PERCENT_9999
));
}
// clear duration in type all duration
long
current
=
System
.
currentTimeMillis
()
/
1000
/
60
;
int
min
=
(
int
)
(
current
%
(
60
));
if
(!
allDurations
.
isEmpty
()
&&
range
.
getValue
()
+
m_maxDurationMinute
<
min
)
{
range
.
getAllDurations
().
clear
();
range
.
setClearDuration
(
true
);
}
if
(
m_clearAll
)
{
range
.
getAllDurations
().
clear
();
}
}
@Override
public
void
visitRange2
(
Range2
range2
)
{
if
(
range2
.
getCount
()
>
0
)
{
range2
.
setAvg
(
range2
.
getSum
()
/
range2
.
getCount
());
}
final
Map
<
Integer
,
AllDuration
>
allDurations
=
range2
.
getAllDurations
();
if
(!
allDurations
.
isEmpty
()
&&
!
range2
.
getClearDuration
())
{
final
Map
<
Integer
,
AllDuration
>
sourtMap
=
sortMap
(
allDurations
);
Map
<
Double
,
Integer
>
lineValues
=
computeLineValue
(
sourtMap
,
new
double
[]
{
PERCENT_50
,
PERCENT_90
,
PERCENT_95
,
PERCENT_99
,
PERCENT_999
,
PERCENT_9999
});
range2
.
setLine50Value
(
lineValues
.
get
(
PERCENT_50
));
range2
.
setLine90Value
(
lineValues
.
get
(
PERCENT_90
));
range2
.
setLine95Value
(
lineValues
.
get
(
PERCENT_95
));
range2
.
setLine99Value
(
lineValues
.
get
(
PERCENT_99
));
range2
.
setLine999Value
(
lineValues
.
get
(
PERCENT_999
));
range2
.
setLine9999Value
(
lineValues
.
get
(
PERCENT_9999
));
}
// clear duration in name all duration
long
current
=
System
.
currentTimeMillis
()
/
1000
/
60
;
int
min
=
(
int
)
(
current
%
(
60
));
if
(!
allDurations
.
isEmpty
()
&&
range2
.
getValue
()
+
m_maxDurationMinute
<
min
)
{
range2
.
getAllDurations
().
clear
();
range2
.
setClearDuration
(
true
);
}
if
(
m_clearAll
)
{
range2
.
getAllDurations
().
clear
();
}
}
@Override
...
...
@@ -104,15 +241,28 @@ public class TransactionStatisticsComputer extends BaseVisitor {
type
.
setAvg
(
avg
);
type
.
setStd
(
std
);
double
line95
=
computeLineValue
(
type
.
getAllDurations
(),
95
);
double
line999
=
computeLineValue
(
type
.
getAllDurations
(),
99.9
);
type
.
setLine95Value
(
line95
);
type
.
setLine99Value
(
line999
);
final
Map
<
Integer
,
AllDuration
>
allDurations
=
type
.
getAllDurations
();
if
(!
allDurations
.
isEmpty
())
{
final
Map
<
Integer
,
AllDuration
>
sourtMap
=
sortMap
(
allDurations
);
Map
<
Double
,
Integer
>
lineValues
=
computeLineValue
(
sourtMap
,
new
double
[]
{
PERCENT_50
,
PERCENT_90
,
PERCENT_95
,
PERCENT_99
,
PERCENT_999
,
PERCENT_9999
});
type
.
setLine50Value
(
lineValues
.
get
(
PERCENT_50
));
type
.
setLine90Value
(
lineValues
.
get
(
PERCENT_90
));
type
.
setLine95Value
(
lineValues
.
get
(
PERCENT_95
));
type
.
setLine99Value
(
lineValues
.
get
(
PERCENT_99
));
type
.
setLine999Value
(
lineValues
.
get
(
PERCENT_999
));
type
.
setLine9999Value
(
lineValues
.
get
(
PERCENT_9999
));
}
if
(
m_duration
>
0
)
{
type
.
setTps
(
type
.
getTotalCount
()
*
1.0
/
m_duration
);
}
}
if
(
m_clearAll
)
{
type
.
getAllDurations
().
clear
();
}
}
private
static
enum
TransactionComparator
implements
Comparator
<
Integer
>
{
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/util/InvidStringBuilder.java
0 → 100644
浏览文件 @
1fea6433
package
com.dianping.cat.consumer.util
;
import
sun.misc.BASE64Encoder
;
public
class
InvidStringBuilder
{
public
static
final
int
s_lengthLimit
=
256
;
public
static
String
getValidString
(
String
key
)
{
String
result
=
null
;
if
(
key
.
length
()
>
s_lengthLimit
)
{
result
=
key
.
substring
(
0
,
s_lengthLimit
);
}
else
{
result
=
key
;
}
StringBuilder
sb
=
new
StringBuilder
(
32
);
int
length
=
result
.
length
();
boolean
needBase64
=
true
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
final
char
charAt
=
result
.
charAt
(
i
);
if
(
charAt
>
126
||
charAt
<
32
)
{
sb
.
append
(
'.'
);
}
else
{
sb
.
append
(
charAt
);
needBase64
=
false
;
}
}
if
(
needBase64
)
{
return
"Base64."
+
new
BASE64Encoder
().
encodeBuffer
(
key
.
getBytes
()).
trim
();
}
else
{
return
sb
.
toString
();
}
}
}
cat-consumer/src/main/java/com/dianping/cat/consumer/util/StringUtils.java
0 → 100644
浏览文件 @
1fea6433
package
com.dianping.cat.consumer.util
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
public
class
StringUtils
{
public
static
final
boolean
isEmpty
(
String
str
)
{
return
str
==
null
||
str
.
length
()
==
0
;
}
public
static
final
boolean
isNotEmpty
(
String
str
)
{
return
str
!=
null
&&
str
.
length
()
>
0
;
}
public
static
List
<
String
>
spilt
(
String
str
,
int
start
,
char
c
)
{
int
length
=
str
.
length
();
List
<
String
>
strs
=
new
ArrayList
<
String
>();
for
(
int
index
=
start
;
index
<
length
;
index
++)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
j
=
index
;
j
<
length
;
j
++)
{
final
char
charAt
=
str
.
charAt
(
j
);
if
(
j
==
length
-
1
)
{
sb
.
append
(
str
.
charAt
(
j
));
strs
.
add
(
sb
.
toString
());
index
=
j
++;
break
;
}
else
if
(
charAt
==
c
)
{
strs
.
add
(
sb
.
toString
());
index
=
j
;
break
;
}
else
{
sb
.
append
(
str
.
charAt
(
j
));
}
}
}
return
strs
;
}
public
static
final
String
join
(
Collection
<
String
>
list
,
String
separator
)
{
StringBuilder
sb
=
new
StringBuilder
(
1024
);
boolean
first
=
true
;
for
(
String
item
:
list
)
{
if
(
first
)
{
first
=
false
;
}
else
{
sb
.
append
(
separator
);
}
sb
.
append
(
item
);
}
return
sb
.
toString
();
}
public
static
final
String
join
(
double
[]
count
,
char
spit
)
{
boolean
first
=
true
;
StringBuilder
sb
=
new
StringBuilder
(
128
);
for
(
double
i
:
count
)
{
if
(
first
)
{
sb
.
append
(
i
);
first
=
false
;
}
else
{
sb
.
append
(
spit
).
append
(
i
);
}
}
return
sb
.
toString
();
}
public
static
final
String
join
(
int
[]
count
,
char
spit
)
{
boolean
first
=
true
;
StringBuilder
sb
=
new
StringBuilder
(
128
);
for
(
int
i
:
count
)
{
if
(
first
)
{
sb
.
append
(
i
);
first
=
false
;
}
else
{
sb
.
append
(
spit
).
append
(
i
);
}
}
return
sb
.
toString
();
}
public
static
final
String
join
(
long
[]
count
,
char
spit
)
{
boolean
first
=
true
;
StringBuilder
sb
=
new
StringBuilder
(
128
);
for
(
long
i
:
count
)
{
if
(
first
)
{
sb
.
append
(
i
);
first
=
false
;
}
else
{
sb
.
append
(
spit
).
append
(
i
);
}
}
return
sb
.
toString
();
}
public
static
final
String
join
(
String
[]
array
,
String
separator
)
{
StringBuilder
sb
=
new
StringBuilder
(
1024
);
boolean
first
=
true
;
for
(
String
item
:
array
)
{
if
(
first
)
{
first
=
false
;
}
else
{
sb
.
append
(
separator
);
}
sb
.
append
(
item
);
}
return
sb
.
toString
();
}
public
static
final
String
normalizeSpace
(
String
str
)
{
int
len
=
str
.
length
();
StringBuilder
sb
=
new
StringBuilder
(
len
);
boolean
space
=
false
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
char
ch
=
str
.
charAt
(
i
);
switch
(
ch
)
{
case
' '
:
case
'\t'
:
case
'\r'
:
case
'\n'
:
space
=
true
;
break
;
default
:
if
(
space
)
{
sb
.
append
(
' '
);
space
=
false
;
}
sb
.
append
(
ch
);
}
}
return
sb
.
toString
();
}
public
static
final
List
<
String
>
split
(
String
str
,
char
c
)
{
List
<
String
>
results
=
new
ArrayList
<
String
>();
for
(
int
i
=
0
;
i
<
str
.
length
();)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
j
=
i
;
j
<
str
.
length
();
j
++)
{
char
tmp
=
str
.
charAt
(
j
);
if
(
j
==
str
.
length
()
-
1
)
{
sb
.
append
(
tmp
);
results
.
add
(
sb
.
toString
());
i
=
j
+
1
;
break
;
}
else
if
(
tmp
==
c
)
{
results
.
add
(
sb
.
toString
());
i
=
j
+
1
;
break
;
}
else
{
sb
.
append
(
tmp
);
}
}
}
return
results
;
}
public
static
final
String
trimAll
(
String
str
)
{
if
(
str
==
null
)
{
return
str
;
}
int
len
=
str
.
length
();
StringBuilder
sb
=
new
StringBuilder
(
len
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
char
ch
=
str
.
charAt
(
i
);
switch
(
ch
)
{
case
' '
:
case
'\t'
:
case
'\r'
:
case
'\n'
:
break
;
default
:
sb
.
append
(
ch
);
}
}
return
sb
.
toString
();
}
}
cat-consumer/src/main/resources/META-INF/dal/model/event-report-model.xml
浏览文件 @
1fea6433
<?xml version="1.0" encoding="UTF-8"?>
<model
model-package=
"com.dianping.cat.consumer.event.model"
enable-merger=
"true"
enable-sax-parser=
"true"
enable-base-visitor=
"true"
enable-native-parser=
"true"
enable-native-builder=
"true"
>
<entity
name=
"event-report"
root=
"true"
>
<attribute
name=
"domain"
key=
"true"
/>
<element
name=
"domain"
value-type=
"String"
type=
"set"
names=
"domain-names"
/>
<element
name=
"ip"
value-type=
"String"
type=
"set"
names=
"ips"
/>
<entity-ref
name=
"machine"
type=
"map"
names=
"machines"
method-find-or-create=
"true"
/>
</entity>
<entity
name=
"machine"
>
<attribute
name=
"ip"
value-type=
"String"
key=
"true"
/>
<entity-ref
name=
"type"
type=
"map"
names=
"types"
method-find-or-create=
"true"
/>
</entity>
<entity
name=
"type"
class-name=
"EventType"
>
<attribute
name=
"id"
key=
"true"
/>
<attribute
name=
"tps"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"totalCount"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"failCount"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"failPercent"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<entity-ref
name=
"name"
type=
"map"
method-find-or-create=
"true"
/>
<entity-ref
name=
"graph-trend"
/>
</entity>
<entity
name=
"name"
class-name=
"EventName"
>
<attribute
name=
"id"
key=
"true"
/>
<attribute
name=
"tps"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"totalCount"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"failCount"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"failPercent"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"totalPercent"
value-type=
"double"
primitive=
"true"
format=
"0.00"
render=
"false"
/>
<entity-ref
name=
"range"
type=
"map"
names=
"ranges"
method-find-or-create=
"true"
/>
<entity-ref
name=
"graph-trend"
/>
</entity>
<entity
name=
"range"
>
<attribute
name=
"value"
value-type=
"int"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"fails"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
</entity>
<entity
name=
"graph-trend"
>
<attribute
name=
"duration"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"String"
primitive=
"true"
/>
<attribute
name=
"fails"
value-type=
"String"
primitive=
"true"
/>
</entity>
<model
model-package=
"com.dianping.cat.consumer.event.model"
enable-merger=
"true"
enable-sax-parser=
"true"
enable-base-visitor=
"true"
enable-native-parser=
"true"
enable-native-builder=
"true"
>
<entity
name=
"event-report"
root=
"true"
>
<attribute
name=
"domain"
key=
"true"
/>
<element
name=
"domain"
value-type=
"String"
type=
"set"
names=
"domain-names"
/>
<element
name=
"ip"
value-type=
"String"
type=
"set"
names=
"ips"
/>
<entity-ref
name=
"machine"
type=
"map"
names=
"machines"
method-find-or-create=
"true"
thread-safe=
"true"
/>
</entity>
<entity
name=
"machine"
>
<attribute
name=
"ip"
value-type=
"String"
key=
"true"
/>
<entity-ref
name=
"type"
type=
"map"
names=
"types"
method-find-or-create=
"true"
thread-safe=
"true"
/>
</entity>
<entity
name=
"type"
class-name=
"EventType"
>
<attribute
name=
"id"
key=
"true"
/>
<attribute
name=
"tps"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"totalCount"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"failCount"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"failPercent"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<entity-ref
name=
"name"
type=
"map"
method-find-or-create=
"true"
thread-safe=
"true"
/>
<entity-ref
name=
"graph-trend"
/>
</entity>
<entity
name=
"name"
class-name=
"EventName"
>
<attribute
name=
"id"
key=
"true"
/>
<attribute
name=
"tps"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"totalCount"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"failCount"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"failPercent"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"totalPercent"
value-type=
"double"
primitive=
"true"
format=
"0.00"
render=
"false"
/>
<entity-ref
name=
"range"
type=
"map"
names=
"ranges"
method-find-or-create=
"true"
thread-safe=
"true"
/>
<entity-ref
name=
"graph-trend"
/>
<entity-ref
name=
"statusCode"
type=
"map"
names=
"statusCodes"
method-find-or-create=
"true"
thread-safe=
"true"
/>
</entity>
<entity
name=
"range"
>
<attribute
name=
"value"
value-type=
"int"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"fails"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
</entity>
<entity
name=
"graph-trend"
>
<attribute
name=
"duration"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"String"
primitive=
"true"
default-value=
""
/>
<attribute
name=
"fails"
value-type=
"String"
primitive=
"true"
default-value=
""
/>
</entity>
<entity
name=
"statusCode"
>
<attribute
name=
"id"
value-type=
"String"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
</entity>
</model>
cat-consumer/src/main/resources/META-INF/dal/model/transaction-report-model.xml
浏览文件 @
1fea6433
<?xml version="1.0" encoding="UTF-8"?>
<model
model-package=
"com.dianping.cat.consumer.transaction.model"
enable-merger=
"true"
enable-sax-parser=
"true"
enable-base-visitor=
"true"
enable-native-parser=
"true"
enable-native-builder=
"true"
>
<entity
name=
"transaction-report"
root=
"true"
>
<attribute
name=
"domain"
key=
"true"
/>
<attribute
name=
"startTime"
value-type=
"Date"
format=
"yyyy-MM-dd HH:mm:ss"
/>
<attribute
name=
"endTime"
value-type=
"Date"
format=
"yyyy-MM-dd HH:mm:ss"
/>
<element
name=
"domain"
value-type=
"String"
type=
"set"
names=
"domain-names"
/>
<element
name=
"ip"
value-type=
"String"
type=
"set"
names=
"ips"
/>
<entity-ref
name=
"machine"
type=
"map"
names=
"machines"
method-find-or-create=
"true"
/>
</entity>
<entity
name=
"machine"
>
<attribute
name=
"ip"
value-type=
"String"
key=
"true"
/>
<entity-ref
name=
"type"
type=
"map"
names=
"types"
method-find-or-create=
"true"
/>
</entity>
<entity
name=
"type"
class-name=
"TransactionType"
dynamic-attributes=
"true"
>
<attribute
name=
"id"
key=
"true"
/>
<attribute
name=
"totalCount"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"failCount"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"failPercent"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"tps"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"min"
value-type=
"double"
primitive=
"true"
format=
"0.00"
default-value=
"86400000"
/>
<attribute
name=
"max"
value-type=
"double"
primitive=
"true"
format=
"0.00"
default-value=
"-1"
/>
<attribute
name=
"avg"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"line95Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"line99Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"sum"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"sum2"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"std"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<entity-ref
name=
"name"
type=
"map"
method-find-or-create=
"true"
/>
<entity-ref
name=
"range2"
type=
"map"
names=
"range2s"
method-find-or-create=
"true"
render=
"false"
/>
<entity-ref
name=
"graph2"
type=
"map"
names=
"graph2s"
method-find-or-create=
"true"
/>
<entity-ref
name=
"all-duration"
type=
"map"
names=
"all-durations"
method-find-or-create=
"true"
render=
"false"
/>
<entity-ref
name=
"graph-trend"
/>
<element
name=
"longestMessageUrl"
value-type=
"String"
/>
</entity>
<entity
name=
"name"
class-name=
"TransactionName"
>
<attribute
name=
"id"
key=
"true"
/>
<attribute
name=
"totalCount"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"failCount"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"failPercent"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"totalPercent"
value-type=
"double"
primitive=
"true"
format=
"0.00"
render=
"false"
/>
<attribute
name=
"tps"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"min"
value-type=
"double"
primitive=
"true"
format=
"0.00"
default-value=
"86400000"
/>
<attribute
name=
"max"
value-type=
"double"
primitive=
"true"
format=
"0.00"
default-value=
"-1"
/>
<attribute
name=
"avg"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"line95Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"line99Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"sum"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"sum2"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"std"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<entity-ref
name=
"range"
type=
"map"
names=
"ranges"
method-find-or-create=
"true"
/>
<entity-ref
name=
"graph"
type=
"map"
names=
"graphs"
method-find-or-create=
"true"
/>
<entity-ref
name=
"duration"
type=
"map"
names=
"durations"
method-find-or-create=
"true"
/>
<entity-ref
name=
"all-duration"
type=
"map"
names=
"all-durations"
method-find-or-create=
"true"
render=
"false"
/>
<entity-ref
name=
"graph-trend"
/>
<element
name=
"longestMessageUrl"
value-type=
"String"
/>
</entity>
<entity
name=
"range"
>
<attribute
name=
"value"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"sum"
value-type=
"double"
primitive=
"true"
/>
<attribute
name=
"avg"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"fails"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
<model
model-package=
"com.dianping.cat.consumer.transaction.model"
enable-merger=
"true"
enable-sax-parser=
"true"
enable-base-visitor=
"true"
enable-native-parser=
"true"
enable-native-builder=
"true"
>
<entity
name=
"transaction-report"
root=
"true"
>
<attribute
name=
"domain"
key=
"true"
/>
<attribute
name=
"startTime"
value-type=
"Date"
format=
"yyyy-MM-dd HH:mm:ss"
/>
<attribute
name=
"endTime"
value-type=
"Date"
format=
"yyyy-MM-dd HH:mm:ss"
/>
<element
name=
"domain"
value-type=
"String"
type=
"set"
names=
"domain-names"
/>
<element
name=
"ip"
value-type=
"String"
type=
"set"
names=
"ips"
/>
<entity-ref
name=
"machine"
type=
"map"
names=
"machines"
method-find-or-create=
"true"
thread-safe=
"true"
/>
</entity>
<entity
name=
"machine"
>
<attribute
name=
"ip"
value-type=
"String"
key=
"true"
/>
<entity-ref
name=
"type"
type=
"map"
names=
"types"
method-find-or-create=
"true"
thread-safe=
"true"
/>
</entity>
<entity
name=
"type"
class-name=
"TransactionType"
dynamic-attributes=
"true"
>
<attribute
name=
"id"
key=
"true"
/>
<attribute
name=
"totalCount"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"failCount"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"failPercent"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"tps"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"min"
value-type=
"double"
primitive=
"true"
format=
"0.00"
default-value=
"86400000"
/>
<attribute
name=
"max"
value-type=
"double"
primitive=
"true"
format=
"0.00"
default-value=
"-1"
/>
<attribute
name=
"avg"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"line95Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"line99Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"sum"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"sum2"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"std"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"line999Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"line90Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<entity-ref
name=
"name"
type=
"map"
method-find-or-create=
"true"
thread-safe=
"true"
/>
<entity-ref
name=
"graph2"
type=
"map"
names=
"graph2s"
method-find-or-create=
"true"
thread-safe=
"true"
/>
<entity-ref
name=
"all-duration"
type=
"map"
names=
"all-durations"
method-find-or-create=
"true"
render=
"false"
thread-safe=
"true"
/>
<entity-ref
name=
"graph-trend"
/>
<entity-ref
name=
"range2"
type=
"map"
names=
"range2s"
method-find-or-create=
"true"
thread-safe=
"true"
/>
<attribute
name=
"line50Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"line9999Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<element
name=
"longestMessageUrl"
value-type=
"String"
/>
</entity>
<entity
name=
"name"
class-name=
"TransactionName"
>
<attribute
name=
"id"
key=
"true"
/>
<attribute
name=
"totalCount"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"failCount"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"failPercent"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"totalPercent"
value-type=
"double"
primitive=
"true"
format=
"0.00"
render=
"false"
/>
<attribute
name=
"tps"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"min"
value-type=
"double"
primitive=
"true"
format=
"0.00"
default-value=
"86400000"
/>
<attribute
name=
"max"
value-type=
"double"
primitive=
"true"
format=
"0.00"
default-value=
"-1"
/>
<attribute
name=
"avg"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"line95Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"line99Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"sum"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"sum2"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"std"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"line999Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"line90Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<entity-ref
name=
"range"
type=
"map"
names=
"ranges"
method-find-or-create=
"true"
thread-safe=
"true"
/>
<entity-ref
name=
"graph"
type=
"map"
names=
"graphs"
method-find-or-create=
"true"
thread-safe=
"true"
/>
<entity-ref
name=
"duration"
type=
"map"
names=
"durations"
method-find-or-create=
"true"
thread-safe=
"true"
/>
<entity-ref
name=
"all-duration"
type=
"map"
names=
"all-durations"
method-find-or-create=
"true"
render=
"false"
thread-safe=
"true"
/>
<entity-ref
name=
"graph-trend"
/>
<entity-ref
name=
"statusCode"
type=
"map"
names=
"statusCodes"
method-find-or-create=
"true"
thread-safe=
"true"
/>
<attribute
name=
"line50Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"line9999Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<element
name=
"longestMessageUrl"
value-type=
"String"
/>
</entity>
<entity
name=
"range"
>
<attribute
name=
"value"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"sum"
value-type=
"double"
primitive=
"true"
/>
<attribute
name=
"avg"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"fails"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"min"
value-type=
"double"
primitive=
"true"
format=
"0.00"
default-value=
"86400000"
/>
<attribute
name=
"max"
value-type=
"double"
primitive=
"true"
format=
"0.00"
default-value=
"-1"
/>
<attribute
name=
"line95Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
...
...
@@ -73,13 +84,13 @@
<attribute
name=
"clear-duration"
value-type=
"boolean"
primitive=
"true"
render=
"false"
/>
<attribute
name=
"line50Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"line9999Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
</entity>
<entity
name=
"range2"
>
<attribute
name=
"value"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"sum"
value-type=
"double"
primitive=
"true"
/>
<attribute
name=
"avg"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"fails"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
</entity>
<entity
name=
"range2"
>
<attribute
name=
"value"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"sum"
value-type=
"double"
primitive=
"true"
/>
<attribute
name=
"avg"
value-type=
"double"
primitive=
"true"
format=
"0.0"
/>
<attribute
name=
"fails"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
<attribute
name=
"min"
value-type=
"double"
primitive=
"true"
format=
"0.00"
default-value=
"86400000"
/>
<attribute
name=
"max"
value-type=
"double"
primitive=
"true"
format=
"0.00"
default-value=
"-1"
/>
<attribute
name=
"line95Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
...
...
@@ -91,35 +102,38 @@
<attribute
name=
"clear-duration"
value-type=
"boolean"
primitive=
"true"
render=
"false"
/>
<attribute
name=
"line50Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<attribute
name=
"line9999Value"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
</entity>
<entity
name=
"graph"
>
<attribute
name=
"duration"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"sum"
value-type=
"String"
primitive=
"true"
/>
<attribute
name=
"avg"
value-type=
"String"
primitive=
"true"
/>
<attribute
name=
"count"
value-type=
"String"
primitive=
"true"
/>
<attribute
name=
"fails"
value-type=
"String"
primitive=
"true"
/>
</entity>
<entity
name=
"graph2"
>
<attribute
name=
"duration"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"sum"
value-type=
"String"
primitive=
"true"
/>
<attribute
name=
"avg"
value-type=
"String"
primitive=
"true"
/>
<attribute
name=
"count"
value-type=
"String"
primitive=
"true"
/>
<attribute
name=
"fails"
value-type=
"String"
primitive=
"true"
/>
</entity>
<entity
name=
"graph-trend"
>
<attribute
name=
"duration"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"sum"
value-type=
"String"
primitive=
"true"
/>
<attribute
name=
"avg"
value-type=
"String"
primitive=
"true"
/>
<attribute
name=
"count"
value-type=
"String"
primitive=
"true"
/>
<attribute
name=
"fails"
value-type=
"String"
primitive=
"true"
/>
</entity>
<entity
name=
"duration"
>
<attribute
name=
"value"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
</entity>
<entity
name=
"all-duration"
>
<attribute
name=
"value"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
</entity>
</model>
</entity>
<entity
name=
"graph"
>
<attribute
name=
"duration"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"sum"
value-type=
"String"
primitive=
"true"
default-value=
""
/>
<attribute
name=
"avg"
value-type=
"String"
primitive=
"true"
default-value=
""
/>
<attribute
name=
"count"
value-type=
"String"
primitive=
"true"
default-value=
""
/>
<attribute
name=
"fails"
value-type=
"String"
primitive=
"true"
default-value=
""
/>
</entity>
<entity
name=
"graph2"
>
<attribute
name=
"duration"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"sum"
value-type=
"String"
primitive=
"true"
default-value=
""
/>
<attribute
name=
"avg"
value-type=
"String"
primitive=
"true"
default-value=
""
/>
<attribute
name=
"count"
value-type=
"String"
primitive=
"true"
default-value=
""
/>
<attribute
name=
"fails"
value-type=
"String"
primitive=
"true"
default-value=
""
/>
</entity>
<entity
name=
"graph-trend"
>
<attribute
name=
"duration"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"sum"
value-type=
"String"
primitive=
"true"
default-value=
""
/>
<attribute
name=
"avg"
value-type=
"String"
primitive=
"true"
default-value=
""
/>
<attribute
name=
"count"
value-type=
"String"
primitive=
"true"
default-value=
""
/>
<attribute
name=
"fails"
value-type=
"String"
primitive=
"true"
default-value=
""
/>
</entity>
<entity
name=
"duration"
>
<attribute
name=
"value"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
</entity>
<entity
name=
"all-duration"
>
<attribute
name=
"value"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"int"
primitive=
"true"
method-inc=
"true"
/>
</entity>
<entity
name=
"statusCode"
>
<attribute
name=
"id"
value-type=
"String"
key=
"true"
/>
<attribute
name=
"count"
value-type=
"long"
primitive=
"true"
method-inc=
"true"
/>
</entity>
</model>
\ No newline at end of file
cat-consumer/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
1fea6433
...
...
@@ -14,10 +14,10 @@
<role>
com.dianping.cat.config.server.ServerFilterConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.
AtomicMessage
ConfigManager
</role>
<role>
com.dianping.cat.config.
transaction.TpValueStatistic
ConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.
transaction.TpValueStatistic
ConfigManager
</role>
<role>
com.dianping.cat.config.
AtomicMessage
ConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.server.ServerConfigManager
</role>
...
...
@@ -38,6 +38,12 @@
<requirement>
<role>
com.dianping.cat.consumer.config.AllReportConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.server.ServerConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.AtomicMessageConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
...
...
@@ -78,7 +84,7 @@
<role-hint>
event
</role-hint>
</requirement>
<requirement>
<role>
com.dianping.cat.config.
server.ServerFilter
ConfigManager
</role>
<role>
com.dianping.cat.config.
AtomicMessage
ConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.server.ServerConfigManager
</role>
...
...
@@ -99,6 +105,12 @@
<requirement>
<role>
com.dianping.cat.consumer.config.AllReportConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.server.ServerConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.AtomicMessageConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
...
...
@@ -775,6 +787,18 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.config.server.ServerConfigManager
</role>
<implementation>
com.dianping.cat.config.server.ServerConfigManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.core.config.ConfigDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.content.ContentFetcher
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.config.transaction.TpValueStatisticConfigManager
</role>
<implementation>
com.dianping.cat.config.transaction.TpValueStatisticConfigManager
</implementation>
...
...
cat-consumer/src/test/java/com/dianping/cat/consumer/AllTests.java
浏览文件 @
1fea6433
...
...
@@ -27,7 +27,6 @@ import com.dianping.cat.consumer.state.StateReportMergerTest;
import
com.dianping.cat.consumer.top.TopAnalyzerTest
;
import
com.dianping.cat.consumer.top.TopReportMergerTest
;
import
com.dianping.cat.consumer.transaction.TransactionAnalyzerTest
;
import
com.dianping.cat.consumer.transaction.TransactionReportFilterTest
;
import
com.dianping.cat.consumer.transaction.TransactionReportMergerTest
;
import
com.dianping.cat.consumer.transaction.TransactionReportTest
;
import
com.dianping.cat.consumer.transaction.TransactionReportTypeAggergatorTest
;
...
...
@@ -43,8 +42,6 @@ TransactionAnalyzerTest.class,
TransactionReportTest
.
class
,
TransactionReportFilterTest
.
class
,
TransactionReportMergerTest
.
class
,
/* event */
...
...
cat-consumer/src/test/java/com/dianping/cat/consumer/transaction/TransactionReportFilterTest.java
已删除
100644 → 0
浏览文件 @
1e29a466
package
com.dianping.cat.consumer.transaction
;
import
junit.framework.Assert
;
import
org.junit.Test
;
import
org.unidal.helper.Files
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionName
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionType
;
import
com.dianping.cat.consumer.transaction.model.transform.DefaultSaxParser
;
public
class
TransactionReportFilterTest
{
private
final
int
MAX_URL_NUM
=
401
;
@Test
public
void
whether_url_has_max_names
()
throws
Exception
{
String
source
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"transaction_report_filter.xml"
),
"utf-8"
);
TransactionReport
report
=
DefaultSaxParser
.
parse
(
source
);
TransactionType
type
=
report
.
findMachine
(
"10.1.77.193"
).
findType
(
"URL"
);
for
(
int
i
=
0
;
i
<
3500
;
i
++)
{
type
.
addName
(
new
TransactionName
(
"Test"
+
i
));
}
TransactionReportCountFilter
f1
=
new
TransactionReportCountFilter
();
f1
.
visitTransactionReport
(
report
);
String
filterReport
=
report
.
toString
();
TransactionReport
newReport
=
DefaultSaxParser
.
parse
(
filterReport
);
int
newSize
=
newReport
.
findMachine
(
"10.1.77.193"
).
findType
(
"URL"
).
getNames
().
size
();
Assert
.
assertEquals
(
MAX_URL_NUM
,
newSize
);
}
}
cat-core/src/main/java/com/dianping/cat/config/server/ServerConfigManager.java
浏览文件 @
1fea6433
...
...
@@ -329,6 +329,18 @@ public class ServerConfigManager implements LogEnabled, Initializable {
return
defaultValue
;
}
public
int
getMaxTypeThreshold
()
{
return
Integer
.
parseInt
(
getProperty
(
"max-type-threshold"
,
"100"
));
}
public
int
getTypeNameLengthLimit
()
{
return
Integer
.
parseInt
(
getProperty
(
"type-name-length-limit"
,
"256"
));
}
public
int
getTpValueExpireMinute
()
{
return
Integer
.
parseInt
(
getProperty
(
"tp-value-expire-minute"
,
"1"
));
}
public
ServerConfig
getServerConfig
()
{
return
m_config
;
}
...
...
cat-home/src/main/java/com/dianping/cat/report/page/event/task/EventReportBuilder.java
浏览文件 @
1fea6433
...
...
@@ -9,6 +9,8 @@ import org.unidal.lookup.annotation.Inject;
import
org.unidal.lookup.annotation.Named
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.config.AtomicMessageConfigManager
;
import
com.dianping.cat.config.server.ServerConfigManager
;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
import
com.dianping.cat.consumer.event.EventAnalyzer
;
import
com.dianping.cat.consumer.event.EventReportCountFilter
;
...
...
@@ -32,6 +34,12 @@ public class EventReportBuilder implements TaskBuilder, Initializable {
@Inject
protected
EventReportService
m_reportService
;
@Inject
protected
ServerConfigManager
m_serverConfigManager
;
@Inject
private
AtomicMessageConfigManager
m_atomicMessageConfigManager
;
@Override
public
boolean
buildDailyTask
(
String
name
,
String
domain
,
Date
period
)
{
try
{
...
...
@@ -137,8 +145,8 @@ public class EventReportBuilder implements TaskBuilder, Initializable {
for
(;
startTime
<
endTime
;
startTime
+=
TimeHelper
.
ONE_DAY
)
{
try
{
EventReport
reportModel
=
m_reportService
.
queryReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeHelper
.
ONE_DAY
));
EventReport
reportModel
=
m_reportService
.
queryReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeHelper
.
ONE_DAY
));
creator
.
createGraph
(
reportModel
);
reportModel
.
accept
(
merger
);
...
...
@@ -150,12 +158,14 @@ public class EventReportBuilder implements TaskBuilder, Initializable {
eventReport
.
setStartTime
(
start
);
eventReport
.
setEndTime
(
end
);
new
EventReportCountFilter
().
visitEventReport
(
eventReport
);
new
EventReportCountFilter
(
m_serverConfigManager
.
getMaxTypeThreshold
(),
m_atomicMessageConfigManager
.
getMaxNameThreshold
(
domain
),
m_serverConfigManager
.
getTypeNameLengthLimit
())
.
visitEventReport
(
eventReport
);
return
eventReport
;
}
private
EventReport
queryHourlyReportsByDuration
(
String
name
,
String
domain
,
Date
start
,
Date
endDate
)
throws
DalException
{
throws
DalException
{
long
startTime
=
start
.
getTime
();
long
endTime
=
endDate
.
getTime
();
double
duration
=
(
endTime
-
startTime
)
*
1.0
/
TimeHelper
.
ONE_DAY
;
...
...
@@ -164,8 +174,8 @@ public class EventReportBuilder implements TaskBuilder, Initializable {
EventReportHourlyGraphCreator
graphCreator
=
new
EventReportHourlyGraphCreator
(
merger
.
getEventReport
(),
10
);
for
(;
startTime
<
endTime
;
startTime
=
startTime
+
TimeHelper
.
ONE_HOUR
)
{
EventReport
report
=
m_reportService
.
queryReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeHelper
.
ONE_HOUR
));
EventReport
report
=
m_reportService
.
queryReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeHelper
.
ONE_HOUR
));
graphCreator
.
createGraph
(
report
);
report
.
accept
(
merger
);
...
...
@@ -178,7 +188,9 @@ public class EventReportBuilder implements TaskBuilder, Initializable {
dailyReport
.
setStartTime
(
TaskHelper
.
todayZero
(
date
));
dailyReport
.
setEndTime
(
end
);
new
EventReportCountFilter
().
visitEventReport
(
dailyReport
);
new
EventReportCountFilter
(
m_serverConfigManager
.
getMaxTypeThreshold
(),
m_atomicMessageConfigManager
.
getMaxNameThreshold
(
domain
),
m_serverConfigManager
.
getTypeNameLengthLimit
())
.
visitEventReport
(
dailyReport
);
return
dailyReport
;
}
...
...
cat-home/src/main/java/com/dianping/cat/report/page/logview/util/JdbcRefParser.java
已删除
100644 → 0
浏览文件 @
1e29a466
package
com.dianping.cat.report.page.logview.util
;
import
java.util.List
;
import
com.dianping.cat.message.Event
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.internal.DefaultEvent
;
import
com.dianping.cat.message.internal.DefaultTransaction
;
import
com.dianping.cat.message.spi.MessageTree
;
public
class
JdbcRefParser
{
public
static
void
hideJdbcRef
(
MessageTree
tree
)
{
List
<
Event
>
events
=
tree
.
getEvents
();
if
(
events
!=
null
&&
events
.
size
()
>
0
)
{
for
(
Event
event
:
events
)
{
final
String
type
=
event
.
getType
();
if
(
type
.
equals
(
"SQL.Database"
))
{
((
DefaultEvent
)
(
event
)).
setData
(
""
);
}
}
}
List
<
Transaction
>
transactions
=
tree
.
getTransactions
();
if
(
transactions
!=
null
&&
transactions
.
size
()
>
0
)
{
for
(
Transaction
t
:
transactions
)
{
final
String
type
=
t
.
getType
();
if
(
"SQL.Conn"
.
equals
(
type
))
{
((
DefaultTransaction
)
(
t
)).
setName
(
"${SQL.Conn}"
);
}
}
}
}
}
cat-home/src/main/java/com/dianping/cat/report/page/transaction/task/TransactionReportBuilder.java
浏览文件 @
1fea6433
...
...
@@ -11,6 +11,8 @@ import org.unidal.lookup.annotation.Inject;
import
org.unidal.lookup.annotation.Named
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.config.AtomicMessageConfigManager
;
import
com.dianping.cat.config.server.ServerConfigManager
;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
import
com.dianping.cat.consumer.transaction.TransactionAnalyzer
;
import
com.dianping.cat.consumer.transaction.TransactionReportCountFilter
;
...
...
@@ -34,6 +36,12 @@ public class TransactionReportBuilder implements Initializable, TaskBuilder, Log
@Inject
protected
TransactionReportService
m_reportService
;
@Inject
protected
ServerConfigManager
m_serverConfigManager
;
@Inject
private
AtomicMessageConfigManager
m_atomicMessageConfigManager
;
private
Logger
m_logger
;
@Override
...
...
@@ -130,9 +138,9 @@ public class TransactionReportBuilder implements Initializable, TaskBuilder, Log
}
@Override
public
String
getReportName
()
{
public
String
getReportName
()
{
return
ID
;
}
}
});
}
...
...
@@ -140,18 +148,18 @@ public class TransactionReportBuilder implements Initializable, TaskBuilder, Log
long
startTime
=
start
.
getTime
();
long
endTime
=
end
.
getTime
();
double
duration
=
(
end
.
getTime
()
-
start
.
getTime
())
*
1.0
/
TimeHelper
.
ONE_DAY
;
HistoryTransactionReportMerger
merger
=
new
HistoryTransactionReportMerger
(
new
TransactionReport
(
domain
))
.
setDuration
(
duration
);
.
setDuration
(
duration
);
TransactionReport
transactionReport
=
merger
.
getTransactionReport
();
TransactionReportDailyGraphCreator
creator
=
new
TransactionReportDailyGraphCreator
(
transactionReport
,
(
int
)
duration
,
start
);
TransactionReportDailyGraphCreator
creator
=
new
TransactionReportDailyGraphCreator
(
transactionReport
,
(
int
)
duration
,
start
);
for
(;
startTime
<
endTime
;
startTime
+=
TimeHelper
.
ONE_DAY
)
{
try
{
TransactionReport
reportModel
=
m_reportService
.
queryReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeHelper
.
ONE_DAY
));
TransactionReport
reportModel
=
m_reportService
.
queryReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeHelper
.
ONE_DAY
));
creator
.
createGraph
(
reportModel
);
reportModel
.
accept
(
merger
);
...
...
@@ -163,24 +171,26 @@ public class TransactionReportBuilder implements Initializable, TaskBuilder, Log
transactionReport
.
setStartTime
(
start
);
transactionReport
.
setEndTime
(
end
);
new
TransactionReportCountFilter
().
visitTransactionReport
(
transactionReport
);
new
TransactionReportCountFilter
(
m_serverConfigManager
.
getMaxTypeThreshold
(),
m_atomicMessageConfigManager
.
getMaxNameThreshold
(
domain
),
m_serverConfigManager
.
getTypeNameLengthLimit
())
.
visitTransactionReport
(
transactionReport
);
return
transactionReport
;
}
private
TransactionReport
queryHourlyReportsByDuration
(
String
name
,
String
domain
,
Date
start
,
Date
endDate
)
throws
DalException
{
throws
DalException
{
long
startTime
=
start
.
getTime
();
long
endTime
=
endDate
.
getTime
();
double
duration
=
(
endTime
-
startTime
)
*
1.0
/
TimeHelper
.
ONE_DAY
;
HistoryTransactionReportMerger
dailyMerger
=
new
HistoryTransactionReportMerger
(
new
TransactionReport
(
domain
))
.
setDuration
(
duration
);
.
setDuration
(
duration
);
TransactionReportHourlyGraphCreator
graphCreator
=
new
TransactionReportHourlyGraphCreator
(
dailyMerger
.
getTransactionReport
(),
10
);
dailyMerger
.
getTransactionReport
(),
10
);
for
(;
startTime
<
endTime
;
startTime
=
startTime
+
TimeHelper
.
ONE_HOUR
)
{
TransactionReport
report
=
m_reportService
.
queryReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeHelper
.
ONE_HOUR
));
TransactionReport
report
=
m_reportService
.
queryReport
(
domain
,
new
Date
(
startTime
),
new
Date
(
startTime
+
TimeHelper
.
ONE_HOUR
));
graphCreator
.
createGraph
(
report
);
report
.
accept
(
dailyMerger
);
...
...
@@ -193,9 +203,11 @@ public class TransactionReportBuilder implements Initializable, TaskBuilder, Log
dailyreport
.
setStartTime
(
TaskHelper
.
todayZero
(
date
));
dailyreport
.
setEndTime
(
end
);
new
TransactionReportCountFilter
().
visitTransactionReport
(
dailyreport
);
new
TransactionReportCountFilter
(
m_serverConfigManager
.
getMaxTypeThreshold
(),
m_atomicMessageConfigManager
.
getMaxNameThreshold
(
domain
),
m_serverConfigManager
.
getTypeNameLengthLimit
())
.
visitTransactionReport
(
dailyreport
);
return
dailyreport
;
}
}
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
1fea6433
...
...
@@ -507,6 +507,12 @@
<requirement>
<role>
com.dianping.cat.report.page.transaction.service.TransactionReportService
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.server.ServerConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.AtomicMessageConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
...
...
@@ -654,6 +660,12 @@
<requirement>
<role>
com.dianping.cat.report.page.event.service.EventReportService
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.server.ServerConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.config.AtomicMessageConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录