Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
bec40b6e
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,发现更多精彩内容 >>
提交
bec40b6e
编写于
6月 07, 2017
作者:
P
pengys5
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed testcase error
上级
7e17692d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
35 addition
and
97 deletion
+35
-97
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/analysis/SegmentAnalysis.java
...pm/collector/worker/segment/analysis/SegmentAnalysis.java
+6
-3
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/JsonBuilder.java
...king/apm/collector/worker/segment/entity/JsonBuilder.java
+0
-70
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/persistence/SegmentTopSearchWithTimeSlice.java
...er/segment/persistence/SegmentTopSearchWithTimeSlice.java
+15
-12
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/tools/JsonFileReader.java
...skywalking/apm/collector/worker/tools/JsonFileReader.java
+6
-0
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/httpserver/AbstractGetTestCase.java
.../apm/collector/worker/httpserver/AbstractGetTestCase.java
+7
-11
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/span/persistence/SpanSearchWithIdTestCase.java
...tor/worker/span/persistence/SpanSearchWithIdTestCase.java
+1
-1
未找到文件。
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/analysis/SegmentAnalysis.java
浏览文件 @
bec40b6e
...
...
@@ -2,12 +2,15 @@ package org.skywalking.apm.collector.worker.segment.analysis;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.skywalking.apm.collector.actor.*
;
import
org.skywalking.apm.collector.actor.AbstractLocalAsyncWorkerProvider
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.actor.LocalWorkerContext
;
import
org.skywalking.apm.collector.actor.ProviderNotFoundException
;
import
org.skywalking.apm.collector.actor.WorkerRefs
;
import
org.skywalking.apm.collector.actor.selector.RollingSelector
;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.worker.RecordAnalysisMember
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.segment.entity.Segment
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentAndJson
;
import
org.skywalking.apm.collector.worker.segment.persistence.SegmentSave
;
...
...
@@ -30,7 +33,7 @@ public class SegmentAnalysis extends RecordAnalysisMember {
@Override
public
void
analyse
(
Object
message
)
throws
Exception
{
if
(
message
instanceof
SegmentAndJson
)
{
SegmentAndJson
segmentAndJson
=
(
SegmentAndJson
)
message
;
SegmentAndJson
segmentAndJson
=
(
SegmentAndJson
)
message
;
getSelfContext
().
lookup
(
SegmentSave
.
Role
.
INSTANCE
).
tell
(
segmentAndJson
);
}
else
{
logger
.
error
(
"unhandled message, message instance must Segment, but is %s"
,
message
.
getClass
().
toString
());
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/JsonBuilder.java
已删除
100644 → 0
浏览文件 @
7e17692d
package
org.skywalking.apm.collector.worker.segment.entity
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author pengys5
*/
public
enum
JsonBuilder
{
INSTANCE
;
public
void
append
(
StringBuilder
builder
,
String
name
,
String
value
,
boolean
first
)
{
if
(!
first
)
{
builder
.
append
(
","
);
}
builder
.
append
(
"\""
).
append
(
name
).
append
(
"\":\""
).
append
(
value
).
append
(
"\""
);
}
public
void
append
(
StringBuilder
builder
,
String
name
,
Number
value
,
boolean
first
)
{
if
(!
first
)
{
builder
.
append
(
","
);
}
builder
.
append
(
"\""
).
append
(
name
).
append
(
"\":"
).
append
(
value
);
}
public
void
append
(
StringBuilder
builder
,
String
name
,
List
<?>
value
,
boolean
first
)
{
if
(!
first
)
{
builder
.
append
(
","
);
}
builder
.
append
(
"\""
).
append
(
name
).
append
(
"\":"
);
builder
.
append
(
"["
);
boolean
isFirst
=
true
;
for
(
int
i
=
0
;
i
<
value
.
size
();
i
++)
{
DeserializeObject
deserializeObject
=
(
DeserializeObject
)
value
.
get
(
i
);
if
(!
isFirst
)
{
builder
.
append
(
","
);
}
builder
.
append
(
deserializeObject
.
getJsonStr
());
isFirst
=
false
;
}
builder
.
append
(
"]"
);
}
public
void
append
(
StringBuilder
builder
,
String
name
,
Map
<
String
,
?>
tagsWithStr
,
boolean
first
)
{
if
(!
first
)
{
builder
.
append
(
","
);
}
builder
.
append
(
"\""
).
append
(
name
).
append
(
"\":"
);
builder
.
append
(
"{"
);
boolean
isFirst
=
true
;
for
(
Map
.
Entry
<
String
,
?>
entry
:
tagsWithStr
.
entrySet
())
{
String
key
=
entry
.
getKey
();
Object
value
=
entry
.
getValue
();
if
(!
isFirst
)
{
builder
.
append
(
","
);
}
if
(
value
instanceof
String
)
{
builder
.
append
(
"\""
).
append
(
key
).
append
(
"\":\""
).
append
(
value
).
append
(
"\""
);
}
else
{
builder
.
append
(
"\""
).
append
(
key
).
append
(
"\":"
).
append
(
value
);
}
isFirst
=
false
;
}
builder
.
append
(
"}"
);
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/persistence/SegmentTopSearchWithTimeSlice.java
浏览文件 @
bec40b6e
...
...
@@ -2,6 +2,7 @@ package org.skywalking.apm.collector.worker.segment.persistence;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
java.util.List
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchType
;
...
...
@@ -10,27 +11,29 @@ import org.elasticsearch.index.query.QueryBuilders;
import
org.elasticsearch.index.query.RangeQueryBuilder
;
import
org.elasticsearch.search.SearchHit
;
import
org.elasticsearch.search.sort.SortOrder
;
import
org.skywalking.apm.collector.actor.*
;
import
org.skywalking.apm.collector.actor.AbstractLocalSyncWorker
;
import
org.skywalking.apm.collector.actor.AbstractLocalSyncWorkerProvider
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.actor.LocalWorkerContext
;
import
org.skywalking.apm.collector.actor.ProviderNotFoundException
;
import
org.skywalking.apm.collector.actor.Role
;
import
org.skywalking.apm.collector.actor.selector.RollingSelector
;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.worker.segment.SegmentCostIndex
;
import
org.skywalking.apm.collector.worker.segment.SegmentExceptionIndex
;
import
org.skywalking.apm.collector.worker.segment.SegmentIndex
;
import
org.skywalking.apm.collector.worker.segment.entity.GlobalTraceId
;
import
org.skywalking.apm.collector.worker.segment.entity.Segment
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentDeserialize
;
import
org.skywalking.apm.collector.worker.storage.EsClient
;
import
org.skywalking.apm.collector.worker.tools.CollectionTools
;
import
java.util.List
;
/**
* @author pengys5
*/
public
class
SegmentTopSearchWithTimeSlice
extends
AbstractLocalSyncWorker
{
private
SegmentTopSearchWithTimeSlice
(
Role
role
,
ClusterWorkerContext
clusterContext
,
LocalWorkerContext
selfContext
)
{
LocalWorkerContext
selfContext
)
{
super
(
role
,
clusterContext
,
selfContext
);
}
...
...
@@ -42,7 +45,7 @@ public class SegmentTopSearchWithTimeSlice extends AbstractLocalSyncWorker {
@Override
protected
void
onWork
(
Object
request
,
Object
response
)
throws
Exception
{
if
(
request
instanceof
RequestEntity
)
{
RequestEntity
search
=
(
RequestEntity
)
request
;
RequestEntity
search
=
(
RequestEntity
)
request
;
SearchRequestBuilder
searchRequestBuilder
=
EsClient
.
INSTANCE
.
getClient
().
prepareSearch
(
SegmentCostIndex
.
INDEX
);
searchRequestBuilder
.
setTypes
(
SegmentCostIndex
.
TYPE_RECORD
);
...
...
@@ -77,15 +80,15 @@ public class SegmentTopSearchWithTimeSlice extends AbstractLocalSyncWorker {
for
(
SearchHit
searchHit
:
searchResponse
.
getHits
().
getHits
())
{
JsonObject
topSegmentJson
=
new
JsonObject
();
topSegmentJson
.
addProperty
(
"num"
,
num
);
String
segId
=
(
String
)
searchHit
.
getSource
().
get
(
SegmentCostIndex
.
SEG_ID
);
String
segId
=
(
String
)
searchHit
.
getSource
().
get
(
SegmentCostIndex
.
SEG_ID
);
topSegmentJson
.
addProperty
(
SegmentCostIndex
.
SEG_ID
,
segId
);
topSegmentJson
.
addProperty
(
SegmentCostIndex
.
START_TIME
,
(
Number
)
searchHit
.
getSource
().
get
(
SegmentCostIndex
.
START_TIME
));
topSegmentJson
.
addProperty
(
SegmentCostIndex
.
START_TIME
,
(
Number
)
searchHit
.
getSource
().
get
(
SegmentCostIndex
.
START_TIME
));
if
(
searchHit
.
getSource
().
containsKey
(
SegmentCostIndex
.
END_TIME
))
{
topSegmentJson
.
addProperty
(
SegmentCostIndex
.
END_TIME
,
(
Number
)
searchHit
.
getSource
().
get
(
SegmentCostIndex
.
END_TIME
));
topSegmentJson
.
addProperty
(
SegmentCostIndex
.
END_TIME
,
(
Number
)
searchHit
.
getSource
().
get
(
SegmentCostIndex
.
END_TIME
));
}
topSegmentJson
.
addProperty
(
SegmentCostIndex
.
OPERATION_NAME
,
(
String
)
searchHit
.
getSource
().
get
(
SegmentCostIndex
.
OPERATION_NAME
));
topSegmentJson
.
addProperty
(
SegmentCostIndex
.
COST
,
(
Number
)
searchHit
.
getSource
().
get
(
SegmentCostIndex
.
COST
));
topSegmentJson
.
addProperty
(
SegmentCostIndex
.
OPERATION_NAME
,
(
String
)
searchHit
.
getSource
().
get
(
SegmentCostIndex
.
OPERATION_NAME
));
topSegmentJson
.
addProperty
(
SegmentCostIndex
.
COST
,
(
Number
)
searchHit
.
getSource
().
get
(
SegmentCostIndex
.
COST
));
String
segmentSource
=
EsClient
.
INSTANCE
.
getClient
().
prepareGet
(
SegmentIndex
.
INDEX
,
SegmentIndex
.
TYPE_RECORD
,
segId
).
get
().
getSourceAsString
();
logger
().
debug
(
"segmentSource:"
+
segmentSource
);
...
...
@@ -115,7 +118,7 @@ public class SegmentTopSearchWithTimeSlice extends AbstractLocalSyncWorker {
topSegArray
.
add
(
topSegmentJson
);
}
JsonObject
resJsonObj
=
(
JsonObject
)
response
;
JsonObject
resJsonObj
=
(
JsonObject
)
response
;
resJsonObj
.
add
(
"result"
,
topSegPaging
);
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/tools/JsonFileReader.java
浏览文件 @
bec40b6e
...
...
@@ -15,6 +15,12 @@ public enum JsonFileReader {
public
String
read
(
String
path
)
throws
FileNotFoundException
{
JsonParser
jsonParser
=
new
JsonParser
();
JsonElement
jsonElement
=
jsonParser
.
parse
(
new
FileReader
(
path
));
return
jsonElement
.
toString
();
}
public
String
readSegment
(
String
path
)
throws
FileNotFoundException
{
JsonParser
jsonParser
=
new
JsonParser
();
JsonElement
jsonElement
=
jsonParser
.
parse
(
new
FileReader
(
path
));
StringBuilder
segmentBuilder
=
new
StringBuilder
();
JsonArray
segments
=
jsonElement
.
getAsJsonArray
();
...
...
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/httpserver/AbstractGetTestCase.java
浏览文件 @
bec40b6e
package
org.skywalking.apm.collector.worker.httpserver
;
import
com.google.gson.JsonObject
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
static
org
.
mockito
.
Mockito
.*;
import
static
org
.
mockito
.
Mockito
.
any
;
import
static
org
.
mockito
.
Mockito
.
doThrow
;
import
static
org
.
mockito
.
Mockito
.
spy
;
import
static
org
.
mockito
.
Mockito
.
verify
;
/**
* @author pengys5
*/
public
class
AbstractGetTestCase
{
private
TestAbstractGet
get
;
@Before
public
void
init
()
{
get
=
mock
(
TestAbstractGet
.
class
);
}
private
TestAbstractGet
get
=
spy
(
new
TestAbstractGet
(
TestAbstractGet
.
WorkerRole
.
INSTANCE
,
null
,
null
));
@Test
public
void
testOnWork
()
throws
Exception
{
...
...
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/span/persistence/SpanSearchWithIdTestCase.java
浏览文件 @
bec40b6e
...
...
@@ -75,7 +75,7 @@ public class SpanSearchWithIdTestCase {
spanSearchWithId
.
onWork
(
request
,
response
);
JsonObject
spanJsonObj
=
response
.
get
(
Const
.
RESULT
).
getAsJsonObject
();
String
value
=
spanJsonObj
.
get
(
"o
perationName
"
).
getAsString
();
String
value
=
spanJsonObj
.
get
(
"o
n
"
).
getAsString
();
Assert
.
assertEquals
(
"/portal/"
,
value
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录