Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
ba16593f
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,发现更多精彩内容 >>
提交
ba16593f
编写于
6月 04, 2013
作者:
S
sunryuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add feature that report can aggretate based on rules
上级
bf4deae7
变更
37
展开全部
隐藏空白更改
内联
并排
Showing
37 changed file
with
29484 addition
and
104 deletion
+29484
-104
cat-consumer/src/main/java/com/dianping/cat/consumer/CatConsumerModule.java
...ain/java/com/dianping/cat/consumer/CatConsumerModule.java
+2
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/build/CatCoreDatabaseConfigurator.java
...nping/cat/consumer/build/CatCoreDatabaseConfigurator.java
+1
-1
cat-consumer/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
...m/dianping/cat/consumer/build/ComponentsConfigurator.java
+15
-1
cat-consumer/src/main/java/com/dianping/cat/consumer/core/ProblemAnalyzer.java
.../java/com/dianping/cat/consumer/core/ProblemAnalyzer.java
+12
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/core/aggregation/AggregationHandler.java
...ing/cat/consumer/core/aggregation/AggregationHandler.java
+25
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/core/aggregation/AggregationManager.java
...ing/cat/consumer/core/aggregation/AggregationManager.java
+134
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/core/aggregation/AggregationMessageFormat.java
...t/consumer/core/aggregation/AggregationMessageFormat.java
+52
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/core/aggregation/CompositeFormat.java
...anping/cat/consumer/core/aggregation/CompositeFormat.java
+42
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/core/aggregation/DefaultAggregationHandler.java
.../consumer/core/aggregation/DefaultAggregationHandler.java
+186
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/core/aggregation/DefaultFormat.java
...dianping/cat/consumer/core/aggregation/DefaultFormat.java
+50
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/core/aggregation/Format.java
...va/com/dianping/cat/consumer/core/aggregation/Format.java
+21
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/core/aggregation/TrieTreeNode.java
.../dianping/cat/consumer/core/aggregation/TrieTreeNode.java
+97
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/core/problem/ProblemReportAggregation.java
...g/cat/consumer/core/problem/ProblemReportAggregation.java
+112
-0
cat-consumer/src/main/resources/META-INF/dal/jdbc/report-codegen.xml
...r/src/main/resources/META-INF/dal/jdbc/report-codegen.xml
+42
-0
cat-consumer/src/main/resources/META-INF/dal/jdbc/report-dal.xml
...sumer/src/main/resources/META-INF/dal/jdbc/report-dal.xml
+13
-0
cat-consumer/src/main/resources/META-INF/plexus/components.xml
...onsumer/src/main/resources/META-INF/plexus/components.xml
+52
-2
cat-consumer/src/main/resources/META-INF/wizard/jdbc/wizard.xml
...nsumer/src/main/resources/META-INF/wizard/jdbc/wizard.xml
+1
-0
cat-consumer/src/test/java/com/dianping/cat/consumer/core/ProblemReportAggregationTest.java
...nping/cat/consumer/core/ProblemReportAggregationTest.java
+140
-0
cat-consumer/src/test/java/com/dianping/cat/consumer/core/aggregation/CompositeFormatTest.java
...ng/cat/consumer/core/aggregation/CompositeFormatTest.java
+26
-0
cat-consumer/src/test/java/com/dianping/cat/consumer/core/aggregation/DefaultFormatTest.java
...ping/cat/consumer/core/aggregation/DefaultFormatTest.java
+33
-0
cat-consumer/src/test/resources/com/dianping/cat/consumer/core/problem-report-after-aggregation.xml
...ng/cat/consumer/core/problem-report-after-aggregation.xml
+9333
-0
cat-consumer/src/test/resources/com/dianping/cat/consumer/core/problem-report-before-aggregation.xml
...g/cat/consumer/core/problem-report-before-aggregation.xml
+18944
-0
cat-core/src/main/resources/com/dianping/cat/configuration/client/config.xsd
...esources/com/dianping/cat/configuration/client/config.xsd
+2
-1
cat-core/src/main/resources/com/dianping/cat/status/model/status.xsd
...c/main/resources/com/dianping/cat/status/model/status.xsd
+2
-1
cat-home/src/main/java/com/dianping/cat/CatHomeModule.java
cat-home/src/main/java/com/dianping/cat/CatHomeModule.java
+2
-0
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
...n/java/com/dianping/cat/build/ComponentsConfigurator.java
+1
-2
cat-home/src/main/java/com/dianping/cat/report/page/jsError/Handler.java
...in/java/com/dianping/cat/report/page/jsError/Handler.java
+1
-0
cat-home/src/main/java/com/dianping/cat/report/page/model/problem/ProblemReportMergerManager.java
...report/page/model/problem/ProblemReportMergerManager.java
+13
-0
cat-home/src/main/java/com/dianping/cat/report/page/model/problem/ProblemReportMergerWithAggregation.java
...age/model/problem/ProblemReportMergerWithAggregation.java
+64
-0
cat-home/src/main/java/com/dianping/cat/report/page/problem/Handler.java
...in/java/com/dianping/cat/report/page/problem/Handler.java
+21
-2
cat-home/src/main/java/com/dianping/cat/system/SystemModule.java
...e/src/main/java/com/dianping/cat/system/SystemModule.java
+1
-1
cat-home/src/main/java/com/dianping/cat/system/page/aggregation/Handler.java
...ava/com/dianping/cat/system/page/aggregation/Handler.java
+4
-3
cat-home/src/main/java/com/dianping/cat/system/page/aggregation/Model.java
.../java/com/dianping/cat/system/page/aggregation/Model.java
+1
-1
cat-home/src/main/resources/META-INF/dal/jdbc/report-codegen.xml
...e/src/main/resources/META-INF/dal/jdbc/report-codegen.xml
+0
-41
cat-home/src/main/resources/META-INF/dal/jdbc/report-dal.xml
cat-home/src/main/resources/META-INF/dal/jdbc/report-dal.xml
+1
-14
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+38
-33
cat-home/src/main/resources/META-INF/wizard/jdbc/wizard.xml
cat-home/src/main/resources/META-INF/wizard/jdbc/wizard.xml
+0
-1
未找到文件。
cat-consumer/src/main/java/com/dianping/cat/consumer/CatConsumerModule.java
浏览文件 @
ba16593f
...
...
@@ -6,6 +6,7 @@ import org.unidal.initialization.ModuleContext;
import
com.dianping.cat.CatCoreModule
;
import
com.dianping.cat.configuration.ServerConfigManager
;
import
com.dianping.cat.consumer.core.aggregation.AggregationManager
;
import
com.dianping.cat.message.io.TcpSocketReceiver
;
public
class
CatConsumerModule
extends
AbstractModule
{
...
...
@@ -15,6 +16,7 @@ public class CatConsumerModule extends AbstractModule {
protected
void
execute
(
ModuleContext
ctx
)
{
TcpSocketReceiver
receiver
=
ctx
.
lookup
(
TcpSocketReceiver
.
class
);
ServerConfigManager
manager
=
ctx
.
lookup
(
ServerConfigManager
.
class
);
ctx
.
lookup
(
AggregationManager
.
class
);
int
encodeThreadNumber
=
10
;
if
(
manager
.
isLocalMode
())
{
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/build/CatCoreDatabaseConfigurator.java
浏览文件 @
ba16593f
...
...
@@ -11,7 +11,7 @@ final class CatCoreDatabaseConfigurator extends AbstractJdbcResourceConfigurator
public
List
<
Component
>
defineComponents
()
{
List
<
Component
>
all
=
new
ArrayList
<
Component
>();
all
.
add
(
defineJdbcDataSourceComponent
(
"cat"
,
"com.mysql.jdbc.Driver"
,
"jdbc:mysql://1
92.168.7.43:3306/cat"
,
"dpcom_ca
t"
,
"password"
,
"<![CDATA[useUnicode=true&autoReconnect=true]]>"
));
all
.
add
(
defineJdbcDataSourceComponent
(
"cat"
,
"com.mysql.jdbc.Driver"
,
"jdbc:mysql://1
27.0.0.1:3306/cat"
,
"roo
t"
,
"password"
,
"<![CDATA[useUnicode=true&autoReconnect=true]]>"
));
defineSimpleTableProviderComponents
(
all
,
"cat"
,
com
.
dainping
.
cat
.
consumer
.
core
.
dal
.
_INDEX
.
getEntityClasses
());
defineDaoComponents
(
all
,
com
.
dainping
.
cat
.
consumer
.
core
.
dal
.
_INDEX
.
getDaoClasses
());
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
浏览文件 @
ba16593f
...
...
@@ -8,6 +8,7 @@ import org.unidal.initialization.Module;
import
org.unidal.lookup.configuration.AbstractResourceConfigurator
;
import
org.unidal.lookup.configuration.Component
;
import
com.dainping.cat.consumer.core.dal.AggregationRuleDao
;
import
com.dainping.cat.consumer.core.dal.HostinfoDao
;
import
com.dainping.cat.consumer.core.dal.ProjectDao
;
import
com.dainping.cat.consumer.core.dal.ReportDao
;
...
...
@@ -25,9 +26,13 @@ import com.dianping.cat.consumer.core.ProblemAnalyzer;
import
com.dianping.cat.consumer.core.StateAnalyzer
;
import
com.dianping.cat.consumer.core.TopAnalyzer
;
import
com.dianping.cat.consumer.core.TransactionAnalyzer
;
import
com.dianping.cat.consumer.core.aggregation.AggregationHandler
;
import
com.dianping.cat.consumer.core.aggregation.AggregationManager
;
import
com.dianping.cat.consumer.core.aggregation.DefaultAggregationHandler
;
import
com.dianping.cat.consumer.core.problem.DefaultProblemHandler
;
import
com.dianping.cat.consumer.core.problem.LongExecutionProblemHandler
;
import
com.dianping.cat.consumer.core.problem.ProblemHandler
;
import
com.dianping.cat.consumer.core.problem.ProblemReportAggregation
;
import
com.dianping.cat.message.spi.MessageConsumer
;
import
com.dianping.cat.status.ServerStateManager
;
import
com.dianping.cat.storage.BucketManager
;
...
...
@@ -39,6 +44,13 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
public
List
<
Component
>
defineComponents
()
{
List
<
Component
>
all
=
new
ArrayList
<
Component
>();
all
.
add
(
C
(
AggregationHandler
.
class
,
DefaultAggregationHandler
.
class
));
all
.
add
(
C
(
AggregationManager
.
class
).
req
(
AggregationRuleDao
.
class
,
ServerConfigManager
.
class
,
AggregationHandler
.
class
));
all
.
add
(
C
(
ProblemReportAggregation
.
class
).
req
(
AggregationManager
.
class
));
all
.
add
(
C
(
MessageAnalyzerManager
.
class
,
DefaultMessageAnalyzerManager
.
class
));
all
.
add
(
C
(
MessageConsumer
.
class
,
RealtimeConsumer
.
ID
,
RealtimeConsumer
.
class
)
//
...
...
@@ -52,7 +64,7 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
.
req
(
ServerConfigManager
.
class
));
all
.
add
(
C
(
MessageAnalyzer
.
class
,
ProblemAnalyzer
.
ID
,
ProblemAnalyzer
.
class
).
is
(
PER_LOOKUP
)
//
.
req
(
BucketManager
.
class
,
ReportDao
.
class
,
TaskDao
.
class
)
//
.
req
(
BucketManager
.
class
,
ReportDao
.
class
,
TaskDao
.
class
,
ProblemReportAggregation
.
class
)
//
.
req
(
ProblemHandler
.
class
,
new
String
[]
{
DefaultProblemHandler
.
ID
,
LongExecutionProblemHandler
.
ID
},
"m_handlers"
));
all
.
add
(
C
(
MessageAnalyzer
.
class
,
TransactionAnalyzer
.
ID
,
TransactionAnalyzer
.
class
).
is
(
PER_LOOKUP
)
//
...
...
@@ -77,6 +89,8 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
Module
.
class
,
CatConsumerModule
.
ID
,
CatConsumerModule
.
class
));
// database
all
.
add
(
C
(
JdbcDataSourceConfigurationManager
.
class
)
//
.
config
(
E
(
"datasourceFile"
).
value
(
"/data/appdatas/cat/datasources.xml"
)));
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/core/ProblemAnalyzer.java
浏览文件 @
ba16593f
...
...
@@ -21,6 +21,7 @@ import com.dianping.cat.Cat;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
import
com.dianping.cat.consumer.AbstractMessageAnalyzer
;
import
com.dianping.cat.consumer.core.problem.ProblemHandler
;
import
com.dianping.cat.consumer.core.problem.ProblemReportAggregation
;
import
com.dianping.cat.consumer.problem.model.entity.Duration
;
import
com.dianping.cat.consumer.problem.model.entity.Entry
;
import
com.dianping.cat.consumer.problem.model.entity.Machine
;
...
...
@@ -48,6 +49,11 @@ public class ProblemAnalyzer extends AbstractMessageAnalyzer<ProblemReport> impl
@Inject
private
List
<
ProblemHandler
>
m_handlers
;
@Inject
private
ProblemReportAggregation
m_problemReportAggregation
;
private
static
final
String
FRONT_END
=
"FrontEnd"
;
private
Map
<
String
,
ProblemReport
>
m_reports
=
new
HashMap
<
String
,
ProblemReport
>();
...
...
@@ -173,6 +179,12 @@ public class ProblemAnalyzer extends AbstractMessageAnalyzer<ProblemReport> impl
if
(
atEnd
&&
!
isLocalMode
())
{
Date
period
=
new
Date
(
m_startTime
);
String
ip
=
NetworkInterfaceManager
.
INSTANCE
.
getLocalHostAddress
();
for
(
String
domain
:
m_reports
.
keySet
())
{
if
(
domain
.
equals
(
FRONT_END
)){
m_reports
.
get
(
domain
).
accept
(
m_problemReportAggregation
);
m_reports
.
put
(
domain
,
m_problemReportAggregation
.
getReport
());
}
}
ProblemReport
all
=
buildTotalProblemReport
();
m_reports
.
put
(
ALL
,
all
);
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/core/aggregation/AggregationHandler.java
0 → 100644
浏览文件 @
ba16593f
package
com.dianping.cat.consumer.core.aggregation
;
import
java.util.List
;
import
java.util.Map
;
import
com.dainping.cat.consumer.core.dal.AggregationRule
;
public
interface
AggregationHandler
{
/**
* register aggregation rule to handler
* @param formats page type and domain to rule List Map
*/
public
void
register
(
Map
<
Integer
,
Map
<
String
,
List
<
AggregationRule
>>>
formats
);
/**
* parse input to output use aggregation rule
* @param type page type, like transaction,problem。。
* @param domain
* @param input
* @return string after parse
*/
public
String
handle
(
int
type
,
String
domain
,
String
input
);
}
cat-consumer/src/main/java/com/dianping/cat/consumer/core/aggregation/AggregationManager.java
0 → 100644
浏览文件 @
ba16593f
package
com.dianping.cat.consumer.core.aggregation
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
org.unidal.dal.jdbc.DalException
;
import
org.unidal.helper.Threads
;
import
org.unidal.helper.Threads.Task
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dainping.cat.consumer.core.dal.AggregationRule
;
import
com.dainping.cat.consumer.core.dal.AggregationRuleDao
;
import
com.dainping.cat.consumer.core.dal.AggregationRuleEntity
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.configuration.ServerConfigManager
;
public
class
AggregationManager
implements
Initializable
{
@Inject
private
AggregationRuleDao
m_ruleDao
;
@Inject
private
ServerConfigManager
m_serverConfigManager
;
@Inject
protected
AggregationHandler
m_handler
;
private
static
Map
<
Integer
,
Map
<
String
,
List
<
AggregationRule
>>>
m_ruleMap
=
new
HashMap
<
Integer
,
Map
<
String
,
List
<
AggregationRule
>>>();
public
static
final
int
ONE_MINUTE
=
60
*
1000
;
public
static
final
int
TRANSACTION_TYPE
=
1
;
public
static
final
int
EVENT_TYPE
=
2
;
public
static
final
int
PROBLEM_TYPE
=
3
;
@Override
public
void
initialize
()
throws
InitializationException
{
if
(!
m_serverConfigManager
.
isLocalMode
())
{
try
{
RuleReload
reload
=
new
RuleReload
();
Threads
.
forGroup
(
"Cat"
).
start
(
reload
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
}
/**
* Reload aggregation rule from database
*/
public
void
reload
()
{
synchronized
(
m_ruleMap
)
{
try
{
List
<
AggregationRule
>
ruleList
=
m_ruleDao
.
findAll
(
AggregationRuleEntity
.
READSET_FULL
);
if
(
ruleList
.
size
()
>
0
)
{
Map
<
Integer
,
Map
<
String
,
List
<
AggregationRule
>>>
tmpRuleMap
=
new
HashMap
<
Integer
,
Map
<
String
,
List
<
AggregationRule
>>>();
for
(
AggregationRule
rule
:
ruleList
)
{
int
type
=
rule
.
getType
();
String
domain
=
rule
.
getDomain
();
Map
<
String
,
List
<
AggregationRule
>>
typeRuleMap
=
null
;
List
<
AggregationRule
>
domainRules
=
null
;
if
(
tmpRuleMap
.
containsKey
(
type
))
{
typeRuleMap
=
tmpRuleMap
.
get
(
type
);
if
(
typeRuleMap
.
containsKey
(
domain
))
{
typeRuleMap
.
get
(
domain
).
add
(
rule
);
}
else
{
domainRules
=
new
ArrayList
<
AggregationRule
>();
domainRules
.
add
(
rule
);
typeRuleMap
.
put
(
domain
,
domainRules
);
}
}
else
{
domainRules
=
new
ArrayList
<
AggregationRule
>();
domainRules
.
add
(
rule
);
typeRuleMap
=
new
HashMap
<
String
,
List
<
AggregationRule
>>();
typeRuleMap
.
put
(
domain
,
domainRules
);
tmpRuleMap
.
put
(
type
,
typeRuleMap
);
}
}
m_ruleMap
=
tmpRuleMap
;
m_handler
.
register
(
m_ruleMap
);
}
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
}
}
}
/**
* Thread to reload aggregation rule from database
* @author renyuan.sun
*
*/
public
class
RuleReload
implements
Task
{
@Override
public
String
getName
()
{
return
"Aggregation-Rule-Info-Reload"
;
}
@Override
public
void
run
()
{
boolean
active
=
true
;
while
(
active
)
{
try
{
reload
();
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
try
{
Thread
.
sleep
(
3
*
ONE_MINUTE
);
}
catch
(
InterruptedException
e
)
{
active
=
false
;
}
}
}
@Override
public
void
shutdown
()
{
}
}
public
String
handle
(
int
type
,
String
domain
,
String
status
)
{
return
m_handler
.
handle
(
type
,
domain
,
status
);
}
}
cat-consumer/src/main/java/com/dianping/cat/consumer/core/aggregation/AggregationMessageFormat.java
0 → 100644
浏览文件 @
ba16593f
package
com.dianping.cat.consumer.core.aggregation
;
import
java.text.MessageFormat
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
public
class
AggregationMessageFormat
{
private
List
<
String
>
m_formatTokens
=
new
ArrayList
<
String
>();
private
MessageFormat
m_messageFormat
;
public
AggregationMessageFormat
(
String
pattern
)
{
m_messageFormat
=
new
MessageFormat
(
build
(
pattern
));
}
/**
* build message format by user's aggregation rule
* @param pattern
* @return
*/
private
String
build
(
String
pattern
)
{
Pattern
p
=
Pattern
.
compile
(
"\\{(.*?)\\}"
);
Matcher
matcher
=
p
.
matcher
(
pattern
);
int
index
=
0
;
StringBuffer
output
=
new
StringBuffer
();
while
(
matcher
.
find
())
{
m_formatTokens
.
add
(
matcher
.
group
(
1
).
trim
());
matcher
.
appendReplacement
(
output
,
"{"
+
index
+
"}"
);
if
(
index
<
9
){
index
++;
}
}
matcher
.
appendTail
(
output
);
return
output
.
toString
();
}
public
List
<
String
>
getFormatTokens
()
{
return
m_formatTokens
;
}
/**
* message format is not thread safe, so return a clone
* @return message format clone
*/
public
MessageFormat
getMessageFormat
()
{
return
(
MessageFormat
)
m_messageFormat
.
clone
();
}
}
cat-consumer/src/main/java/com/dianping/cat/consumer/core/aggregation/CompositeFormat.java
0 → 100644
浏览文件 @
ba16593f
package
com.dianping.cat.consumer.core.aggregation
;
import
java.text.ParseException
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Composite format of many message format
* @author renyuan.sun
*
*/
public
class
CompositeFormat
extends
Format
{
private
AggregationMessageFormat
m_aggregationMessageFormat
;
@Override
public
String
parse
(
String
input
)
throws
ParseException
{
Object
[]
tokens
=
m_aggregationMessageFormat
.
getMessageFormat
().
parse
(
input
);
List
<
String
>
items
=
new
ArrayList
<
String
>();
int
index
=
0
;
for
(
String
pattern:
m_aggregationMessageFormat
.
getFormatTokens
())
{
Format
format
=
new
DefaultFormat
();
format
.
setPattern
(
pattern
);
String
output
=
format
.
parse
(
tokens
[
index
].
toString
());
items
.
add
(
output
);
index
++;
}
return
m_aggregationMessageFormat
.
getMessageFormat
().
format
(
items
.
toArray
()).
toString
();
}
public
CompositeFormat
(
AggregationMessageFormat
amf
)
{
this
.
m_aggregationMessageFormat
=
amf
;
}
public
AggregationMessageFormat
getAmf
()
{
return
m_aggregationMessageFormat
;
}
public
void
setAmf
(
AggregationMessageFormat
amf
)
{
this
.
m_aggregationMessageFormat
=
amf
;
}
}
cat-consumer/src/main/java/com/dianping/cat/consumer/core/aggregation/DefaultAggregationHandler.java
0 → 100644
浏览文件 @
ba16593f
package
com.dianping.cat.consumer.core.aggregation
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.dainping.cat.consumer.core.dal.AggregationRule
;
public
class
DefaultAggregationHandler
implements
AggregationHandler
{
Map
<
Integer
,
Map
<
String
,
TrieTreeNode
>>
m_formatMap
;
@Override
public
void
register
(
Map
<
Integer
,
Map
<
String
,
List
<
AggregationRule
>>>
ruleMap
)
{
Map
<
Integer
,
Map
<
String
,
TrieTreeNode
>>
tmpFormatMap
=
new
HashMap
<
Integer
,
Map
<
String
,
TrieTreeNode
>>();
for
(
int
type
:
ruleMap
.
keySet
())
{
Map
<
String
,
TrieTreeNode
>
tmpDomainToFormatMap
=
new
HashMap
<
String
,
TrieTreeNode
>();
tmpFormatMap
.
put
(
type
,
tmpDomainToFormatMap
);
Map
<
String
,
List
<
AggregationRule
>>
domainToRuleMap
=
ruleMap
.
get
(
type
);
for
(
String
domain
:
domainToRuleMap
.
keySet
())
{
TrieTreeNode
formatTree
=
new
TrieTreeNode
();
tmpDomainToFormatMap
.
put
(
domain
,
formatTree
);
List
<
AggregationRule
>
ruleList
=
domainToRuleMap
.
get
(
domain
);
for
(
AggregationRule
rule
:
ruleList
)
{
String
format
=
rule
.
getPattern
();
if
(
format
==
null
||
format
.
isEmpty
())
{
continue
;
}
int
index1
=
format
.
indexOf
(
'{'
);
if
(
index1
==
-
1
||
index1
==
format
.
length
()
-
1
)
{
continue
;
}
int
index2
=
format
.
lastIndexOf
(
'}'
);
if
(
index2
==
-
1
||
index2
<
index1
)
{
continue
;
}
String
key1
=
format
.
substring
(
0
,
index1
);
String
key2
=
format
.
substring
(
index2
+
1
);
AggregationMessageFormat
value
=
new
AggregationMessageFormat
(
format
);
buildFormatTree
(
formatTree
,
key1
.
toCharArray
(),
key2
.
toCharArray
(),
value
);
}
}
}
m_formatMap
=
tmpFormatMap
;
}
/**
* build a format tree use prefix as trieTree index and suffix as map key or conversely
* @param tree
* @param prefix
* @param suffix
* @param format
*/
private
void
buildFormatTree
(
TrieTreeNode
tree
,
char
[]
prefix
,
char
[]
suffix
,
AggregationMessageFormat
format
)
{
if
(
prefix
.
length
==
0
&&
suffix
.
length
==
0
)
{
tree
.
addFormat
(
""
,
format
);
return
;
}
boolean
isPrefix
=
true
;
int
sIndex
=
0
,
eIndex
=
0
;
TrieTreeNode
sCurrent
=
tree
,
eCurrent
=
tree
;
if
(
prefix
.
length
!=
0
)
{
for
(
int
i
=
0
;
i
<
prefix
.
length
;
i
++)
{
TrieTreeNode
node
=
sCurrent
.
getChildNode
(
prefix
[
i
],
true
);
if
(
node
==
null
)
{
node
=
new
TrieTreeNode
();
sCurrent
.
addTreeNode
(
prefix
[
i
],
true
,
node
);
sIndex
++;
}
sCurrent
=
node
;
}
}
if
(
suffix
.
length
!=
0
)
{
for
(
int
i
=
suffix
.
length
-
1
;
i
>=
0
;
i
--)
{
TrieTreeNode
node
=
eCurrent
.
getChildNode
(
suffix
[
i
],
false
);
if
(
node
==
null
)
{
node
=
new
TrieTreeNode
();
eCurrent
.
addTreeNode
(
suffix
[
i
],
false
,
node
);
eIndex
++;
}
eCurrent
=
node
;
}
}
//choose prefix or suffix as trieTree index based on size of tree leaf
if
(
sIndex
>
eIndex
)
{
isPrefix
=
true
;
}
else
if
(
sIndex
<
eIndex
)
{
isPrefix
=
false
;
}
else
{
isPrefix
=
sCurrent
.
getFormatMap
().
size
()
>=
eCurrent
.
getFormatMap
().
size
()
?
false
:
true
;
}
if
(
isPrefix
)
{
sCurrent
.
addFormat
(
String
.
copyValueOf
(
suffix
),
format
);
}
else
{
eCurrent
.
addFormat
(
String
.
copyValueOf
(
prefix
),
format
);
}
}
private
TrieTreeNode
getFormatTree
(
int
type
,
String
domain
)
{
Map
<
String
,
TrieTreeNode
>
domainToFormatMap
=
m_formatMap
.
get
(
type
);
if
(
domainToFormatMap
==
null
)
{
return
null
;
}
return
domainToFormatMap
.
get
(
domain
);
}
/**
* parse input to output based on format tree
* @param formatTree
* @param input
* @return
*/
private
String
parse
(
TrieTreeNode
formatTree
,
String
input
)
{
char
[]
cs
=
input
.
toCharArray
();
List
<
Map
<
String
,
AggregationMessageFormat
>>
sformatSet
=
new
ArrayList
<
Map
<
String
,
AggregationMessageFormat
>>();
List
<
Map
<
String
,
AggregationMessageFormat
>>
eformatSet
=
new
ArrayList
<
Map
<
String
,
AggregationMessageFormat
>>();
TrieTreeNode
current
=
formatTree
;
int
i
=
0
;
for
(;
i
<
cs
.
length
;
i
++)
{
sformatSet
.
add
(
current
.
getFormatMap
());
TrieTreeNode
node
=
current
.
getChildNode
(
cs
[
i
],
true
);
if
(
node
==
null
)
{
i
--;
break
;
}
current
=
node
;
}
current
=
formatTree
;
int
j
=
cs
.
length
-
1
;
for
(;
j
>
0
;
j
--)
{
eformatSet
.
add
(
current
.
getFormatMap
());
TrieTreeNode
node
=
current
.
getChildNode
(
cs
[
j
],
false
);
if
(
node
==
null
)
{
j
++;
break
;
}
current
=
node
;
}
for
(
Map
<
String
,
AggregationMessageFormat
>
amfMap
:
sformatSet
)
{
for
(
String
key:
amfMap
.
keySet
())
{
if
(!
input
.
endsWith
(
key
))
{
continue
;
}
AggregationMessageFormat
amf
=
amfMap
.
get
(
key
);
CompositeFormat
cf
=
new
CompositeFormat
(
amf
);
String
output
;
try
{
output
=
cf
.
parse
(
input
);
}
catch
(
Exception
e
)
{
continue
;
}
return
output
;
}
}
for
(
Map
<
String
,
AggregationMessageFormat
>
amfMap
:
eformatSet
)
{
for
(
String
key:
amfMap
.
keySet
())
{
if
(!
input
.
startsWith
(
key
))
{
continue
;
}
AggregationMessageFormat
amf
=
amfMap
.
get
(
key
);
CompositeFormat
cf
=
new
CompositeFormat
(
amf
);
String
output
;
try
{
output
=
cf
.
parse
(
input
);
}
catch
(
Exception
e
)
{
continue
;
}
return
output
;
}
}
return
input
;
}
@Override
public
String
handle
(
int
type
,
String
domain
,
String
input
)
{
TrieTreeNode
formatTree
=
getFormatTree
(
type
,
domain
);
if
(
formatTree
==
null
)
{
return
input
;
}
return
parse
(
formatTree
,
input
);
}
}
cat-consumer/src/main/java/com/dianping/cat/consumer/core/aggregation/DefaultFormat.java
0 → 100644
浏览文件 @
ba16593f
package
com.dianping.cat.consumer.core.aggregation
;
import
java.text.ParseException
;
public
class
DefaultFormat
extends
Format
{
@Override
public
String
parse
(
String
input
)
throws
ParseException
{
String
pattern
=
getPattern
();
String
item
=
""
;
String
describe
=
""
;
int
index
=
pattern
.
indexOf
(
":"
);
if
(
index
!=
-
1
&&
pattern
.
length
()
>
index
+
1
)
{
item
=
pattern
.
substring
(
0
,
index
).
trim
();
describe
=
pattern
.
substring
(
index
+
1
).
trim
();
}
if
(!
describe
.
isEmpty
())
{
int
length
=
1
;
try
{
length
=
Integer
.
parseInt
(
describe
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ParseException
(
pattern
+
"is illegal"
,
0
);
}
if
(
input
.
length
()
!=
length
)
{
throw
new
ParseException
(
"not match "
+
pattern
,
0
);
}
}
if
(
pattern
.
equals
(
"*"
))
{
return
input
;
}
else
if
(
item
.
equals
(
"md5"
))
{
char
[]
charArray
=
input
.
toCharArray
();
for
(
Character
ch
:
charArray
)
{
if
(!
Character
.
isDigit
(
ch
)
&&
!
Character
.
isLowerCase
(
ch
))
{
return
input
;
}
}
}
else
if
(
item
.
equals
(
"number"
))
{
char
[]
charArray
=
input
.
toCharArray
();
for
(
Character
ch
:
charArray
)
{
if
(!
Character
.
isDigit
(
ch
))
{
return
input
;
}
}
}
return
(
"{"
+
pattern
+
"}"
);
}
public
static
void
main
(
String
[]
str
)
{
}
}
cat-consumer/src/main/java/com/dianping/cat/consumer/core/aggregation/Format.java
0 → 100644
浏览文件 @
ba16593f
package
com.dianping.cat.consumer.core.aggregation
;
import
java.text.ParseException
;
public
abstract
class
Format
{
private
String
m_pattern
;
public
abstract
String
parse
(
String
input
)
throws
ParseException
;
public
String
getPattern
()
{
return
m_pattern
;
}
public
void
setPattern
(
String
pattern
)
{
this
.
m_pattern
=
pattern
;
}
}
cat-consumer/src/main/java/com/dianping/cat/consumer/core/aggregation/TrieTreeNode.java
0 → 100644
浏览文件 @
ba16593f
package
com.dianping.cat.consumer.core.aggregation
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
TrieTreeNode
{
/**
* tree index
*/
private
Map
<
TrieTreeKey
,
TrieTreeNode
>
m_childMap
=
new
HashMap
<
TrieTreeKey
,
TrieTreeNode
>();
/**
* data of node
*/
private
Map
<
String
,
AggregationMessageFormat
>
m_formatMap
=
new
HashMap
<
String
,
AggregationMessageFormat
>();
public
void
addFormat
(
String
key
,
AggregationMessageFormat
format
){
m_formatMap
.
put
(
key
,
format
);
}
public
void
addTreeNode
(
char
ch
,
boolean
isPrefix
,
TrieTreeNode
node
){
TrieTreeKey
key
=
new
TrieTreeKey
(
ch
,
isPrefix
);
m_childMap
.
put
(
key
,
node
);
}
public
TrieTreeNode
getChildNode
(
char
ch
,
boolean
isPrefix
){
TrieTreeKey
key
=
new
TrieTreeKey
(
ch
,
isPrefix
);
return
m_childMap
.
get
(
key
);
}
public
Map
<
String
,
AggregationMessageFormat
>
getFormatMap
()
{
return
m_formatMap
;
}
@Override
public
String
toString
()
{
return
"TrieTreeNode [m_childMap="
+
m_childMap
+
", m_formatList="
+
m_formatMap
+
"]"
;
}
/**
* Used as trie tree index
* @author renyuan.sun
*
*/
class
TrieTreeKey
{
/**
* character index
*/
char
m_ch
;
/**
* true when the character is prefix
* false when the character is suffix
*/
boolean
m_isPrefix
;
public
TrieTreeKey
(
char
ch
,
boolean
isPrefix
)
{
super
();
this
.
m_ch
=
ch
;
this
.
m_isPrefix
=
isPrefix
;
}
@Override
public
int
hashCode
()
{
final
int
prime
=
31
;
int
result
=
1
;
result
=
prime
*
result
+
getOuterType
().
hashCode
();
result
=
prime
*
result
+
m_ch
;
result
=
prime
*
result
+
(
m_isPrefix
?
1231
:
1237
);
return
result
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
return
true
;
if
(
obj
==
null
)
return
false
;
if
(
getClass
()
!=
obj
.
getClass
())
return
false
;
TrieTreeKey
other
=
(
TrieTreeKey
)
obj
;
if
(!
getOuterType
().
equals
(
other
.
getOuterType
()))
return
false
;
if
(
m_ch
!=
other
.
m_ch
)
return
false
;
if
(
m_isPrefix
!=
other
.
m_isPrefix
)
return
false
;
return
true
;
}
private
TrieTreeNode
getOuterType
()
{
return
TrieTreeNode
.
this
;
}
@Override
public
String
toString
()
{
return
"TrieTreeKey [m_ch="
+
m_ch
+
", m_isPrefix="
+
m_isPrefix
+
"]"
;
}
}
}
cat-consumer/src/main/java/com/dianping/cat/consumer/core/problem/ProblemReportAggregation.java
0 → 100644
浏览文件 @
ba16593f
package
com.dianping.cat.consumer.core.problem
;
import
java.util.List
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.consumer.core.aggregation.AggregationManager
;
import
com.dianping.cat.consumer.problem.model.entity.Duration
;
import
com.dianping.cat.consumer.problem.model.entity.Entry
;
import
com.dianping.cat.consumer.problem.model.entity.JavaThread
;
import
com.dianping.cat.consumer.problem.model.entity.Machine
;
import
com.dianping.cat.consumer.problem.model.entity.ProblemReport
;
import
com.dianping.cat.consumer.problem.model.entity.Segment
;
import
com.dianping.cat.consumer.problem.model.transform.BaseVisitor
;
public
class
ProblemReportAggregation
extends
BaseVisitor
{
@Inject
private
AggregationManager
m_aggregationManger
;
private
ProblemReport
m_report
;
private
Machine
m_currentMachine
;
private
Entry
m_currentEntry
;
private
JavaThread
m_currentThread
;
private
String
m_domain
;
private
static
final
int
SIZE
=
60
;
public
void
setRuleManger
(
AggregationManager
ruleManger
)
{
m_aggregationManger
=
ruleManger
;
}
@Override
public
void
visitProblemReport
(
ProblemReport
problemReport
)
{
m_domain
=
problemReport
.
getDomain
();
m_report
=
new
ProblemReport
();
m_report
.
getIps
().
addAll
(
problemReport
.
getIps
());
m_report
.
getDomainNames
().
addAll
(
problemReport
.
getDomainNames
());
m_report
.
setDomain
(
problemReport
.
getDomain
());
m_report
.
setStartTime
(
problemReport
.
getStartTime
());
m_report
.
setEndTime
(
problemReport
.
getEndTime
());
super
.
visitProblemReport
(
problemReport
);
}
@Override
public
void
visitMachine
(
Machine
machine
)
{
m_currentMachine
=
m_report
.
findOrCreateMachine
(
machine
.
getIp
());
super
.
visitMachine
(
machine
);
}
@Override
public
void
visitEntry
(
Entry
entry
)
{
String
type
=
entry
.
getType
();
String
status
=
entry
.
getStatus
();
status
=
m_aggregationManger
.
handle
(
AggregationManager
.
PROBLEM_TYPE
,
m_domain
,
status
);
m_currentEntry
=
findOrCreatEntry
(
m_currentMachine
,
type
,
status
);
super
.
visitEntry
(
entry
);
}
@Override
public
void
visitDuration
(
Duration
duration
)
{
int
value
=
duration
.
getValue
();
Duration
temp
=
m_currentEntry
.
findOrCreateDuration
(
value
);
mergeDuration
(
temp
,
duration
);
}
protected
void
mergeDuration
(
Duration
old
,
Duration
duration
)
{
old
.
setValue
(
duration
.
getValue
());
old
.
setCount
(
old
.
getCount
()
+
duration
.
getCount
());
List
<
String
>
messages
=
old
.
getMessages
();
if
(
messages
.
size
()
<
SIZE
)
{
messages
.
addAll
(
duration
.
getMessages
());
if
(
messages
.
size
()
>
SIZE
)
{
messages
=
messages
.
subList
(
0
,
SIZE
);
}
}
}
@Override
public
void
visitThread
(
JavaThread
thread
)
{
m_currentThread
=
m_currentEntry
.
findOrCreateThread
(
thread
.
getId
());
super
.
visitThread
(
thread
);
}
@Override
public
void
visitSegment
(
Segment
segment
)
{
m_currentThread
.
addSegment
(
segment
);
}
protected
Entry
findOrCreatEntry
(
Machine
machine
,
String
type
,
String
status
)
{
List
<
Entry
>
entries
=
machine
.
getEntries
();
for
(
Entry
entry
:
entries
)
{
if
(
entry
.
getType
().
equals
(
type
)
&&
entry
.
getStatus
().
equals
(
status
))
{
return
entry
;
}
}
Entry
entry
=
new
Entry
();
entry
.
setStatus
(
status
);
entry
.
setType
(
type
);
entries
.
add
(
entry
);
return
entry
;
}
public
ProblemReport
getReport
()
{
return
m_report
;
}
}
cat-consumer/src/main/resources/META-INF/dal/jdbc/report-codegen.xml
浏览文件 @
ba16593f
<?xml version="1.0" encoding="UTF-8"?>
<entities>
<entity
name=
"aggregation-rule"
table=
"aggregationRule"
alias=
"a"
>
<member
name=
"id"
field=
"id"
value-type=
"int"
length=
"10"
nullable=
"false"
key=
"true"
auto-increment=
"true"
/>
<member
name=
"type"
field=
"type"
value-type=
"int"
length=
"10"
nullable=
"false"
/>
<member
name=
"domain"
field=
"domain"
value-type=
"String"
length=
"50"
nullable=
"false"
/>
<member
name=
"pattern"
field=
"pattern"
value-type=
"String"
length=
"200"
nullable=
"false"
/>
<member
name=
"display-name"
field=
"display_name"
value-type=
"String"
length=
"200"
nullable=
"false"
/>
<member
name=
"sample"
field=
"sample"
value-type=
"String"
length=
"200"
/>
<member
name=
"create-date"
field=
"create_date"
value-type=
"Date"
nullable=
"false"
/>
<member
name=
"update-date"
field=
"update_date"
value-type=
"Date"
nullable=
"false"
/>
<var
name=
"key-id"
value-type=
"int"
key-member=
"id"
/>
<primary-key
name=
"PRIMARY"
members=
"id"
/>
<readsets>
<readset
name=
"FULL"
all=
"true"
/>
</readsets>
<updatesets>
<updateset
name=
"FULL"
all=
"true"
/>
</updatesets>
<query-defs>
<query
name=
"find-by-PK"
type=
"SELECT"
>
<param
name=
"key-id"
/>
<statement>
<![CDATA[SELECT <FIELDS/>
FROM
<TABLE/>
WHERE
<FIELD
name=
'id'
/>
= ${key-id}]]>
</statement>
</query>
<query
name=
"insert"
type=
"INSERT"
>
<statement>
<![CDATA[INSERT INTO <TABLE/>
(
<FIELDS/>
)
VALUES(
<VALUES/>
)]]>
</statement>
</query>
<query
name=
"update-by-PK"
type=
"UPDATE"
>
<param
name=
"key-id"
/>
<statement>
<![CDATA[UPDATE <TABLE/>
SET
<FIELDS/>
WHERE
<FIELD
name=
'id'
/>
= ${key-id}]]>
</statement>
</query>
<query
name=
"delete-by-PK"
type=
"DELETE"
>
<param
name=
"key-id"
/>
<statement>
<![CDATA[DELETE FROM <TABLE/>
WHERE
<FIELD
name=
'id'
/>
= ${key-id}]]>
</statement>
</query>
</query-defs>
</entity>
<entity
name=
"hostinfo"
table=
"hostinfo"
alias=
"h"
>
<member
name=
"id"
field=
"id"
value-type=
"int"
length=
"10"
nullable=
"false"
key=
"true"
auto-increment=
"true"
/>
<member
name=
"ip"
field=
"ip"
value-type=
"String"
length=
"50"
nullable=
"false"
/>
...
...
@@ -140,6 +181,7 @@
<var
name=
"key-id"
value-type=
"int"
key-member=
"id"
/>
<primary-key
name=
"PRIMARY"
members=
"id"
/>
<index
name=
"task_period_domain_name"
unique=
"true"
members=
"report_period ASC, report_domain ASC, report_name ASC, task_type ASC"
/>
<index
name=
"status"
members=
"status ASC"
/>
<readsets>
<readset
name=
"FULL"
all=
"true"
/>
</readsets>
...
...
cat-consumer/src/main/resources/META-INF/dal/jdbc/report-dal.xml
浏览文件 @
ba16593f
...
...
@@ -318,4 +318,17 @@
</query>
</query-defs>
</entity>
<entity
name=
"aggregation-rule"
table=
"aggregationRule"
alias=
"a"
>
<member
name=
"create-date"
insert-expr=
"NOW()"
/>
<member
name=
"update-date"
insert-expr=
"NOW()"
update-expr=
"NOW()"
/>
<query-defs>
<query
name=
"find-all"
type=
"SELECT"
multiple=
"true"
>
<statement>
<![CDATA[
SELECT <FIELDS/>
FROM
<TABLE/>
]]>
</statement>
</query>
</query-defs>
</entity>
</entities>
\ No newline at end of file
cat-consumer/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
ba16593f
<plexus>
<components>
<component>
<role>
com.dianping.cat.consumer.core.aggregation.AggregationHandler
</role>
<implementation>
com.dianping.cat.consumer.core.aggregation.DefaultAggregationHandler
</implementation>
</component>
<component>
<role>
com.dianping.cat.consumer.core.aggregation.AggregationManager
</role>
<implementation>
com.dianping.cat.consumer.core.aggregation.AggregationManager
</implementation>
<requirements>
<requirement>
<role>
com.dainping.cat.consumer.core.dal.AggregationRuleDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.configuration.ServerConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.consumer.core.aggregation.AggregationHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.consumer.core.problem.ProblemReportAggregation
</role>
<implementation>
com.dianping.cat.consumer.core.problem.ProblemReportAggregation
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.consumer.core.aggregation.AggregationManager
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.consumer.MessageAnalyzerManager
</role>
<implementation>
com.dianping.cat.consumer.DefaultMessageAnalyzerManager
</implementation>
...
...
@@ -51,6 +79,9 @@
<requirement>
<role>
com.dainping.cat.consumer.core.dal.TaskDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.consumer.core.problem.ProblemReportAggregation
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.consumer.core.problem.ProblemHandler
</role>
<role-hints>
...
...
@@ -191,8 +222,8 @@
<statement-cache-size>
1000
</statement-cache-size>
<properties>
<driver>
com.mysql.jdbc.Driver
</driver>
<URL>
jdbc:mysql://1
92.168.7.43
:3306/cat
</URL>
<user>
dpcom_ca
t
</user>
<URL>
jdbc:mysql://1
27.0.0.1
:3306/cat
</URL>
<user>
roo
t
</user>
<password>
password
</password>
<connectionProperties>
<![CDATA[useUnicode=true&autoReconnect=true]]>
</connectionProperties>
</properties>
...
...
@@ -203,6 +234,16 @@
</requirement>
</requirements>
</component>
<component>
<role>
org.unidal.dal.jdbc.mapping.TableProvider
</role>
<role-hint>
aggregation-rule
</role-hint>
<implementation>
org.unidal.dal.jdbc.mapping.SimpleTableProvider
</implementation>
<configuration>
<logical-table-name>
aggregation-rule
</logical-table-name>
<physical-table-name>
aggregationRule
</physical-table-name>
<data-source-name>
cat
</data-source-name>
</configuration>
</component>
<component>
<role>
org.unidal.dal.jdbc.mapping.TableProvider
</role>
<role-hint>
hostinfo
</role-hint>
...
...
@@ -243,6 +284,15 @@
<data-source-name>
cat
</data-source-name>
</configuration>
</component>
<component>
<role>
com.dainping.cat.consumer.core.dal.AggregationRuleDao
</role>
<implementation>
com.dainping.cat.consumer.core.dal.AggregationRuleDao
</implementation>
<requirements>
<requirement>
<role>
org.unidal.dal.jdbc.QueryEngine
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dainping.cat.consumer.core.dal.HostinfoDao
</role>
<implementation>
com.dainping.cat.consumer.core.dal.HostinfoDao
</implementation>
...
...
cat-consumer/src/main/resources/META-INF/wizard/jdbc/wizard.xml
浏览文件 @
ba16593f
...
...
@@ -13,6 +13,7 @@
<table
name=
"hostinfo"
/>
<table
name=
"task"
/>
<table
name=
"project"
/>
<table
name=
"aggregationRule"
/>
</group>
</jdbc>
</wizard>
cat-consumer/src/test/java/com/dianping/cat/consumer/core/ProblemReportAggregationTest.java
0 → 100644
浏览文件 @
ba16593f
package
com.dianping.cat.consumer.core
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
junit.framework.Assert
;
import
org.junit.Test
;
import
org.unidal.helper.Files
;
import
org.xml.sax.SAXException
;
import
com.dainping.cat.consumer.core.dal.AggregationRule
;
import
com.dianping.cat.consumer.core.aggregation.AggregationManager
;
import
com.dianping.cat.consumer.core.aggregation.DefaultAggregationHandler
;
import
com.dianping.cat.consumer.core.problem.ProblemReportAggregation
;
import
com.dianping.cat.consumer.problem.model.entity.ProblemReport
;
import
com.dianping.cat.consumer.problem.model.transform.DefaultSaxParser
;
public
class
ProblemReportAggregationTest
{
@Test
public
void
testAggregation
()
throws
IOException
,
SAXException
{
ProblemReportAggregation
aggregation
=
new
ProblemReportAggregation
();
String
oldXml
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"problem-report-before-aggregation.xml"
),
"utf-8"
);
String
newXml
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"problem-report-after-aggregation.xml"
),
"utf-8"
);
ProblemReport
reportOld
=
DefaultSaxParser
.
parse
(
oldXml
);
ProblemReport
reportNew
=
DefaultSaxParser
.
parse
(
newXml
);
MockRuleManger
ruleManger
=
new
MockRuleManger
();
ruleManger
.
register
();
aggregation
.
setRuleManger
(
ruleManger
);
long
start
=
(
new
Date
()).
getTime
();
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
aggregation
.
visitProblemReport
(
reportOld
);
}
System
.
out
.
println
(((
new
Date
()).
getTime
()-
start
)*
1.0
/
1000
);
Assert
.
assertEquals
(
reportNew
.
toString
().
replaceAll
(
"\r"
,
""
),
aggregation
.
getReport
().
toString
().
replaceAll
(
"\r"
,
""
));
}
class
MockRuleManger
extends
AggregationManager
{
private
void
register
(){
List
<
AggregationRule
>
rules
=
getAggregationRule
(
AggregationManager
.
PROBLEM_TYPE
,
"FrontEnd"
);
Map
<
Integer
,
Map
<
String
,
List
<
AggregationRule
>>>
ruleMap
=
new
HashMap
<
Integer
,
Map
<
String
,
List
<
AggregationRule
>>>();
Map
<
String
,
List
<
AggregationRule
>>
typeRuleMap
=
new
HashMap
<
String
,
List
<
AggregationRule
>>();
typeRuleMap
.
put
(
"FrontEnd"
,
rules
);
ruleMap
.
put
(
AggregationManager
.
PROBLEM_TYPE
,
typeRuleMap
);
m_handler
=
new
DefaultAggregationHandler
();
m_handler
.
register
(
ruleMap
);
}
public
List
<
AggregationRule
>
getAggregationRule
(
int
type
,
String
domain
)
{
List
<
AggregationRule
>
rules
=
new
ArrayList
<
AggregationRule
>();
AggregationRule
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://www.dianping.com/{City}/food"
);
rules
.
add
(
rule
);
for
(
int
i
=
0
;
i
<
10000
;
i
++)
{
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://www.dianping.com/{City}/"
+
i
);
rules
.
add
(
rule
);
}
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://www.dianping.com/{City}/wedding"
);
rules
.
add
(
rule
);
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://www.dianping.com/{City}/beauty"
);
rules
.
add
(
rule
);
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://www.dianping.com/{City}/shopping"
);
rules
.
add
(
rule
);
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://www.dianping.com/{City}/group"
);
rules
.
add
(
rule
);
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://www.dianping.com/{City}/car"
);
rules
.
add
(
rule
);
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://www.dianping.com/{City}/hotel"
);
rules
.
add
(
rule
);
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://www.dianping.com/{City}/sports"
);
rules
.
add
(
rule
);
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://www.dianping.com/{City}/beauty"
);
rules
.
add
(
rule
);
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://www.dianping.com/{City}/other"
);
rules
.
add
(
rule
);
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://www.dianping.com/review/{reviewid}"
);
rules
.
add
(
rule
);
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://www.dianping.com/photos/{photoid}"
);
rules
.
add
(
rule
);
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://www.dianping.com/shop/{shopid}"
);
rules
.
add
(
rule
);
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"{*}/s/j/app/shop/review.{md5:32}.js"
);
rules
.
add
(
rule
);
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://i{x}.dpfile.com/{*}"
);
rules
.
add
(
rule
);
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://www.dianping.com/shoplist/{shopListType}"
);
rules
.
add
(
rule
);
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://www.dianping.com/photoList/{photoListType}"
);
rules
.
add
(
rule
);
rule
=
new
AggregationRule
();
rule
.
setPattern
(
"http://s.dianping.com/{city}/group"
);
rules
.
add
(
rule
);
return
rules
;
}
}
}
cat-consumer/src/test/java/com/dianping/cat/consumer/core/aggregation/CompositeFormatTest.java
0 → 100644
浏览文件 @
ba16593f
package
com.dianping.cat.consumer.core.aggregation
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
java.text.ParseException
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
com.dianping.cat.consumer.core.aggregation.AggregationMessageFormat
;
import
com.dianping.cat.consumer.core.aggregation.CompositeFormat
;
public
class
CompositeFormatTest
{
@Rule
public
ExpectedException
exception
=
ExpectedException
.
none
();
@Test
public
void
TestParse
()
throws
ParseException
{
AggregationMessageFormat
amf
=
new
AggregationMessageFormat
(
"Hello {world}.I am{*}.{md5:8}."
);
CompositeFormat
format
=
new
CompositeFormat
(
amf
);
assertEquals
(
"Hello {world}.I am Jack.{md5:8}."
,
format
.
parse
(
"Hello world.I am Jack.balabala."
));
}
}
cat-consumer/src/test/java/com/dianping/cat/consumer/core/aggregation/DefaultFormatTest.java
0 → 100644
浏览文件 @
ba16593f
package
com.dianping.cat.consumer.core.aggregation
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
java.text.ParseException
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
com.dianping.cat.consumer.core.aggregation.DefaultFormat
;
import
com.dianping.cat.consumer.core.aggregation.Format
;
public
class
DefaultFormatTest
{
@Rule
public
ExpectedException
exception
=
ExpectedException
.
none
();
@Test
public
void
TestParse
()
throws
ParseException
{
Format
format
=
new
DefaultFormat
();
format
.
setPattern
(
"*"
);
assertEquals
(
"balabala"
,
format
.
parse
(
"balabala"
));
format
.
setPattern
(
"id"
);
assertEquals
(
"{id}"
,
format
.
parse
(
"balabala"
));
format
.
setPattern
(
"md5:2"
);
assertEquals
(
"{md5:2}"
,
format
.
parse
(
"b2"
));
exception
.
expect
(
ParseException
.
class
);
format
.
parse
(
"hello"
);
format
.
parse
(
"Ad"
);
}
}
cat-consumer/src/test/resources/com/dianping/cat/consumer/core/problem-report-after-aggregation.xml
0 → 100644
浏览文件 @
ba16593f
此差异已折叠。
点击以展开。
cat-consumer/src/test/resources/com/dianping/cat/consumer/core/problem-report-before-aggregation.xml
0 → 100644
浏览文件 @
ba16593f
此差异已折叠。
点击以展开。
cat-core/src/main/resources/com/dianping/cat/configuration/client/config.xsd
浏览文件 @
ba16593f
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
xmlns:xs=
"http://www.w3.org/2001/XMLSchema"
elementFormDefault=
"qualified"
attributeFormDefault=
"unqualified"
>
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
xmlns:xs=
"http://www.w3.org/2001/XMLSchema"
elementFormDefault=
"qualified"
attributeFormDefault=
"unqualified"
>
<xs:element
name=
"config"
type=
"ConfigType"
/>
<xs:complexType
name=
"ConfigType"
>
<xs:sequence>
...
...
cat-core/src/main/resources/com/dianping/cat/status/model/status.xsd
浏览文件 @
ba16593f
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
xmlns:xs=
"http://www.w3.org/2001/XMLSchema"
elementFormDefault=
"qualified"
attributeFormDefault=
"unqualified"
>
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
xmlns:xs=
"http://www.w3.org/2001/XMLSchema"
elementFormDefault=
"qualified"
attributeFormDefault=
"unqualified"
>
<xs:element
name=
"status"
type=
"StatusType"
/>
<xs:complexType
name=
"StatusType"
>
<xs:sequence>
...
...
cat-home/src/main/java/com/dianping/cat/CatHomeModule.java
浏览文件 @
ba16593f
...
...
@@ -11,6 +11,7 @@ import com.dianping.cat.configuration.ServerConfigManager;
import
com.dianping.cat.consumer.CatConsumerAdvancedModule
;
import
com.dianping.cat.consumer.CatConsumerModule
;
import
com.dianping.cat.consumer.RealtimeConsumer
;
import
com.dianping.cat.consumer.core.aggregation.AggregationManager
;
import
com.dianping.cat.message.io.TcpSocketReceiver
;
import
com.dianping.cat.message.spi.MessageConsumer
;
import
com.dianping.cat.report.task.thread.DefaultTaskConsumer
;
...
...
@@ -35,6 +36,7 @@ public class CatHomeModule extends AbstractModule {
ctx
.
lookup
(
MessageConsumer
.
class
,
RealtimeConsumer
.
ID
);
ctx
.
lookup
(
DomainNavManager
.
class
);
ctx
.
lookup
(
AggregationManager
.
class
);
DefaultTaskConsumer
taskConsumer
=
ctx
.
lookup
(
DefaultTaskConsumer
.
class
);
TaskProducer
dailyTaskProducer
=
ctx
.
lookup
(
TaskProducer
.
class
);
...
...
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
浏览文件 @
ba16593f
...
...
@@ -18,6 +18,7 @@ import com.dianping.cat.CatHomeModule;
import
com.dianping.cat.configuration.ServerConfigManager
;
import
com.dianping.cat.consumer.DomainManager
;
import
com.dianping.cat.consumer.RealtimeConsumer
;
import
com.dianping.cat.home.dal.report.DailygraphDao
;
import
com.dianping.cat.home.dal.report.DailyreportDao
;
import
com.dianping.cat.home.dal.report.EventDao
;
...
...
@@ -174,9 +175,7 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
Module
.
class
,
CatHomeModule
.
ID
,
CatHomeModule
.
class
));
all
.
add
(
C
(
ModuleManager
.
class
,
DefaultModuleManager
.
class
)
//
.
config
(
E
(
"topLevelModules"
).
value
(
CatHomeModule
.
ID
)));
all
.
add
(
C
(
DomainNavManager
.
class
).
req
(
ProjectDao
.
class
,
ServerConfigManager
.
class
));
all
.
add
(
C
(
HourlyReportService
.
class
,
HourlyReportServiceImpl
.
class
)
//
.
req
(
ReportDao
.
class
,
BusinessReportDao
.
class
));
...
...
cat-home/src/main/java/com/dianping/cat/report/page/jsError/Handler.java
浏览文件 @
ba16593f
...
...
@@ -70,6 +70,7 @@ public class Handler implements PageHandler<Context> {
String
error
=
payload
.
getError
();
String
file
=
payload
.
getFile
();
String
host
=
parseHost
();
if
(
file
==
null
||
file
.
length
()
==
0
||
(!
file
.
startsWith
(
"http:"
)))
{
file
=
"unknown"
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/model/problem/ProblemReportMergerManager.java
0 → 100644
浏览文件 @
ba16593f
//package com.dianping.cat.report.page.model.problem;
//
//import com.dianping.cat.consumer.problem.model.entity.ProblemReport;
//
//public class ProblemReportMergerManager {
// public static ProblemReportMerger getProblemReportMerger(ProblemReport report){
// if(report.getDomain().toLowerCase().equals("cat")){
// return new ProblemReportMergerWithAggregation(report);
// } else{
// return new ProblemReportMerger(report);
// }
// }
//}
cat-home/src/main/java/com/dianping/cat/report/page/model/problem/ProblemReportMergerWithAggregation.java
0 → 100644
浏览文件 @
ba16593f
//package com.dianping.cat.report.page.model.problem;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import org.unidal.dal.jdbc.DalException;
//import org.unidal.lookup.annotation.Inject;
//
//import com.dianping.cat.Cat;
//import com.dianping.cat.consumer.core.aggregation.AggregationHandler;
//import com.dianping.cat.consumer.core.aggregation.DefaultAggregationHandler;
//import com.dianping.cat.consumer.problem.model.entity.Entry;
//import com.dianping.cat.consumer.problem.model.entity.Machine;
//import com.dianping.cat.consumer.problem.model.entity.ProblemReport;
//import com.dianping.cat.home.dal.report.AggregationRule;
//import com.dianping.cat.home.dal.report.AggregationRuleDao;
//import com.dianping.cat.home.dal.report.AggregationRuleEntity;
//
//public class ProblemReportMergerWithAggregation extends ProblemReportMerger {
//
// @Inject
// private AggregationRuleDao m_aggregationRuleDao;
//
// protected ProblemReportMergerWithAggregation(ProblemReport problemReport) {
// super(problemReport);
// }
//
// private AggregationHandler aggregationHandler = new DefaultAggregationHandler();
//
// @Override
// public void visitEntry(Entry entry) {
// Machine machine = (Machine) getObjects().peek();
// String status = entry.getStatus();
// status = aggregationHandler.handle(status);
// entry.setStatus(status);
// Entry old = findEntry(machine, entry);
//
// if (old == null) {
// old = new Entry();
// old.setType(entry.getType()).setStatus(entry.getStatus());
// machine.addEntry(old);
// }
//
// visitEntryChildren(old, entry);
// }
// @Override
// public void visitProblemReport(ProblemReport problemReport) {
// List<AggregationRule> rules = null;
// try {
// rules = m_aggregationRuleDao.findAll(AggregationRuleEntity.READSET_FULL);
// } catch (DalException e) {
// Cat.logError(e);
// }
//
// List<String> formats = new ArrayList<String>();
// for(AggregationRule rule:rules){
// if(rule.getDomain().toLowerCase().equals("cat"))
// formats.add(rule.getPattern());
// }
// aggregationHandler.register(formats);
// super.visitProblemReport(problemReport);
// }
//
//}
cat-home/src/main/java/com/dianping/cat/report/page/problem/Handler.java
浏览文件 @
ba16593f
...
...
@@ -20,6 +20,7 @@ import org.unidal.web.mvc.annotation.PayloadMeta;
import
com.dianping.cat.configuration.ServerConfigManager
;
import
com.dianping.cat.configuration.server.entity.Domain
;
import
com.dianping.cat.consumer.core.problem.ProblemReportAggregation
;
import
com.dianping.cat.consumer.problem.model.entity.Machine
;
import
com.dianping.cat.consumer.problem.model.entity.ProblemReport
;
import
com.dianping.cat.helper.CatString
;
...
...
@@ -56,6 +57,9 @@ public class Handler implements PageHandler<Context> {
@Inject
private
PayloadNormalizer
m_normalizePayload
;
@Inject
private
ProblemReportAggregation
m_problemReportAggregation
;
private
Gson
m_gson
=
new
Gson
();
...
...
@@ -65,8 +69,24 @@ public class Handler implements PageHandler<Context> {
cal
.
setTimeInMillis
(
date
);
return
cal
.
get
(
Calendar
.
HOUR_OF_DAY
);
}
private
ProblemReport
getHourlyReport
(
Payload
payload
,
String
type
)
{
ProblemReport
report
=
getHourlyReportInternal
(
payload
,
type
);
if
(
payload
.
getDomain
().
equals
(
"FrontEnd"
)){
if
(
payload
.
getPeriod
()==
ModelPeriod
.
CURRENT
||
payload
.
getPeriod
()==
ModelPeriod
.
LAST
){
report
=
buildFrontEndByRule
(
report
);
}
}
return
report
;
}
private
ProblemReport
buildFrontEndByRule
(
ProblemReport
report
){
report
.
accept
(
m_problemReportAggregation
);
return
m_problemReportAggregation
.
getReport
();
}
private
ProblemReport
getHourlyReportInternal
(
Payload
payload
,
String
type
)
{
String
domain
=
payload
.
getDomain
();
String
date
=
String
.
valueOf
(
payload
.
getDate
());
ModelRequest
request
=
new
ModelRequest
(
domain
,
payload
.
getPeriod
())
//
...
...
@@ -80,7 +100,6 @@ public class Handler implements PageHandler<Context> {
if
(
m_service
.
isEligable
(
request
))
{
ModelResponse
<
ProblemReport
>
response
=
m_service
.
invoke
(
request
);
ProblemReport
report
=
response
.
getModel
();
if
(
payload
.
getPeriod
().
isLast
())
{
Set
<
String
>
domains
=
m_reportService
.
queryAllDomainNames
(
new
Date
(
payload
.
getDate
()),
new
Date
(
payload
.
getDate
()
+
TimeUtil
.
ONE_HOUR
),
"problem"
);
...
...
cat-home/src/main/java/com/dianping/cat/system/SystemModule.java
浏览文件 @
ba16593f
...
...
@@ -13,7 +13,7 @@ com.dianping.cat.system.page.login.Handler.class,
com
.
dianping
.
cat
.
system
.
page
.
project
.
Handler
.
class
,
com
.
dianping
.
cat
.
system
.
page
.
aggregation
.
Handler
.
class
//
com.dianping.cat.system.page.aggregation.Handler.class
})
public
class
SystemModule
extends
AbstractModule
{
...
...
cat-home/src/main/java/com/dianping/cat/system/page/aggregation/Handler.java
浏览文件 @
ba16593f
...
...
@@ -6,10 +6,11 @@ import java.util.List;
import
javax.servlet.ServletException
;
import
com.dainping.cat.consumer.core.dal.AggregationRule
;
import
com.dainping.cat.consumer.core.dal.AggregationRuleDao
;
import
com.dainping.cat.consumer.core.dal.AggregationRuleEntity
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.home.dal.report.AggregationRule
;
import
com.dianping.cat.home.dal.report.AggregationRuleDao
;
import
com.dianping.cat.home.dal.report.AggregationRuleEntity
;
import
com.dianping.cat.system.SystemPage
;
import
org.unidal.dal.jdbc.DalException
;
...
...
cat-home/src/main/java/com/dianping/cat/system/page/aggregation/Model.java
浏览文件 @
ba16593f
...
...
@@ -3,7 +3,7 @@ package com.dianping.cat.system.page.aggregation;
import
java.util.Collections
;
import
java.util.List
;
import
com.d
ianping.cat.home.dal.report
.AggregationRule
;
import
com.d
ainping.cat.consumer.core.dal
.AggregationRule
;
import
com.dianping.cat.system.SystemPage
;
import
org.unidal.web.mvc.ViewModel
;
...
...
cat-home/src/main/resources/META-INF/dal/jdbc/report-codegen.xml
浏览文件 @
ba16593f
<?xml version="1.0" encoding="UTF-8"?>
<entities>
<entity
name=
"aggregation-rule"
table=
"aggregationRule"
alias=
"a"
>
<member
name=
"id"
field=
"id"
value-type=
"int"
length=
"10"
nullable=
"false"
key=
"true"
auto-increment=
"true"
/>
<member
name=
"type"
field=
"type"
value-type=
"int"
length=
"10"
nullable=
"false"
/>
<member
name=
"domain"
field=
"domain"
value-type=
"String"
length=
"50"
nullable=
"false"
/>
<member
name=
"pattern"
field=
"pattern"
value-type=
"String"
length=
"200"
nullable=
"false"
/>
<member
name=
"display-name"
field=
"display_name"
value-type=
"String"
length=
"200"
nullable=
"false"
/>
<member
name=
"sample"
field=
"sample"
value-type=
"String"
length=
"200"
/>
<member
name=
"create-date"
field=
"create_date"
value-type=
"Date"
nullable=
"false"
/>
<member
name=
"update-date"
field=
"update_date"
value-type=
"Date"
nullable=
"false"
/>
<var
name=
"key-id"
value-type=
"int"
key-member=
"id"
/>
<primary-key
name=
"PRIMARY"
members=
"id"
/>
<readsets>
<readset
name=
"FULL"
all=
"true"
/>
</readsets>
<updatesets>
<updateset
name=
"FULL"
all=
"true"
/>
</updatesets>
<query-defs>
<query
name=
"find-by-PK"
type=
"SELECT"
>
<param
name=
"key-id"
/>
<statement>
<![CDATA[SELECT <FIELDS/>
FROM
<TABLE/>
WHERE
<FIELD
name=
'id'
/>
= ${key-id}]]>
</statement>
</query>
<query
name=
"insert"
type=
"INSERT"
>
<statement>
<![CDATA[INSERT INTO <TABLE/>
(
<FIELDS/>
)
VALUES(
<VALUES/>
)]]>
</statement>
</query>
<query
name=
"update-by-PK"
type=
"UPDATE"
>
<param
name=
"key-id"
/>
<statement>
<![CDATA[UPDATE <TABLE/>
SET
<FIELDS/>
WHERE
<FIELD
name=
'id'
/>
= ${key-id}]]>
</statement>
</query>
<query
name=
"delete-by-PK"
type=
"DELETE"
>
<param
name=
"key-id"
/>
<statement>
<![CDATA[DELETE FROM <TABLE/>
WHERE
<FIELD
name=
'id'
/>
= ${key-id}]]>
</statement>
</query>
</query-defs>
</entity>
<entity
name=
"dailygraph"
table=
"dailygraph"
alias=
"d"
>
<member
name=
"id"
field=
"id"
value-type=
"int"
length=
"10"
nullable=
"false"
key=
"true"
auto-increment=
"true"
/>
<member
name=
"name"
field=
"name"
value-type=
"String"
length=
"20"
nullable=
"false"
/>
...
...
cat-home/src/main/resources/META-INF/dal/jdbc/report-dal.xml
浏览文件 @
ba16593f
...
...
@@ -443,20 +443,7 @@
</query>
</query-defs>
</entity>
<entity
name=
"aggregation-rule"
table=
"aggregationRule"
alias=
"a"
>
<member
name=
"create-date"
insert-expr=
"NOW()"
/>
<member
name=
"update-date"
insert-expr=
"NOW()"
update-expr=
"NOW()"
/>
<query-defs>
<query
name=
"find-all"
type=
"SELECT"
multiple=
"true"
>
<statement>
<![CDATA[
SELECT <FIELDS/>
FROM
<TABLE/>
]]>
</statement>
</query>
</query-defs>
</entity>
<entity
name=
"event"
table=
"event"
alias=
"e"
>
<entity
name=
"event"
table=
"event"
alias=
"e"
>
<member
name=
"creation-date"
insert-expr=
"NOW()"
/>
<var
name=
"start-date"
value-type=
"Date"
/>
<var
name=
"end-date"
value-type=
"Date"
/>
...
...
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
ba16593f
...
...
@@ -1283,8 +1283,8 @@
</configuration>
</component>
<component>
<role>
com.d
ianping.cat.home.dal.report
.AggregationRuleDao
</role>
<implementation>
com.d
ianping.cat.home.dal.report
.AggregationRuleDao
</implementation>
<role>
com.d
ainping.cat.consumer.core.dal
.AggregationRuleDao
</role>
<implementation>
com.d
ainping.cat.consumer.core.dal
.AggregationRuleDao
</implementation>
<requirements>
<requirement>
<role>
org.unidal.dal.jdbc.QueryEngine
</role>
...
...
@@ -1594,6 +1594,9 @@
<requirement>
<role>
com.dianping.cat.report.page.PayloadNormalizer
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.consumer.core.problem.ProblemReportAggregation
</role>
</requirement>
</requirements>
</component>
<component>
...
...
@@ -1648,6 +1651,39 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.consumer.core.problem.ProblemReportAggregation
</role>
<implementation>
com.dianping.cat.consumer.core.problem.ProblemReportAggregation
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.consumer.core.aggregation.AggregationManager
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.consumer.core.aggregation.AggregationManager
</role>
<implementation>
com.dianping.cat.consumer.core.aggregation.AggregationManager
</implementation>
<requirements>
<requirement>
<role>
com.dainping.cat.consumer.core.dal.AggregationRuleDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.configuration.ServerConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.consumer.core.aggregation.AggregationHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dainping.cat.consumer.core.dal.AggregationRuleDao
</role>
<implementation>
com.dainping.cat.consumer.core.dal.AggregationRuleDao
</implementation>
<requirements>
<requirement>
<role>
org.unidal.dal.jdbc.QueryEngine
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.transaction.Handler
</role>
<implementation>
com.dianping.cat.report.page.transaction.Handler
</implementation>
...
...
@@ -2829,39 +2865,8 @@
</requirements>
</component>
<component>
<<<<<<
< HEAD
<role
>
com.dianping.cat.system.page.aggregation.Handler
</role>
<implementation>
com.dianping.cat.system.page.aggregation.Handler
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.system.page.aggregation.JspViewer
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.home.dal.report.AggregationRuleDao
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.page.aggregation.JspViewer
</role>
<implementation>
com.dianping.cat.system.page.aggregation.JspViewer
</implementation>
<requirements>
<requirement>
<role>
org.unidal.web.mvc.view.model.ModelHandler
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.home.dal.report.AggregationRuleDao
</role>
<implementation>
com.dianping.cat.home.dal.report.AggregationRuleDao
</implementation>
<requirements>
<requirement>
<role>
org.unidal.dal.jdbc.QueryEngine
</role>
</requirement>
</requirements>
=======
<role>
com.dianping.cat.system.alarm.AlarmContentBuilder
</role>
<implementation>
com.dianping.cat.system.alarm.AlarmContentBuilder
</implementation>
>>>>>>> f04844ca7620423738ae9ff7f60787875551d6e8
</component>
<component>
<role>
com.dianping.cat.system.alarm.AlarmRuleCreator
</role>
...
...
cat-home/src/main/resources/META-INF/wizard/jdbc/wizard.xml
浏览文件 @
ba16593f
...
...
@@ -15,7 +15,6 @@
<table
name=
"weeklyreport"
/>
<table
name=
"monthreport"
/>
<table
name=
"location"
/>
<table
name=
"aggregationRule"
/>
<table
name=
"event"
/>
</group>
<group
name=
"alarm"
package=
"com.dianping.cat.home.dal.alarm"
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录