Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
a6f25ca9
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,发现更多精彩内容 >>
提交
a6f25ca9
编写于
6月 13, 2014
作者:
A
ainilife
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support dal heartbeat report
上级
528d67fc
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
142 addition
and
3 deletion
+142
-3
cat-consumer/src/main/java/com/dianping/cat/consumer/heartbeat/HeartbeatAnalyzer.java
...om/dianping/cat/consumer/heartbeat/HeartbeatAnalyzer.java
+14
-0
cat-consumer/src/main/resources/META-INF/dal/model/heartbeat-report-model.xml
...n/resources/META-INF/dal/model/heartbeat-report-model.xml
+10
-1
cat-home/pom.xml
cat-home/pom.xml
+1
-1
cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/DisplayHeartbeat.java
.../dianping/cat/report/page/heartbeat/DisplayHeartbeat.java
+69
-0
cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/Handler.java
.../java/com/dianping/cat/report/page/heartbeat/Handler.java
+1
-0
cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/Model.java
...in/java/com/dianping/cat/report/page/heartbeat/Model.java
+23
-1
cat-home/src/main/java/com/dianping/cat/report/task/heartbeat/HeartbeatGraphCreator.java
...ping/cat/report/task/heartbeat/HeartbeatGraphCreator.java
+10
-0
cat-home/src/main/webapp/jsp/report/heartbeat/heartbeat.jsp
cat-home/src/main/webapp/jsp/report/heartbeat/heartbeat.jsp
+14
-0
未找到文件。
cat-consumer/src/main/java/com/dianping/cat/consumer/heartbeat/HeartbeatAnalyzer.java
浏览文件 @
a6f25ca9
...
...
@@ -2,6 +2,7 @@ package com.dianping.cat.consumer.heartbeat;
import
java.util.Calendar
;
import
java.util.List
;
import
java.util.Map.Entry
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
...
...
@@ -9,6 +10,7 @@ import org.unidal.lookup.annotation.Inject;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.analysis.AbstractMessageAnalyzer
;
import
com.dianping.cat.consumer.heartbeat.model.entity.Detail
;
import
com.dianping.cat.consumer.heartbeat.model.entity.Disk
;
import
com.dianping.cat.consumer.heartbeat.model.entity.HeartbeatReport
;
import
com.dianping.cat.consumer.heartbeat.model.entity.Period
;
...
...
@@ -20,6 +22,7 @@ import com.dianping.cat.service.DefaultReportManager.StoragePolicy;
import
com.dianping.cat.service.ReportManager
;
import
com.dianping.cat.status.model.entity.DiskInfo
;
import
com.dianping.cat.status.model.entity.DiskVolumeInfo
;
import
com.dianping.cat.status.model.entity.Extension
;
import
com.dianping.cat.status.model.entity.GcInfo
;
import
com.dianping.cat.status.model.entity.MemoryInfo
;
import
com.dianping.cat.status.model.entity.MessageInfo
;
...
...
@@ -113,6 +116,17 @@ public class HeartbeatAnalyzer extends AbstractMessageAnalyzer<HeartbeatReport>
period
.
addDisk
(
disk
);
}
}
for
(
Entry
<
String
,
Extension
>
entry
:
info
.
getExtensions
().
entrySet
())
{
String
id
=
entry
.
getKey
();
Extension
ext
=
entry
.
getValue
();
com
.
dianping
.
cat
.
consumer
.
heartbeat
.
model
.
entity
.
Extension
extension
=
period
.
findOrCreateExtension
(
id
);
for
(
Entry
<
String
,
String
>
kv
:
ext
.
getDynamicAttributes
().
entrySet
())
{
double
value
=
Double
.
valueOf
(
kv
.
getValue
());
extension
.
getDetails
().
put
(
kv
.
getKey
(),
new
Detail
(
kv
.
getKey
()).
setValue
(
value
));
}
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
...
...
cat-consumer/src/main/resources/META-INF/dal/model/heartbeat-report-model.xml
浏览文件 @
a6f25ca9
...
...
@@ -13,7 +13,7 @@
<attribute
name=
"ip"
value-type=
"String"
key=
"true"
/>
<entity-ref
name=
"period"
type=
"list"
names=
"periods"
/>
</entity>
<entity
name=
"period"
>
<entity
name=
"period"
dynamic-attributes=
"true"
>
<attribute
name=
"minute"
value-type=
"int"
primitive=
"true"
key=
"true"
/>
<attribute
name=
"thread-count"
value-type=
"int"
primitive=
"true"
/>
<attribute
name=
"daemon-count"
value-type=
"int"
primitive=
"true"
/>
...
...
@@ -31,6 +31,7 @@
<attribute
name=
"cat-message-overflow"
value-type=
"long"
primitive=
"true"
/>
<attribute
name=
"cat-message-size"
value-type=
"double"
primitive=
"true"
format=
"0.00"
/>
<entity-ref
name=
"disk"
type=
"list"
names=
"disks"
/>
<entity-ref
name=
"extension"
type=
"map"
names=
"extensions"
method-find-or-create=
"true"
/>
</entity>
<entity
name=
"disk"
>
<attribute
name=
"path"
value-type=
"String"
key=
"true"
/>
...
...
@@ -38,6 +39,14 @@
<attribute
name=
"free"
value-type=
"long"
primitive=
"true"
/>
<attribute
name=
"usable"
value-type=
"long"
primitive=
"true"
/>
</entity>
<entity
name=
"extension"
>
<attribute
name=
"id"
value-type=
"String"
key=
"true"
/>
<entity-ref
name=
"detail"
type=
"map"
names=
"details"
method-find-or-create=
"true"
/>
</entity>
<entity
name=
"detail"
>
<attribute
name=
"id"
value-type=
"String"
key=
"true"
/>
<attribute
name=
"value"
value-type=
"double"
primitive=
"true"
/>
</entity>
</model>
cat-home/pom.xml
浏览文件 @
a6f25ca9
...
...
@@ -128,7 +128,7 @@
<plugin>
<groupId>
org.unidal.maven.plugins
</groupId>
<artifactId>
codegen-maven-plugin
</artifactId>
<version>
2.0.
9
</version>
<version>
2.0.
14
</version>
<executions>
<execution>
<id>
generate plexus component descriptor
</id>
...
...
cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/DisplayHeartbeat.java
浏览文件 @
a6f25ca9
...
...
@@ -2,18 +2,32 @@ package com.dianping.cat.report.page.heartbeat;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
com.dianping.cat.consumer.heartbeat.model.entity.Detail
;
import
com.dianping.cat.consumer.heartbeat.model.entity.Disk
;
import
com.dianping.cat.consumer.heartbeat.model.entity.Extension
;
import
com.dianping.cat.consumer.heartbeat.model.entity.HeartbeatReport
;
import
com.dianping.cat.consumer.heartbeat.model.entity.Machine
;
import
com.dianping.cat.consumer.heartbeat.model.entity.Period
;
import
com.dianping.cat.report.graph.AbstractGraphPayload
;
import
com.dianping.cat.report.graph.GraphBuilder
;
import
com.site.helper.Splitters
;
public
class
DisplayHeartbeat
{
private
static
final
int
K
=
1024
;
private
static
final
String
DAL
=
"dal"
;
private
static
final
Map
<
String
,
Integer
>
DAL_INDEX
=
new
HashMap
<
String
,
Integer
>();
private
static
final
AtomicInteger
DAL_INDEX_COUNTER
=
new
AtomicInteger
(
0
);
private
double
[]
m_activeThreads
=
new
double
[
60
];
private
double
[]
m_addCatMessageOverflow
=
new
double
[
60
];
...
...
@@ -60,6 +74,8 @@ public class DisplayHeartbeat {
private
double
[]
m_totalThreads
=
new
double
[
60
];
private
Map
<
String
,
Map
<
String
,
double
[]>>
m_extensions
=
new
HashMap
<
String
,
Map
<
String
,
double
[]>>();
public
DisplayHeartbeat
()
{
}
...
...
@@ -107,6 +123,26 @@ public class DisplayHeartbeat {
m_memoryFree
[
minute
]
=
period
.
getMemoryFree
();
m_systemLoadAverage
[
minute
]
=
period
.
getSystemLoadAverage
();
for
(
Entry
<
String
,
Extension
>
entry
:
period
.
getExtensions
().
entrySet
())
{
Map
<
String
,
double
[]>
groups
=
m_extensions
.
get
(
entry
.
getKey
());
if
(
groups
==
null
)
{
groups
=
new
LinkedHashMap
<
String
,
double
[]>();
m_extensions
.
put
(
entry
.
getKey
(),
groups
);
}
for
(
Entry
<
String
,
Detail
>
detail
:
entry
.
getValue
().
getDetails
().
entrySet
())
{
double
[]
doubles
=
groups
.
get
(
detail
.
getKey
());
if
(
doubles
==
null
)
{
doubles
=
new
double
[
60
];
groups
.
put
(
detail
.
getKey
(),
doubles
);
}
doubles
[
minute
]
=
detail
.
getValue
().
getValue
();
}
}
}
m_newThreads
=
getAddedCount
(
m_totalThreads
);
...
...
@@ -368,6 +404,39 @@ public class DisplayHeartbeat {
return
m_totalThreads
;
}
public
Map
<
String
,
Map
<
String
,
String
>>
getDalGraph
()
{
Map
<
String
,
Map
<
String
,
String
>>
graphs
=
new
HashMap
<
String
,
Map
<
String
,
String
>>();
Map
<
String
,
double
[]>
dalData
=
m_extensions
.
get
(
DAL
);
if
(
dalData
==
null
)
{
return
graphs
;
}
for
(
Entry
<
String
,
double
[]>
entry
:
dalData
.
entrySet
())
{
String
key
=
entry
.
getKey
();
List
<
String
>
split
=
Splitters
.
by
(
'-'
).
trim
().
split
(
key
);
if
(
split
!=
null
&&
split
.
size
()
==
2
)
{
String
db
=
split
.
get
(
0
);
String
title
=
split
.
get
(
1
);
Map
<
String
,
String
>
map
=
graphs
.
get
(
db
);
if
(
map
==
null
)
{
map
=
new
HashMap
<
String
,
String
>();
graphs
.
put
(
split
.
get
(
0
),
map
);
}
if
(!
DAL_INDEX
.
containsKey
(
title
))
{
DAL_INDEX
.
put
(
title
,
DAL_INDEX_COUNTER
.
getAndIncrement
());
}
map
.
put
(
title
,
m_builder
.
build
(
new
HeartbeatPayload
(
DAL_INDEX
.
get
(
title
),
title
,
"Minute"
,
"Count"
,
entry
.
getValue
())));
}
}
return
graphs
;
}
public
static
class
HeartbeatPayload
extends
AbstractGraphPayload
{
private
String
m_idPrefix
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/Handler.java
浏览文件 @
a6f25ca9
...
...
@@ -70,6 +70,7 @@ public class Handler implements PageHandler<Context> {
model
.
setDisksGraph
(
displayHeartbeat
.
getDisksGraph
());
model
.
setSystemLoadAverageGraph
(
displayHeartbeat
.
getSystemLoadAverageGraph
());
model
.
setMemoryFreeGraph
(
displayHeartbeat
.
getMemoryFreeGraph
());
model
.
setExtensionGraph
(
displayHeartbeat
.
getDalGraph
());
}
private
void
buildHistoryGraph
(
Model
model
,
Payload
payload
)
{
...
...
cat-home/src/main/java/com/dianping/cat/report/page/heartbeat/Model.java
浏览文件 @
a6f25ca9
package
com.dianping.cat.report.page.heartbeat
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
org.unidal.web.mvc.view.annotation.EntityMeta
;
...
...
@@ -63,6 +66,8 @@ public class Model extends AbstractReportModel<Action, Context> {
private
String
m_totalThreadGraph
;
private
Map
<
String
,
Map
<
String
,
String
>>
m_dalGraph
=
new
HashMap
<
String
,
Map
<
String
,
String
>>();
public
Model
(
Context
ctx
)
{
super
(
ctx
);
}
...
...
@@ -135,6 +140,20 @@ public class Model extends AbstractReportModel<Action, Context> {
}
}
public
Map
<
String
,
Map
<
String
,
String
>>
getDalGraph
()
{
return
m_dalGraph
;
}
public
int
getDalTableHeight
()
{
int
size
=
0
;
for
(
Entry
<
String
,
Map
<
String
,
String
>>
entry
:
m_dalGraph
.
entrySet
())
{
size
=
entry
.
getValue
().
size
();
break
;
}
return
((
size
/
3
)
+
1
)
*
190
+
20
;
}
public
String
getHeapUsageGraph
()
{
return
m_heapUsageGraph
;
}
...
...
@@ -240,6 +259,10 @@ public class Model extends AbstractReportModel<Action, Context> {
m_disksGraph
=
disksGraph
;
}
public
void
setExtensionGraph
(
Map
<
String
,
Map
<
String
,
String
>>
dalGraph
)
{
m_dalGraph
=
dalGraph
;
}
public
void
setHeapUsageGraph
(
String
heapUsageGraph
)
{
m_heapUsageGraph
=
heapUsageGraph
;
}
...
...
@@ -300,5 +323,4 @@ public class Model extends AbstractReportModel<Action, Context> {
public
void
setTotalThreadGraph
(
String
totalThreadGraph
)
{
m_totalThreadGraph
=
totalThreadGraph
;
}
}
cat-home/src/main/java/com/dianping/cat/report/task/heartbeat/HeartbeatGraphCreator.java
浏览文件 @
a6f25ca9
...
...
@@ -11,7 +11,9 @@ import java.util.Map.Entry;
import
java.util.Set
;
import
java.util.TreeMap
;
import
com.dianping.cat.consumer.heartbeat.model.entity.Detail
;
import
com.dianping.cat.consumer.heartbeat.model.entity.Disk
;
import
com.dianping.cat.consumer.heartbeat.model.entity.Extension
;
import
com.dianping.cat.consumer.heartbeat.model.entity.HeartbeatReport
;
import
com.dianping.cat.consumer.heartbeat.model.entity.Period
;
import
com.dianping.cat.core.dal.Graph
;
...
...
@@ -119,6 +121,14 @@ public class HeartbeatGraphCreator {
key
=
"HttpThread"
;
value
=
period
.
getHttpThreadCount
();
cacheHeartbeatColumn
(
detailCache
,
minute
,
value
,
key
);
for
(
Extension
ext
:
period
.
getExtensions
().
values
()){
for
(
Entry
<
String
,
Detail
>
detail
:
ext
.
getDetails
().
entrySet
()){
key
=
detail
.
getValue
().
getId
();
value
=
detail
.
getValue
().
getValue
();
cacheHeartbeatColumn
(
detailCache
,
minute
,
value
,
key
);
}
}
}
for
(
Entry
<
String
,
GraphLine
>
entry
:
detailCache
.
entrySet
())
{
...
...
cat-home/src/main/webapp/jsp/report/heartbeat/heartbeat.jsp
浏览文件 @
a6f25ca9
...
...
@@ -101,6 +101,20 @@
</svg>
</td>
</tr>
<c:forEach
items=
"
${
model
.
dalGraph
}
"
var=
"entry"
>
<tr>
<th>
Dal ${entry.key} Info
</th>
</tr>
<tr>
<td>
<svg
version=
"1.1"
width=
"1400"
height=
"${model.dalTableHeight}"
xmlns=
"http://www.w3.org/2000/svg"
>
<c:forEach
items=
"
${
entry
.
value
}
"
var=
"kv"
>
${kv.value }
</c:forEach>
</svg>
</td>
</tr>
</c:forEach>
</table>
<table
class=
"heartbeat"
>
<tr>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录