Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
b28c7d72
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
b28c7d72
编写于
2月 26, 2020
作者:
静夜思朝颜
提交者:
GitHub
2月 26, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add profile multiple time ranges unit test (#4420)
* adding unit for multiple time ranges analyze * remove un-use import
上级
fa0b3df3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
62 addition
and
11 deletion
+62
-11
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileAnalyzer.java
...king/oap/server/core/profile/analyze/ProfileAnalyzer.java
+7
-4
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackAnalyze.java
.../oap/server/core/profile/analyze/ProfileStackAnalyze.java
+13
-6
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackData.java
...ing/oap/server/core/profile/analyze/ProfileStackData.java
+18
-1
oap-server/server-core/src/test/resources/thread-snapshot.yml
...server/server-core/src/test/resources/thread-snapshot.yml
+24
-0
未找到文件。
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileAnalyzer.java
浏览文件 @
b28c7d72
...
...
@@ -94,20 +94,23 @@ public class ProfileAnalyzer {
}
protected
SequenceSearch
getAllSequenceRange
(
String
segmentId
,
List
<
ProfileAnalyzeTimeRange
>
timeRanges
)
throws
IOException
{
return
timeRanges
.
parallelStream
().
map
(
r
->
{
final
List
<
SequenceSearch
>
searches
=
timeRanges
.
parallelStream
().
map
(
r
->
{
try
{
return
getAllSequenceRange
(
segmentId
,
r
.
getStart
(),
r
.
getEnd
());
}
catch
(
IOException
e
)
{
LOGGER
.
warn
(
e
.
getMessage
(),
e
);
return
null
;
}
}).
filter
(
Objects:
:
nonNull
).
reduce
(
new
SequenceSearch
(
0
),
SequenceSearch:
:
combine
);
}).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
// using none parallels to combine nodes
return
searches
.
stream
().
reduce
(
new
SequenceSearch
(
0
),
SequenceSearch:
:
combine
);
}
protected
SequenceSearch
getAllSequenceRange
(
String
segmentId
,
long
start
,
long
end
)
throws
IOException
{
// query min and max sequence
// query min and max sequence
(include last seqeucne)
int
minSequence
=
getProfileThreadSnapshotQueryDAO
().
queryMinSequence
(
segmentId
,
start
,
end
);
int
maxSequence
=
getProfileThreadSnapshotQueryDAO
().
queryMaxSequence
(
segmentId
,
start
,
end
);
int
maxSequence
=
getProfileThreadSnapshotQueryDAO
().
queryMaxSequence
(
segmentId
,
start
,
end
)
+
1
;
// data not found
if
(
maxSequence
<=
0
)
{
...
...
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackAnalyze.java
浏览文件 @
b28c7d72
...
...
@@ -19,7 +19,6 @@
package
org.apache.skywalking.oap.server.core.profile.analyze
;
import
java.io.IOException
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -41,12 +40,10 @@ public class ProfileStackAnalyze {
private
List
<
ProfileStackElementMatcher
>
expected
;
public
void
analyzeAndAssert
(
int
maxAnalyzeCount
)
throws
IOException
{
List
<
ProfileThreadSnapshotRecord
>
stacks
=
data
.
transform
();
List
<
ProfileThreadSnapshotRecord
>
stacks
=
data
.
transformSnapshots
();
final
List
<
ProfileAnalyzeTimeRange
>
ranges
=
data
.
transformTimeRanges
();
final
ProfileAnalyzeTimeRange
range
=
new
ProfileAnalyzeTimeRange
();
range
.
setStart
(
0
);
range
.
setEnd
(
0
);
List
<
ProfileStackTree
>
trees
=
buildAnalyzer
(
stacks
,
maxAnalyzeCount
).
analyze
(
null
,
Collections
.
singletonList
(
range
)).
getTrees
();
List
<
ProfileStackTree
>
trees
=
buildAnalyzer
(
stacks
,
maxAnalyzeCount
).
analyze
(
null
,
ranges
).
getTrees
();
assertNotNull
(
trees
);
assertEquals
(
trees
.
size
(),
expected
.
size
());
...
...
@@ -76,11 +73,21 @@ public class ProfileStackAnalyze {
@Override
public
int
queryMinSequence
(
String
segmentId
,
long
start
,
long
end
)
throws
IOException
{
for
(
ProfileThreadSnapshotRecord
stack
:
stacks
)
{
if
(
stack
.
getDumpTime
()
>=
start
)
{
return
stack
.
getSequence
();
}
}
return
0
;
}
@Override
public
int
queryMaxSequence
(
String
segmentId
,
long
start
,
long
end
)
throws
IOException
{
for
(
int
i
=
stacks
.
size
()
-
1
;
i
>=
0
;
i
--)
{
if
(
stacks
.
get
(
i
).
getDumpTime
()
<=
end
)
{
return
stacks
.
get
(
i
).
getSequence
();
}
}
return
stacks
.
size
();
}
...
...
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackData.java
浏览文件 @
b28c7d72
...
...
@@ -22,6 +22,7 @@ import com.google.common.base.Splitter;
import
lombok.Data
;
import
org.apache.skywalking.apm.network.language.profile.ThreadStack
;
import
org.apache.skywalking.oap.server.core.profile.ProfileThreadSnapshotRecord
;
import
org.apache.skywalking.oap.server.core.query.entity.ProfileAnalyzeTimeRange
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -30,9 +31,10 @@ import java.util.List;
public
class
ProfileStackData
{
private
int
limit
;
private
String
timeRanges
;
private
List
<
String
>
snapshots
;
public
List
<
ProfileThreadSnapshotRecord
>
transform
()
{
public
List
<
ProfileThreadSnapshotRecord
>
transform
Snapshots
()
{
ArrayList
<
ProfileThreadSnapshotRecord
>
result
=
new
ArrayList
<>(
snapshots
.
size
());
for
(
int
i
=
0
;
i
<
snapshots
.
size
();
i
++)
{
...
...
@@ -47,4 +49,19 @@ public class ProfileStackData {
return
result
;
}
public
List
<
ProfileAnalyzeTimeRange
>
transformTimeRanges
()
{
final
String
[]
timeRangeString
=
this
.
timeRanges
.
split
(
","
);
final
ArrayList
<
ProfileAnalyzeTimeRange
>
ranges
=
new
ArrayList
<>();
for
(
String
timeRange
:
timeRangeString
)
{
final
ProfileAnalyzeTimeRange
range
=
new
ProfileAnalyzeTimeRange
();
final
String
[]
startEndTimes
=
timeRange
.
split
(
"-"
);
range
.
setStart
(
Integer
.
parseInt
(
startEndTimes
[
0
])
*
limit
);
range
.
setEnd
(
Integer
.
parseInt
(
startEndTimes
[
1
])
*
limit
);
ranges
.
add
(
range
);
}
return
ranges
;
}
}
oap-server/server-core/src/test/resources/thread-snapshot.yml
浏览文件 @
b28c7d72
...
...
@@ -24,6 +24,7 @@ list:
# case 1
-
data
:
limit
:
10
timeRanges
:
0-2
snapshots
:
-
A-B-C
-
A-B
...
...
@@ -48,6 +49,7 @@ list:
# case 2
-
data
:
limit
:
10
timeRanges
:
0-1
snapshots
:
-
A-B-C
-
B-C-D
...
...
@@ -78,6 +80,7 @@ list:
# case 3
-
data
:
limit
:
10
timeRanges
:
0-4
snapshots
:
-
A-B-C-D
-
A-B
...
...
@@ -104,6 +107,7 @@ list:
# case 4:
-
data
:
limit
:
10
timeRanges
:
0-3
snapshots
:
-
A-B-C
-
A-B-C-A
...
...
@@ -139,6 +143,7 @@ list:
# case 5:
-
data
:
limit
:
10
timeRanges
:
0-3
snapshots
:
-
A-B-C
-
A-B-B-C
...
...
@@ -177,6 +182,7 @@ list:
# case 6:
-
data
:
limit
:
10
timeRanges
:
0-2
snapshots
:
-
A-B-C
-
A-B
...
...
@@ -204,6 +210,7 @@ list:
# case 7(only analyze first 10 snapshots):
-
data
:
limit
:
10
timeRanges
:
0-10
snapshots
:
-
A
-
A
...
...
@@ -220,3 +227,20 @@ list:
-
code
:
A
count
:
10
duration
:
90:90
# case 8(multiple time ranges)
-
data
:
limit
:
10
timeRanges
:
0-2,4-5
snapshots
:
-
A
-
A
-
A
-
A-C
-
A
-
A
-
A-D
expected
:
-
code
:
A
count
:
5
duration
:
30:30
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录