Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
9af11e7b
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,发现更多精彩内容 >>
提交
9af11e7b
编写于
1月 22, 2016
作者:
A
ascrutae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加日志
上级
cffcb51b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
66 addition
and
21 deletion
+66
-21
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/config/Constants.java
...va/com/ai/cloud/skywalking/analysis/config/Constants.java
+2
-1
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/dao/CallChainInfoDao.java
...om/ai/cloud/skywalking/analysis/dao/CallChainInfoDao.java
+6
-2
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/mapper/CallChainMapper.java
.../ai/cloud/skywalking/analysis/mapper/CallChainMapper.java
+12
-4
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/ChainInfo.java
...ava/com/ai/cloud/skywalking/analysis/model/ChainInfo.java
+14
-1
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/reduce/ChainInfoReduce.java
.../ai/cloud/skywalking/analysis/reduce/ChainInfoReduce.java
+11
-1
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/reduce/ChainRelate.java
.../com/ai/cloud/skywalking/analysis/reduce/ChainRelate.java
+18
-7
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/util/HBaseUtil.java
...java/com/ai/cloud/skywalking/analysis/util/HBaseUtil.java
+3
-5
未找到文件。
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/config/Constants.java
浏览文件 @
9af11e7b
package
com.ai.cloud.skywalking.analysis.config
;
public
class
Constants
{
public
static
String
UNCATEGORIZED_QUALIFIER_NAME
=
"UNCATEGORIZED_CALL_CHAIN"
;
public
static
final
String
EXCEPTIONMAPPER
=
"-1:"
;
public
static
final
String
UNCATEGORIZED_QUALIFIER_NAME
=
"UNCATEGORIZED_CALL_CHAIN"
;
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/dao/CallChainInfoDao.java
浏览文件 @
9af11e7b
...
...
@@ -41,7 +41,9 @@ public class CallChainInfoDao {
}
int
[]
result
=
preparedStatement
.
executeBatch
();
for
(
int
i
:
result
)
{
//TODO
if
(
i
!=
1
)
{
logger
.
error
(
"Failed to save chain detail ["
+
chainDetail
.
getChainToken
()
+
"]"
);
}
}
preparedStatement
.
close
();
connection
.
commit
();
...
...
@@ -56,7 +58,9 @@ public class CallChainInfoDao {
}
int
[]
result
=
preparedStatement
.
executeBatch
();
for
(
int
i
:
result
)
{
//TODO
if
(
i
!=
1
)
{
logger
.
error
(
"Failed to update chain detail"
);
}
}
preparedStatement
.
close
();
connection
.
commit
();
...
...
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/mapper/CallChainMapper.java
浏览文件 @
9af11e7b
...
...
@@ -25,11 +25,19 @@ public class CallChainMapper extends TableMapper<Text, ChainInfo> {
protected
void
map
(
ImmutableBytesWritable
key
,
Result
value
,
Context
context
)
throws
IOException
,
InterruptedException
{
List
<
Span
>
spanList
=
new
ArrayList
<
Span
>();
for
(
Cell
cell
:
value
.
rawCells
())
{
Span
span
=
new
Span
(
Bytes
.
toString
(
cell
.
getValueArray
(),
cell
.
getValueOffset
(),
cell
.
getValueLength
()));
spanList
.
add
(
span
);
ChainInfo
chainInfo
=
null
;
try
{
for
(
Cell
cell
:
value
.
rawCells
())
{
Span
span
=
new
Span
(
Bytes
.
toString
(
cell
.
getValueArray
(),
cell
.
getValueOffset
(),
cell
.
getValueLength
()));
spanList
.
add
(
span
);
}
chainInfo
=
spanToChainInfo
(
key
.
toString
(),
spanList
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"Failed to mapper call chain["
+
key
.
toString
()
+
"]"
,
e
);
chainInfo
=
new
ChainInfo
(
"-1"
);
}
ChainInfo
chainInfo
=
spanToChainInfo
(
key
.
toString
(),
spanList
);
context
.
write
(
new
Text
(
chainInfo
.
getUserId
()
+
":"
+
chainInfo
.
getEntranceNodeToken
()),
chainInfo
);
}
...
...
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/model/ChainInfo.java
浏览文件 @
9af11e7b
...
...
@@ -17,6 +17,11 @@ public class ChainInfo implements Writable {
private
ChainNode
firstChainNode
;
private
long
startDate
;
public
ChainInfo
(
String
userId
)
{
super
();
this
.
userId
=
userId
;
}
public
ChainInfo
()
{
this
.
nodes
=
new
ArrayList
<
ChainNode
>();
}
...
...
@@ -78,13 +83,17 @@ public class ChainInfo implements Writable {
for
(
ChainNode
node
:
nodes
)
{
chainTokenDesc
.
append
(
node
.
getParentLevelId
()
+
"."
+
node
.
getLevelId
()
+
"-"
+
node
.
getNodeToken
()
+
";"
);
}
this
.
chainToken
=
TokenGenerator
.
generate
(
chainTokenDesc
.
toString
())
+
"-"
+
userId
;
this
.
chainToken
=
TokenGenerator
.
generate
(
chainTokenDesc
.
toString
())
+
"-"
;
}
public
ChainStatus
getChainStatus
()
{
return
chainStatus
;
}
public
void
setChainStatus
(
ChainStatus
chainStatus
)
{
this
.
chainStatus
=
chainStatus
;
}
public
void
addNodes
(
ChainNode
chainNode
)
{
this
.
nodes
.
add
(
0
,
chainNode
);
if
(
chainNode
.
getStatus
()
==
ChainNode
.
NodeStatus
.
ABNORMAL
)
{
...
...
@@ -139,6 +148,10 @@ public class ChainInfo implements Writable {
public
void
setChainToken
(
String
chainToken
)
{
this
.
chainToken
=
chainToken
;
}
public
long
getStartDate
()
{
return
startDate
;
}
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/reduce/ChainInfoReduce.java
浏览文件 @
9af11e7b
package
com.ai.cloud.skywalking.analysis.reduce
;
import
com.ai.cloud.skywalking.analysis.config.Constants
;
import
com.ai.cloud.skywalking.analysis.model.ChainInfo
;
import
com.ai.cloud.skywalking.analysis.util.HBaseUtil
;
import
org.apache.hadoop.hbase.client.Put
;
import
org.apache.hadoop.hbase.mapreduce.TableReducer
;
import
org.apache.hadoop.io.Text
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
import
java.util.Iterator
;
public
class
ChainInfoReduce
extends
TableReducer
<
Text
,
ChainInfo
,
Put
>
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ChainInfoReduce
.
class
.
getName
());
@Override
protected
void
reduce
(
Text
key
,
Iterable
<
ChainInfo
>
values
,
Context
context
)
throws
IOException
,
InterruptedException
{
reduceAction
(
key
.
toString
(),
values
.
iterator
());
}
public
static
void
reduceAction
(
String
key
,
Iterator
<
ChainInfo
>
chainInfoIterator
)
throws
IOException
,
InterruptedException
{
if
(
Constants
.
EXCEPTIONMAPPER
.
equals
(
key
))
{
logger
.
info
(
"Skip Exception Mapper....."
);
return
;
}
try
{
ChainRelate
chainRelate
=
HBaseUtil
.
selectCallChainRelationship
(
key
.
toString
());
Summary
summary
=
new
Summary
();
...
...
@@ -32,7 +42,7 @@ public class ChainInfoReduce extends TableReducer<Text, ChainInfo, Put> {
chainRelate
.
save
();
summary
.
save
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
logger
.
error
(
"Failed to reduce key["
+
key
+
"]"
,
e
);
}
}
}
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/reduce/ChainRelate.java
浏览文件 @
9af11e7b
...
...
@@ -6,12 +6,16 @@ import com.ai.cloud.skywalking.analysis.model.ChainInfo;
import
com.ai.cloud.skywalking.analysis.util.HBaseUtil
;
import
com.google.gson.Gson
;
import
org.apache.hadoop.hbase.client.Put
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
import
java.sql.SQLException
;
import
java.util.*
;
public
class
ChainRelate
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ChainRelate
.
class
.
getName
());
private
String
key
;
private
Map
<
String
,
CategorizedChainInfo
>
categorizedChainInfoMap
=
new
HashMap
<
String
,
CategorizedChainInfo
>();
private
List
<
UncategorizeChainInfo
>
uncategorizeChainInfoList
=
new
ArrayList
<
UncategorizeChainInfo
>();
...
...
@@ -41,12 +45,17 @@ public class ChainRelate {
isContained
=
true
;
}
else
if
(
entry
.
getValue
().
isContained
(
child
))
{
entry
.
getValue
().
add
(
child
);
chainDetailMap
.
put
(
child
.
getChainToken
(),
new
ChainDetail
(
child
.
getChainInfo
()));
isContained
=
true
;
}
}
if
(!
isContained
)
{
uncategorizeChainInfoList
.
add
(
child
);
if
(!
uncategorizeChainInfoList
.
contains
(
child
))
{
chainDetailMap
.
put
(
child
.
getChainToken
(),
new
ChainDetail
(
child
.
getChainInfo
()));
}
}
}
...
...
@@ -71,12 +80,12 @@ public class ChainRelate {
}
}
public
void
save
()
throws
SQLException
{
public
void
save
()
throws
SQLException
,
IOException
,
InterruptedException
{
saveChainRelationShip
();
saveChainDetail
();
}
private
void
saveChainDetail
()
throws
SQLException
{
private
void
saveChainDetail
()
throws
SQLException
,
IOException
,
InterruptedException
{
List
<
Put
>
puts
=
new
ArrayList
<
Put
>();
for
(
Map
.
Entry
<
String
,
ChainDetail
>
entry
:
chainDetailMap
.
entrySet
())
{
Put
put1
=
new
Put
(
entry
.
getKey
().
getBytes
());
...
...
@@ -88,13 +97,15 @@ public class ChainRelate {
try
{
HBaseUtil
.
saveChainDetails
(
puts
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
logger
.
error
(
"Faild to save chain detail to hbase."
,
e
);
throw
e
;
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
logger
.
error
(
"Faild to save chain detail to hbase."
,
e
);
throw
e
;
}
}
private
void
saveChainRelationShip
()
{
private
void
saveChainRelationShip
()
throws
IOException
{
Put
put
=
new
Put
(
getKey
().
getBytes
());
put
.
addColumn
(
Config
.
HBase
.
CHAIN_RELATIONSHIP_COLUMN_FAMILY
.
getBytes
(),
Constants
.
UNCATEGORIZED_QUALIFIER_NAME
.
getBytes
()
...
...
@@ -108,8 +119,8 @@ public class ChainRelate {
try
{
HBaseUtil
.
saveChainRelate
(
put
);
}
catch
(
IOException
e
)
{
//TODO
e
.
printStackTrace
()
;
logger
.
error
(
"Faild to save chain relationship to hbase."
,
e
);
throw
e
;
}
}
...
...
skywalking-analysis/src/main/java/com/ai/cloud/skywalking/analysis/util/HBaseUtil.java
浏览文件 @
9af11e7b
...
...
@@ -2,7 +2,7 @@ package com.ai.cloud.skywalking.analysis.util;
import
com.ai.cloud.skywalking.analysis.config.Config
;
import
com.ai.cloud.skywalking.analysis.config.Constants
;
import
com.ai.cloud.skywalking.analysis.model.
*
;
import
com.ai.cloud.skywalking.analysis.model.
ChainInfo
;
import
com.ai.cloud.skywalking.analysis.reduce.*
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
...
...
@@ -150,8 +150,7 @@ public class HBaseUtil {
table
.
batch
(
puts
,
resultArrays
);
for
(
Object
result
:
resultArrays
)
{
if
(
result
==
null
)
{
//TODO
logger
.
error
(
"Failed to save chain specificTimeWindows Summary."
);
}
}
}
...
...
@@ -163,8 +162,7 @@ public class HBaseUtil {
table
.
batch
(
puts
,
resultArrays
);
for
(
Object
result
:
resultArrays
)
{
if
(
result
==
null
)
{
//TODO
logger
.
error
(
"Failed to save chain specificTimeWindows Summary."
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录