Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
4f7372c4
S
SkyWalking
项目概览
山不在高_有仙则灵
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
12
Star
0
Fork
2
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
4f7372c4
编写于
1月 29, 2016
作者:
A
ascrutae
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master'
上级
22f12c20
3aa2156e
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
265 addition
and
175 deletion
+265
-175
skywalking-protocol/src/main/java/com/ai/cloud/skywalking/protocol/Span.java
.../src/main/java/com/ai/cloud/skywalking/protocol/Span.java
+30
-30
skywalking-protocol/src/main/java/com/ai/cloud/skywalking/protocol/SpanData.java
.../main/java/com/ai/cloud/skywalking/protocol/SpanData.java
+83
-6
skywalking-sdk-plugin/httpclient-4.2.x-plugin/src/main/java/com/ai/cloud/skywalking/plugin/httpclient/v42x/HttpClientTracing.java
.../skywalking/plugin/httpclient/v42x/HttpClientTracing.java
+1
-1
skywalking-sdk-plugin/httpclient-4.2.x-plugin/src/main/java/com/ai/cloud/skywalking/plugin/httpclient/v42x/WebBuriedPointType.java
...skywalking/plugin/httpclient/v42x/WebBuriedPointType.java
+4
-4
skywalking-sdk-plugin/httpclient-4.3.x-plugin/src/main/java/com/ai/cloud/skywalking/plugin/httpclient/v43x/HttpClientTracing.java
.../skywalking/plugin/httpclient/v43x/HttpClientTracing.java
+1
-1
skywalking-sdk-plugin/httpclient-4.3.x-plugin/src/main/java/com/ai/cloud/skywalking/plugin/httpclient/v43x/WebBuriedPointType.java
...skywalking/plugin/httpclient/v43x/WebBuriedPointType.java
+4
-4
skywalking-sdk-plugin/web-plugin/src/main/java/com/ai/cloud/skywalking/plugin/web/SkyWalkingFilter.java
.../com/ai/cloud/skywalking/plugin/web/SkyWalkingFilter.java
+1
-1
skywalking-sdk-plugin/web-plugin/src/main/java/com/ai/cloud/skywalking/plugin/web/WebBuriedPointType.java
...om/ai/cloud/skywalking/plugin/web/WebBuriedPointType.java
+4
-4
skywalking-webui/src/main/java/com/ai/cloud/util/common/SortUtil.java
...ebui/src/main/java/com/ai/cloud/util/common/SortUtil.java
+0
-124
skywalking-webui/src/test/java/com/ai/cloud/util/common/SortTest.java
...ebui/src/test/java/com/ai/cloud/util/common/SortTest.java
+137
-0
未找到文件。
skywalking-protocol/src/main/java/com/ai/cloud/skywalking/protocol/Span.java
浏览文件 @
4f7372c4
...
...
@@ -29,7 +29,7 @@ public class Span extends SpanData {
}
public
Span
(
String
originData
)
{
String
[]
fieldValues
=
originData
.
split
(
SPAN_FIELD_S
PILT_PATTERN
);
String
[]
fieldValues
=
originData
.
split
(
SPAN_FIELD_S
EPARATOR
);
int
index
=
0
;
while
(
this
.
setValueByIndex
(
fieldValues
,
index
))
{
...
...
@@ -67,7 +67,7 @@ public class Span extends SpanData {
break
;
case
8
:
exceptionStack
=
fieldValues
[
8
].
trim
().
replaceAll
(
SPAN_ATTR_SPILT_CHARACTER
,
NEW_LINE_CHARACTER_PATTERN
);
NEW_LINE_PLACEHOLDER
,
OS_NEW_LINE
);
break
;
case
9
:
spanType
=
fieldValues
[
9
];
...
...
@@ -77,7 +77,7 @@ public class Span extends SpanData {
break
;
case
11
:
businessKey
=
fieldValues
[
11
].
trim
().
replaceAll
(
SPAN_ATTR_SPILT_CHARACTER
,
NEW_LINE_CHARACTER_PATTERN
);
NEW_LINE_PLACEHOLDER
,
OS_NEW_LINE
);
break
;
case
12
:
processNo
=
fieldValues
[
12
].
trim
();
...
...
@@ -104,76 +104,76 @@ public class Span extends SpanData {
@Override
public
String
toString
()
{
StringBuilder
toStringValue
=
new
StringBuilder
();
toStringValue
.
append
(
traceId
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
traceId
+
SPAN_FIELD_S
EPARATOR
);
if
(
isNonBlank
(
parentLevel
))
{
toStringValue
.
append
(
parentLevel
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
parentLevel
+
SPAN_FIELD_S
EPARATOR
);
}
else
{
toStringValue
.
append
(
" "
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
" "
+
SPAN_FIELD_S
EPARATOR
);
}
toStringValue
.
append
(
levelId
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
levelId
+
SPAN_FIELD_S
EPARATOR
);
if
(
isNonBlank
(
viewPointId
))
{
toStringValue
.
append
(
viewPointId
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
viewPointId
+
SPAN_FIELD_S
EPARATOR
);
}
else
{
toStringValue
.
append
(
" "
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
" "
+
SPAN_FIELD_S
EPARATOR
);
}
toStringValue
.
append
(
startDate
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
cost
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
startDate
+
SPAN_FIELD_S
EPARATOR
);
toStringValue
.
append
(
cost
+
SPAN_FIELD_S
EPARATOR
);
if
(
isNonBlank
(
address
))
{
toStringValue
.
append
(
address
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
address
+
SPAN_FIELD_S
EPARATOR
);
}
else
{
toStringValue
.
append
(
" "
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
" "
+
SPAN_FIELD_S
EPARATOR
);
}
toStringValue
.
append
(
statusCode
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
statusCode
+
SPAN_FIELD_S
EPARATOR
);
if
(
isNonBlank
(
exceptionStack
))
{
// 换行符在各个系统中表现不一致,
// windows平台的换行符为/r/n
// linux平台的换行符为/n
toStringValue
.
append
(
exceptionStack
.
replaceAll
(
CARRIAGE_RETURN_CHARACTER_PATTERN
,
""
).
replaceAll
(
NEW_LINE_CHARACTER_PATTERN
,
SPAN_ATTR_SPILT_CHARACT
ER
)
+
SPAN_FIELD_S
PILT_PATTERN
);
WINDOWS_OS_NEW_LINE_REDUNDANT_CHAR
,
""
).
replaceAll
(
OS_NEW_LINE
,
NEW_LINE_PLACEHOLD
ER
)
+
SPAN_FIELD_S
EPARATOR
);
}
else
{
toStringValue
.
append
(
" "
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
" "
+
SPAN_FIELD_S
EPARATOR
);
}
toStringValue
.
append
(
spanType
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
isReceiver
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
spanType
+
SPAN_FIELD_S
EPARATOR
);
toStringValue
.
append
(
isReceiver
+
SPAN_FIELD_S
EPARATOR
);
if
(
isNonBlank
(
businessKey
))
{
// 换行符在各个系统中表现不一致,
// windows平台的换行符为/r/n
// linux平台的换行符为/n
toStringValue
.
append
(
businessKey
.
replaceAll
(
CARRIAGE_RETURN_CHARACTER_PATTERN
,
""
).
replaceAll
(
NEW_LINE_CHARACTER_PATTERN
,
SPAN_ATTR_SPILT_CHARACT
ER
)
+
SPAN_FIELD_S
PILT_PATTERN
);
WINDOWS_OS_NEW_LINE_REDUNDANT_CHAR
,
""
).
replaceAll
(
OS_NEW_LINE
,
NEW_LINE_PLACEHOLD
ER
)
+
SPAN_FIELD_S
EPARATOR
);
}
else
{
toStringValue
.
append
(
" "
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
" "
+
SPAN_FIELD_S
EPARATOR
);
}
if
(
isNonBlank
(
processNo
))
{
toStringValue
.
append
(
processNo
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
processNo
+
SPAN_FIELD_S
EPARATOR
);
}
else
{
toStringValue
.
append
(
" "
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
" "
+
SPAN_FIELD_S
EPARATOR
);
}
if
(
isNonBlank
(
applicationId
))
{
toStringValue
.
append
(
applicationId
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
applicationId
+
SPAN_FIELD_S
EPARATOR
);
}
else
{
toStringValue
.
append
(
" "
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
" "
+
SPAN_FIELD_S
EPARATOR
);
}
if
(
isNonBlank
(
userId
))
{
toStringValue
.
append
(
userId
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
userId
+
SPAN_FIELD_S
EPARATOR
);
}
else
{
toStringValue
.
append
(
" "
+
SPAN_FIELD_S
PILT_PATTERN
);
toStringValue
.
append
(
" "
+
SPAN_FIELD_S
EPARATOR
);
}
toStringValue
.
append
(
callType
);
...
...
skywalking-protocol/src/main/java/com/ai/cloud/skywalking/protocol/SpanData.java
浏览文件 @
4f7372c4
package
com.ai.cloud.skywalking.protocol
;
public
abstract
class
SpanData
{
protected
static
final
String
SPAN_FIELD_SPILT_PATTERN
=
"@~"
;
protected
static
final
String
SPAN_ATTR_SPILT_CHARACTER
=
"#~"
;
protected
static
final
String
NEW_LINE_CHARACTER_PATTERN
=
"\n"
;
protected
static
final
String
CARRIAGE_RETURN_CHARACTER_PATTERN
=
"\r"
;
/**
* Span在序列中,各字段间的分隔符
*/
protected
static
final
String
SPAN_FIELD_SEPARATOR
=
"@~"
;
/**
* Span在序列化中,新的换行符
*/
protected
static
final
String
NEW_LINE_PLACEHOLDER
=
"#~"
;
/**
* 字符串中的换行符
*/
protected
static
final
String
OS_NEW_LINE
=
"\n"
;
/**
* windows操作系统的多余换行字符
*/
protected
static
final
String
WINDOWS_OS_NEW_LINE_REDUNDANT_CHAR
=
"\r"
;
/**
* tid,调用链的全局唯一标识
*/
protected
String
traceId
;
/**
* 当前调用链的上级描述<br/>
* 如当前序号为:0.1.0时,parentLevel=0.1
*/
protected
String
parentLevel
;
/**
* 当前调用链的本机描述<br/>
* 如当前序号为:0.1.0时,levelId=0
*/
protected
int
levelId
=
0
;
/**
* 调用链中单个节点的入口描述<br/>
* 如:java方法名,调用的RPC地址等等
*/
protected
String
viewPointId
=
""
;
/**
* 节点调用开始时间
*/
protected
long
startDate
=
System
.
currentTimeMillis
();
/**
* 节点调用花费时间
*/
protected
long
cost
=
0L
;
/**
* 节点调用的发生机器描述<br/>
* 包含机器名 + IP地址
*/
protected
String
address
=
""
;
/**
* 节点调用的状态<br/>
* 0:成功<br/>
* 1:异常<br/>
* 异常判断原则:代码产生exception,并且此exception不在忽略列表中
*/
protected
byte
statusCode
=
0
;
/**
* 节点调用的错误堆栈<br/>
* 堆栈以JAVA的exception为主要判断依据
*/
protected
String
exceptionStack
;
/**
* 节点类型描述<br/>
* 已字符串的形式描述<br/>
* 如:java,dubbo等
*/
protected
String
spanType
=
""
;
/**
* 节点调用类型描述<br/>
* @see com.ai.cloud.skywalking.protocol.CallType
*/
protected
String
callType
=
""
;
/**
* 节点分布式类型<br/>
* 服务端/客户端
*/
protected
boolean
isReceiver
=
false
;
/**
* 节点调用过程中的业务字段<br/>
* 如:业务系统设置的订单号,SQL语句等
*/
protected
String
businessKey
=
""
;
/**
* 节点调用的所在进程号
*/
protected
String
processNo
=
""
;
/**
* 节点调用所在的系统逻辑名称<br/>
* 由授权文件指定
*/
protected
String
applicationId
=
""
;
/**
* 反序列化时,存储序列化前的字符串原文
*/
protected
String
originData
=
""
;
/**
* 用户id<br/>
* 由授权文件指定
*/
protected
String
userId
;
...
...
skywalking-sdk-plugin/httpclient-4.2.x-plugin/src/main/java/com/ai/cloud/skywalking/plugin/httpclient/v42x/HttpClientTracing.java
浏览文件 @
4f7372c4
...
...
@@ -20,7 +20,7 @@ public class HttpClientTracing {
httpRequest
.
setHeader
(
traceHearName
,
"ContextData="
+
sender
.
beforeSend
(
Identification
.
newBuilder
()
.
viewPoint
(
url
)
.
spanType
(
W
EB
BuriedPointType
.
instance
())
.
spanType
(
W
eb
BuriedPointType
.
instance
())
.
build
())
.
toString
());
return
executor
.
execute
();
...
...
skywalking-sdk-plugin/httpclient-4.2.x-plugin/src/main/java/com/ai/cloud/skywalking/plugin/httpclient/v42x/W
EB
BuriedPointType.java
→
skywalking-sdk-plugin/httpclient-4.2.x-plugin/src/main/java/com/ai/cloud/skywalking/plugin/httpclient/v42x/W
eb
BuriedPointType.java
浏览文件 @
4f7372c4
...
...
@@ -3,13 +3,13 @@ package com.ai.cloud.skywalking.plugin.httpclient.v42x;
import
com.ai.cloud.skywalking.api.IBuriedPointType
;
import
com.ai.cloud.skywalking.protocol.CallType
;
public
class
W
EB
BuriedPointType
implements
IBuriedPointType
{
public
class
W
eb
BuriedPointType
implements
IBuriedPointType
{
private
static
W
EB
BuriedPointType
webBuriedPointType
;
private
static
W
eb
BuriedPointType
webBuriedPointType
;
public
static
IBuriedPointType
instance
()
{
if
(
webBuriedPointType
==
null
)
{
webBuriedPointType
=
new
W
EB
BuriedPointType
();
webBuriedPointType
=
new
W
eb
BuriedPointType
();
}
return
webBuriedPointType
;
...
...
@@ -25,7 +25,7 @@ public class WEBBuriedPointType implements IBuriedPointType {
return
CallType
.
SYNC
;
}
private
W
EB
BuriedPointType
()
{
private
W
eb
BuriedPointType
()
{
// Non
}
}
skywalking-sdk-plugin/httpclient-4.3.x-plugin/src/main/java/com/ai/cloud/skywalking/plugin/httpclient/v43x/HttpClientTracing.java
浏览文件 @
4f7372c4
...
...
@@ -20,7 +20,7 @@ public class HttpClientTracing {
httpRequest
.
setHeader
(
traceHearName
,
"ContextData="
+
sender
.
beforeSend
(
Identification
.
newBuilder
()
.
viewPoint
(
url
)
.
spanType
(
W
EB
BuriedPointType
.
instance
())
.
spanType
(
W
eb
BuriedPointType
.
instance
())
.
build
())
.
toString
());
return
executor
.
execute
();
...
...
skywalking-sdk-plugin/httpclient-4.3.x-plugin/src/main/java/com/ai/cloud/skywalking/plugin/httpclient/v43x/W
EB
BuriedPointType.java
→
skywalking-sdk-plugin/httpclient-4.3.x-plugin/src/main/java/com/ai/cloud/skywalking/plugin/httpclient/v43x/W
eb
BuriedPointType.java
浏览文件 @
4f7372c4
...
...
@@ -3,13 +3,13 @@ package com.ai.cloud.skywalking.plugin.httpclient.v43x;
import
com.ai.cloud.skywalking.api.IBuriedPointType
;
import
com.ai.cloud.skywalking.protocol.CallType
;
public
class
W
EB
BuriedPointType
implements
IBuriedPointType
{
public
class
W
eb
BuriedPointType
implements
IBuriedPointType
{
private
static
W
EB
BuriedPointType
webBuriedPointType
;
private
static
W
eb
BuriedPointType
webBuriedPointType
;
public
static
IBuriedPointType
instance
()
{
if
(
webBuriedPointType
==
null
)
{
webBuriedPointType
=
new
W
EB
BuriedPointType
();
webBuriedPointType
=
new
W
eb
BuriedPointType
();
}
return
webBuriedPointType
;
...
...
@@ -25,7 +25,7 @@ public class WEBBuriedPointType implements IBuriedPointType {
return
CallType
.
SYNC
;
}
private
W
EB
BuriedPointType
()
{
private
W
eb
BuriedPointType
()
{
// Non
}
}
skywalking-sdk-plugin/web-plugin/src/main/java/com/ai/cloud/skywalking/plugin/web/SkyWalkingFilter.java
浏览文件 @
4f7372c4
...
...
@@ -70,7 +70,7 @@ public class SkyWalkingFilter implements Filter {
private
Identification
generateIdentification
(
HttpServletRequest
request
)
{
return
Identification
.
newBuilder
()
.
viewPoint
(
request
.
getRequestURL
().
toString
())
.
spanType
(
W
EB
BuriedPointType
.
instance
())
.
spanType
(
W
eb
BuriedPointType
.
instance
())
.
build
();
}
...
...
skywalking-sdk-plugin/web-plugin/src/main/java/com/ai/cloud/skywalking/plugin/web/W
EB
BuriedPointType.java
→
skywalking-sdk-plugin/web-plugin/src/main/java/com/ai/cloud/skywalking/plugin/web/W
eb
BuriedPointType.java
浏览文件 @
4f7372c4
...
...
@@ -3,13 +3,13 @@ package com.ai.cloud.skywalking.plugin.web;
import
com.ai.cloud.skywalking.api.IBuriedPointType
;
import
com.ai.cloud.skywalking.protocol.CallType
;
public
class
W
EB
BuriedPointType
implements
IBuriedPointType
{
public
class
W
eb
BuriedPointType
implements
IBuriedPointType
{
private
static
W
EB
BuriedPointType
webBuriedPointType
;
private
static
W
eb
BuriedPointType
webBuriedPointType
;
public
static
IBuriedPointType
instance
()
{
if
(
webBuriedPointType
==
null
)
{
webBuriedPointType
=
new
W
EB
BuriedPointType
();
webBuriedPointType
=
new
W
eb
BuriedPointType
();
}
return
webBuriedPointType
;
...
...
@@ -25,7 +25,7 @@ public class WEBBuriedPointType implements IBuriedPointType {
return
CallType
.
SYNC
;
}
private
W
EB
BuriedPointType
()
{
private
W
eb
BuriedPointType
()
{
// Non
}
}
skywalking-webui/src/main/java/com/ai/cloud/util/common/SortUtil.java
浏览文件 @
4f7372c4
...
...
@@ -3,21 +3,11 @@
*/
package
com.ai.cloud.util.common
;
import
java.io.IOException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.junit.Test
;
import
com.ai.cloud.dao.impl.BuriedPointSDAO
;
import
com.ai.cloud.util.Constants
;
import
com.ai.cloud.vo.mvo.TraceLogEntry
;
...
...
@@ -73,118 +63,4 @@ public class SortUtil {
return
false
;
}
}
/**
* 测试读取hbase 测试自动补充父级节点 测试排序
*
* @throws IOException
* @throws NoSuchMethodException
* @throws InvocationTargetException
* @throws IllegalAccessException
*
*/
@Test
public
void
testSelectByTraceId
()
throws
IOException
,
IllegalAccessException
,
InvocationTargetException
,
NoSuchMethodException
{
BuriedPointSDAO
sdao
=
new
BuriedPointSDAO
();
Map
<
String
,
TraceLogEntry
>
bpe
=
sdao
.
queryLogByTraceId
(
Constants
.
TABLE_NAME_CHAIN
,
"71e28364128847b3a12626966b60fd8f123"
);
List
<
TraceLogEntry
>
keyList
=
new
ArrayList
<
TraceLogEntry
>();
keyList
.
addAll
(
bpe
.
values
());
Collections
.
sort
(
keyList
,
new
Comparator
<
TraceLogEntry
>()
{
@Override
public
int
compare
(
TraceLogEntry
arg0
,
TraceLogEntry
arg1
)
{
return
arg0
.
getColId
().
compareTo
(
arg1
.
getColId
());
}
});
int
m
=
1
;
for
(
TraceLogEntry
tmpEntry
:
keyList
)
{
logger
.
info
(
"sort result level:{} : {}"
,
m
++,
tmpEntry
);
}
}
/***
* 深度补全测试
*
* @throws IOException
*/
@Test
public
void
testGenTreeMapKey
()
throws
IOException
{
StringBuffer
sb
=
new
StringBuffer
(
"0"
);
/***
* 深度测试 level 5 [ 11ms ] level 10[ 11ms ] level 15[ 11ms ] level 20[
* 12ms ] level 50[ 12ms ] level 100[ 12ms ] level 500[ 12ms ] level
* 1000[ 16ms ] level 2000[ 28ms ] level 5000[ 144ms ] level10000[ 445ms
* ]
*/
for
(
int
i
=
1
;
i
<
10000
;
i
++)
{
sb
.
append
(
".0"
);
}
String
colId
=
sb
.
toString
();
TraceLogEntry
tmpEntry
=
null
;
Map
<
String
,
TraceLogEntry
>
reMap
=
new
HashMap
<
String
,
TraceLogEntry
>();
long
startTime
=
System
.
currentTimeMillis
();
logger
.
info
(
"start time : {}"
,
startTime
);
addCurNodeTreeMapKey
(
reMap
,
colId
,
tmpEntry
);
long
endTime
=
System
.
currentTimeMillis
();
logger
.
info
(
"end time : {}"
,
endTime
);
logger
.
info
(
"run time : {} ms"
,
(
endTime
-
startTime
));
// List<String> keyList = new ArrayList<String>();
// keyList.addAll(reMap.keySet());
// Collections.sort(keyList);
// int m = 1;
// for (String str : keyList) {
// logger.info("sort result level:{} : {}", m++, str);
// }
}
/***
* collection sort 性能测试
*
* @param args
*/
@Test
public
void
testSortList
()
{
List
<
String
>
StrList
=
new
ArrayList
<
String
>();
Random
random
=
new
Random
(
System
.
currentTimeMillis
());
StrList
.
add
(
"0"
);
/***
* Collections.sort(StrList)性能 1000条/19 ms 10000条/42 ms 100000条/129 ms
* 1000000条/1070 ms
*/
for
(
int
m
=
0
;
m
<
1000
;
m
++)
{
String
radNum
=
""
+
Math
.
abs
(
random
.
nextLong
());
StringBuffer
tmpBf
=
new
StringBuffer
(
"0"
);
for
(
int
n
=
0
;
n
<
radNum
.
length
();
n
++)
{
tmpBf
.
append
(
"."
).
append
(
radNum
.
charAt
(
n
));
}
StrList
.
add
(
tmpBf
.
toString
());
}
long
startTime
=
System
.
currentTimeMillis
();
logger
.
info
(
"start time : {}"
,
startTime
);
Collections
.
sort
(
StrList
);
long
endTime
=
System
.
currentTimeMillis
();
logger
.
info
(
"end time : {}"
,
endTime
);
logger
.
info
(
"run time : {} ms"
,
(
endTime
-
startTime
));
// int i = 1;
// for (String tmpStr : StrList) {
// logger.info("sort {} : {}", i++, tmpStr);
// }
}
}
skywalking-webui/src/test/java/com/ai/cloud/util/common/SortTest.java
0 → 100644
浏览文件 @
4f7372c4
package
com.ai.cloud.util.common
;
import
java.io.IOException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.junit.Test
;
import
com.ai.cloud.dao.impl.BuriedPointSDAO
;
import
com.ai.cloud.util.Constants
;
import
com.ai.cloud.vo.mvo.TraceLogEntry
;
public
class
SortTest
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
SortUtil
.
class
);
/**
* 测试读取hbase 测试自动补充父级节点 测试排序
*
* @throws IOException
* @throws NoSuchMethodException
* @throws InvocationTargetException
* @throws IllegalAccessException
*
*/
@Test
public
void
testSelectByTraceId
()
throws
IOException
,
IllegalAccessException
,
InvocationTargetException
,
NoSuchMethodException
{
BuriedPointSDAO
sdao
=
new
BuriedPointSDAO
();
Map
<
String
,
TraceLogEntry
>
bpe
=
sdao
.
queryLogByTraceId
(
Constants
.
TABLE_NAME_CHAIN
,
"71e28364128847b3a12626966b60fd8f123"
);
List
<
TraceLogEntry
>
keyList
=
new
ArrayList
<
TraceLogEntry
>();
keyList
.
addAll
(
bpe
.
values
());
Collections
.
sort
(
keyList
,
new
Comparator
<
TraceLogEntry
>()
{
@Override
public
int
compare
(
TraceLogEntry
arg0
,
TraceLogEntry
arg1
)
{
return
arg0
.
getColId
().
compareTo
(
arg1
.
getColId
());
}
});
int
m
=
1
;
for
(
TraceLogEntry
tmpEntry
:
keyList
)
{
logger
.
info
(
"sort result level:{} : {}"
,
m
++,
tmpEntry
);
}
}
/***
* 深度补全测试
*
* @throws IOException
*/
@Test
public
void
testGenTreeMapKey
()
throws
IOException
{
StringBuffer
sb
=
new
StringBuffer
(
"0"
);
/***
* 深度测试 level 5 [ 11ms ] level 10[ 11ms ] level 15[ 11ms ] level 20[
* 12ms ] level 50[ 12ms ] level 100[ 12ms ] level 500[ 12ms ] level
* 1000[ 16ms ] level 2000[ 28ms ] level 5000[ 144ms ] level10000[ 445ms
* ]
*/
for
(
int
i
=
1
;
i
<
10000
;
i
++)
{
sb
.
append
(
".0"
);
}
String
colId
=
sb
.
toString
();
TraceLogEntry
tmpEntry
=
null
;
Map
<
String
,
TraceLogEntry
>
reMap
=
new
HashMap
<
String
,
TraceLogEntry
>();
long
startTime
=
System
.
currentTimeMillis
();
logger
.
info
(
"start time : {}"
,
startTime
);
SortUtil
.
addCurNodeTreeMapKey
(
reMap
,
colId
,
tmpEntry
);
long
endTime
=
System
.
currentTimeMillis
();
logger
.
info
(
"end time : {}"
,
endTime
);
logger
.
info
(
"run time : {} ms"
,
(
endTime
-
startTime
));
// List<String> keyList = new ArrayList<String>();
// keyList.addAll(reMap.keySet());
// Collections.sort(keyList);
// int m = 1;
// for (String str : keyList) {
// logger.info("sort result level:{} : {}", m++, str);
// }
}
/***
* collection sort 性能测试
*
* @param args
*/
@Test
public
void
testSortList
()
{
List
<
String
>
StrList
=
new
ArrayList
<
String
>();
Random
random
=
new
Random
(
System
.
currentTimeMillis
());
StrList
.
add
(
"0"
);
/***
* Collections.sort(StrList)性能 1000条/19 ms 10000条/42 ms 100000条/129 ms
* 1000000条/1070 ms
*/
for
(
int
m
=
0
;
m
<
1000
;
m
++)
{
String
radNum
=
""
+
Math
.
abs
(
random
.
nextLong
());
StringBuffer
tmpBf
=
new
StringBuffer
(
"0"
);
for
(
int
n
=
0
;
n
<
radNum
.
length
();
n
++)
{
tmpBf
.
append
(
"."
).
append
(
radNum
.
charAt
(
n
));
}
StrList
.
add
(
tmpBf
.
toString
());
}
long
startTime
=
System
.
currentTimeMillis
();
logger
.
info
(
"start time : {}"
,
startTime
);
Collections
.
sort
(
StrList
);
long
endTime
=
System
.
currentTimeMillis
();
logger
.
info
(
"end time : {}"
,
endTime
);
logger
.
info
(
"run time : {} ms"
,
(
endTime
-
startTime
));
// int i = 1;
// for (String tmpStr : StrList) {
// logger.info("sort {} : {}", i++, tmpStr);
// }
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录