Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿信在这里
SkyWalking
提交
b0c4674d
S
SkyWalking
项目概览
阿信在这里
/
SkyWalking
与 Fork 源项目一致
Fork自
山不在高_有仙则灵 / SkyWalking
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b0c4674d
编写于
3月 11, 2016
作者:
Z
zhang.xin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1. 新增天,月,小时的统计
上级
65679624
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
232 addition
and
10 deletion
+232
-10
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/chainbuild/entity/CallChainTreeNode.java
...walking/analysis/chainbuild/entity/CallChainTreeNode.java
+81
-10
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/chainbuild/entity/ChainNodeSpecificDaySummary.java
...alysis/chainbuild/entity/ChainNodeSpecificDaySummary.java
+47
-0
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/chainbuild/entity/ChainNodeSpecificHourSummary.java
...lysis/chainbuild/entity/ChainNodeSpecificHourSummary.java
+43
-0
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/chainbuild/entity/ChainNodeSpecificMonthSummary.java
...ysis/chainbuild/entity/ChainNodeSpecificMonthSummary.java
+46
-0
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/chainbuild/util/HBaseUtil.java
.../cloud/skywalking/analysis/chainbuild/util/HBaseUtil.java
+15
-0
未找到文件。
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/chainbuild/entity/CallChainTreeNode.java
浏览文件 @
b0c4674d
...
...
@@ -30,31 +30,102 @@ public class CallChainTreeNode {
* key: treeId + 小时
* value: 当前树的当前小时范围内的,所有分钟和节点的统计数据
*/
private
Map
<
String
,
ChainNodeSpecificMinSummary
>
chainNodeContainer
;
private
Map
<
String
,
ChainNodeSpecificMinSummary
>
chainNodeSpecificMinSummaryContainer
;
/**
* key: treeId + 天
* value: 当前树的当前天范围内的,所有小时和节点的统计数据
*/
private
Map
<
String
,
ChainNodeSpecificHourSummary
>
chainNodeSpecificHourSummaryContainer
;
/**
* key: treeId + 月
* value: 当前树的当前月范围内的,所有天和节点的统计数据
*/
private
Map
<
String
,
ChainNodeSpecificDaySummary
>
chainNodeSpecificDaySummaryContainer
;
/**
* key: treeId + 年
* value: 当前树的当前年范围内的,所有月份和节点的统计数据
*/
private
Map
<
String
,
ChainNodeSpecificMonthSummary
>
chainNodeSpecificMonthSummaryContainer
;
public
CallChainTreeNode
(
ChainNode
node
)
{
this
.
traceLevelId
=
node
.
getTraceLevelId
();
chainNodeContainer
=
new
HashMap
<
String
,
ChainNodeSpecificMinSummary
>();
chainNodeSpecificMinSummaryContainer
=
new
HashMap
<
String
,
ChainNodeSpecificMinSummary
>();
chainNodeSpecificHourSummaryContainer
=
new
HashMap
<
String
,
ChainNodeSpecificHourSummary
>();
chainNodeSpecificDaySummaryContainer
=
new
HashMap
<
String
,
ChainNodeSpecificDaySummary
>();
chainNodeSpecificMonthSummaryContainer
=
new
HashMap
<
String
,
ChainNodeSpecificMonthSummary
>();
this
.
viewPointId
=
node
.
getViewPoint
();
}
public
void
summary
(
String
treeId
,
ChainNode
node
)
throws
IOException
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
new
Date
(
node
.
getStartDate
()));
summaryMinResult
(
treeId
,
node
,
calendar
);
summaryHourResult
(
treeId
,
node
,
calendar
);
summaryDayResult
(
treeId
,
node
,
calendar
);
summaryMonthResult
(
treeId
,
node
,
calendar
);
}
private
void
summaryMonthResult
(
String
treeId
,
ChainNode
node
,
Calendar
calendar
)
{
String
keyOfMonthSummaryTable
=
generateKeyOfMonthSummaryTable
(
treeId
,
calendar
);
ChainNodeSpecificMonthSummary
monthSummary
=
chainNodeSpecificMonthSummaryContainer
.
get
(
keyOfMonthSummaryTable
);
if
(
monthSummary
==
null
)
{
monthSummary
=
HBaseUtil
.
loadSpecificMonthSummary
(
keyOfMonthSummaryTable
,
getTreeNodeId
());
chainNodeSpecificMonthSummaryContainer
.
put
(
keyOfMonthSummaryTable
,
monthSummary
);
}
monthSummary
.
summary
(
String
.
valueOf
(
calendar
.
get
(
Calendar
.
YEAR
)),
node
);
}
private
void
summaryDayResult
(
String
treeId
,
ChainNode
node
,
Calendar
calendar
)
{
String
keyOfDaySummaryTable
=
generateKeyOfDaySummaryTable
(
treeId
,
calendar
);
ChainNodeSpecificDaySummary
daySummary
=
chainNodeSpecificDaySummaryContainer
.
get
(
keyOfDaySummaryTable
);
if
(
daySummary
==
null
)
{
daySummary
=
HBaseUtil
.
loadSpecificDaySummary
(
keyOfDaySummaryTable
,
getTreeNodeId
());
chainNodeSpecificDaySummaryContainer
.
put
(
keyOfDaySummaryTable
,
daySummary
);
}
daySummary
.
summary
(
String
.
valueOf
(
calendar
.
get
(
Calendar
.
DAY_OF_MONTH
)),
node
);
}
private
void
summaryHourResult
(
String
treeId
,
ChainNode
node
,
Calendar
calendar
)
{
String
keyOfHourSummaryTable
=
generateKeyOfHourSummaryTable
(
treeId
,
calendar
);
ChainNodeSpecificHourSummary
hourSummary
=
chainNodeSpecificHourSummaryContainer
.
get
(
keyOfHourSummaryTable
);
if
(
hourSummary
==
null
)
{
hourSummary
=
HBaseUtil
.
loadSpecificHourSummary
(
keyOfHourSummaryTable
,
getTreeNodeId
());
chainNodeSpecificHourSummaryContainer
.
put
(
keyOfHourSummaryTable
,
hourSummary
);
}
hourSummary
.
summary
(
String
.
valueOf
(
calendar
.
get
(
Calendar
.
HOUR
)),
node
);
}
/**
* 按分钟维度进行汇总<br/>
* chainNodeContainer以treeId和时间(精确到分钟)为key,value为当前时间范围内的所有分钟的汇总数据
*/
private
void
summaryMinResult
(
String
treeId
,
ChainNode
node
,
Calendar
calendar
)
throws
IOException
{
String
keyOfMinSummaryTable
=
generateKeyOfMinSummaryTable
(
treeId
,
calendar
);
ChainNodeSpecificMinSummary
minSummary
=
chainNodeContainer
.
get
(
keyOfMinSummaryTable
);
ChainNodeSpecificMinSummary
minSummary
=
chainNode
SpecificMinSummary
Container
.
get
(
keyOfMinSummaryTable
);
if
(
minSummary
==
null
)
{
minSummary
=
HBaseUtil
.
loadSpecificMinSummary
(
keyOfMinSummaryTable
,
getTreeNodeId
());
chainNodeContainer
.
put
(
keyOfMinSummaryTable
,
minSummary
);
chainNode
SpecificMinSummary
Container
.
put
(
keyOfMinSummaryTable
,
minSummary
);
}
minSummary
.
summary
(
String
.
valueOf
(
calendar
.
get
(
Calendar
.
MINUTE
)),
node
);
}
private
String
generateKeyOfMonthSummaryTable
(
String
treeId
,
Calendar
calendar
)
{
return
treeId
+
"/"
+
calendar
.
get
(
Calendar
.
YEAR
);
}
private
String
generateKeyOfDaySummaryTable
(
String
treeId
,
Calendar
calendar
)
{
return
treeId
+
"/"
+
calendar
.
get
(
Calendar
.
YEAR
)
+
"-"
+
(
calendar
.
get
(
Calendar
.
MONTH
)
+
1
);
}
private
String
generateKeyOfHourSummaryTable
(
String
treeId
,
Calendar
calendar
)
{
return
treeId
+
"/"
+
calendar
.
get
(
Calendar
.
YEAR
)
+
"-"
+
(
calendar
.
get
(
Calendar
.
MONTH
)
+
1
)
+
"-"
+
calendar
.
get
(
Calendar
.
DAY_OF_MONTH
);
}
private
String
generateKeyOfMinSummaryTable
(
String
treeId
,
Calendar
calendar
)
{
return
treeId
+
"/"
+
calendar
.
get
(
Calendar
.
YEAR
)
+
"-"
+
(
calendar
.
get
(
Calendar
.
MONTH
)
+
1
)
+
"-"
+
calendar
.
get
(
Calendar
.
DAY_OF_MONTH
)
+
" "
+
calendar
.
get
(
Calendar
.
HOUR
)
+
":00:00"
;
...
...
@@ -76,7 +147,7 @@ public class CallChainTreeNode {
*/
public
void
saveSummaryResultToHBase
()
throws
IOException
,
InterruptedException
{
List
<
Put
>
puts
=
new
ArrayList
<
Put
>();
for
(
Map
.
Entry
<
String
,
ChainNodeSpecificMinSummary
>
entry
:
chainNodeContainer
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
ChainNodeSpecificMinSummary
>
entry
:
chainNode
SpecificMinSummary
Container
.
entrySet
())
{
Put
put
=
new
Put
(
entry
.
getKey
().
getBytes
());
put
.
addColumn
(
HBaseTableMetaData
.
TABLE_CHAIN_ONE_MINUTE_SUMMARY
.
COLUMN_FAMILY_NAME
.
getBytes
()
,
getTreeNodeId
().
getBytes
(),
entry
.
getValue
().
toString
().
getBytes
());
...
...
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/chainbuild/entity/ChainNodeSpecificDaySummary.java
0 → 100644
浏览文件 @
b0c4674d
package
com.ai.cloud.skywalking.analysis.chainbuild.entity
;
import
com.ai.cloud.skywalking.analysis.chainbuild.po.ChainNode
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonParser
;
import
com.google.gson.reflect.TypeToken
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* Created by xin on 16-3-10.
*/
public
class
ChainNodeSpecificDaySummary
{
/**
* key : 天
*/
private
Map
<
String
,
ChainNodeSpecificTimeWindowSummaryValue
>
summaryValueMap
;
public
ChainNodeSpecificDaySummary
(
String
originData
)
{
JsonObject
jsonObject
=
(
JsonObject
)
new
JsonParser
().
parse
(
originData
);
summaryValueMap
=
new
Gson
().
fromJson
(
jsonObject
.
get
(
"summaryValueMap"
).
toString
(),
new
TypeToken
<
Map
<
String
,
ChainNodeSpecificTimeWindowSummaryValue
>>()
{
}.
getType
());
}
public
ChainNodeSpecificDaySummary
()
{
summaryValueMap
=
new
HashMap
<
String
,
ChainNodeSpecificTimeWindowSummaryValue
>();
}
public
void
summary
(
String
minute
,
ChainNode
node
)
{
ChainNodeSpecificTimeWindowSummaryValue
summarValue
=
summaryValueMap
.
get
(
minute
);
if
(
summarValue
==
null
)
{
summarValue
=
new
ChainNodeSpecificTimeWindowSummaryValue
();
summaryValueMap
.
put
(
minute
,
summarValue
);
}
summarValue
.
summary
(
node
);
}
@Override
public
String
toString
()
{
return
new
Gson
().
toJson
(
this
);
}
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/chainbuild/entity/ChainNodeSpecificHourSummary.java
0 → 100644
浏览文件 @
b0c4674d
package
com.ai.cloud.skywalking.analysis.chainbuild.entity
;
import
com.ai.cloud.skywalking.analysis.chainbuild.po.ChainNode
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonParser
;
import
com.google.gson.reflect.TypeToken
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
ChainNodeSpecificHourSummary
{
/**
* key : 小时
*/
private
Map
<
String
,
ChainNodeSpecificTimeWindowSummaryValue
>
summaryValueMap
;
public
ChainNodeSpecificHourSummary
(
String
originData
)
{
JsonObject
jsonObject
=
(
JsonObject
)
new
JsonParser
().
parse
(
originData
);
summaryValueMap
=
new
Gson
().
fromJson
(
jsonObject
.
get
(
"summaryValueMap"
).
toString
(),
new
TypeToken
<
Map
<
String
,
ChainNodeSpecificTimeWindowSummaryValue
>>()
{
}.
getType
());
}
public
ChainNodeSpecificHourSummary
()
{
summaryValueMap
=
new
HashMap
<
String
,
ChainNodeSpecificTimeWindowSummaryValue
>();
}
public
void
summary
(
String
minute
,
ChainNode
node
)
{
ChainNodeSpecificTimeWindowSummaryValue
summarValue
=
summaryValueMap
.
get
(
minute
);
if
(
summarValue
==
null
)
{
summarValue
=
new
ChainNodeSpecificTimeWindowSummaryValue
();
summaryValueMap
.
put
(
minute
,
summarValue
);
}
summarValue
.
summary
(
node
);
}
@Override
public
String
toString
()
{
return
new
Gson
().
toJson
(
this
);
}
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/chainbuild/entity/ChainNodeSpecificMonthSummary.java
0 → 100644
浏览文件 @
b0c4674d
package
com.ai.cloud.skywalking.analysis.chainbuild.entity
;
import
com.ai.cloud.skywalking.analysis.chainbuild.po.ChainNode
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonParser
;
import
com.google.gson.reflect.TypeToken
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* Created by xin on 16-3-10.
*/
public
class
ChainNodeSpecificMonthSummary
{
/**
* key : 月
*/
private
Map
<
String
,
ChainNodeSpecificTimeWindowSummaryValue
>
summaryValueMap
;
public
ChainNodeSpecificMonthSummary
(
String
originData
)
{
JsonObject
jsonObject
=
(
JsonObject
)
new
JsonParser
().
parse
(
originData
);
summaryValueMap
=
new
Gson
().
fromJson
(
jsonObject
.
get
(
"summaryValueMap"
).
toString
(),
new
TypeToken
<
Map
<
String
,
ChainNodeSpecificTimeWindowSummaryValue
>>()
{
}.
getType
());
}
public
ChainNodeSpecificMonthSummary
()
{
summaryValueMap
=
new
HashMap
<
String
,
ChainNodeSpecificTimeWindowSummaryValue
>();
}
public
void
summary
(
String
minute
,
ChainNode
node
)
{
ChainNodeSpecificTimeWindowSummaryValue
summarValue
=
summaryValueMap
.
get
(
minute
);
if
(
summarValue
==
null
)
{
summarValue
=
new
ChainNodeSpecificTimeWindowSummaryValue
();
summaryValueMap
.
put
(
minute
,
summarValue
);
}
summarValue
.
summary
(
node
);
}
@Override
public
String
toString
()
{
return
new
Gson
().
toJson
(
this
);
}
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/chainbuild/util/HBaseUtil.java
浏览文件 @
b0c4674d
...
...
@@ -4,6 +4,9 @@ import java.io.IOException;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.ai.cloud.skywalking.analysis.chainbuild.entity.ChainNodeSpecificDaySummary
;
import
com.ai.cloud.skywalking.analysis.chainbuild.entity.ChainNodeSpecificHourSummary
;
import
com.ai.cloud.skywalking.analysis.chainbuild.entity.ChainNodeSpecificMonthSummary
;
import
org.apache.hadoop.conf.Configuration
;
import
org.apache.hadoop.hbase.Cell
;
import
org.apache.hadoop.hbase.HBaseConfiguration
;
...
...
@@ -155,4 +158,16 @@ public class HBaseUtil {
index
++;
}
}
public
static
ChainNodeSpecificHourSummary
loadSpecificHourSummary
(
String
keyOfHourSummaryTable
,
String
treeNodeId
)
{
return
null
;
}
public
static
ChainNodeSpecificDaySummary
loadSpecificDaySummary
(
String
keyOfDaySummaryTable
,
String
treeNodeId
)
{
return
null
;
}
public
static
ChainNodeSpecificMonthSummary
loadSpecificMonthSummary
(
String
keyOfMonthSummaryTable
,
String
treeNodeId
)
{
return
null
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录