Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
fb309caa
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 1 年多
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
fb309caa
编写于
1月 21, 2016
作者:
Z
zhangxin10
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交保存逻辑
上级
dbdb9ee4
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
254 addition
and
58 deletion
+254
-58
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/config/Config.java
.../java/com/ai/cloud/skywalking/analysis/config/Config.java
+11
-1
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/config/Constants.java
...va/com/ai/cloud/skywalking/analysis/config/Constants.java
+5
-0
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/CategorizedChainInfo.java
...cloud/skywalking/analysis/model/CategorizedChainInfo.java
+23
-0
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/ChainDetail.java
...a/com/ai/cloud/skywalking/analysis/model/ChainDetail.java
+14
-0
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/ChainNodeSpecificTimeWindowSummary.java
...ng/analysis/model/ChainNodeSpecificTimeWindowSummary.java
+15
-9
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/ChainRelate.java
...a/com/ai/cloud/skywalking/analysis/model/ChainRelate.java
+67
-5
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/ChainSpecificTimeWindowSummary.java
...alking/analysis/model/ChainSpecificTimeWindowSummary.java
+17
-10
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/Summary.java
.../java/com/ai/cloud/skywalking/analysis/model/Summary.java
+30
-10
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/SummaryResult.java
...com/ai/cloud/skywalking/analysis/model/SummaryResult.java
+0
-2
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/UncategorizeChainInfo.java
...loud/skywalking/analysis/model/UncategorizeChainInfo.java
+10
-0
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/reduce/ChainInfoReduce.java
.../ai/cloud/skywalking/analysis/reduce/ChainInfoReduce.java
+1
-1
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/util/HBaseUtil.java
...java/com/ai/cloud/skywalking/analysis/util/HBaseUtil.java
+61
-20
未找到文件。
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/config/Config.java
浏览文件 @
fb309caa
...
@@ -3,6 +3,8 @@ package com.ai.cloud.skywalking.analysis.config;
...
@@ -3,6 +3,8 @@ package com.ai.cloud.skywalking.analysis.config;
public
class
Config
{
public
class
Config
{
public
static
class
HBase
{
public
static
class
HBase
{
public
static
String
CHAIN_SUMMARY_COLUMN_FAMILY
=
"chain_summary"
;
public
static
String
TRACE_INFO_COLUMN_FAMILY
=
"trace_info"
;
public
static
String
TRACE_INFO_COLUMN_FAMILY
=
"trace_info"
;
public
static
String
CALL_CHAIN_TABLE_NAME
;
public
static
String
CALL_CHAIN_TABLE_NAME
;
...
@@ -11,12 +13,16 @@ public class Config {
...
@@ -11,12 +13,16 @@ public class Config {
public
static
String
ZK_CLIENT_PORT
;
public
static
String
ZK_CLIENT_PORT
;
public
static
String
TRACE_INFO_TABLE_NAME
;
public
static
String
TRACE_INFO_TABLE_NAME
=
"trace_info"
;
public
static
String
TABLE_CALL_CHAIN_RELATIONSHIP
=
"sw_chain_relationship"
;
public
static
String
TABLE_CALL_CHAIN_RELATIONSHIP
=
"sw_chain_relationship"
;
public
static
String
CHAIN_RELATIONSHIP_COLUMN_FAMILY
=
"chain_relationship"
;
public
static
String
TABLE_CHAIN_INFO
=
"sw_chain_info"
;
public
static
String
TABLE_CHAIN_INFO
=
"sw_chain_info"
;
public
static
String
TABLE_CHAIN_SUMMARY
=
"sw_chain_summary"
;
}
}
public
static
class
TraceInfo
{
public
static
class
TraceInfo
{
...
@@ -37,4 +43,8 @@ public class Config {
...
@@ -37,4 +43,8 @@ public class Config {
public
static
class
Filter
{
public
static
class
Filter
{
public
static
String
FILTER_PACKAGE_NAME
;
public
static
String
FILTER_PACKAGE_NAME
;
}
}
public
class
ChainNodeSummary
{
public
static
final
long
INTERVAL
=
5L
;
}
}
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/config/Constants.java
0 → 100644
浏览文件 @
fb309caa
package
com.ai.cloud.skywalking.analysis.config
;
public
class
Constants
{
public
static
String
UNCATEGORIZED_QUALIFIER_NAME
=
"UNCATEGORIZED_CALL_CHAIN"
;
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/CategorizedChainInfo.java
浏览文件 @
fb309caa
package
com.ai.cloud.skywalking.analysis.model
;
package
com.ai.cloud.skywalking.analysis.model
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
import
com.google.gson.reflect.TypeToken
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
...
@@ -27,11 +31,25 @@ public class CategorizedChainInfo {
...
@@ -27,11 +31,25 @@ public class CategorizedChainInfo {
children_Token
=
new
ArrayList
<
String
>();
children_Token
=
new
ArrayList
<
String
>();
}
}
public
CategorizedChainInfo
(
String
value
)
{
JsonObject
jsonObject
=
new
Gson
().
fromJson
(
value
,
JsonObject
.
class
);
chainToken
=
jsonObject
.
get
(
"chainToken"
).
getAsString
();
chainStr
=
jsonObject
.
get
(
"chainStr"
).
getAsString
();
children_Token
=
new
Gson
().
fromJson
(
jsonObject
.
get
(
"children_Token"
),
new
TypeToken
<
List
<
String
>>()
{
}.
getType
());
}
public
String
getChainStr
()
{
public
String
getChainStr
()
{
return
chainStr
;
return
chainStr
;
}
}
public
boolean
isContained
(
UncategorizeChainInfo
uncategorizeChainInfo
)
{
public
boolean
isContained
(
UncategorizeChainInfo
uncategorizeChainInfo
)
{
if
(
children_Token
.
contains
(
uncategorizeChainInfo
.
getChainToken
()))
{
return
false
;
}
Pattern
pattern
=
Pattern
.
compile
(
uncategorizeChainInfo
.
getNodeRegEx
());
Pattern
pattern
=
Pattern
.
compile
(
uncategorizeChainInfo
.
getNodeRegEx
());
return
pattern
.
matcher
(
getChainStr
()).
find
();
return
pattern
.
matcher
(
getChainStr
()).
find
();
}
}
...
@@ -39,4 +57,9 @@ public class CategorizedChainInfo {
...
@@ -39,4 +57,9 @@ public class CategorizedChainInfo {
public
void
add
(
UncategorizeChainInfo
uncategorizeChainInfo
)
{
public
void
add
(
UncategorizeChainInfo
uncategorizeChainInfo
)
{
children_Token
.
add
(
uncategorizeChainInfo
.
getChainToken
());
children_Token
.
add
(
uncategorizeChainInfo
.
getChainToken
());
}
}
@Override
public
String
toString
()
{
return
new
Gson
().
toJson
(
this
);
}
}
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/ChainDetail.java
0 → 100644
浏览文件 @
fb309caa
package
com.ai.cloud.skywalking.analysis.model
;
/**
* Created by astraea on 2016/1/21.
*/
public
class
ChainDetail
{
public
ChainDetail
(
ChainInfo
chainInfo
)
{
}
public
ChainDetail
(
UncategorizeChainInfo
child
)
{
}
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/ChainNodeSpecificTimeWindowSummary.java
浏览文件 @
fb309caa
package
com.ai.cloud.skywalking.analysis.model
;
package
com.ai.cloud.skywalking.analysis.model
;
import
com.ai.cloud.skywalking.analysis.config.Config
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
com.google.gson.reflect.TypeToken
;
import
com.google.gson.reflect.TypeToken
;
...
@@ -12,15 +13,15 @@ public class ChainNodeSpecificTimeWindowSummary {
...
@@ -12,15 +13,15 @@ public class ChainNodeSpecificTimeWindowSummary {
private
String
traceLevelId
;
private
String
traceLevelId
;
private
Map
<
String
,
SummaryResult
>
summerResultMap
;
private
Map
<
String
,
SummaryResult
>
summerResultMap
;
public
static
ChainNodeSpecificTimeWindowSummary
newInstance
(
String
traceLevelId
){
public
static
ChainNodeSpecificTimeWindowSummary
newInstance
(
String
traceLevelId
)
{
ChainNodeSpecificTimeWindowSummary
cns
=
new
ChainNodeSpecificTimeWindowSummary
();
ChainNodeSpecificTimeWindowSummary
cns
=
new
ChainNodeSpecificTimeWindowSummary
();
cns
.
traceLevelId
=
traceLevelId
;
cns
.
traceLevelId
=
traceLevelId
;
return
cns
;
return
cns
;
}
}
private
ChainNodeSpecificTimeWindowSummary
(){
private
ChainNodeSpecificTimeWindowSummary
()
{
summerResultMap
=
new
HashMap
<
String
,
SummaryResult
>();
summerResultMap
=
new
HashMap
<
String
,
SummaryResult
>();
}
}
public
ChainNodeSpecificTimeWindowSummary
(
String
value
)
{
public
ChainNodeSpecificTimeWindowSummary
(
String
value
)
{
...
@@ -57,7 +58,12 @@ public class ChainNodeSpecificTimeWindowSummary {
...
@@ -57,7 +58,12 @@ public class ChainNodeSpecificTimeWindowSummary {
}
}
private
String
generateKey
(
long
startTime
)
{
private
String
generateKey
(
long
startTime
)
{
long
minutes
=
(
startTime
%
(
1000
*
60
*
60
))
/
(
1000
*
60
);
return
String
.
valueOf
(
minutes
/
Config
.
ChainNodeSummary
.
INTERVAL
);
}
return
null
;
@Override
public
String
toString
()
{
return
new
Gson
().
toJson
(
this
);
}
}
}
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/ChainRelate.java
浏览文件 @
fb309caa
package
com.ai.cloud.skywalking.analysis.model
;
package
com.ai.cloud.skywalking.analysis.model
;
import
com.ai.cloud.skywalking.analysis.config.Config
;
import
com.ai.cloud.skywalking.analysis.config.Constants
;
import
com.ai.cloud.skywalking.analysis.util.HBaseUtil
;
import
com.google.gson.Gson
;
import
org.apache.hadoop.hbase.client.Put
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.*
;
public
class
ChainRelate
{
public
class
ChainRelate
{
private
Map
<
String
,
CategorizedChainInfo
>
categorizedChainInfoList
=
new
HashMap
<
String
,
CategorizedChainInfo
>();
private
String
key
;
private
Map
<
String
,
CategorizedChainInfo
>
categorizedChainInfoMap
=
new
HashMap
<
String
,
CategorizedChainInfo
>();
private
List
<
UncategorizeChainInfo
>
uncategorizeChainInfoList
=
new
ArrayList
<
UncategorizeChainInfo
>();
private
List
<
UncategorizeChainInfo
>
uncategorizeChainInfoList
=
new
ArrayList
<
UncategorizeChainInfo
>();
private
Map
<
String
,
ChainDetail
>
chainDetailMap
=
new
HashMap
<
String
,
ChainDetail
>();
public
ChainRelate
(
String
key
)
{
this
.
key
=
key
;
}
private
void
categoryUncategorizedChainInfo
(
CategorizedChainInfo
parentChains
)
{
private
void
categoryUncategorizedChainInfo
(
CategorizedChainInfo
parentChains
)
{
if
(
uncategorizeChainInfoList
!=
null
&&
uncategorizeChainInfoList
.
size
()
>
0
)
{
if
(
uncategorizeChainInfoList
!=
null
&&
uncategorizeChainInfoList
.
size
()
>
0
)
{
...
@@ -21,24 +34,34 @@ public class ChainRelate {
...
@@ -21,24 +34,34 @@ public class ChainRelate {
private
void
classifiedChains
(
UncategorizeChainInfo
child
)
{
private
void
classifiedChains
(
UncategorizeChainInfo
child
)
{
boolean
isContained
=
false
;
boolean
isContained
=
false
;
for
(
Map
.
Entry
<
String
,
CategorizedChainInfo
>
entry
:
categorizedChainInfo
List
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
CategorizedChainInfo
>
entry
:
categorizedChainInfo
Map
.
entrySet
())
{
if
(
entry
.
getValue
().
isContained
(
child
))
{
if
(
entry
.
getValue
().
isContained
(
child
))
{
entry
.
getValue
().
add
(
child
);
entry
.
getValue
().
add
(
child
);
isContained
=
true
;
isContained
=
true
;
}
}
}
}
if
(!
isContained
)
{
if
(!
isContained
)
{
uncategorizeChainInfoList
.
add
(
child
);
uncategorizeChainInfoList
.
add
(
child
);
if
(!
uncategorizeChainInfoList
.
contains
(
child
)){
chainDetailMap
.
put
(
child
.
getChainToken
(),
new
ChainDetail
(
child
));
}
}
}
}
}
private
CategorizedChainInfo
addCategorizedChain
(
ChainInfo
chainInfo
)
{
private
CategorizedChainInfo
addCategorizedChain
(
ChainInfo
chainInfo
)
{
if
(!
categorizedChainInfo
List
.
containsKey
(
chainInfo
.
getChainToken
()))
{
if
(!
categorizedChainInfo
Map
.
containsKey
(
chainInfo
.
getChainToken
()))
{
categorizedChainInfo
List
.
put
(
chainInfo
.
getChainToken
(),
categorizedChainInfo
Map
.
put
(
chainInfo
.
getChainToken
(),
new
CategorizedChainInfo
(
chainInfo
));
new
CategorizedChainInfo
(
chainInfo
));
chainDetailMap
.
put
(
chainInfo
.
getChainToken
(),
new
ChainDetail
(
chainInfo
));
}
}
return
categorizedChainInfo
List
.
get
(
chainInfo
.
getChainToken
());
return
categorizedChainInfo
Map
.
get
(
chainInfo
.
getChainToken
());
}
}
public
void
addRelate
(
ChainInfo
chainInfo
)
{
public
void
addRelate
(
ChainInfo
chainInfo
)
{
...
@@ -52,6 +75,45 @@ public class ChainRelate {
...
@@ -52,6 +75,45 @@ public class ChainRelate {
}
}
public
void
save
()
{
public
void
save
()
{
Put
put
=
new
Put
(
getKey
().
getBytes
());
put
.
addColumn
(
Config
.
HBase
.
CHAIN_RELATIONSHIP_COLUMN_FAMILY
.
getBytes
(),
Constants
.
UNCATEGORIZED_QUALIFIER_NAME
.
getBytes
()
,
new
Gson
().
toJson
(
getUncategorizeChainInfoList
()).
getBytes
());
for
(
Map
.
Entry
<
String
,
CategorizedChainInfo
>
entry
:
getCategorizedChainInfoMap
().
entrySet
())
{
put
.
addColumn
(
Config
.
HBase
.
CHAIN_RELATIONSHIP_COLUMN_FAMILY
.
getBytes
(),
entry
.
getKey
().
getBytes
()
,
entry
.
getValue
().
toString
().
getBytes
());
}
try
{
HBaseUtil
.
saveChainRelate
(
put
);
}
catch
(
IOException
e
)
{
//TODO
e
.
printStackTrace
();
}
}
public
void
addUncategorizeChain
(
UncategorizeChainInfo
uncategorizeChainInfo
)
{
uncategorizeChainInfoList
.
add
(
uncategorizeChainInfo
);
}
public
void
addCategorizeChain
(
String
qualifierName
,
CategorizedChainInfo
categorizedChainInfo
)
{
categorizedChainInfoMap
.
put
(
qualifierName
,
categorizedChainInfo
);
}
public
String
getKey
()
{
return
key
;
}
public
Map
<
String
,
CategorizedChainInfo
>
getCategorizedChainInfoMap
()
{
return
categorizedChainInfoMap
;
}
public
List
<
UncategorizeChainInfo
>
getUncategorizeChainInfoList
()
{
return
uncategorizeChainInfoList
;
}
public
void
addUncategorizeChain
(
List
<
UncategorizeChainInfo
>
uncategorizeChainInfos
)
{
uncategorizeChainInfoList
.
addAll
(
uncategorizeChainInfos
);
}
}
}
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/ChainSpecificTimeWindowSummary.java
浏览文件 @
fb309caa
package
com.ai.cloud.skywalking.analysis.model
;
package
com.ai.cloud.skywalking.analysis.model
;
import
com.ai.cloud.skywalking.analysis.config.Config
;
import
com.ai.cloud.skywalking.analysis.util.HBaseUtil
;
import
com.ai.cloud.skywalking.analysis.util.HBaseUtil
;
import
org.apache.hadoop.hbase.client.Put
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -28,18 +30,23 @@ public class ChainSpecificTimeWindowSummary {
...
@@ -28,18 +30,23 @@ public class ChainSpecificTimeWindowSummary {
return
result
;
return
result
;
}
}
public
void
summaryResult
(
ChainInfo
chainInfo
)
{
public
void
addNodeSummaryResult
(
ChainNodeSpecificTimeWindowSummary
chainNodeSummaryResult
)
{
for
(
ChainNode
node
:
chainInfo
.
getNodes
())
{
chainNodeSummaryResultMap
.
put
(
chainNodeSummaryResult
.
getTraceLevelId
(),
chainNodeSummaryResult
);
String
tlid
=
node
.
getTraceLevelId
();
}
ChainNodeSpecificTimeWindowSummary
chainNodeSummaryResult
=
chainNodeSummaryResultMap
.
get
(
tlid
);
if
(
chainNodeSummaryResult
==
null
){
public
void
summaryResult
(
ChainNode
node
)
{
chainNodeSummaryResult
=
ChainNodeSpecificTimeWindowSummary
.
newInstance
(
tlid
);
String
tlid
=
node
.
getTraceLevelId
();
}
ChainNodeSpecificTimeWindowSummary
chainNodeSummaryResult
=
chainNodeSummaryResultMap
.
get
(
tlid
);
chainNodeSummaryResult
.
summary
(
node
);
if
(
chainNodeSummaryResult
==
null
)
{
chainNodeSummaryResult
=
ChainNodeSpecificTimeWindowSummary
.
newInstance
(
tlid
);
chainNodeSummaryResultMap
.
put
(
tlid
,
chainNodeSummaryResult
);
}
}
chainNodeSummaryResult
.
summary
(
node
);
}
}
public
void
addNodeSummaryResult
(
ChainNodeSpecificTimeWindowSummary
chainNodeSummaryResult
)
{
public
void
save
(
Put
put
)
{
chainNodeSummaryResultMap
.
put
(
chainNodeSummaryResult
.
getTraceLevelId
(),
chainNodeSummaryResult
);
for
(
Map
.
Entry
<
String
,
ChainNodeSpecificTimeWindowSummary
>
entry
:
chainNodeSummaryResultMap
.
entrySet
())
{
put
.
addColumn
(
Config
.
HBase
.
CHAIN_SUMMARY_COLUMN_FAMILY
.
getBytes
(),
entry
.
getKey
().
getBytes
(),
entry
.
getValue
().
toString
().
getBytes
());
}
}
}
}
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/Summary.java
浏览文件 @
fb309caa
package
com.ai.cloud.skywalking.analysis.model
;
package
com.ai.cloud.skywalking.analysis.model
;
import
com.ai.cloud.skywalking.analysis.util.HBaseUtil
;
import
org.apache.hadoop.hbase.client.Put
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
public
class
Summary
{
public
class
Summary
{
private
Map
<
String
,
ChainSpecificTimeWindowSummary
>
summaryResultMap
;
private
Map
<
String
,
ChainSpecificTimeWindowSummary
>
summaryResultMap
;
public
Summary
()
{
summaryResultMap
=
new
HashMap
<
String
,
ChainSpecificTimeWindowSummary
>();
}
public
void
summary
(
ChainInfo
chainInfo
)
{
public
void
summary
(
ChainInfo
chainInfo
)
{
String
csk
=
generateChainSummaryKey
(
chainInfo
);
for
(
ChainNode
node
:
chainInfo
.
getNodes
())
{
ChainSpecificTimeWindowSummary
chainSummaryResult
=
summaryResultMap
.
get
(
csk
);
String
csk
=
generateChainSummaryKey
(
chainInfo
.
getChainToken
(),
node
.
getStartDate
());
if
(
chainSummaryResult
==
null
)
{
ChainSpecificTimeWindowSummary
chainSummaryResult
=
summaryResultMap
.
get
(
csk
);
chainSummaryResult
=
ChainSpecificTimeWindowSummary
.
load
(
csk
);
if
(
chainSummaryResult
==
null
)
{
summaryResultMap
.
put
(
csk
,
chainSummaryResult
);
chainSummaryResult
=
ChainSpecificTimeWindowSummary
.
load
(
csk
);
summaryResultMap
.
put
(
csk
,
chainSummaryResult
);
}
chainSummaryResult
.
summaryResult
(
node
);
}
}
chainSummaryResult
.
summaryResult
(
chainInfo
);
}
}
private
String
generateChainSummaryKey
(
ChainInfo
chainInfo
)
{
private
String
generateChainSummaryKey
(
String
chainToken
,
long
startDate
)
{
return
chain
Info
.
getChainToken
()
+
":"
+
(
chainInfo
.
getStartDate
()
/
(
1000
*
60
*
60
));
return
chain
Token
+
"-"
+
(
startDate
/
(
1000
*
60
*
60
));
}
}
public
void
save
()
{
public
void
save
()
throws
IOException
,
InterruptedException
{
List
<
Put
>
puts
=
new
ArrayList
<
Put
>();
for
(
Map
.
Entry
<
String
,
ChainSpecificTimeWindowSummary
>
entry
:
summaryResultMap
.
entrySet
())
{
Put
put
=
new
Put
(
entry
.
getKey
().
getBytes
());
entry
.
getValue
().
save
(
put
);
puts
.
add
(
put
);
}
HBaseUtil
.
batchSaveChainSpecificTimeWindowSummary
(
puts
);
}
}
}
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/SummaryResult.java
浏览文件 @
fb309caa
...
@@ -36,12 +36,10 @@ public class SummaryResult {
...
@@ -36,12 +36,10 @@ public class SummaryResult {
}
}
public
void
summary
(
ChainNode
node
)
{
public
void
summary
(
ChainNode
node
)
{
totalCall
++;
totalCall
++;
if
(
node
.
getStatus
()
==
ChainNode
.
NodeStatus
.
NORMAL
)
{
if
(
node
.
getStatus
()
==
ChainNode
.
NodeStatus
.
NORMAL
)
{
correctNumber
++;
correctNumber
++;
}
}
totalCostTime
+=
node
.
getCost
();
totalCostTime
+=
node
.
getCost
();
}
}
}
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/UncategorizeChainInfo.java
浏览文件 @
fb309caa
package
com.ai.cloud.skywalking.analysis.model
;
package
com.ai.cloud.skywalking.analysis.model
;
import
com.google.gson.Gson
;
public
class
UncategorizeChainInfo
{
public
class
UncategorizeChainInfo
{
private
String
chainToken
;
private
String
chainToken
;
private
String
nodeRegEx
;
private
String
nodeRegEx
;
public
UncategorizeChainInfo
()
{
}
public
UncategorizeChainInfo
(
ChainInfo
chainInfo
)
{
public
UncategorizeChainInfo
(
ChainInfo
chainInfo
)
{
this
.
chainToken
=
chainInfo
.
getChainToken
();
this
.
chainToken
=
chainInfo
.
getChainToken
();
StringBuilder
stringBuilder
=
new
StringBuilder
();
StringBuilder
stringBuilder
=
new
StringBuilder
();
...
@@ -34,4 +39,9 @@ public class UncategorizeChainInfo {
...
@@ -34,4 +39,9 @@ public class UncategorizeChainInfo {
public
void
setNodeRegEx
(
String
nodeRegEx
)
{
public
void
setNodeRegEx
(
String
nodeRegEx
)
{
this
.
nodeRegEx
=
nodeRegEx
;
this
.
nodeRegEx
=
nodeRegEx
;
}
}
@Override
public
String
toString
()
{
return
new
Gson
().
toJson
(
this
);
}
}
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/reduce/ChainInfoReduce.java
浏览文件 @
fb309caa
...
@@ -14,7 +14,6 @@ import java.util.Iterator;
...
@@ -14,7 +14,6 @@ import java.util.Iterator;
public
class
ChainInfoReduce
extends
TableReducer
<
Text
,
ChainInfo
,
Put
>
{
public
class
ChainInfoReduce
extends
TableReducer
<
Text
,
ChainInfo
,
Put
>
{
@Override
@Override
protected
void
reduce
(
Text
key
,
Iterable
<
ChainInfo
>
values
,
Context
context
)
throws
IOException
,
InterruptedException
{
protected
void
reduce
(
Text
key
,
Iterable
<
ChainInfo
>
values
,
Context
context
)
throws
IOException
,
InterruptedException
{
ChainRelate
chainRelate
=
HBaseUtil
.
selectCallChainRelationship
(
key
.
toString
());
ChainRelate
chainRelate
=
HBaseUtil
.
selectCallChainRelationship
(
key
.
toString
());
Summary
summary
=
new
Summary
();
Summary
summary
=
new
Summary
();
Iterator
<
ChainInfo
>
chainInfoIterator
=
values
.
iterator
();
Iterator
<
ChainInfo
>
chainInfoIterator
=
values
.
iterator
();
...
@@ -29,5 +28,6 @@ public class ChainInfoReduce extends TableReducer<Text, ChainInfo, Put> {
...
@@ -29,5 +28,6 @@ public class ChainInfoReduce extends TableReducer<Text, ChainInfo, Put> {
summary
.
save
();
summary
.
save
();
// 入Mysql表
// 入Mysql表
}
}
}
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/util/HBaseUtil.java
浏览文件 @
fb309caa
package
com.ai.cloud.skywalking.analysis.util
;
package
com.ai.cloud.skywalking.analysis.util
;
import
com.ai.cloud.skywalking.analysis.config.Config
;
import
com.ai.cloud.skywalking.analysis.config.Config
;
import
com.ai.cloud.skywalking.analysis.model.ChainInfo
;
import
com.ai.cloud.skywalking.analysis.config.Constants
;
import
com.ai.cloud.skywalking.analysis.model.ChainNodeSpecificTimeWindowSummary
;
import
com.ai.cloud.skywalking.analysis.model.*
;
import
com.ai.cloud.skywalking.analysis.model.ChainRelate
;
import
com.google.gson.Gson
;
import
com.ai.cloud.skywalking.analysis.model.ChainSpecificTimeWindowSummary
;
import
com.google.gson.reflect.TypeToken
;
import
com.ai.cloud.skywalking.protocol.Span
;
import
org.apache.hadoop.conf.Configuration
;
import
org.apache.hadoop.conf.Configuration
;
import
org.apache.hadoop.hbase.*
;
import
org.apache.hadoop.hbase.*
;
import
org.apache.hadoop.hbase.client.*
;
import
org.apache.hadoop.hbase.client.*
;
...
@@ -14,7 +13,6 @@ import org.slf4j.Logger;
...
@@ -14,7 +13,6 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
public
class
HBaseUtil
{
public
class
HBaseUtil
{
...
@@ -53,18 +51,27 @@ public class HBaseUtil {
...
@@ -53,18 +51,27 @@ public class HBaseUtil {
static
{
static
{
try
{
try
{
initHBaseClient
();
initHBaseClient
();
Admin
admin
=
connection
.
getAdmin
();
//
if
(!
admin
.
isTableAvailable
(
TableName
.
valueOf
(
Config
.
HBase
.
TRACE_INFO_TABLE_NAME
)))
{
createTableIfNeed
(
Config
.
HBase
.
TRACE_INFO_TABLE_NAME
,
Config
.
HBase
.
TRACE_INFO_COLUMN_FAMILY
);
HTableDescriptor
tableDesc
=
new
HTableDescriptor
(
TableName
.
valueOf
(
Config
.
HBase
.
TRACE_INFO_TABLE_NAME
));
//
tableDesc
.
addFamily
(
new
HColumnDescriptor
(
Config
.
HBase
.
TRACE_INFO_COLUMN_FAMILY
));
createTableIfNeed
(
Config
.
HBase
.
TABLE_CALL_CHAIN_RELATIONSHIP
,
Config
.
HBase
.
CHAIN_RELATIONSHIP_COLUMN_FAMILY
);
admin
.
createTable
(
tableDesc
);
logger
.
info
(
"Create table [{}] ok!"
,
Config
.
HBase
.
TRACE_INFO_TABLE_NAME
);
createTableIfNeed
(
Config
.
HBase
.
TABLE_CHAIN_SUMMARY
,
Config
.
HBase
.
CHAIN_SUMMARY_COLUMN_FAMILY
);
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
logger
.
error
(
"Create table[{}] failed"
,
Config
.
HBase
.
TRACE_INFO_TABLE_NAME
,
e
);
logger
.
error
(
"Create table[{}] failed"
,
Config
.
HBase
.
TRACE_INFO_TABLE_NAME
,
e
);
}
}
}
}
private
static
void
createTableIfNeed
(
String
tableName
,
String
familyName
)
throws
IOException
{
Admin
admin
=
connection
.
getAdmin
();
if
(!
admin
.
isTableAvailable
(
TableName
.
valueOf
(
tableName
)))
{
HTableDescriptor
tableDesc
=
new
HTableDescriptor
(
TableName
.
valueOf
(
tableName
));
tableDesc
.
addFamily
(
new
HColumnDescriptor
(
familyName
.
getBytes
()));
admin
.
createTable
(
tableDesc
);
logger
.
info
(
"Create table [{}] ok!"
,
tableName
);
}
}
private
static
void
initHBaseClient
()
throws
IOException
{
private
static
void
initHBaseClient
()
throws
IOException
{
if
(
configuration
==
null
)
{
if
(
configuration
==
null
)
{
configuration
=
HBaseConfiguration
.
create
();
configuration
=
HBaseConfiguration
.
create
();
...
@@ -79,21 +86,34 @@ public class HBaseUtil {
...
@@ -79,21 +86,34 @@ public class HBaseUtil {
}
}
public
static
ChainRelate
selectCallChainRelationship
(
String
id
)
throws
IOException
{
public
static
ChainRelate
selectCallChainRelationship
(
String
key
)
throws
IOException
{
List
<
Span
>
entries
=
new
ArrayList
<
Span
>(
);
ChainRelate
chainRelate
=
new
ChainRelate
(
key
);
Table
table
=
connection
.
getTable
(
TableName
.
valueOf
(
Config
.
HBase
.
TABLE_CALL_CHAIN_RELATIONSHIP
));
Table
table
=
connection
.
getTable
(
TableName
.
valueOf
(
Config
.
HBase
.
TABLE_CALL_CHAIN_RELATIONSHIP
));
Get
g
=
new
Get
(
Bytes
.
toBytes
(
id
));
Get
g
=
new
Get
(
Bytes
.
toBytes
(
key
));
Result
r
=
table
.
get
(
g
);
Result
r
=
table
.
get
(
g
);
for
(
Cell
cell
:
r
.
rawCells
())
{
for
(
Cell
cell
:
r
.
rawCells
())
{
if
(
cell
.
getValueArray
().
length
>
0
)
if
(
cell
.
getValueArray
().
length
>
0
)
{
entries
.
add
(
new
Span
(
Bytes
.
toString
(
cell
.
getValueArray
(),
cell
.
getValueOffset
(),
cell
.
getValueLength
())));
String
qualifierName
=
Bytes
.
toString
(
cell
.
getQualifierArray
(),
cell
.
getQualifierOffset
(),
cell
.
getQualifierLength
());
if
(
Constants
.
UNCATEGORIZED_QUALIFIER_NAME
.
equals
(
qualifierName
))
{
List
<
UncategorizeChainInfo
>
uncategorizeChainInfoList
=
new
Gson
().
fromJson
(
Bytes
.
toString
(
cell
.
getValueArray
(),
cell
.
getValueOffset
(),
cell
.
getValueLength
()),
new
TypeToken
<
List
<
UncategorizeChainInfo
>>()
{
}.
getType
());
chainRelate
.
addUncategorizeChain
(
uncategorizeChainInfoList
);
}
else
{
chainRelate
.
addCategorizeChain
(
qualifierName
,
new
CategorizedChainInfo
(
Bytes
.
toString
(
cell
.
getValueArray
(),
cell
.
getValueOffset
(),
cell
.
getValueLength
())
));
}
}
}
}
return
null
;
return
chainRelate
;
}
}
public
static
ChainSpecificTimeWindowSummary
selectChainSummaryResult
(
String
key
)
throws
IOException
{
public
static
ChainSpecificTimeWindowSummary
selectChainSummaryResult
(
String
key
)
throws
IOException
{
ChainSpecificTimeWindowSummary
result
=
null
;
ChainSpecificTimeWindowSummary
result
=
null
;
//TODO 初始化表
Table
table
=
connection
.
getTable
(
TableName
.
valueOf
(
Config
.
HBase
.
TABLE_CHAIN_INFO
));
Table
table
=
connection
.
getTable
(
TableName
.
valueOf
(
Config
.
HBase
.
TABLE_CHAIN_INFO
));
Get
g
=
new
Get
(
Bytes
.
toBytes
(
key
));
Get
g
=
new
Get
(
Bytes
.
toBytes
(
key
));
Result
r
=
table
.
get
(
g
);
Result
r
=
table
.
get
(
g
);
...
@@ -107,4 +127,25 @@ public class HBaseUtil {
...
@@ -107,4 +127,25 @@ public class HBaseUtil {
return
result
;
return
result
;
}
}
public
static
void
saveChainRelate
(
Put
put
)
throws
IOException
{
Table
table
=
connection
.
getTable
(
TableName
.
valueOf
(
Config
.
HBase
.
TABLE_CALL_CHAIN_RELATIONSHIP
));
table
.
put
(
put
);
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Insert data[RowKey:{}] success."
,
put
.
getId
());
}
}
public
static
void
batchSaveChainSpecificTimeWindowSummary
(
List
<
Put
>
puts
)
throws
IOException
,
InterruptedException
{
Table
table
=
connection
.
getTable
(
TableName
.
valueOf
(
Config
.
HBase
.
TABLE_CHAIN_SUMMARY
));
Object
[]
resultArrays
=
new
Object
[
puts
.
size
()];
table
.
batch
(
puts
,
resultArrays
);
for
(
Object
result
:
resultArrays
)
{
if
(
result
==
null
)
{
//TODO
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录