Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
4b3aafab
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,发现更多精彩内容 >>
提交
4b3aafab
编写于
8月 20, 2012
作者:
Y
youyong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify the cat cross and cache report
上级
7ab755ea
变更
40
隐藏空白更改
内联
并排
Showing
40 changed file
with
1582 addition
and
503 deletion
+1582
-503
cat-consumer/src/main/java/com/dianping/cat/consumer/RealtimeConsumer.java
...main/java/com/dianping/cat/consumer/RealtimeConsumer.java
+2
-3
cat-consumer/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
...m/dianping/cat/consumer/build/ComponentsConfigurator.java
+7
-34
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/ProblemAnalyzer.java
...va/com/dianping/cat/consumer/problem/ProblemAnalyzer.java
+0
-1
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/DefaultProblemHandler.java
...g/cat/consumer/problem/handler/DefaultProblemHandler.java
+47
-7
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/ErrorHandler.java
...m/dianping/cat/consumer/problem/handler/ErrorHandler.java
+0
-74
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/Handler.java
...va/com/dianping/cat/consumer/problem/handler/Handler.java
+6
-4
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/HeartbeatHandler.java
...anping/cat/consumer/problem/handler/HeartbeatHandler.java
+0
-55
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/LongCacheHandler.java
...anping/cat/consumer/problem/handler/LongCacheHandler.java
+0
-61
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/LongExecutionHandler.java
...ng/cat/consumer/problem/handler/LongExecutionHandler.java
+194
-0
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/LongServiceHandler.java
...ping/cat/consumer/problem/handler/LongServiceHandler.java
+0
-78
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/LongUrlHandler.java
...dianping/cat/consumer/problem/handler/LongUrlHandler.java
+0
-80
cat-consumer/src/main/resources/META-INF/plexus/components.xml
...onsumer/src/main/resources/META-INF/plexus/components.xml
+7
-49
cat-consumer/src/test/java/com/dianping/cat/consumer/problem/handler/DefaultHandlerTest.java
...ping/cat/consumer/problem/handler/DefaultHandlerTest.java
+47
-0
cat-consumer/src/test/java/com/dianping/cat/consumer/problem/handler/LongurlHandlerTest.java
...ping/cat/consumer/problem/handler/LongurlHandlerTest.java
+0
-34
cat-home/src/main/java/com/dianping/cat/report/ReportModule.java
...e/src/main/java/com/dianping/cat/report/ReportModule.java
+3
-1
cat-home/src/main/java/com/dianping/cat/report/ReportPage.java
...ome/src/main/java/com/dianping/cat/report/ReportPage.java
+3
-1
cat-home/src/main/java/com/dianping/cat/report/graph/DefaultValueTranslater.java
...com/dianping/cat/report/graph/DefaultValueTranslater.java
+5
-1
cat-home/src/main/java/com/dianping/cat/report/page/cache/Action.java
.../main/java/com/dianping/cat/report/page/cache/Action.java
+26
-0
cat-home/src/main/java/com/dianping/cat/report/page/cache/CacheReport.java
.../java/com/dianping/cat/report/page/cache/CacheReport.java
+237
-0
cat-home/src/main/java/com/dianping/cat/report/page/cache/Context.java
...main/java/com/dianping/cat/report/page/cache/Context.java
+7
-0
cat-home/src/main/java/com/dianping/cat/report/page/cache/Handler.java
...main/java/com/dianping/cat/report/page/cache/Handler.java
+300
-0
cat-home/src/main/java/com/dianping/cat/report/page/cache/JspFile.java
...main/java/com/dianping/cat/report/page/cache/JspFile.java
+17
-0
cat-home/src/main/java/com/dianping/cat/report/page/cache/JspViewer.java
...in/java/com/dianping/cat/report/page/cache/JspViewer.java
+22
-0
cat-home/src/main/java/com/dianping/cat/report/page/cache/Model.java
...c/main/java/com/dianping/cat/report/page/cache/Model.java
+61
-0
cat-home/src/main/java/com/dianping/cat/report/page/cache/Payload.java
...main/java/com/dianping/cat/report/page/cache/Payload.java
+76
-0
cat-home/src/main/java/com/dianping/cat/report/page/cache/TransactionReportVistor.java
...anping/cat/report/page/cache/TransactionReportVistor.java
+101
-0
cat-home/src/main/java/com/dianping/cat/report/page/cross/Handler.java
...main/java/com/dianping/cat/report/page/cross/Handler.java
+4
-2
cat-home/src/main/java/com/dianping/cat/report/page/cross/display/MethodInfo.java
...om/dianping/cat/report/page/cross/display/MethodInfo.java
+48
-12
cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/DisplayHeartbeat.java
.../dianping/cat/report/page/heartbeat/DisplayHeartbeat.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/page/matrix/DisplayMatrix.java
...va/com/dianping/cat/report/page/matrix/DisplayMatrix.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/view/NavigationBar.java
...main/java/com/dianping/cat/report/view/NavigationBar.java
+2
-0
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+38
-0
cat-home/src/main/resources/META-INF/wizard/webapp/wizard.xml
...home/src/main/resources/META-INF/wizard/webapp/wizard.xml
+3
-0
cat-home/src/main/webapp/jsp/report/cache.jsp
cat-home/src/main/webapp/jsp/report/cache.jsp
+103
-0
cat-home/src/main/webapp/jsp/report/cacheHistory.jsp
cat-home/src/main/webapp/jsp/report/cacheHistory.jsp
+96
-0
cat-home/src/main/webapp/jsp/report/crossHistoryHost.jsp
cat-home/src/main/webapp/jsp/report/crossHistoryHost.jsp
+2
-2
cat-home/src/main/webapp/jsp/report/crossHost.jsp
cat-home/src/main/webapp/jsp/report/crossHost.jsp
+2
-2
cat-home/src/main/webapp/jsp/report/problemHistoryReport.jsp
cat-home/src/main/webapp/jsp/report/problemHistoryReport.jsp
+1
-0
cat-home/src/main/webapp/jsp/report/problemStatics.jsp
cat-home/src/main/webapp/jsp/report/problemStatics.jsp
+1
-0
cat-home/src/test/java/com/dianping/cat/demo/TestSendMessage.java
.../src/test/java/com/dianping/cat/demo/TestSendMessage.java
+112
-0
未找到文件。
cat-consumer/src/main/java/com/dianping/cat/consumer/RealtimeConsumer.java
浏览文件 @
4b3aafab
...
...
@@ -455,9 +455,8 @@ public class RealtimeConsumer extends ContainerHolder implements MessageConsumer
boolean
result
=
m_queue
.
offer
(
tree
);
if
(!
result
)
{
// trace queue overflow
m_queueOverflow
++;
if
(
m_queueOverflow
>=
100
)
{
m_logger
.
warn
(
m_analyzer
+
" queue overflow"
);
m_queueOverflow
=
0
;
if
(
m_queueOverflow
%
1000
==
0
)
{
m_logger
.
warn
(
m_analyzer
.
getClass
().
getSimpleName
()
+
" queue overflow number "
+
m_queueOverflow
);
}
}
return
result
;
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
浏览文件 @
4b3aafab
package
com.dianping.cat.consumer.build
;
import
static
com
.
dianping
.
cat
.
consumer
.
problem
.
ProblemType
.
ERROR
;
import
static
com
.
dianping
.
cat
.
consumer
.
problem
.
ProblemType
.
FAILURE
;
import
static
com
.
dianping
.
cat
.
consumer
.
problem
.
ProblemType
.
HEARTBEAT
;
import
static
com
.
dianping
.
cat
.
consumer
.
problem
.
ProblemType
.
LONG_SERVICE
;
import
static
com
.
dianping
.
cat
.
consumer
.
problem
.
ProblemType
.
LONG_SQL
;
import
static
com
.
dianping
.
cat
.
consumer
.
problem
.
ProblemType
.
LONG_URL
;
import
static
com
.
dianping
.
cat
.
consumer
.
problem
.
ProblemType
.
LONG_CACHE
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -27,14 +19,9 @@ import com.dianping.cat.consumer.ip.TopIpAnalyzer;
import
com.dianping.cat.consumer.logview.LogviewUploader
;
import
com.dianping.cat.consumer.matrix.MatrixAnalyzer
;
import
com.dianping.cat.consumer.problem.ProblemAnalyzer
;
import
com.dianping.cat.consumer.problem.handler.ErrorHandler
;
import
com.dianping.cat.consumer.problem.handler.FailureHandler
;
import
com.dianping.cat.consumer.problem.handler.DefaultProblemHandler
;
import
com.dianping.cat.consumer.problem.handler.Handler
;
import
com.dianping.cat.consumer.problem.handler.HeartbeatHandler
;
import
com.dianping.cat.consumer.problem.handler.LongCacheHandler
;
import
com.dianping.cat.consumer.problem.handler.LongServiceHandler
;
import
com.dianping.cat.consumer.problem.handler.LongSqlHandler
;
import
com.dianping.cat.consumer.problem.handler.LongUrlHandler
;
import
com.dianping.cat.consumer.problem.handler.LongExecutionHandler
;
import
com.dianping.cat.consumer.transaction.TransactionAnalyzer
;
import
com.dianping.cat.hadoop.dal.HostinfoDao
;
import
com.dianping.cat.hadoop.dal.LogviewDao
;
...
...
@@ -66,30 +53,16 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
String
errorTypes
=
"Error,RuntimeException,Exception"
;
String
failureTypes
=
"URL,SQL,Call,Cache"
;
all
.
add
(
C
(
Handler
.
class
,
HEARTBEAT
.
getName
(),
HeartbeatHandler
.
class
));
all
.
add
(
C
(
Handler
.
class
,
ERROR
.
getName
(),
ErrorHandler
.
class
)
//
all
.
add
(
C
(
Handler
.
class
,
"DefaultHandler"
,
DefaultProblemHandler
.
class
)
//
.
config
(
E
(
"failureType"
).
value
(
failureTypes
))
//
.
config
(
E
(
"errorType"
).
value
(
errorTypes
)));
all
.
add
(
C
(
Handler
.
class
,
FAILURE
.
getName
(),
FailureHandler
.
class
)
//
.
config
(
E
(
"failureType"
).
value
(
failureTypes
)));
all
.
add
(
C
(
Handler
.
class
,
LONG_URL
.
getName
(),
LongUrlHandler
.
class
)
//
all
.
add
(
C
(
Handler
.
class
,
"LongHandler"
,
LongExecutionHandler
.
class
)
//
.
req
(
ServerConfigManager
.
class
));
all
.
add
(
C
(
Handler
.
class
,
LONG_SQL
.
getName
(),
LongSqlHandler
.
class
)
//
.
req
(
ServerConfigManager
.
class
));
all
.
add
(
C
(
Handler
.
class
,
LONG_SERVICE
.
getName
(),
LongServiceHandler
.
class
)
//
.
req
(
ServerConfigManager
.
class
));
all
.
add
(
C
(
Handler
.
class
,
LONG_CACHE
.
getName
(),
LongCacheHandler
.
class
));
all
.
add
(
C
(
ProblemAnalyzer
.
class
).
is
(
PER_LOOKUP
)
//
.
req
(
BucketManager
.
class
,
ReportDao
.
class
,
TaskDao
.
class
)
//
.
req
(
Handler
.
class
,
new
String
[]
{
FAILURE
.
getName
(),
ERROR
.
getName
(),
//
LONG_URL
.
getName
(),
LONG_SQL
.
getName
(),
LONG_SERVICE
.
getName
(),
//
LONG_CACHE
.
getName
(),
HEARTBEAT
.
getName
()
},
"m_handlers"
));
.
req
(
Handler
.
class
,
new
String
[]
{
"DefaultHandler"
,
"LongHandler"
},
"m_handlers"
));
all
.
add
(
C
(
TransactionAnalyzer
.
class
).
is
(
PER_LOOKUP
)
//
.
req
(
BucketManager
.
class
,
ReportDao
.
class
,
TaskDao
.
class
));
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/ProblemAnalyzer.java
浏览文件 @
4b3aafab
...
...
@@ -131,7 +131,6 @@ public class ProblemAnalyzer extends AbstractMessageAnalyzer<ProblemReport> impl
}
report
.
addIp
(
tree
.
getIpAddress
());
//Machine machine = findOrCreateMachine(report, tree);
Machine
machine
=
report
.
findOrCreateMachine
(
tree
.
getIpAddress
());
int
count
=
0
;
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/
Failure
Handler.java
→
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/
DefaultProblem
Handler.java
浏览文件 @
4b3aafab
...
...
@@ -7,25 +7,48 @@ import java.util.Set;
import
com.dianping.cat.consumer.problem.ProblemType
;
import
com.dianping.cat.consumer.problem.model.entity.Entry
;
import
com.dianping.cat.consumer.problem.model.entity.Machine
;
import
com.dianping.cat.message.Event
;
import
com.dianping.cat.message.Heartbeat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.spi.MessageTree
;
import
com.site.helper.Splitters
;
import
com.site.lookup.annotation.Inject
;
public
class
FailureHandler
extends
Handler
{
public
class
DefaultProblemHandler
extends
Handler
{
@Inject
private
Set
<
String
>
m_errorTypes
;
@Inject
private
Set
<
String
>
m_failureTypes
;
@Override
public
int
handle
(
Machine
machine
,
MessageTree
tree
)
{
Message
message
=
tree
.
getMessage
();
int
count
=
0
;
Message
message
=
tree
.
getMessage
();
if
(
message
instanceof
Transaction
)
{
Transaction
transaction
=
(
Transaction
)
message
;
count
+=
processTransaction
(
machine
,
(
Transaction
)
message
,
tree
);
}
else
if
(
message
instanceof
Event
)
{
count
+=
processEvent
(
machine
,
(
Event
)
message
,
tree
);
}
else
if
(
message
instanceof
Heartbeat
)
{
count
+=
processHeartbeat
(
machine
,
(
Heartbeat
)
message
,
tree
);
}
return
count
;
}
private
int
processEvent
(
Machine
machine
,
Event
message
,
MessageTree
tree
)
{
int
count
=
0
;
if
(!
message
.
getStatus
().
equals
(
Message
.
SUCCESS
)
&&
m_errorTypes
.
contains
(
message
.
getType
()))
{
String
type
=
ProblemType
.
ERROR
.
getName
();
String
status
=
message
.
getName
();
count
+=
processTransaction
(
machine
,
transaction
,
tree
);
Entry
entry
=
findOrCreatEntry
(
machine
,
type
,
status
);
updateEntry
(
tree
,
entry
,
0
);
count
++;
}
return
count
;
...
...
@@ -34,9 +57,11 @@ public class FailureHandler extends Handler {
private
int
processTransaction
(
Machine
machine
,
Transaction
transaction
,
MessageTree
tree
)
{
int
count
=
0
;
String
transactionStatus
=
transaction
.
getStatus
();
if
(!
transactionStatus
.
equals
(
Transaction
.
SUCCESS
))
{
String
type
=
transaction
.
getType
();
String
status
=
""
;
if
(
m_failureTypes
.
contains
(
type
))
{
type
=
transaction
.
getType
().
toLowerCase
();
status
=
transaction
.
getName
();
...
...
@@ -55,15 +80,30 @@ public class FailureHandler extends Handler {
for
(
Message
message
:
children
)
{
if
(
message
instanceof
Transaction
)
{
Transaction
temp
=
(
Transaction
)
message
;
count
+=
processTransaction
(
machine
,
temp
,
tree
);
count
+=
processTransaction
(
machine
,
(
Transaction
)
message
,
tree
);
}
else
if
(
message
instanceof
Event
)
{
count
+=
processEvent
(
machine
,
(
Event
)
message
,
tree
);
}
else
if
(
message
instanceof
Heartbeat
)
{
count
+=
processHeartbeat
(
machine
,
(
Heartbeat
)
message
,
tree
);
}
}
return
count
;
}
private
int
processHeartbeat
(
Machine
machine
,
Heartbeat
heartbeat
,
MessageTree
tree
)
{
String
type
=
ProblemType
.
HEARTBEAT
.
getName
();
String
status
=
heartbeat
.
getName
();
Entry
entry
=
findOrCreatEntry
(
machine
,
type
,
status
);
updateEntry
(
tree
,
entry
,
0
);
return
1
;
}
public
void
setErrorType
(
String
type
)
{
m_errorTypes
=
new
HashSet
<
String
>(
Splitters
.
by
(
','
).
noEmptyItem
().
split
(
type
));
}
public
void
setFailureType
(
String
type
)
{
m_failureTypes
=
new
HashSet
<
String
>(
Splitters
.
by
(
','
).
noEmptyItem
().
split
(
type
));
}
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/ErrorHandler.java
已删除
100644 → 0
浏览文件 @
7ab755ea
package
com.dianping.cat.consumer.problem.handler
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
com.dianping.cat.consumer.problem.ProblemType
;
import
com.dianping.cat.consumer.problem.model.entity.Entry
;
import
com.dianping.cat.consumer.problem.model.entity.Machine
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.spi.MessageTree
;
import
com.site.helper.Splitters
;
import
com.site.lookup.annotation.Inject
;
public
class
ErrorHandler
extends
Handler
{
@Inject
private
Set
<
String
>
m_errorTypes
;
@Override
public
int
handle
(
Machine
machine
,
MessageTree
tree
)
{
Message
message
=
tree
.
getMessage
();
int
count
=
0
;
if
(
message
instanceof
Transaction
)
{
Transaction
transaction
=
(
Transaction
)
message
;
count
+=
processTransaction
(
machine
,
transaction
,
tree
);
}
else
{
count
+=
processMessage
(
machine
,
message
,
tree
);
}
return
count
;
}
private
int
processMessage
(
Machine
machine
,
Message
message
,
MessageTree
tree
)
{
int
count
=
0
;
if
(!
message
.
getStatus
().
equals
(
Message
.
SUCCESS
)
&&
m_errorTypes
.
contains
(
message
.
getType
()))
{
String
type
=
ProblemType
.
ERROR
.
getName
();
String
status
=
message
.
getName
();
Entry
entry
=
findOrCreatEntry
(
machine
,
type
,
status
);
updateEntry
(
tree
,
entry
,
0
);
count
++;
}
return
count
;
}
private
int
processTransaction
(
Machine
machine
,
Transaction
transaction
,
MessageTree
tree
)
{
List
<
Message
>
children
=
transaction
.
getChildren
();
int
count
=
0
;
count
+=
processMessage
(
machine
,
transaction
,
tree
);
for
(
Message
message
:
children
)
{
if
(
message
instanceof
Transaction
)
{
Transaction
temp
=
(
Transaction
)
message
;
count
+=
processTransaction
(
machine
,
temp
,
tree
);
}
else
{
count
+=
processMessage
(
machine
,
message
,
tree
);
}
}
return
count
;
}
public
void
setErrorType
(
String
type
)
{
m_errorTypes
=
new
HashSet
<
String
>(
Splitters
.
by
(
','
).
noEmptyItem
().
split
(
type
));
}
}
\ No newline at end of file
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/Handler.java
浏览文件 @
4b3aafab
...
...
@@ -34,10 +34,11 @@ public abstract class Handler {
public
void
updateEntry
(
MessageTree
tree
,
Entry
entry
,
int
value
)
{
Duration
duration
=
entry
.
findOrCreateDuration
(
value
);
List
<
String
>
messages
=
duration
.
getMessages
();
duration
.
incCount
();
if
(
duration
.
getMessages
()
.
size
()
<
MAX_LOG_SIZE
)
{
duration
.
getMessages
()
.
add
(
tree
.
getMessageId
());
if
(
messages
.
size
()
<
MAX_LOG_SIZE
)
{
messages
.
add
(
tree
.
getMessageId
());
}
JavaThread
thread
=
entry
.
findOrCreateThread
(
tree
.
getThreadId
());
...
...
@@ -50,10 +51,11 @@ public abstract class Handler {
}
Segment
segment
=
thread
.
findOrCreateSegment
(
getSegmentByMessage
(
tree
));
List
<
String
>
segmentMessages
=
segment
.
getMessages
();
segment
.
incCount
();
if
(
segment
.
getMessages
()
.
size
()
<
MAX_LOG_SIZE
)
{
segment
.
getMessages
()
.
add
(
tree
.
getMessageId
());
if
(
segment
Messages
.
size
()
<
MAX_LOG_SIZE
)
{
segment
Messages
.
add
(
tree
.
getMessageId
());
}
}
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/HeartbeatHandler.java
已删除
100644 → 0
浏览文件 @
7ab755ea
package
com.dianping.cat.consumer.problem.handler
;
import
java.util.List
;
import
com.dianping.cat.consumer.problem.ProblemType
;
import
com.dianping.cat.consumer.problem.model.entity.Entry
;
import
com.dianping.cat.consumer.problem.model.entity.Machine
;
import
com.dianping.cat.message.Heartbeat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.spi.MessageTree
;
public
class
HeartbeatHandler
extends
Handler
{
@Override
public
int
handle
(
Machine
machine
,
MessageTree
tree
)
{
Message
message
=
tree
.
getMessage
();
int
count
=
0
;
if
(
message
instanceof
Transaction
)
{
Transaction
transaction
=
(
Transaction
)
message
;
count
+=
processTransaction
(
machine
,
transaction
,
tree
);
}
else
if
(
message
instanceof
Heartbeat
)
{
count
+=
processHeartbeat
(
machine
,
(
Heartbeat
)
message
,
tree
);
}
return
count
;
}
private
int
processHeartbeat
(
Machine
machine
,
Heartbeat
heartbeat
,
MessageTree
tree
)
{
String
type
=
ProblemType
.
HEARTBEAT
.
getName
();
String
status
=
heartbeat
.
getName
();
Entry
entry
=
findOrCreatEntry
(
machine
,
type
,
status
);
updateEntry
(
tree
,
entry
,
0
);
return
1
;
}
private
int
processTransaction
(
Machine
machine
,
Transaction
transaction
,
MessageTree
tree
)
{
List
<
Message
>
children
=
transaction
.
getChildren
();
int
count
=
0
;
for
(
Message
message
:
children
)
{
if
(
message
instanceof
Transaction
)
{
Transaction
temp
=
(
Transaction
)
message
;
count
+=
processTransaction
(
machine
,
temp
,
tree
);
}
else
if
(
message
instanceof
Heartbeat
)
{
count
+=
processHeartbeat
(
machine
,
(
Heartbeat
)
message
,
tree
);
}
}
return
count
;
}
}
\ No newline at end of file
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/LongCacheHandler.java
已删除
100644 → 0
浏览文件 @
7ab755ea
package
com.dianping.cat.consumer.problem.handler
;
import
java.util.List
;
import
com.dianping.cat.configuration.ServerConfigManager
;
import
com.dianping.cat.consumer.problem.ProblemType
;
import
com.dianping.cat.consumer.problem.model.entity.Entry
;
import
com.dianping.cat.consumer.problem.model.entity.Machine
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.spi.MessageTree
;
import
com.site.lookup.annotation.Inject
;
public
class
LongCacheHandler
extends
Handler
{
@Inject
private
ServerConfigManager
m_configManager
;
private
int
m_defaultCacheThreshold
=
10
;
private
int
processTransaction
(
Machine
machine
,
Transaction
transaction
,
MessageTree
tree
)
{
int
count
=
0
;
if
(
transaction
instanceof
Transaction
&&
transaction
.
getType
().
startsWith
(
"Cache."
))
{
long
duration
=
((
Transaction
)
transaction
).
getDurationInMillis
();
if
(
duration
>
m_defaultCacheThreshold
)
{
String
type
=
ProblemType
.
LONG_CACHE
.
getName
();
String
status
=
transaction
.
getName
();
Entry
entry
=
findOrCreatEntry
(
machine
,
type
,
status
);
updateEntry
(
tree
,
entry
,
0
);
count
++;
}
}
List
<
Message
>
messageList
=
transaction
.
getChildren
();
for
(
Message
message
:
messageList
)
{
if
(
message
instanceof
Transaction
)
{
Transaction
temp
=
(
Transaction
)
message
;
count
+=
processTransaction
(
machine
,
temp
,
tree
);
}
}
return
count
;
}
@Override
public
int
handle
(
Machine
machine
,
MessageTree
tree
)
{
Message
message
=
tree
.
getMessage
();
int
count
=
0
;
if
(
message
instanceof
Transaction
)
{
Transaction
transaction
=
(
Transaction
)
message
;
count
=
processTransaction
(
machine
,
transaction
,
tree
);
}
return
count
;
}
}
\ No newline at end of file
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/Long
Sql
Handler.java
→
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/Long
Execution
Handler.java
浏览文件 @
4b3aafab
...
...
@@ -17,51 +17,51 @@ import com.dianping.cat.message.Transaction;
import
com.dianping.cat.message.spi.MessageTree
;
import
com.site.lookup.annotation.Inject
;
public
class
Long
Sql
Handler
extends
Handler
implements
Initializable
{
public
class
Long
Execution
Handler
extends
Handler
implements
Initializable
{
@Inject
private
ServerConfigManager
m_configManager
;
// private int m_defaultSqlThreshold
;
private
int
m_defaultCacheThreshold
=
10
;
private
Map
<
String
,
Integer
>
m_thresholds
=
new
HashMap
<
String
,
Integer
>()
;
private
int
[]
m_defaultLongServiceDuration
=
{
50
,
100
,
200
}
;
private
int
[]
m_defaultLongSqlDuration
=
{
100
,
500
,
1000
};
private
int
[]
m_defaultLongSqlDuration
=
{
100
,
500
,
1000
,
2000
};
private
int
processTransaction
(
Machine
machine
,
Transaction
transaction
,
MessageTree
tree
)
{
int
count
=
0
;
String
transactionType
=
transaction
.
getType
();
private
int
[]
m_defaultLongUrlDuration
=
{
1000
,
2000
,
3000
,
4000
,
5000
};
if
(
transactionType
.
equals
(
"SQL"
))
{
long
duration
=
transaction
.
getDurationInMillis
();
String
domain
=
tree
.
getDomain
();
long
nomarizeDuration
=
getDuration
(
duration
,
domain
);
if
(
nomarizeDuration
>
0
)
{
String
type
=
ProblemType
.
LONG_SQL
.
getName
();
String
status
=
transaction
.
getName
();
Entry
entry
=
findOrCreatEntry
(
machine
,
type
,
status
);
updateEntry
(
tree
,
entry
,
(
int
)
nomarizeDuration
);
count
++;
}
}
private
Map
<
String
,
Integer
>
m_longServiceThresholds
=
new
HashMap
<
String
,
Integer
>();
List
<
Message
>
messageList
=
transaction
.
getChildren
();
private
Map
<
String
,
Integer
>
m_longSqlThresholds
=
new
HashMap
<
String
,
Integer
>
();
for
(
Message
message
:
messageList
)
{
if
(
message
instanceof
Transaction
)
{
Transaction
temp
=
(
Transaction
)
message
;
private
Map
<
String
,
Integer
>
m_longUrlThresholds
=
new
HashMap
<
String
,
Integer
>();
count
+=
processTransaction
(
machine
,
temp
,
tree
);
public
int
computeLongDuration
(
long
duration
,
String
domain
,
int
[]
m_defaultLongDuration
,
Map
<
String
,
Integer
>
longThresholds
)
{
int
[]
messageDuration
=
m_defaultLongDuration
;
for
(
int
i
=
messageDuration
.
length
-
1
;
i
>=
0
;
i
--)
{
if
(
duration
>=
messageDuration
[
i
])
{
return
messageDuration
[
i
];
}
}
return
count
;
Integer
value
=
longThresholds
.
get
(
domain
);
if
(
value
==
null
)
{
return
-
1
;
}
if
(
duration
>=
value
)
{
return
value
;
}
return
-
1
;
}
@Override
public
int
handle
(
Machine
machine
,
MessageTree
tree
)
{
Message
message
=
tree
.
getMessage
();
int
count
=
0
;
count
+=
processLongUrl
(
machine
,
tree
);
count
+=
processLongService
(
machine
,
tree
);
if
(
message
instanceof
Transaction
)
{
Transaction
transaction
=
(
Transaction
)
message
;
...
...
@@ -76,28 +76,119 @@ public class LongSqlHandler extends Handler implements Initializable {
public
void
initialize
()
throws
InitializationException
{
Map
<
String
,
Domain
>
domains
=
m_configManager
.
getLongConfigDomains
();
// m_defaultSqlThreshold = m_configManager.getLongSqlDefaultThreshold();
for
(
Domain
domain
:
domains
.
values
())
{
if
(
domain
.
getSqlThreshold
()
!=
null
)
{
m_thresholds
.
put
(
domain
.
getName
(),
domain
.
getSqlThreshold
());
Integer
serviceThreshold
=
domain
.
getServiceThreshold
();
Integer
urlThreshold
=
domain
.
getUrlThreshold
();
Integer
sqlThreshold
=
domain
.
getSqlThreshold
();
if
(
serviceThreshold
!=
null
)
{
m_longServiceThresholds
.
put
(
domain
.
getName
(),
serviceThreshold
);
}
if
(
urlThreshold
!=
null
)
{
m_longUrlThresholds
.
put
(
domain
.
getName
(),
urlThreshold
);
}
if
(
sqlThreshold
!=
null
)
{
m_longSqlThresholds
.
put
(
domain
.
getName
(),
sqlThreshold
);
}
}
}
public
int
getDuration
(
long
duration
,
String
domain
)
{
for
(
int
i
=
m_defaultLongSqlDuration
.
length
-
1
;
i
>=
0
;
i
--)
{
if
(
duration
>=
m_defaultLongSqlDuration
[
i
])
{
return
m_defaultLongSqlDuration
[
i
];
private
int
processLongCache
(
Machine
machine
,
Transaction
transaction
,
MessageTree
tree
,
int
count
)
{
long
duration
=
((
Transaction
)
transaction
).
getDurationInMillis
();
if
(
duration
>
m_defaultCacheThreshold
)
{
String
type
=
ProblemType
.
LONG_CACHE
.
getName
();
String
status
=
transaction
.
getName
();
Entry
entry
=
findOrCreatEntry
(
machine
,
type
,
status
);
updateEntry
(
tree
,
entry
,
0
);
count
++;
}
return
count
;
}
private
int
processLongService
(
Machine
machine
,
MessageTree
tree
)
{
Message
message
=
tree
.
getMessage
();
int
count
=
0
;
if
(
message
instanceof
Transaction
&&
(
"Service"
.
equals
(
message
.
getType
())
||
"PigeonService"
.
equals
(
message
.
getType
())))
{
long
duration
=
((
Transaction
)
message
).
getDurationInMillis
();
String
domain
=
tree
.
getDomain
();
long
nomarizeDuration
=
computeLongDuration
(
duration
,
domain
,
m_defaultLongServiceDuration
,
m_longServiceThresholds
);
if
(
nomarizeDuration
>
0
)
{
String
type
=
ProblemType
.
LONG_SERVICE
.
getName
();
String
status
=
message
.
getName
();
Entry
entry
=
findOrCreatEntry
(
machine
,
type
,
status
);
updateEntry
(
tree
,
entry
,
(
int
)
nomarizeDuration
);
count
++;
}
}
Integer
value
=
m_thresholds
.
get
(
domain
);
if
(
value
==
null
)
{
return
-
1
;
return
count
;
}
private
int
processLongSql
(
Machine
machine
,
Transaction
transaction
,
MessageTree
tree
,
int
count
)
{
long
duration
=
transaction
.
getDurationInMillis
();
String
domain
=
tree
.
getDomain
();
long
nomarizeDuration
=
computeLongDuration
(
duration
,
domain
,
m_defaultLongSqlDuration
,
m_longSqlThresholds
);
if
(
nomarizeDuration
>
0
)
{
String
type
=
ProblemType
.
LONG_SQL
.
getName
();
String
status
=
transaction
.
getName
();
Entry
entry
=
findOrCreatEntry
(
machine
,
type
,
status
);
updateEntry
(
tree
,
entry
,
(
int
)
nomarizeDuration
);
count
++;
}
if
(
duration
>=
value
)
{
return
value
;
return
count
;
}
private
int
processLongUrl
(
Machine
machine
,
MessageTree
tree
)
{
Message
message
=
tree
.
getMessage
();
int
count
=
0
;
if
(
message
instanceof
Transaction
&&
"URL"
.
equals
(
message
.
getType
()))
{
long
duration
=
((
Transaction
)
message
).
getDurationInMillis
();
String
domain
=
tree
.
getDomain
();
long
nomarizeDuration
=
computeLongDuration
(
duration
,
domain
,
m_defaultLongUrlDuration
,
m_longUrlThresholds
);
if
(
nomarizeDuration
>
0
)
{
String
type
=
ProblemType
.
LONG_URL
.
getName
();
String
status
=
message
.
getName
();
Entry
entry
=
findOrCreatEntry
(
machine
,
type
,
status
);
updateEntry
(
tree
,
entry
,
(
int
)
nomarizeDuration
);
count
++;
}
}
return
-
1
;
return
count
;
}
}
\ No newline at end of file
private
int
processTransaction
(
Machine
machine
,
Transaction
transaction
,
MessageTree
tree
)
{
int
count
=
0
;
String
transactionType
=
transaction
.
getType
();
if
(
transactionType
.
startsWith
(
"Cache."
))
{
count
=
processLongCache
(
machine
,
transaction
,
tree
,
count
);
}
else
if
(
transactionType
.
equals
(
"SQL"
))
{
count
=
processLongSql
(
machine
,
transaction
,
tree
,
count
);
}
List
<
Message
>
messageList
=
transaction
.
getChildren
();
for
(
Message
message
:
messageList
)
{
if
(
message
instanceof
Transaction
)
{
count
+=
processTransaction
(
machine
,
(
Transaction
)
message
,
tree
);
}
}
return
count
;
}
}
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/LongServiceHandler.java
已删除
100644 → 0
浏览文件 @
7ab755ea
package
com.dianping.cat.consumer.problem.handler
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
com.dianping.cat.configuration.ServerConfigManager
;
import
com.dianping.cat.configuration.server.entity.Domain
;
import
com.dianping.cat.consumer.problem.ProblemType
;
import
com.dianping.cat.consumer.problem.model.entity.Entry
;
import
com.dianping.cat.consumer.problem.model.entity.Machine
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.spi.MessageTree
;
import
com.site.lookup.annotation.Inject
;
public
class
LongServiceHandler
extends
Handler
implements
Initializable
{
@Inject
private
ServerConfigManager
m_configManager
;
private
Map
<
String
,
Integer
>
m_thresholds
=
new
HashMap
<
String
,
Integer
>();
private
int
[]
m_defaultLongServiceDuration
=
{
50
,
100
,
200
};
@Override
public
int
handle
(
Machine
machine
,
MessageTree
tree
)
{
Message
message
=
tree
.
getMessage
();
int
count
=
0
;
if
(
message
instanceof
Transaction
&&
(
"Service"
.
equals
(
message
.
getType
())
||
"PigeonService"
.
equals
(
message
.
getType
())))
{
long
duration
=
((
Transaction
)
message
).
getDurationInMillis
();
String
domain
=
tree
.
getDomain
();
long
nomarizeDuration
=
getDuration
(
duration
,
domain
);
if
(
nomarizeDuration
>
0
)
{
String
type
=
ProblemType
.
LONG_SERVICE
.
getName
();
String
status
=
message
.
getName
();
Entry
entry
=
findOrCreatEntry
(
machine
,
type
,
status
);
updateEntry
(
tree
,
entry
,
(
int
)
nomarizeDuration
);
count
++;
}
}
return
count
;
}
@Override
public
void
initialize
()
throws
InitializationException
{
Map
<
String
,
Domain
>
domains
=
m_configManager
.
getLongConfigDomains
();
for
(
Domain
domain
:
domains
.
values
())
{
if
(
domain
.
getServiceThreshold
()
!=
null
)
{
m_thresholds
.
put
(
domain
.
getName
(),
domain
.
getUrlThreshold
());
}
}
}
public
int
getDuration
(
long
duration
,
String
domain
)
{
for
(
int
i
=
m_defaultLongServiceDuration
.
length
-
1
;
i
>=
0
;
i
--)
{
if
(
duration
>=
m_defaultLongServiceDuration
[
i
])
{
return
m_defaultLongServiceDuration
[
i
];
}
}
Integer
value
=
m_thresholds
.
get
(
domain
);
if
(
value
==
null
)
{
return
-
1
;
}
if
(
duration
>=
value
)
{
return
value
;
}
return
-
1
;
}
}
\ No newline at end of file
cat-consumer/src/main/java/com/dianping/cat/consumer/problem/handler/LongUrlHandler.java
已删除
100644 → 0
浏览文件 @
7ab755ea
package
com.dianping.cat.consumer.problem.handler
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
com.dianping.cat.configuration.ServerConfigManager
;
import
com.dianping.cat.configuration.server.entity.Domain
;
import
com.dianping.cat.consumer.problem.ProblemType
;
import
com.dianping.cat.consumer.problem.model.entity.Entry
;
import
com.dianping.cat.consumer.problem.model.entity.Machine
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.spi.MessageTree
;
import
com.site.lookup.annotation.Inject
;
public
class
LongUrlHandler
extends
Handler
implements
Initializable
{
@Inject
private
ServerConfigManager
m_configManager
;
// private int m_defaultUrlThreshold;
private
Map
<
String
,
Integer
>
m_thresholds
=
new
HashMap
<
String
,
Integer
>();
private
int
[]
m_defaultLongUrlDuration
=
{
1000
,
2000
,
3000
,
4000
,
5000
};
@Override
public
int
handle
(
Machine
machine
,
MessageTree
tree
)
{
Message
message
=
tree
.
getMessage
();
int
count
=
0
;
if
(
message
instanceof
Transaction
&&
"URL"
.
equals
(
message
.
getType
()))
{
long
duration
=
((
Transaction
)
message
).
getDurationInMillis
();
String
domain
=
tree
.
getDomain
();
long
nomarizeDuration
=
getDuration
(
duration
,
domain
);
if
(
nomarizeDuration
>
0
)
{
String
type
=
ProblemType
.
LONG_URL
.
getName
();
String
status
=
message
.
getName
();
Entry
entry
=
findOrCreatEntry
(
machine
,
type
,
status
);
updateEntry
(
tree
,
entry
,
(
int
)
nomarizeDuration
);
count
++;
}
}
return
count
;
}
@Override
public
void
initialize
()
throws
InitializationException
{
Map
<
String
,
Domain
>
domains
=
m_configManager
.
getLongConfigDomains
();
// m_defaultUrlThreshold = m_configManager.getLongUrlDefaultThreshold();
for
(
Domain
domain
:
domains
.
values
())
{
if
(
domain
.
getUrlThreshold
()
!=
null
)
{
m_thresholds
.
put
(
domain
.
getName
(),
domain
.
getUrlThreshold
());
}
}
}
public
int
getDuration
(
long
duration
,
String
domain
)
{
for
(
int
i
=
m_defaultLongUrlDuration
.
length
-
1
;
i
>=
0
;
i
--)
{
if
(
duration
>=
m_defaultLongUrlDuration
[
i
])
{
return
m_defaultLongUrlDuration
[
i
];
}
}
Integer
value
=
m_thresholds
.
get
(
domain
);
if
(
value
==
null
)
{
return
-
1
;
}
if
(
duration
>=
value
)
{
return
value
;
}
return
-
1
;
}
}
\ No newline at end of file
cat-consumer/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
4b3aafab
...
...
@@ -23,60 +23,23 @@
</component>
<component>
<role>
com.dianping.cat.consumer.problem.handler.Handler
</role>
<role-hint>
heartbeat
</role-hint>
<implementation>
com.dianping.cat.consumer.problem.handler.HeartbeatHandler
</implementation>
</component>
<component>
<role>
com.dianping.cat.consumer.problem.handler.Handler
</role>
<role-hint>
error
</role-hint>
<implementation>
com.dianping.cat.consumer.problem.handler.ErrorHandler
</implementation>
<configuration>
<errorType>
Error,RuntimeException,Exception
</errorType>
</configuration>
</component>
<component>
<role>
com.dianping.cat.consumer.problem.handler.Handler
</role>
<role-hint>
failure
</role-hint>
<implementation>
com.dianping.cat.consumer.problem.handler.FailureHandler
</implementation>
<role-hint>
DefaultHandler
</role-hint>
<implementation>
com.dianping.cat.consumer.problem.handler.DefaultProblemHandler
</implementation>
<configuration>
<failureType>
URL,SQL,Call,Cache
</failureType>
<errorType>
Error,RuntimeException,Exception
</errorType>
</configuration>
</component>
<component>
<role>
com.dianping.cat.consumer.problem.handler.Handler
</role>
<role-hint>
long-url
</role-hint>
<implementation>
com.dianping.cat.consumer.problem.handler.Long
Url
Handler
</implementation>
<role-hint>
LongHandler
</role-hint>
<implementation>
com.dianping.cat.consumer.problem.handler.Long
Execution
Handler
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.configuration.ServerConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.consumer.problem.handler.Handler
</role>
<role-hint>
long-sql
</role-hint>
<implementation>
com.dianping.cat.consumer.problem.handler.LongSqlHandler
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.configuration.ServerConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.consumer.problem.handler.Handler
</role>
<role-hint>
long-service
</role-hint>
<implementation>
com.dianping.cat.consumer.problem.handler.LongServiceHandler
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.configuration.ServerConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.consumer.problem.handler.Handler
</role>
<role-hint>
long-cache
</role-hint>
<implementation>
com.dianping.cat.consumer.problem.handler.LongCacheHandler
</implementation>
</component>
<component>
<role>
com.dianping.cat.consumer.problem.ProblemAnalyzer
</role>
<implementation>
com.dianping.cat.consumer.problem.ProblemAnalyzer
</implementation>
...
...
@@ -94,13 +57,8 @@
<requirement>
<role>
com.dianping.cat.consumer.problem.handler.Handler
</role>
<role-hints>
<role-hint>
failure
</role-hint>
<role-hint>
error
</role-hint>
<role-hint>
long-url
</role-hint>
<role-hint>
long-sql
</role-hint>
<role-hint>
long-service
</role-hint>
<role-hint>
long-cache
</role-hint>
<role-hint>
heartbeat
</role-hint>
<role-hint>
DefaultHandler
</role-hint>
<role-hint>
LongHandler
</role-hint>
</role-hints>
<field-name>
m_handlers
</field-name>
</requirement>
...
...
cat-consumer/src/test/java/com/dianping/cat/consumer/problem/handler/DefaultHandlerTest.java
0 → 100644
浏览文件 @
4b3aafab
package
com.dianping.cat.consumer.problem.handler
;
import
java.util.HashMap
;
import
java.util.Map
;
import
junit.framework.Assert
;
import
org.junit.Test
;
public
class
DefaultHandlerTest
{
private
LongExecutionHandler
m_handler
;
private
int
[]
m_defaultLongUrlDuration
=
{
1000
,
2000
,
3000
,
4000
,
5000
};
private
Map
<
String
,
Integer
>
m_longUrlThresholds
=
new
HashMap
<
String
,
Integer
>();
@Test
public
void
testHandler
()
{
m_handler
=
new
LongExecutionHandler
();
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
Assert
.
assertEquals
(-
1
,
m_handler
.
computeLongDuration
(
i
,
"domain"
,
m_defaultLongUrlDuration
,
m_longUrlThresholds
));
}
for
(
int
i
=
1000
;
i
<
2000
;
i
++)
{
Assert
.
assertEquals
(
1000
,
m_handler
.
computeLongDuration
(
i
,
"domain"
,
m_defaultLongUrlDuration
,
m_longUrlThresholds
));
}
for
(
int
i
=
2000
;
i
<
3000
;
i
++)
{
Assert
.
assertEquals
(
2000
,
m_handler
.
computeLongDuration
(
i
,
"domain"
,
m_defaultLongUrlDuration
,
m_longUrlThresholds
));
}
for
(
int
i
=
3000
;
i
<
4000
;
i
++)
{
Assert
.
assertEquals
(
3000
,
m_handler
.
computeLongDuration
(
i
,
"domain"
,
m_defaultLongUrlDuration
,
m_longUrlThresholds
));
}
for
(
int
i
=
4000
;
i
<
5000
;
i
++)
{
Assert
.
assertEquals
(
4000
,
m_handler
.
computeLongDuration
(
i
,
"domain"
,
m_defaultLongUrlDuration
,
m_longUrlThresholds
));
}
for
(
int
i
=
5000
;
i
<
8000
;
i
++)
{
Assert
.
assertEquals
(
5000
,
m_handler
.
computeLongDuration
(
i
,
"domain"
,
m_defaultLongUrlDuration
,
m_longUrlThresholds
));
}
}
}
cat-consumer/src/test/java/com/dianping/cat/consumer/problem/handler/LongurlHandlerTest.java
已删除
100644 → 0
浏览文件 @
7ab755ea
package
com.dianping.cat.consumer.problem.handler
;
import
junit.framework.Assert
;
import
org.junit.Test
;
public
class
LongurlHandlerTest
{
private
LongUrlHandler
m_handler
;
@Test
public
void
testHandler
(){
m_handler
=
new
LongUrlHandler
();
for
(
int
i
=
0
;
i
<
1000
;
i
++){
Assert
.
assertEquals
(-
1
,
m_handler
.
getDuration
(
i
,
"domain"
));
}
for
(
int
i
=
1000
;
i
<
2000
;
i
++){
Assert
.
assertEquals
(
1000
,
m_handler
.
getDuration
(
i
,
"domain"
));
}
for
(
int
i
=
2000
;
i
<
3000
;
i
++){
Assert
.
assertEquals
(
2000
,
m_handler
.
getDuration
(
i
,
"domain"
));
}
for
(
int
i
=
3000
;
i
<
4000
;
i
++){
Assert
.
assertEquals
(
3000
,
m_handler
.
getDuration
(
i
,
"domain"
));
}
for
(
int
i
=
4000
;
i
<
5000
;
i
++){
Assert
.
assertEquals
(
4000
,
m_handler
.
getDuration
(
i
,
"domain"
));
}
for
(
int
i
=
5000
;
i
<
8000
;
i
++){
Assert
.
assertEquals
(
5000
,
m_handler
.
getDuration
(
i
,
"domain"
));
}
}
}
cat-home/src/main/java/com/dianping/cat/report/ReportModule.java
浏览文件 @
4b3aafab
...
...
@@ -35,7 +35,9 @@ com.dianping.cat.report.page.matrix.Handler.class,
com
.
dianping
.
cat
.
report
.
page
.
monthreport
.
Handler
.
class
,
com
.
dianping
.
cat
.
report
.
page
.
cross
.
Handler
.
class
com
.
dianping
.
cat
.
report
.
page
.
cross
.
Handler
.
class
,
com
.
dianping
.
cat
.
report
.
page
.
cache
.
Handler
.
class
})
public
class
ReportModule
extends
AbstractModule
{
...
...
cat-home/src/main/java/com/dianping/cat/report/ReportPage.java
浏览文件 @
4b3aafab
...
...
@@ -33,7 +33,9 @@ public enum ReportPage implements Page {
MONTHREPORT
(
"monthreport"
,
"monthreport"
,
"Monthreport"
,
"Monthreport"
,
false
),
CROSS
(
"cross"
,
"cross"
,
"Cross"
,
"Cross"
,
true
);
CROSS
(
"cross"
,
"cross"
,
"Cross"
,
"Cross"
,
true
),
CACHE
(
"cache"
,
"cache"
,
"Cache"
,
"Cache"
,
true
);
private
String
m_name
;
...
...
cat-home/src/main/java/com/dianping/cat/report/graph/DefaultValueTranslater.java
浏览文件 @
4b3aafab
...
...
@@ -38,8 +38,12 @@ public class DefaultValueTranslater implements ValueTranslater {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
double
value
=
values
[
i
];
double
temp
=
value
*
height
/
maxValue
;
result
[
i
]
=
(
int
)
(
value
*
height
/
maxValue
);
if
(
temp
>
0
&&
temp
<
1
)
{
temp
=
1
;
}
result
[
i
]
=
(
int
)
temp
;
}
return
result
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/cache/Action.java
0 → 100644
浏览文件 @
4b3aafab
package
com.dianping.cat.report.page.cache
;
public
enum
Action
implements
com
.
site
.
web
.
mvc
.
Action
{
HOURLY_REPORT
(
"view"
),
HISTORY_REPORT
(
"history"
);
private
String
m_name
;
private
Action
(
String
name
)
{
m_name
=
name
;
}
public
static
Action
getByName
(
String
name
,
Action
defaultAction
)
{
for
(
Action
action
:
Action
.
values
())
{
if
(
action
.
getName
().
equals
(
name
))
{
return
action
;
}
}
return
defaultAction
;
}
@Override
public
String
getName
()
{
return
m_name
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/cache/CacheReport.java
0 → 100644
浏览文件 @
4b3aafab
package
com.dianping.cat.report.page.cache
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
com.dianping.cat.consumer.event.model.entity.EventName
;
import
com.dianping.cat.consumer.event.model.entity.EventType
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionName
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionType
;
public
class
CacheReport
{
private
String
m_domain
;
private
Set
<
String
>
m_domains
;
private
java
.
util
.
Date
m_startTime
;
private
java
.
util
.
Date
m_endTime
;
private
Set
<
String
>
m_domainNames
=
new
LinkedHashSet
<
String
>();
private
Set
<
String
>
m_ips
=
new
LinkedHashSet
<
String
>();
private
Map
<
String
,
CacheTypeItem
>
m_typeItems
=
new
HashMap
<
String
,
CacheTypeItem
>();
private
Map
<
String
,
CacheNameItem
>
m_nameItems
=
new
HashMap
<
String
,
CacheNameItem
>();
private
String
m_sortBy
;
public
void
addNewTypeItem
(
TransactionType
transactionType
,
EventType
eventType
)
{
String
key
=
transactionType
.
getId
();
CacheTypeItem
item
=
m_typeItems
.
get
(
key
);
if
(
item
==
null
)
{
item
=
new
CacheTypeItem
();
item
.
setType
(
transactionType
);
item
.
setMissed
(
eventType
.
getTotalCount
());
item
.
setHited
((
double
)
eventType
.
getTotalCount
()
/
transactionType
.
getTotalCount
());
m_typeItems
.
put
(
key
,
item
);
}
}
public
void
addNewNameItem
(
TransactionName
transactionName
,
EventName
eventName
)
{
String
key
=
transactionName
.
getId
();
CacheNameItem
item
=
m_nameItems
.
get
(
key
);
if
(
item
==
null
)
{
item
=
new
CacheNameItem
();
item
.
setName
(
transactionName
);
item
.
setMissed
(
eventName
.
getTotalCount
());
item
.
setHited
((
double
)
eventName
.
getTotalCount
()
/
transactionName
.
getTotalCount
());
m_nameItems
.
put
(
key
,
item
);
}
}
public
String
getDomain
()
{
return
m_domain
;
}
public
void
setDomain
(
String
domain
)
{
m_domain
=
domain
;
}
public
Set
<
String
>
getDomains
()
{
return
m_domains
;
}
public
void
setDomains
(
Set
<
String
>
domains
)
{
m_domains
=
domains
;
}
public
java
.
util
.
Date
getStartTime
()
{
return
m_startTime
;
}
public
void
setStartTime
(
java
.
util
.
Date
startTime
)
{
m_startTime
=
startTime
;
}
public
java
.
util
.
Date
getEndTime
()
{
return
m_endTime
;
}
public
void
setEndTime
(
java
.
util
.
Date
endTime
)
{
m_endTime
=
endTime
;
}
public
Set
<
String
>
getDomainNames
()
{
return
m_domainNames
;
}
public
void
setDomainNames
(
Set
<
String
>
domainNames
)
{
m_domainNames
=
domainNames
;
}
public
Set
<
String
>
getIps
()
{
return
m_ips
;
}
public
void
setIps
(
Set
<
String
>
ips
)
{
m_ips
=
ips
;
}
public
List
<
CacheNameItem
>
getNameItems
()
{
List
<
CacheNameItem
>
result
=
new
ArrayList
<
CacheNameItem
>(
m_nameItems
.
values
());
Collections
.
sort
(
result
,
new
CacheNameItemCompator
(
m_sortBy
));
return
result
;
}
public
List
<
CacheTypeItem
>
getTypeItems
()
{
List
<
CacheTypeItem
>
result
=
new
ArrayList
<
CacheTypeItem
>(
m_typeItems
.
values
());
Collections
.
sort
(
result
,
new
CacheTypeItemCompator
(
m_sortBy
));
return
result
;
}
public
static
class
CacheNameItem
{
private
TransactionName
m_name
;
private
long
m_missed
;
private
double
m_hited
;
public
TransactionName
getName
()
{
return
m_name
;
}
public
void
setName
(
TransactionName
name
)
{
m_name
=
name
;
}
public
long
getMissed
()
{
return
m_missed
;
}
public
void
setMissed
(
long
missed
)
{
m_missed
=
missed
;
}
public
double
getHited
()
{
return
m_hited
;
}
public
void
setHited
(
double
hited
)
{
m_hited
=
hited
;
}
}
public
static
class
CacheTypeItem
{
private
TransactionType
m_type
;
private
long
m_missed
;
private
double
m_hited
;
public
TransactionType
getType
()
{
return
m_type
;
}
public
void
setType
(
TransactionType
type
)
{
m_type
=
type
;
}
public
long
getMissed
()
{
return
m_missed
;
}
public
void
setMissed
(
long
missed
)
{
m_missed
=
missed
;
}
public
double
getHited
()
{
return
m_hited
;
}
public
void
setHited
(
double
hited
)
{
m_hited
=
hited
;
}
}
public
void
setSortBy
(
String
sortBy
)
{
m_sortBy
=
sortBy
;
}
public
static
class
CacheTypeItemCompator
implements
Comparator
<
CacheTypeItem
>
{
private
String
m_sort
;
private
CacheTypeItemCompator
(
String
sort
)
{
m_sort
=
sort
;
}
@Override
public
int
compare
(
CacheTypeItem
o1
,
CacheTypeItem
o2
)
{
if
(
m_sort
.
equals
(
"total"
))
{
return
(
int
)
(
o2
.
getType
().
getTotalCount
()
-
o1
.
getType
().
getTotalCount
());
}
else
if
(
m_sort
.
equals
(
"missed"
))
{
return
(
int
)
(
o2
.
getMissed
()
-
o1
.
getMissed
());
}
else
if
(
m_sort
.
equals
(
"hitPercent"
))
{
return
(
int
)
(
o2
.
getHited
()
*
100
-
o1
.
getHited
()
*
100
);
}
else
if
(
m_sort
.
equals
(
"avg"
))
{
return
(
int
)
(
o2
.
getType
().
getAvg
()
*
100
-
o1
.
getType
().
getAvg
()
*
100
);
}
else
if
(
m_sort
.
equals
(
"type"
))
{
return
o1
.
getType
().
getId
().
compareTo
(
o2
.
getType
().
getId
());
}
return
0
;
}
}
public
static
class
CacheNameItemCompator
implements
Comparator
<
CacheNameItem
>
{
private
String
m_sort
;
private
CacheNameItemCompator
(
String
sort
)
{
m_sort
=
sort
;
}
@Override
public
int
compare
(
CacheNameItem
o1
,
CacheNameItem
o2
)
{
if
(
m_sort
.
equals
(
"total"
))
{
return
(
int
)
(
o2
.
getName
().
getTotalCount
()
-
o1
.
getName
().
getTotalCount
());
}
else
if
(
m_sort
.
equals
(
"missed"
))
{
return
(
int
)
(
o2
.
getMissed
()
-
o1
.
getMissed
());
}
else
if
(
m_sort
.
equals
(
"hitPercent"
))
{
return
(
int
)
(
o2
.
getHited
()
*
100
-
o1
.
getHited
()
*
100
);
}
else
if
(
m_sort
.
equals
(
"avg"
))
{
return
(
int
)
(
o2
.
getName
().
getAvg
()
*
100
-
o1
.
getName
().
getAvg
()
*
100
);
}
else
if
(
m_sort
.
equals
(
"name"
))
{
return
o1
.
getName
().
getId
().
compareTo
(
o2
.
getName
().
getId
());
}
return
0
;
}
}
}
cat-home/src/main/java/com/dianping/cat/report/page/cache/Context.java
0 → 100644
浏览文件 @
4b3aafab
package
com.dianping.cat.report.page.cache
;
import
com.dianping.cat.report.ReportContext
;
public
class
Context
extends
ReportContext
<
Payload
>
{
}
cat-home/src/main/java/com/dianping/cat/report/page/cache/Handler.java
0 → 100644
浏览文件 @
4b3aafab
package
com.dianping.cat.report.page.cache
;
import
java.io.IOException
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
javax.servlet.ServletException
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.configuration.ServerConfigManager
;
import
com.dianping.cat.consumer.event.model.entity.EventReport
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
import
com.dianping.cat.consumer.transaction.model.transform.DefaultSaxParser
;
import
com.dianping.cat.hadoop.dal.Dailyreport
;
import
com.dianping.cat.hadoop.dal.DailyreportDao
;
import
com.dianping.cat.hadoop.dal.DailyreportEntity
;
import
com.dianping.cat.hadoop.dal.Report
;
import
com.dianping.cat.hadoop.dal.ReportDao
;
import
com.dianping.cat.hadoop.dal.ReportEntity
;
import
com.dianping.cat.helper.CatString
;
import
com.dianping.cat.report.ReportPage
;
import
com.dianping.cat.report.page.model.event.EventReportMerger
;
import
com.dianping.cat.report.page.model.spi.ModelRequest
;
import
com.dianping.cat.report.page.model.spi.ModelResponse
;
import
com.dianping.cat.report.page.model.spi.ModelService
;
import
com.dianping.cat.report.page.model.transaction.TransactionReportMerger
;
import
com.dianping.cat.report.task.TaskHelper
;
import
com.dianping.cat.report.task.event.EventMerger
;
import
com.dianping.cat.report.task.transaction.TransactionMerger
;
import
com.site.dal.jdbc.DalException
;
import
com.site.lookup.annotation.Inject
;
import
com.site.lookup.util.StringUtils
;
import
com.site.web.mvc.PageHandler
;
import
com.site.web.mvc.annotation.InboundActionMeta
;
import
com.site.web.mvc.annotation.OutboundActionMeta
;
import
com.site.web.mvc.annotation.PayloadMeta
;
public
class
Handler
implements
PageHandler
<
Context
>
{
@Inject
private
JspViewer
m_jspViewer
;
@Inject
protected
ReportDao
m_reportDao
;
@Inject
private
DailyreportDao
m_dailyreportDao
;
@Inject
private
EventMerger
m_eventMerger
;
@Inject
private
TransactionMerger
m_transactionMerger
;
@Inject
private
ServerConfigManager
m_manager
;
@Inject
(
type
=
ModelService
.
class
,
value
=
"transaction"
)
private
ModelService
<
TransactionReport
>
m_transactionService
;
@Inject
(
type
=
ModelService
.
class
,
value
=
"event"
)
private
ModelService
<
EventReport
>
m_eventService
;
@Override
@PayloadMeta
(
Payload
.
class
)
@InboundActionMeta
(
name
=
"cache"
)
public
void
handleInbound
(
Context
ctx
)
throws
ServletException
,
IOException
{
// display only, no action here
}
@Override
@OutboundActionMeta
(
name
=
"cache"
)
public
void
handleOutbound
(
Context
ctx
)
throws
ServletException
,
IOException
{
Model
model
=
new
Model
(
ctx
);
Payload
payload
=
ctx
.
getPayload
();
normalize
(
model
,
payload
);
switch
(
payload
.
getAction
())
{
case
HOURLY_REPORT:
TransactionReport
transactionReport
=
getHourlyTransactionReport
(
payload
);
EventReport
eventReport
=
getHourlyEventReport
(
payload
);
CacheReport
cacheReport
=
buildCacheReport
(
transactionReport
,
eventReport
,
payload
.
getType
(),
payload
.
getSortBy
());
model
.
setReport
(
cacheReport
);
break
;
case
HISTORY_REPORT:
TransactionReport
transactionHistoryReport
=
getHistoryTransactionReport
(
payload
);
EventReport
eventHistoryReport
=
getHistoryEventReport
(
payload
);
CacheReport
cacheHistoryReport
=
buildCacheReport
(
transactionHistoryReport
,
eventHistoryReport
,
payload
.
getType
(),
payload
.
getSortBy
());
model
.
setReport
(
cacheHistoryReport
);
break
;
}
m_jspViewer
.
view
(
ctx
,
model
);
}
private
void
normalize
(
Model
model
,
Payload
payload
)
{
if
(
StringUtils
.
isEmpty
(
payload
.
getDomain
()))
{
payload
.
setDomain
(
m_manager
.
getConsoleDefaultDomain
());
}
String
ip
=
payload
.
getIpAddress
();
if
(
StringUtils
.
isEmpty
(
ip
))
{
payload
.
setIpAddress
(
CatString
.
ALL_IP
);
}
model
.
setIpAddress
(
payload
.
getIpAddress
());
model
.
setAction
(
payload
.
getAction
());
model
.
setPage
(
ReportPage
.
CACHE
);
model
.
setDisplayDomain
(
payload
.
getDomain
());
if
(
payload
.
getPeriod
().
isCurrent
())
{
model
.
setCreatTime
(
new
Date
());
}
else
{
model
.
setCreatTime
(
new
Date
(
payload
.
getDate
()
+
60
*
60
*
1000
-
1000
));
}
if
(
payload
.
getAction
()
==
Action
.
HISTORY_REPORT
)
{
String
type
=
payload
.
getReportType
();
if
(
type
==
null
||
type
.
length
()
==
0
)
{
payload
.
setReportType
(
"day"
);
}
model
.
setReportType
(
payload
.
getReportType
());
payload
.
computeStartDate
();
model
.
setLongDate
(
payload
.
getDate
());
model
.
setCustomDate
(
payload
.
getHistoryStartDate
(),
payload
.
getHistoryEndDate
());
}
}
private
CacheReport
buildCacheReport
(
TransactionReport
transactionReport
,
EventReport
eventReport
,
String
type
,
String
sortBy
)
{
TransactionReportVistor
vistor
=
new
TransactionReportVistor
();
vistor
.
setType
(
type
).
setSortBy
(
sortBy
);
vistor
.
setEventReport
(
eventReport
);
vistor
.
visitTransactionReport
(
transactionReport
);
return
vistor
.
getCacheReport
();
}
private
TransactionReport
getHourlyTransactionReport
(
Payload
payload
)
{
String
domain
=
payload
.
getDomain
();
String
date
=
String
.
valueOf
(
payload
.
getDate
());
String
ipAddress
=
payload
.
getIpAddress
();
String
type
=
payload
.
getType
();
ModelRequest
request
=
new
ModelRequest
(
domain
,
payload
.
getPeriod
())
//
.
setProperty
(
"date"
,
date
)
//
.
setProperty
(
"ip"
,
ipAddress
);
if
(
StringUtils
.
isEmpty
(
type
))
{
request
.
setProperty
(
"type"
,
"Cache.web"
);
ModelResponse
<
TransactionReport
>
response
=
m_transactionService
.
invoke
(
request
);
TransactionReport
webCacheReport
=
response
.
getModel
();
request
.
setProperty
(
"type"
,
"Cache.memcached"
);
ModelResponse
<
TransactionReport
>
memcachedResponse
=
m_transactionService
.
invoke
(
request
);
TransactionReport
memcachedReport
=
memcachedResponse
.
getModel
();
request
.
setProperty
(
"type"
,
"Cache.kvdb"
);
ModelResponse
<
TransactionReport
>
kvdbResponse
=
m_transactionService
.
invoke
(
request
);
TransactionReport
kvdbReport
=
kvdbResponse
.
getModel
();
TransactionReportMerger
merger
=
new
TransactionReportMerger
(
new
TransactionReport
(
domain
));
merger
.
visitTransactionReport
(
webCacheReport
);
merger
.
visitTransactionReport
(
memcachedReport
);
merger
.
visitTransactionReport
(
kvdbReport
);
return
merger
.
getTransactionReport
();
}
else
{
request
.
setProperty
(
"type"
,
type
);
ModelResponse
<
TransactionReport
>
response
=
m_transactionService
.
invoke
(
request
);
return
response
.
getModel
();
}
}
private
EventReport
getHourlyEventReport
(
Payload
payload
)
{
String
domain
=
payload
.
getDomain
();
String
date
=
String
.
valueOf
(
payload
.
getDate
());
String
ipAddress
=
payload
.
getIpAddress
();
String
type
=
payload
.
getType
();
ModelRequest
request
=
new
ModelRequest
(
domain
,
payload
.
getPeriod
())
//
.
setProperty
(
"date"
,
date
)
//
.
setProperty
(
"ip"
,
ipAddress
);
if
(
StringUtils
.
isEmpty
(
type
))
{
request
.
setProperty
(
"type"
,
"Cache.web"
);
ModelResponse
<
EventReport
>
response
=
m_eventService
.
invoke
(
request
);
EventReport
webCacheReport
=
response
.
getModel
();
request
.
setProperty
(
"type"
,
"Cache.memcached"
);
ModelResponse
<
EventReport
>
memcachedResponse
=
m_eventService
.
invoke
(
request
);
EventReport
memcachedReport
=
memcachedResponse
.
getModel
();
request
.
setProperty
(
"type"
,
"Cache.kvdb"
);
ModelResponse
<
EventReport
>
kvdbResponse
=
m_eventService
.
invoke
(
request
);
EventReport
kvdbReport
=
kvdbResponse
.
getModel
();
EventReportMerger
merger
=
new
EventReportMerger
(
new
EventReport
(
domain
));
merger
.
visitEventReport
(
webCacheReport
);
merger
.
visitEventReport
(
memcachedReport
);
merger
.
visitEventReport
(
kvdbReport
);
return
merger
.
getEventReport
();
}
else
{
request
.
setProperty
(
"type"
,
type
);
ModelResponse
<
EventReport
>
response
=
m_eventService
.
invoke
(
request
);
return
response
.
getModel
();
}
}
private
TransactionReport
getHistoryTransactionReport
(
Payload
payload
)
{
String
domain
=
payload
.
getDomain
();
Date
start
=
payload
.
getHistoryStartDate
();
Date
end
=
payload
.
getHistoryEndDate
();
Date
currentDayStart
=
TaskHelper
.
todayZero
(
new
Date
());
TransactionReport
transactionReport
=
null
;
if
(
currentDayStart
.
getTime
()
==
start
.
getTime
())
{
try
{
List
<
Report
>
reports
=
m_reportDao
.
findAllByDomainNameDuration
(
start
,
end
,
domain
,
"transaction"
,
ReportEntity
.
READSET_FULL
);
List
<
Report
>
allReports
=
m_reportDao
.
findAllByDomainNameDuration
(
start
,
end
,
null
,
null
,
ReportEntity
.
READSET_DOMAIN_NAME
);
Set
<
String
>
domains
=
new
HashSet
<
String
>();
for
(
Report
report
:
allReports
)
{
domains
.
add
(
report
.
getDomain
());
}
transactionReport
=
m_transactionMerger
.
mergeForDaily
(
domain
,
reports
,
domains
);
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
}
}
else
{
try
{
List
<
Dailyreport
>
reports
=
m_dailyreportDao
.
findAllByDomainNameDuration
(
start
,
end
,
domain
,
"transaction"
,
DailyreportEntity
.
READSET_FULL
);
TransactionReportMerger
merger
=
new
TransactionReportMerger
(
new
TransactionReport
(
domain
));
for
(
Dailyreport
report
:
reports
)
{
String
xml
=
report
.
getContent
();
TransactionReport
reportModel
=
DefaultSaxParser
.
parse
(
xml
);
reportModel
.
accept
(
merger
);
}
transactionReport
=
merger
.
getTransactionReport
();
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
if
(
transactionReport
!=
null
)
{
transactionReport
.
setStartTime
(
start
);
transactionReport
.
setEndTime
(
end
);
}
return
transactionReport
;
}
private
EventReport
getHistoryEventReport
(
Payload
payload
)
{
String
domain
=
payload
.
getDomain
();
Date
start
=
payload
.
getHistoryStartDate
();
Date
end
=
payload
.
getHistoryEndDate
();
Date
currentDayStart
=
TaskHelper
.
todayZero
(
new
Date
());
EventReport
eventReport
=
null
;
if
(
currentDayStart
.
getTime
()
==
start
.
getTime
())
{
try
{
List
<
Report
>
reports
=
m_reportDao
.
findAllByDomainNameDuration
(
start
,
end
,
domain
,
"event"
,
ReportEntity
.
READSET_FULL
);
List
<
Report
>
allReports
=
m_reportDao
.
findAllByDomainNameDuration
(
start
,
end
,
null
,
null
,
ReportEntity
.
READSET_DOMAIN_NAME
);
Set
<
String
>
domains
=
new
HashSet
<
String
>();
for
(
Report
report
:
allReports
)
{
domains
.
add
(
report
.
getDomain
());
}
eventReport
=
m_eventMerger
.
mergeForDaily
(
domain
,
reports
,
domains
);
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
}
}
else
{
try
{
List
<
Dailyreport
>
reports
=
m_dailyreportDao
.
findAllByDomainNameDuration
(
start
,
end
,
domain
,
"event"
,
DailyreportEntity
.
READSET_FULL
);
EventReportMerger
merger
=
new
EventReportMerger
(
new
EventReport
(
domain
));
for
(
Dailyreport
report
:
reports
)
{
String
xml
=
report
.
getContent
();
EventReport
reportModel
=
com
.
dianping
.
cat
.
consumer
.
event
.
model
.
transform
.
DefaultSaxParser
.
parse
(
xml
);
reportModel
.
accept
(
merger
);
}
eventReport
=
merger
.
getEventReport
();
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
if
(
eventReport
!=
null
)
{
eventReport
.
setStartTime
(
start
);
eventReport
.
setEndTime
(
end
);
}
return
eventReport
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/cache/JspFile.java
0 → 100644
浏览文件 @
4b3aafab
package
com.dianping.cat.report.page.cache
;
public
enum
JspFile
{
HOURLY_REPORT
(
"/jsp/report/cache.jsp"
),
HISTORY_REPORT
(
"/jsp/report/cacheHistory.jsp"
),
;
private
String
m_path
;
private
JspFile
(
String
path
)
{
m_path
=
path
;
}
public
String
getPath
()
{
return
m_path
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/cache/JspViewer.java
0 → 100644
浏览文件 @
4b3aafab
package
com.dianping.cat.report.page.cache
;
import
com.dianping.cat.report.ReportPage
;
import
com.site.web.mvc.view.BaseJspViewer
;
public
class
JspViewer
extends
BaseJspViewer
<
ReportPage
,
Action
,
Context
,
Model
>
{
@Override
protected
String
getJspFilePath
(
Context
ctx
,
Model
model
)
{
Action
action
=
model
.
getAction
();
switch
(
action
)
{
case
HISTORY_REPORT:
return
JspFile
.
HISTORY_REPORT
.
getPath
();
case
HOURLY_REPORT:
return
JspFile
.
HOURLY_REPORT
.
getPath
();
default
:
break
;
}
throw
new
RuntimeException
(
"Unknown action: "
+
action
);
}
}
cat-home/src/main/java/com/dianping/cat/report/page/cache/Model.java
0 → 100644
浏览文件 @
4b3aafab
package
com.dianping.cat.report.page.cache
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
com.dianping.cat.report.page.AbstractReportModel
;
import
com.dianping.cat.report.view.StringSortHelper
;
public
class
Model
extends
AbstractReportModel
<
Action
,
Context
>
{
private
CacheReport
m_report
;
private
String
m_queryName
;
public
Model
(
Context
ctx
)
{
super
(
ctx
);
}
@Override
public
Action
getDefaultAction
()
{
return
Action
.
HISTORY_REPORT
;
}
@Override
public
String
getDomain
()
{
return
m_report
.
getDomain
();
}
@Override
public
Collection
<
String
>
getDomains
()
{
if
(
m_report
==
null
)
{
return
new
ArrayList
<
String
>();
}
else
{
return
StringSortHelper
.
sortDomain
(
m_report
.
getDomainNames
());
}
}
public
Collection
<
String
>
getIps
(){
if
(
m_report
==
null
)
{
return
new
ArrayList
<
String
>();
}
else
{
return
StringSortHelper
.
sortDomain
(
m_report
.
getIps
());
}
}
public
CacheReport
getReport
()
{
return
m_report
;
}
public
String
getQueryName
()
{
return
m_queryName
;
}
public
void
setQueryName
(
String
queryName
)
{
m_queryName
=
queryName
;
}
public
void
setReport
(
CacheReport
report
)
{
m_report
=
report
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/cache/Payload.java
0 → 100644
浏览文件 @
4b3aafab
package
com.dianping.cat.report.page.cache
;
import
com.dianping.cat.report.ReportPage
;
import
com.dianping.cat.report.page.AbstractReportPayload
;
import
com.site.web.mvc.ActionContext
;
import
com.site.web.mvc.payload.annotation.FieldMeta
;
public
class
Payload
extends
AbstractReportPayload
<
Action
>
{
@FieldMeta
(
"op"
)
private
Action
m_action
;
private
ReportPage
m_page
;
@FieldMeta
(
"query"
)
private
String
m_queryName
;
@FieldMeta
(
"type"
)
private
String
m_type
;
@FieldMeta
(
"sort"
)
private
String
m_sortBy
;
public
Payload
()
{
super
(
ReportPage
.
CACHE
);
}
@Override
public
Action
getAction
()
{
return
m_action
;
}
@Override
public
ReportPage
getPage
()
{
return
m_page
;
}
public
String
getQueryName
()
{
return
m_queryName
;
}
public
String
getType
()
{
return
m_type
;
}
public
void
setAction
(
String
action
)
{
m_action
=
Action
.
getByName
(
action
,
Action
.
HOURLY_REPORT
);
}
@Override
public
void
setPage
(
String
page
)
{
m_page
=
ReportPage
.
getByName
(
page
,
ReportPage
.
CACHE
);
}
public
void
setQueryName
(
String
queryName
)
{
m_queryName
=
queryName
;
}
public
void
setType
(
String
type
)
{
m_type
=
type
;
}
public
String
getSortBy
()
{
return
m_sortBy
;
}
public
void
setSortBy
(
String
sortBy
)
{
m_sortBy
=
sortBy
;
}
@Override
public
void
validate
(
ActionContext
<?>
ctx
)
{
if
(
m_action
==
null
){
m_action
=
Action
.
HOURLY_REPORT
;
}
}
}
cat-home/src/main/java/com/dianping/cat/report/page/cache/TransactionReportVistor.java
0 → 100644
浏览文件 @
4b3aafab
package
com.dianping.cat.report.page.cache
;
import
java.util.HashSet
;
import
java.util.Set
;
import
org.apache.commons.lang.StringUtils
;
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.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
;
public
class
TransactionReportVistor
extends
BaseVisitor
{
private
CacheReport
m_cacheReport
=
new
CacheReport
();
private
EventReport
m_eventReport
;
private
String
m_currentIp
;
private
String
m_currentType
;
private
String
m_type
;
private
Set
<
String
>
m_cacheTypes
=
new
HashSet
<
String
>();
private
String
m_sortBy
=
"missed"
;
public
CacheReport
getCacheReport
()
{
return
m_cacheReport
;
}
public
TransactionReportVistor
setType
(
String
type
)
{
m_type
=
type
;
return
this
;
}
public
TransactionReportVistor
setEventReport
(
EventReport
eventReport
)
{
m_eventReport
=
eventReport
;
return
this
;
}
public
void
setSortBy
(
String
sortBy
)
{
if
(
sortBy
!=
null
){
m_sortBy
=
sortBy
;
}
}
@Override
public
void
visitName
(
TransactionName
transactionName
)
{
com
.
dianping
.
cat
.
consumer
.
event
.
model
.
entity
.
Machine
machine
=
m_eventReport
.
findOrCreateMachine
(
m_currentIp
);
EventType
eventType
=
machine
.
findOrCreateType
(
m_currentType
);
EventName
eventName
=
eventType
.
findOrCreateName
(
transactionName
.
getId
()
+
":missed"
);
m_cacheReport
.
addNewNameItem
(
transactionName
,
eventName
);
}
@Override
public
void
visitMachine
(
Machine
machine
)
{
m_currentIp
=
machine
.
getIp
();
super
.
visitMachine
(
machine
);
}
@Override
public
void
visitType
(
TransactionType
transactionType
)
{
String
id
=
transactionType
.
getId
();
if
(
m_cacheTypes
.
contains
(
id
))
{
if
(
StringUtils
.
isEmpty
(
m_type
))
{
m_currentType
=
transactionType
.
getId
();
com
.
dianping
.
cat
.
consumer
.
event
.
model
.
entity
.
Machine
machine
=
m_eventReport
.
findOrCreateMachine
(
m_currentIp
);
EventType
eventType
=
machine
.
findOrCreateType
(
m_currentType
);
m_cacheReport
.
addNewTypeItem
(
transactionType
,
eventType
);
super
.
visitType
(
transactionType
);
}
else
if
(
id
.
equalsIgnoreCase
(
m_type
))
{
m_currentType
=
transactionType
.
getId
();
super
.
visitType
(
transactionType
);
}
}
}
@Override
public
void
visitTransactionReport
(
TransactionReport
transactionReport
)
{
m_cacheTypes
.
add
(
"Cache.memcached"
);
m_cacheTypes
.
add
(
"Cache.web"
);
m_cacheTypes
.
add
(
"Cache.kvdb"
);
m_cacheReport
.
setSortBy
(
m_sortBy
);
super
.
visitTransactionReport
(
transactionReport
);
m_cacheReport
.
setDomain
(
transactionReport
.
getDomain
());
m_cacheReport
.
setDomainNames
(
transactionReport
.
getDomainNames
());
m_cacheReport
.
setStartTime
(
transactionReport
.
getStartTime
());
m_cacheReport
.
setEndTime
(
transactionReport
.
getEndTime
());
m_cacheReport
.
setIps
(
transactionReport
.
getIps
());
}
}
cat-home/src/main/java/com/dianping/cat/report/page/cross/Handler.java
浏览文件 @
4b3aafab
...
...
@@ -166,8 +166,9 @@ public class Handler implements PageHandler<Context> {
CrossReport
methodReport
=
getHourlyReport
(
payload
);
MethodInfo
methodInfo
=
new
MethodInfo
(
payload
.
getHourDuration
());
methodInfo
.
setHostInfoDao
(
m_hostinfoDao
);
methodInfo
.
setClientIp
(
model
.
getIpAddress
()).
setCallSortBy
(
model
.
getCallSort
())
.
setServiceSortBy
(
model
.
getServiceSort
());
.
setServiceSortBy
(
model
.
getServiceSort
())
.
setRemoteProject
(
payload
.
getProjectName
())
;
methodInfo
.
setRemoteIp
(
payload
.
getRemoteIp
()).
setQuery
(
model
.
getQueryName
());
methodInfo
.
visitCrossReport
(
methodReport
);
model
.
setReport
(
methodReport
);
...
...
@@ -200,8 +201,9 @@ public class Handler implements PageHandler<Context> {
CrossReport
historyMethodReport
=
getSummarizeReport
(
payload
);
MethodInfo
historyMethodInfo
=
new
MethodInfo
(
payload
.
getHourDuration
());
historyMethodInfo
.
setHostInfoDao
(
m_hostinfoDao
);
historyMethodInfo
.
setClientIp
(
model
.
getIpAddress
()).
setCallSortBy
(
model
.
getCallSort
())
.
setServiceSortBy
(
model
.
getServiceSort
());
.
setServiceSortBy
(
model
.
getServiceSort
())
.
setRemoteProject
(
payload
.
getProjectName
())
;
historyMethodInfo
.
setRemoteIp
(
payload
.
getRemoteIp
()).
setQuery
(
model
.
getQueryName
());
historyMethodInfo
.
visitCrossReport
(
historyMethodReport
);
model
.
setReport
(
historyMethodReport
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/cross/display/MethodInfo.java
浏览文件 @
4b3aafab
...
...
@@ -15,6 +15,10 @@ import com.dianping.cat.consumer.cross.model.entity.Name;
import
com.dianping.cat.consumer.cross.model.entity.Remote
;
import
com.dianping.cat.consumer.cross.model.entity.Type
;
import
com.dianping.cat.consumer.cross.model.transform.BaseVisitor
;
import
com.dianping.cat.hadoop.dal.Hostinfo
;
import
com.dianping.cat.hadoop.dal.HostinfoDao
;
import
com.dianping.cat.hadoop.dal.HostinfoEntity
;
import
com.site.dal.jdbc.DalException
;
public
class
MethodInfo
extends
BaseVisitor
{
...
...
@@ -24,6 +28,8 @@ public class MethodInfo extends BaseVisitor {
private
Map
<
String
,
NameDetailInfo
>
m_serviceProjectsInfo
=
new
LinkedHashMap
<
String
,
NameDetailInfo
>();
private
String
m_remoteProject
;
private
String
m_clientIp
;
private
String
m_currentType
;
...
...
@@ -40,6 +46,10 @@ public class MethodInfo extends BaseVisitor {
private
String
m_serviceSortBy
=
"Avg"
;
private
HostinfoDao
m_hostInfoDao
;
private
static
final
String
UNKNOWN_PROJECT
=
"UnknownProject"
;
public
MethodInfo
(
long
reportDuration
)
{
m_reportDuration
=
reportDuration
;
}
...
...
@@ -168,18 +178,8 @@ public class MethodInfo extends BaseVisitor {
@Override
public
void
visitRemote
(
Remote
remote
)
{
String
role
=
remote
.
getRole
();
if
(
role
.
endsWith
(
"Server"
))
{
if
(
m_remoteIp
.
equals
(
HostInfo
.
ALL_SERVER_IP
))
{
m_currentRole
=
remote
.
getRole
();
super
.
visitRemote
(
remote
);
}
}
else
if
(
role
.
endsWith
(
"Client"
))
{
if
(
m_remoteIp
.
equals
(
HostInfo
.
ALL_CLIENT_IP
))
{
m_currentRole
=
remote
.
getRole
();
super
.
visitRemote
(
remote
);
}
}
if
(
m_remoteIp
.
equals
(
remote
.
getId
())){
String
ip
=
remote
.
getId
();
if
(
projectContains
(
m_remoteProject
,
ip
,
role
)
||
m_remoteIp
.
equals
(
remote
.
getId
()))
{
m_currentRole
=
remote
.
getRole
();
super
.
visitRemote
(
remote
);
}
...
...
@@ -190,4 +190,40 @@ public class MethodInfo extends BaseVisitor {
m_currentType
=
type
.
getId
();
super
.
visitType
(
type
);
}
public
void
setRemoteProject
(
String
remoteProject
)
{
m_remoteProject
=
remoteProject
;
}
public
void
setHostInfoDao
(
HostinfoDao
hostInfoDao
)
{
m_hostInfoDao
=
hostInfoDao
;
}
private
boolean
projectContains
(
String
projectName
,
String
ip
,
String
role
)
{
if
(
m_remoteIp
.
startsWith
(
"All"
))
{
if
(
m_remoteProject
.
startsWith
(
"AllClient"
)
&&
role
.
endsWith
(
"Client"
))
{
return
true
;
}
else
if
(
m_remoteProject
.
startsWith
(
"AllServer"
)
&&
role
.
endsWith
(
"Server"
))
{
return
true
;
}
if
(
ip
.
indexOf
(
':'
)
>
0
)
{
ip
=
ip
.
substring
(
0
,
ip
.
indexOf
(
':'
));
}
try
{
Hostinfo
hostInfo
=
m_hostInfoDao
.
findByIp
(
ip
,
HostinfoEntity
.
READSET_FULL
);
if
(
hostInfo
!=
null
)
{
if
(
projectName
.
equalsIgnoreCase
(
hostInfo
.
getDomain
()))
{
return
true
;
}
else
{
return
false
;
}
}
}
catch
(
DalException
e
)
{
if
(
projectName
.
equals
(
UNKNOWN_PROJECT
))
{
return
true
;
}
}
}
return
false
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/DisplayHeartbeat.java
浏览文件 @
4b3aafab
...
...
@@ -93,7 +93,7 @@ public class DisplayHeartbeat {
m_catMessageProduced
[
minute
]
=
period
.
getCatMessageProduced
();
m_catMessageOverflow
[
minute
]
=
period
.
getCatMessageOverflow
();
period
.
setCatMessageSize
(
period
.
getCatMessageSize
()
/
K
/
K
);
m_catMessageSize
[
minute
]
=
period
.
getCatMessageSize
()
;
m_catMessageSize
[
minute
]
=
(
double
)
period
.
getCatMessageSize
()
/
K
/
K
;
m_newGcCount
[
minute
]
=
period
.
getNewGcCount
();
m_oldGcCount
[
minute
]
=
period
.
getOldGcCount
();
...
...
cat-home/src/main/java/com/dianping/cat/report/page/matrix/DisplayMatrix.java
浏览文件 @
4b3aafab
...
...
@@ -273,7 +273,7 @@ public class DisplayMatrix {
return
(
int
)
(
o2
.
getCallAvg
()
*
100
-
o1
.
getCallAvg
()
*
100
);
}
if
(
m_sort
.
equalsIgnoreCase
(
"CallAvgTotalTime"
))
{
return
o2
.
getCallTime
()
-
o1
.
getCa
cheMin
();
return
o2
.
getCallTime
()
-
o1
.
getCa
llTime
();
}
if
(
m_sort
.
equalsIgnoreCase
(
"callTimePercent"
))
{
return
(
int
)
(
o2
.
getCallTimePercent
()
*
100
-
o1
.
getCallTimePercent
()
*
100
);
...
...
cat-home/src/main/java/com/dianping/cat/report/view/NavigationBar.java
浏览文件 @
4b3aafab
...
...
@@ -20,6 +20,8 @@ public class NavigationBar {
ReportPage
.
MATRIX
,
ReportPage
.
CROSS
,
ReportPage
.
CACHE
,
ReportPage
.
IP
,
...
...
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
4b3aafab
...
...
@@ -1561,5 +1561,43 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.cache.Handler
</role>
<implementation>
com.dianping.cat.report.page.cache.Handler
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.report.page.cache.JspViewer
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.hadoop.dal.ReportDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.hadoop.dal.DailyreportDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.report.task.event.EventMerger
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.report.task.transaction.TransactionMerger
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.configuration.ServerConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.report.page.model.spi.ModelService
</role>
<role-hint>
transaction
</role-hint>
<field-name>
m_transactionService
</field-name>
</requirement>
<requirement>
<role>
com.dianping.cat.report.page.model.spi.ModelService
</role>
<role-hint>
event
</role-hint>
<field-name>
m_eventService
</field-name>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.cache.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.cache.JspViewer
</implementation>
</component>
</components>
</plexus>
cat-home/src/main/resources/META-INF/wizard/webapp/wizard.xml
浏览文件 @
4b3aafab
...
...
@@ -47,6 +47,9 @@
<page
name=
"cross"
title=
"Cross"
path=
"cross"
>
<description>
Cross
</description>
</page>
<page
name=
"cache"
title=
"Cache"
path=
"cache"
>
<description>
Cache
</description>
</page>
</module>
</webapp>
</wizard>
...
...
cat-home/src/main/webapp/jsp/report/cache.jsp
0 → 100644
浏览文件 @
4b3aafab
<%@ page
session=
"false"
language=
"java"
pageEncoding=
"UTF-8"
%>
<%@ page
contentType=
"text/html; charset=utf-8"
%>
<%@ taglib
prefix=
"a"
uri=
"/WEB-INF/app.tld"
%>
<%@ taglib
prefix=
"w"
uri=
"http://www.unidal.org/web/core"
%>
<%@ taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%>
<%@ taglib
prefix=
"res"
uri=
"http://www.unidal.org/webres"
%>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<jsp:useBean
id=
"ctx"
type=
"com.dianping.cat.report.page.cache.Context"
scope=
"request"
/>
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.report.page.cache.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.report.page.cache.Model"
scope=
"request"
/>
<c:set
var=
"report"
value=
"
${
model
.
report
}
"
/>
<a:report
title=
"Cache Report${empty payload.type ? '' : ' :: '}<a href='?domain=${model.domain}&date=${model.date}&type=${payload.type}'>${payload.type}</a>"
navUrlPrefix=
"ip=${model.ipAddress}&queryname=${model.queryName}&domain=${model.domain}${empty payload.type ? '' : '&type='}${payload.type}"
timestamp=
"
${
w:
format
(
model
.
creatTime
,
'yyyy-MM-dd HH:mm:ss'
)
}
"
>
<jsp:attribute
name=
"subtitle"
>
From ${w:format(report.startTime,'yyyy-MM-dd HH:mm:ss')} to ${w:format(report.endTime,'yyyy-MM-dd HH:mm:ss')}
</jsp:attribute>
<jsp:body>
<res:useJs
value=
"
${
res
.
js
.
local
[
'jquery-1.7.1.js'
]
}
"
target=
"head-js"
/>
</br>
<table
class=
"machines"
>
<tr
style=
"text-align:left"
>
<th>
Machines:
[
<c:choose>
<c:when
test=
"
${
model
.
ipAddress
eq
'All'
}
"
>
<a
href=
"?domain=${model.domain}&date=${model.date}&type=${payload.type}&queryname=${model.queryName}"
class=
"current"
>
All
</a>
</c:when>
<c:otherwise>
<a
href=
"?domain=${model.domain}&date=${model.date}&type=${payload.type}&queryname=${model.queryName}"
>
All
</a>
</c:otherwise>
</c:choose>
]
<c:forEach
var=
"ip"
items=
"
${
model
.
ips
}
"
>
[
<c:choose>
<c:when
test=
"
${
model
.
ipAddress
eq
ip
}
"
>
<a
href=
"?domain=${model.domain}&ip=${ip}&date=${model.date}&type=${payload.type}&queryname=${model.queryName}"
class=
"current"
>
${ip}
</a>
</c:when>
<c:otherwise>
<a
href=
"?domain=${model.domain}&ip=${ip}&date=${model.date}&type=${payload.type}&queryname=${model.queryName}"
>
${ip}
</a>
</c:otherwise>
</c:choose>
]
</c:forEach>
</th>
</tr>
</table>
<br>
<table
class=
"cache"
>
<c:choose>
<c:when
test=
"
${
empty
payload
.
type
}
"
>
<tr><th><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=type"
>
Type
</a></th>
<th><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=total"
>
Total
</a></th>
<th><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=missed"
>
Missed
</a></th>
<th><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=hitPercent"
>
Hit Rate(%)
</a></th>
<th><a
href=
"?domain=${model.domain}&date=${model.date}&sort=avg"
>
Avg
</a>
(ms)
</th>
<th>
TPS
</th></tr>
<c:forEach
var=
"item"
items=
"
${
model
.
report
.
typeItems
}
"
varStatus=
"status"
>
<c:set
var=
"e"
value=
"
${
item
.
type
}
"
/>
<c:set
var=
"lastIndex"
value=
"
${
status
.
index
}
"
/>
<tr
class=
"${status.index mod 2 != 0 ? 'odd' : 'even'}"
>
<td
style=
"text-align:left"
><a
href=
"?domain=${report.domain}&date=${model.date}&ip=${model.ipAddress}&type=${e.id}"
>
${e.id}
</a></td>
<td>
${w:format(e.totalCount,'#,###,###,###,##0')}
</td>
<td>
${item.missed}
</td>
<td>
${w:format(item.hited,'0.00%')}
</td>
<td>
${w:format(e.avg,'0.0')}
</td>
<td>
${w:format(e.tps,'0.0')}
</td>
</tr>
</c:forEach>
</c:when>
<c:otherwise>
<tr><th
colspan=
'11'
><input
type=
"text"
name=
"queryname"
id=
"queryname"
size=
"40"
value=
"${model.queryName}"
>
<input
style=
"WIDTH: 60px"
value=
"Filter"
onclick=
"selectByName('${model.date}','${model.domain}','${model.ipAddress}','${payload.type}')"
type=
"submit"
>
支持多个字符串查询,例如sql|url|task,查询结果为包含任一sql、url、task的列
</th></tr>
<tr>
<th>
<a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=type&queryname=${model.queryName}"
>
Name
</a></th>
<th><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total&queryname=${model.queryName}"
>
Total
</a></th>
<th><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=missed&queryname=${model.queryName}"
>
Missed
</a></th>
<th><a
href=
"?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=hitPercent&queryname=${model.queryName}"
>
Hit Rate(%)
</a></th>
<th><a
href=
"?domain=${model.domain}&date=${model.date}&type=${payload.type}&sort=avg&queryname=${model.queryName}"
>
Avg
</a>
(ms)
</th>
<th>
TPS
</th></tr>
<c:forEach
var=
"item"
items=
"
${
model
.
report
.
nameItems
}
"
varStatus=
"status"
>
<c:set
var=
"e"
value=
"
${
item
.
name
}
"
/>
<c:set
var=
"lastIndex"
value=
"
${
status
.
index
}
"
/>
<tr
class=
"${status.index mod 2 != 0 ? 'odd' : 'even'}"
>
<td
width=
"25%"
style=
"text-align:left;word-wrap:break-word;word-break:break-all;"
>
${w:shorten(e.id, 80)}
</td>
<td>
${w:format(e.totalCount,'#,###,###,###,##0')}
</td>
<td>
${item.missed}
</td>
<td>
${w:format(item.hited,'0.00%')}
</td>
<td>
${w:format(e.avg,'0.0')}
</td>
<td>
${w:format(e.tps,'0.0')}
</td>
</tr>
</c:forEach>
</c:otherwise>
</c:choose>
</table>
<font
color=
"white"
>
${lastIndex+1}
</font>
</jsp:body>
</a:report>
cat-home/src/main/webapp/jsp/report/cacheHistory.jsp
0 → 100644
浏览文件 @
4b3aafab
<%@ page
session=
"false"
language=
"java"
pageEncoding=
"UTF-8"
%>
<%@ page
contentType=
"text/html; charset=utf-8"
%>
<%@ taglib
prefix=
"a"
uri=
"/WEB-INF/app.tld"
%>
<%@ taglib
prefix=
"w"
uri=
"http://www.unidal.org/web/core"
%>
<%@ taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%>
<%@ taglib
prefix=
"res"
uri=
"http://www.unidal.org/webres"
%>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<jsp:useBean
id=
"ctx"
type=
"com.dianping.cat.report.page.cache.Context"
scope=
"request"
/>
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.report.page.cache.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.report.page.cache.Model"
scope=
"request"
/>
<c:set
var=
"report"
value=
"
${
model
.
report
}
"
/>
<a:historyReport
title=
"Cache Report${empty payload.type ? '' : ' :: '}<a href='?op=history&domain=${model.domain}&date=${model.date}&type=${payload.type}'>${payload.type}</a>"
navUrlPrefix=
"ip=${model.ipAddress}&queryname=${model.queryName}&domain=${model.domain}${empty payload.type ? '' : '&type='}${payload.type}"
timestamp=
"
${
w:
format
(
model
.
creatTime
,
'yyyy-MM-dd HH:mm:ss'
)
}
"
>
<jsp:attribute
name=
"subtitle"
>
From ${w:format(report.startTime,'yyyy-MM-dd HH:mm:ss')} to ${w:format(report.endTime,'yyyy-MM-dd HH:mm:ss')}
</jsp:attribute>
<jsp:body>
<res:useJs
value=
"
${
res
.
js
.
local
[
'jquery-1.7.1.js'
]
}
"
target=
"head-js"
/>
</br>
<table
class=
"machines"
>
<tr
style=
"text-align:left"
>
<th>
Machines:
<c:forEach
var=
"ip"
items=
"
${
model
.
ips
}
"
>
[
<c:choose>
<c:when
test=
"
${
model
.
ipAddress
eq
ip
}
"
>
<a
href=
"?op=history&domain=${model.domain}&ip=${ip}&date=${model.date}&type=${payload.type}&queryname=${model.queryName}"
class=
"current"
>
${ip}
</a>
</c:when>
<c:otherwise>
<a
href=
"?op=history&domain=${model.domain}&ip=${ip}&date=${model.date}&type=${payload.type}&queryname=${model.queryName}"
>
${ip}
</a>
</c:otherwise>
</c:choose>
]
</c:forEach>
</th>
</tr>
</table>
<br>
<table
class=
"cache"
>
<c:choose>
<c:when
test=
"
${
empty
payload
.
type
}
"
>
<tr><th><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=type"
>
Type
</a></th>
<th><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=total"
>
Total
</a></th>
<th><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=missed"
>
Missed
</a></th>
<th><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=hitPercent"
>
Hit Rate(%)
</a></th>
<th><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&sort=avg"
>
Avg
</a>
(ms)
</th>
<th>
TPS
</th></tr>
<c:forEach
var=
"item"
items=
"
${
model
.
report
.
typeItems
}
"
varStatus=
"status"
>
<c:set
var=
"e"
value=
"
${
item
.
type
}
"
/>
<c:set
var=
"lastIndex"
value=
"
${
status
.
index
}
"
/>
<tr
class=
"${status.index mod 2 != 0 ? 'odd' : 'even'}"
>
<td
style=
"text-align:left"
><a
href=
"?op=history&domain=${report.domain}&date=${model.date}&ip=${model.ipAddress}&type=${e.id}"
>
${e.id}
</a></td>
<td>
${w:format(e.totalCount,'#,###,###,###,##0')}
</td>
<td>
${item.missed}
</td>
<td>
${w:format(item.hited,'0.00%')}
</td>
<td>
${w:format(e.avg,'0.0')}
</td>
<td>
${w:format(e.tps,'0.0')}
</td>
</tr>
</c:forEach>
</c:when>
<c:otherwise>
<tr><th
colspan=
'11'
><input
type=
"text"
name=
"queryname"
id=
"queryname"
size=
"40"
value=
"${model.queryName}"
>
<input
style=
"WIDTH: 60px"
value=
"Filter"
onclick=
"selectByName('${model.date}','${model.domain}','${model.ipAddress}','${payload.type}')"
type=
"submit"
>
支持多个字符串查询,例如sql|url|task,查询结果为包含任一sql、url、task的列
</th></tr>
<tr>
<th>
<a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=type&queryname=${model.queryName}"
>
Name
</a></th>
<th
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total&queryname=${model.queryName}"
>
Total
</a></th>
<th
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=missed&queryname=${model.queryName}"
>
Missed
</a></th>
<th
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=hitPercent&queryname=${model.queryName}"
>
Hit Rate(%)
</a></th>
<th
><a
href=
"?op=history&domain=${model.domain}&date=${model.date}&type=${payload.type}&sort=avg&queryname=${model.queryName}"
>
Avg
</a>
(ms)
</th>
<th>
TPS
</th></tr>
<c:forEach
var=
"item"
items=
"
${
model
.
report
.
nameItems
}
"
varStatus=
"status"
>
<c:set
var=
"e"
value=
"
${
item
.
name
}
"
/>
<c:set
var=
"lastIndex"
value=
"
${
status
.
index
}
"
/>
<tr
class=
"${status.index mod 2 != 0 ? 'odd' : 'even'}"
>
<td
width=
"25%"
style=
"text-align:left;word-wrap:break-word;word-break:break-all;"
>
${w:shorten(e.id, 80)}
</td>
<td>
${w:format(e.totalCount,'#,###,###,###,##0')}
</td>
<td>
${item.missed}
</td>
<td>
${w:format(item.hited,'0.00%')}
</td>
<td>
${w:format(e.avg,'0.0')}
</td>
<td>
${w:format(e.tps,'0.0')}
</td>
</tr>
</c:forEach>
</c:otherwise>
</c:choose>
</table>
<font
color=
"white"
>
${lastIndex+1}
</font>
</jsp:body>
</a:historyReport>
cat-home/src/main/webapp/jsp/report/crossHistoryHost.jsp
浏览文件 @
4b3aafab
...
...
@@ -57,7 +57,7 @@
<c:forEach
var=
"callInfo"
items=
"
${
model
.
hostInfo
.
callProjectsInfo
}
"
varStatus=
"status"
>
<tr
class=
"${status.index mod 2 != 0 ? 'odd' : 'even'}"
>
<td
class=
"left"
>
${callInfo.type}
</td>
<td
class=
"left"
><a
href=
"?op=historyMethod&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&remote=${callInfo.ip }"
>
${callInfo.ip}
</a></td>
<td
class=
"left"
><a
href=
"?op=historyMethod&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&remote=${callInfo.ip }
&project=${payload.projectName}
"
>
${callInfo.ip}
</a></td>
<td>
${w:format(callInfo.totalCount,'#,###,###,###,##0')}
</td>
<td>
${w:format(callInfo.failureCount,'#,###,###,###,##0')}
</td>
<td>
${w:format(callInfo.failurePercent,'0.00%')}
</td>
...
...
@@ -82,7 +82,7 @@
<c:forEach
var=
"serviceInfo"
items=
"
${
model
.
hostInfo
.
serviceProjectsInfo
}
"
varStatus=
"status"
>
<tr
class=
"${status.index mod 2 != 0 ? 'odd' : 'even'}"
>
<td
class=
"left"
>
${serviceInfo.type}
</td>
<td
class=
"left"
><a
href=
"?op=historyMethod&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&remote=${serviceInfo.ip}"
>
${serviceInfo.ip}
</a></td>
<td
class=
"left"
><a
href=
"?op=historyMethod&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&remote=${serviceInfo.ip}
&project=${payload.projectName}
"
>
${serviceInfo.ip}
</a></td>
<td>
${w:format(serviceInfo.totalCount,'#,###,###,###,##0')}
</td>
<td>
${w:format(serviceInfo.failureCount,'#,###,###,###,##0')}
</td>
<td>
${w:format(serviceInfo.failurePercent,'0.00%')}
</td>
...
...
cat-home/src/main/webapp/jsp/report/crossHost.jsp
浏览文件 @
4b3aafab
...
...
@@ -57,7 +57,7 @@
<c:forEach
var=
"callInfo"
items=
"
${
model
.
hostInfo
.
callProjectsInfo
}
"
varStatus=
"status"
>
<tr
class=
"${status.index mod 2 != 0 ? 'odd' : 'even'}"
>
<td
class=
"left"
>
${callInfo.type}
</td>
<td
class=
"left"
><a
href=
"?op=method&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&remote=${callInfo.ip
}"
>
${callInfo.ip}
</a></td>
<td
class=
"left"
><a
href=
"?op=method&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&remote=${callInfo.ip
}&project=${payload.projectName
}"
>
${callInfo.ip}
</a></td>
<td>
${w:format(callInfo.totalCount,'#,###,###,###,##0')}
</td>
<td>
${w:format(callInfo.failureCount,'#,###,###,###,##0')}
</td>
<td>
${w:format(callInfo.failurePercent,'0.00%')}
</td>
...
...
@@ -82,7 +82,7 @@
<c:forEach
var=
"serviceInfo"
items=
"
${
model
.
hostInfo
.
serviceProjectsInfo
}
"
varStatus=
"status"
>
<tr
class=
"${status.index mod 2 != 0 ? 'odd' : 'even'}"
>
<td
class=
"left"
>
${serviceInfo.type}
</td>
<td
class=
"left"
><a
href=
"?op=method&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&remote=${serviceInfo.ip}"
>
${serviceInfo.ip}
</a></td>
<td
class=
"left"
><a
href=
"?op=method&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&remote=${serviceInfo.ip}
&project=${payload.projectName}
"
>
${serviceInfo.ip}
</a></td>
<td>
${w:format(serviceInfo.totalCount,'#,###,###,###,##0')}
</td>
<td>
${w:format(serviceInfo.failureCount,'#,###,###,###,##0')}
</td>
<td>
${w:format(serviceInfo.failurePercent,'0.00%')}
</td>
...
...
cat-home/src/main/webapp/jsp/report/problemHistoryReport.jsp
浏览文件 @
4b3aafab
...
...
@@ -56,6 +56,7 @@
<option
value=
"100"
>
100 ms
</option>
<option
value=
"500"
>
500 ms
</option>
<option
value=
"1000"
>
1000 ms
</option>
<option
value=
"2000"
>
2000 ms
</option>
</select>
<script>
var
threshold
=
'
${model.threshold}
'
;
...
...
cat-home/src/main/webapp/jsp/report/problemStatics.jsp
浏览文件 @
4b3aafab
...
...
@@ -59,6 +59,7 @@
<option
value=
"100"
>
100 ms
</option>
<option
value=
"500"
>
500 ms
</option>
<option
value=
"1000"
>
1000 ms
</option>
<option
value=
"2000"
>
2000 ms
</option>
</select>
<script>
var
threshold
=
'
${model.threshold}
'
;
...
...
cat-home/src/test/java/com/dianping/cat/demo/TestSendMessage.java
浏览文件 @
4b3aafab
...
...
@@ -8,6 +8,44 @@ import com.dianping.cat.message.Transaction;
public
class
TestSendMessage
{
@Test
public
void
sendSendUrlErrorMessage
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"URL"
,
"Test"
);
t
.
addData
(
"key and value"
);
t
.
setStatus
(
new
NullPointerException
());
t
.
complete
();
}
Thread
.
sleep
(
1000
);
}
@Test
public
void
sendSendCallErrorMessage
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"Call"
,
"Test"
);
t
.
addData
(
"key and value"
);
t
.
setStatus
(
new
NullPointerException
());
t
.
complete
();
}
Thread
.
sleep
(
1000
);
}
@Test
public
void
sendSendSqlErrorMessage
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"SQL"
,
"Test"
);
t
.
addData
(
"key and value"
);
t
.
setStatus
(
new
NullPointerException
());
t
.
complete
();
}
Thread
.
sleep
(
1000
);
}
@Test
public
void
sendMessage
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
...
...
@@ -20,6 +58,15 @@ public class TestSendMessage {
Thread
.
sleep
(
1000
);
}
@Test
public
void
sendError
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
Cat
.
getProducer
().
logError
(
new
NullPointerException
());
Cat
.
getProducer
().
logError
(
new
OutOfMemoryError
());
}
Thread
.
sleep
(
1000
);
}
@Test
public
void
sendEvent
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
...
...
@@ -108,4 +155,69 @@ public class TestSendMessage {
t
.
complete
();
}
}
@Test
public
void
sendLongCacheTransaction
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"Cache.kvdb"
,
"Method6"
);
Cat
.
getProducer
().
newEvent
(
"PigeonService.client"
,
"192.168.7.77"
);
t
.
addData
(
"key and value"
);
Thread
.
sleep
(
11
);
Transaction
t2
=
Cat
.
getProducer
().
newTransaction
(
"Cache.local"
,
"Method"
);
Cat
.
getProducer
().
newEvent
(
"PigeonService.client"
,
"192.168.7.77"
);
t2
.
addData
(
"key and value"
);
Thread
.
sleep
(
11
);
t2
.
complete
();
t
.
complete
();
}
}
@Test
public
void
sendLongURLTransaction
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"URL"
,
"Method6"
);
t
.
addData
(
"key and value"
);
Thread
.
sleep
(
60
);
t
.
complete
();
}
}
@Test
public
void
sendLongSQLTransaction
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"SQL"
,
"Method6"
);
t
.
addData
(
"key and value"
);
Thread
.
sleep
(
102
);
t
.
complete
();
}
}
@Test
public
void
sendCacheTransactionWithMissed
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
130
;
i
++)
{
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"Cache.kvdb"
,
"Method"
+
i
%
10
);
Cat
.
getProducer
().
newEvent
(
"Cache.kvdb"
,
"Method"
+
i
%
10
+
":missed"
);
t
.
addData
(
"key and value"
);
Transaction
t2
=
Cat
.
getProducer
().
newTransaction
(
"Cache.web"
,
"Method"
+
i
%
10
);
Cat
.
getProducer
().
newEvent
(
"Cache.web"
,
"Method"
+
i
%
10
+
":missed"
);
t2
.
addData
(
"key and value"
);
Thread
.
sleep
(
2
);
t2
.
complete
();
t
.
complete
();
Transaction
t3
=
Cat
.
getProducer
().
newTransaction
(
"Cache.memcached"
,
"Method"
+
i
%
10
);
t3
.
addData
(
"key and value"
);
Thread
.
sleep
(
3
);
t3
.
complete
();
}
Transaction
t2
=
Cat
.
getProducer
().
newTransaction
(
"Cache.web"
,
"Method"
);
t2
.
addData
(
"key and value"
);
Thread
.
sleep
(
2
);
t2
.
complete
();
Thread
.
sleep
(
1000
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录