Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
d5e24351
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,发现更多精彩内容 >>
提交
d5e24351
编写于
6月 16, 2014
作者:
曾
曾伟伟
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
net topo config bug fix
上级
bc748e79
变更
4
展开全部
显示空白变更内容
内联
并排
Showing
4 changed file
with
274 addition
and
417 deletion
+274
-417
cat-home/src/main/java/com/dianping/cat/report/page/network/nettopology/NetGraphBuilder.java
.../cat/report/page/network/nettopology/NetGraphBuilder.java
+1
-39
cat-home/src/main/java/com/dianping/cat/report/page/network/nettopology/NetGraphManager.java
.../cat/report/page/network/nettopology/NetGraphManager.java
+18
-6
cat-home/src/main/java/com/dianping/cat/report/task/network/NetTopologyReportBuilder.java
...ing/cat/report/task/network/NetTopologyReportBuilder.java
+16
-2
cat-home/src/main/resources/config/default-nettopology-config.xml
.../src/main/resources/config/default-nettopology-config.xml
+239
-370
未找到文件。
cat-home/src/main/java/com/dianping/cat/report/page/network/nettopology/NetGraphBuilder.java
浏览文件 @
d5e24351
package
com.dianping.cat.report.page.network.nettopology
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.consumer.metric.model.entity.MetricItem
;
...
...
@@ -20,17 +14,8 @@ import com.dianping.cat.home.nettopo.entity.NetGraph;
import
com.dianping.cat.home.nettopo.entity.NetGraphSet
;
import
com.dianping.cat.home.nettopo.entity.NetTopology
;
import
com.dianping.cat.home.nettopo.entity.Switch
;
import
com.dianping.cat.home.nettopo.transform.DefaultSaxParser
;
public
class
NetGraphBuilder
implements
Initializable
{
private
NetGraph
m_netGraphTemplate
;
private
Set
<
String
>
m_requireGroups
;
public
Set
<
String
>
buildRequireGroups
()
{
return
m_requireGroups
;
}
public
class
NetGraphBuilder
{
public
NetGraphSet
buildGraphSet
(
NetGraph
netGraphTemplate
,
Map
<
String
,
MetricReport
>
reports
,
List
<
String
>
alertKeys
)
{
NetGraphSet
netGraphSet
=
new
NetGraphSet
();
...
...
@@ -183,27 +168,4 @@ public class NetGraphBuilder implements Initializable {
}
}
@Override
public
void
initialize
()
throws
InitializationException
{
InputStream
is
=
NetGraphManager
.
class
.
getResourceAsStream
(
"/config/default-nettopology-config.xml"
);
NetGraphSet
netGraphSet
=
null
;
try
{
netGraphSet
=
DefaultSaxParser
.
parse
(
is
);
m_netGraphTemplate
=
netGraphSet
.
getNetGraphs
().
get
(
0
);
is
.
close
();
m_requireGroups
=
new
HashSet
<
String
>();
for
(
NetTopology
netTopology
:
m_netGraphTemplate
.
getNetTopologies
())
{
for
(
Connection
connection
:
netTopology
.
getConnections
())
{
for
(
Interface
inter
:
connection
.
getInterfaces
())
{
m_requireGroups
.
add
(
inter
.
getGroup
());
}
}
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
}
cat-home/src/main/java/com/dianping/cat/report/page/network/nettopology/NetGraphManager.java
浏览文件 @
d5e24351
...
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -22,6 +23,8 @@ import com.dianping.cat.Constants;
import
com.dianping.cat.ServerConfigManager
;
import
com.dianping.cat.consumer.metric.model.entity.MetricReport
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.home.nettopo.entity.Connection
;
import
com.dianping.cat.home.nettopo.entity.Interface
;
import
com.dianping.cat.home.nettopo.entity.NetGraph
;
import
com.dianping.cat.home.nettopo.entity.NetGraphSet
;
import
com.dianping.cat.home.nettopo.entity.NetTopology
;
...
...
@@ -105,11 +108,10 @@ public class NetGraphManager implements Initializable, LogEnabled {
}
}
private
Map
<
String
,
MetricReport
>
queryMetricReports
(
Date
date
)
{
Set
<
String
>
groupSet
=
m_netGraphBuilder
.
buildRequireGroups
();
private
Map
<
String
,
MetricReport
>
queryMetricReports
(
Set
<
String
>
groups
,
Date
date
)
{
Map
<
String
,
MetricReport
>
reports
=
new
HashMap
<
String
,
MetricReport
>();
for
(
String
group
:
group
Set
)
{
for
(
String
group
:
group
s
)
{
ModelRequest
request
=
new
ModelRequest
(
group
,
date
.
getTime
());
MetricReport
report
=
m_service
.
invoke
(
request
);
...
...
@@ -140,14 +142,24 @@ public class NetGraphManager implements Initializable, LogEnabled {
Transaction
t
=
Cat
.
newTransaction
(
"NetGraph"
,
"M"
+
minuteStr
);
try
{
Map
<
String
,
MetricReport
>
currentMetricReports
=
queryMetricReports
(
TimeUtil
.
getCurrentHour
());
List
<
String
>
alertKeys
=
m_alertInfo
.
queryLastestAlarmKey
(
5
);
NetGraph
netGraphTemplate
=
m_netGraphConfigManager
.
getConfig
().
getNetGraphs
().
get
(
0
);
Set
<
String
>
groups
=
new
HashSet
<
String
>();
for
(
NetTopology
netTopology
:
netGraphTemplate
.
getNetTopologies
())
{
for
(
Connection
connection
:
netTopology
.
getConnections
())
{
for
(
Interface
inter
:
connection
.
getInterfaces
())
{
groups
.
add
(
inter
.
getGroup
());
}
}
}
Map
<
String
,
MetricReport
>
currentMetricReports
=
queryMetricReports
(
groups
,
TimeUtil
.
getCurrentHour
());
List
<
String
>
alertKeys
=
m_alertInfo
.
queryLastestAlarmKey
(
5
);
m_currentNetGraphSet
=
m_netGraphBuilder
.
buildGraphSet
(
netGraphTemplate
,
currentMetricReports
,
alertKeys
);
Date
lastHour
=
new
Date
(
TimeUtil
.
getCurrentHour
().
getTime
()
-
TimeUtil
.
ONE_HOUR
);
Map
<
String
,
MetricReport
>
lastHourReports
=
queryMetricReports
(
lastHour
);
Map
<
String
,
MetricReport
>
lastHourReports
=
queryMetricReports
(
groups
,
lastHour
);
m_lastNetGraphSet
=
m_netGraphBuilder
.
buildGraphSet
(
netGraphTemplate
,
lastHourReports
,
new
ArrayList
<
String
>());
t
.
setStatus
(
Transaction
.
SUCCESS
);
...
...
cat-home/src/main/java/com/dianping/cat/report/task/network/NetTopologyReportBuilder.java
浏览文件 @
d5e24351
...
...
@@ -3,6 +3,7 @@ package com.dianping.cat.report.task.network;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -12,8 +13,11 @@ import com.dianping.cat.configuration.NetworkInterfaceManager;
import
com.dianping.cat.consumer.metric.model.entity.MetricReport
;
import
com.dianping.cat.core.dal.HourlyReport
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.home.nettopo.entity.Connection
;
import
com.dianping.cat.home.nettopo.entity.Interface
;
import
com.dianping.cat.home.nettopo.entity.NetGraph
;
import
com.dianping.cat.home.nettopo.entity.NetGraphSet
;
import
com.dianping.cat.home.nettopo.entity.NetTopology
;
import
com.dianping.cat.home.nettopo.transform.DefaultNativeBuilder
;
import
com.dianping.cat.report.page.network.nettopology.NetGraphBuilder
;
import
com.dianping.cat.report.service.ReportService
;
...
...
@@ -38,7 +42,17 @@ public class NetTopologyReportBuilder implements ReportTaskBuilder {
@Override
public
boolean
buildHourlyTask
(
String
name
,
String
domain
,
Date
period
)
{
Set
<
String
>
groups
=
m_netGraphBuilder
.
buildRequireGroups
();
NetGraph
netGraphTemplate
=
m_netGraphConfigManager
.
getConfig
().
getNetGraphs
().
get
(
0
);
Set
<
String
>
groups
=
new
HashSet
<
String
>();
for
(
NetTopology
netTopology
:
netGraphTemplate
.
getNetTopologies
())
{
for
(
Connection
connection
:
netTopology
.
getConnections
())
{
for
(
Interface
inter
:
connection
.
getInterfaces
())
{
groups
.
add
(
inter
.
getGroup
());
}
}
}
Map
<
String
,
MetricReport
>
reports
=
new
HashMap
<
String
,
MetricReport
>();
for
(
String
group
:
groups
)
{
...
...
@@ -47,7 +61,7 @@ public class NetTopologyReportBuilder implements ReportTaskBuilder {
reports
.
put
(
group
,
report
);
}
NetGraph
netGraphTemplate
=
m_netGraphConfigManager
.
getConfig
().
getNetGraphs
().
get
(
0
);
NetGraphSet
netGraphSet
=
m_netGraphBuilder
.
buildGraphSet
(
netGraphTemplate
,
reports
,
new
ArrayList
<
String
>());
HourlyReport
hourlyReport
=
new
HourlyReport
();
...
...
cat-home/src/main/resources/config/default-nettopology-config.xml
浏览文件 @
d5e24351
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录