Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
93a45165
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,发现更多精彩内容 >>
提交
93a45165
编写于
7月 05, 2017
作者:
wu-sheng
提交者:
GitHub
7月 05, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #265 from wu-sheng/feature/254
Feature/254
上级
3af55a53
a470b286
变更
103
展开全部
隐藏空白更改
内联
并排
Showing
103 changed file
with
1628 addition
and
1253 deletion
+1628
-1253
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/CollectorSystem.java
...in/java/org/skywalking/apm/collector/CollectorSystem.java
+11
-4
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/actor/AbstractClusterWorker.java
...skywalking/apm/collector/actor/AbstractClusterWorker.java
+11
-1
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/actor/AbstractClusterWorkerProvider.java
...ng/apm/collector/actor/AbstractClusterWorkerProvider.java
+10
-1
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/actor/ClusterWorkerContext.java
.../skywalking/apm/collector/actor/ClusterWorkerContext.java
+8
-3
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/cluster/WorkerListenerMessage.java
...ywalking/apm/collector/cluster/WorkerListenerMessage.java
+1
-2
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/cluster/WorkersListener.java
...org/skywalking/apm/collector/cluster/WorkersListener.java
+1
-1
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/rpc/RPCAddress.java
...ain/java/org/skywalking/apm/collector/rpc/RPCAddress.java
+22
-0
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/rpc/RPCAddressContext.java
...a/org/skywalking/apm/collector/rpc/RPCAddressContext.java
+25
-0
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/rpc/RPCAddressListener.java
.../org/skywalking/apm/collector/rpc/RPCAddressListener.java
+51
-0
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/rpc/RPCAddressListenerMessage.java
...ywalking/apm/collector/rpc/RPCAddressListenerMessage.java
+21
-0
apm-collector/apm-collector-commons/src/main/java/org/skywalking/apm/collector/commons/serializer/JsonSerializer.java
...king/apm/collector/commons/serializer/JsonSerializer.java
+0
-32
apm-collector/apm-collector-commons/src/main/resources/application.conf
...apm-collector-commons/src/main/resources/application.conf
+2
-2
apm-collector/apm-collector-worker/pom.xml
apm-collector/apm-collector-worker/pom.xml
+6
-1
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/CollectorBootStartUp.java
...skywalking/apm/collector/worker/CollectorBootStartUp.java
+2
-0
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/config/GRPCConfig.java
...rg/skywalking/apm/collector/worker/config/GRPCConfig.java
+12
-0
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/config/GRPCConfigProvider.java
...lking/apm/collector/worker/config/GRPCConfigProvider.java
+23
-0
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/config/WorkerConfig.java
.../skywalking/apm/collector/worker/config/WorkerConfig.java
+6
-0
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/globaltrace/GlobalTraceGetWithGlobalId.java
...lector/worker/globaltrace/GlobalTraceGetWithGlobalId.java
+6
-1
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/globaltrace/analysis/GlobalTraceAnalysis.java
...ctor/worker/globaltrace/analysis/GlobalTraceAnalysis.java
+10
-14
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/globaltrace/persistence/GlobalTraceSearchWithGlobalId.java
...lobaltrace/persistence/GlobalTraceSearchWithGlobalId.java
+16
-20
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/grpcserver/AbstractReceiver.java
...ing/apm/collector/worker/grpcserver/AbstractReceiver.java
+27
-0
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/grpcserver/AbstractReceiverProvider.java
...collector/worker/grpcserver/AbstractReceiverProvider.java
+11
-0
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/grpcserver/GRPCAddressGet.java
...lking/apm/collector/worker/grpcserver/GRPCAddressGet.java
+69
-0
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/grpcserver/GRPCAddressRegister.java
.../apm/collector/worker/grpcserver/GRPCAddressRegister.java
+65
-0
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/grpcserver/GRPCServer.java
...kywalking/apm/collector/worker/grpcserver/GRPCServer.java
+41
-0
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/grpcserver/ServicesCreator.java
...king/apm/collector/worker/grpcserver/ServicesCreator.java
+29
-0
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/grpcserver/TraceSegmentServiceImpl.java
.../collector/worker/grpcserver/TraceSegmentServiceImpl.java
+61
-0
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/grpcserver/WorkerCaller.java
...walking/apm/collector/worker/grpcserver/WorkerCaller.java
+13
-0
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/httpserver/AbstractGet.java
...ywalking/apm/collector/worker/httpserver/AbstractGet.java
+2
-2
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/httpserver/AbstractServlet.java
...king/apm/collector/worker/httpserver/AbstractServlet.java
+20
-14
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/httpserver/AbstractStreamPost.java
...g/apm/collector/worker/httpserver/AbstractStreamPost.java
+3
-2
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/httpserver/HttpServer.java
...kywalking/apm/collector/worker/httpserver/HttpServer.java
+0
-1
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/node/analysis/AbstractNodeCompAnalysis.java
...lector/worker/node/analysis/AbstractNodeCompAnalysis.java
+14
-16
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/node/analysis/AbstractNodeMappingAnalysis.java
...tor/worker/node/analysis/AbstractNodeMappingAnalysis.java
+7
-7
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/node/analysis/NodeCompAnalysis.java
.../apm/collector/worker/node/analysis/NodeCompAnalysis.java
+6
-6
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/node/analysis/NodeMappingDayAnalysis.java
...ollector/worker/node/analysis/NodeMappingDayAnalysis.java
+6
-6
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/node/analysis/NodeMappingHourAnalysis.java
...llector/worker/node/analysis/NodeMappingHourAnalysis.java
+6
-6
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/node/analysis/NodeMappingMinuteAnalysis.java
...ector/worker/node/analysis/NodeMappingMinuteAnalysis.java
+6
-6
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/noderef/NodeRefResSumGetGroupWithTimeSlice.java
...or/worker/noderef/NodeRefResSumGetGroupWithTimeSlice.java
+6
-1
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/noderef/analysis/AbstractNodeRefAnalysis.java
...ctor/worker/noderef/analysis/AbstractNodeRefAnalysis.java
+14
-15
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/noderef/analysis/NodeRefDayAnalysis.java
...collector/worker/noderef/analysis/NodeRefDayAnalysis.java
+6
-6
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/noderef/analysis/NodeRefHourAnalysis.java
...ollector/worker/noderef/analysis/NodeRefHourAnalysis.java
+6
-6
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/noderef/analysis/NodeRefMinuteAnalysis.java
...lector/worker/noderef/analysis/NodeRefMinuteAnalysis.java
+6
-6
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/SegmentIndex.java
...skywalking/apm/collector/worker/segment/SegmentIndex.java
+10
-20
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/SegmentReceiver.java
...walking/apm/collector/worker/segment/SegmentReceiver.java
+67
-67
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/SegmentTopGet.java
...kywalking/apm/collector/worker/segment/SegmentTopGet.java
+6
-1
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/analysis/SegmentAnalysis.java
...pm/collector/worker/segment/analysis/SegmentAnalysis.java
+4
-4
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/analysis/SegmentCostAnalysis.java
...ollector/worker/segment/analysis/SegmentCostAnalysis.java
+26
-25
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/analysis/SegmentExceptionAnalysis.java
...tor/worker/segment/analysis/SegmentExceptionAnalysis.java
+16
-17
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/GlobalTraceId.java
...ng/apm/collector/worker/segment/entity/GlobalTraceId.java
+0
-53
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/LogData.java
...ywalking/apm/collector/worker/segment/entity/LogData.java
+0
-24
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/Segment.java
...ywalking/apm/collector/worker/segment/entity/Segment.java
+0
-59
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/SegmentAndBase64.java
...apm/collector/worker/segment/entity/SegmentAndBase64.java
+34
-0
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/SegmentAndJson.java
...g/apm/collector/worker/segment/entity/SegmentAndJson.java
+0
-23
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/SegmentDeserialize.java
...m/collector/worker/segment/entity/SegmentDeserialize.java
+16
-9
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/Span.java
.../skywalking/apm/collector/worker/segment/entity/Span.java
+0
-74
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/TraceSegmentRef.java
.../apm/collector/worker/segment/entity/TraceSegmentRef.java
+0
-37
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/tag/AbstractTag.java
.../apm/collector/worker/segment/entity/tag/AbstractTag.java
+0
-16
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/tag/BooleanTag.java
...g/apm/collector/worker/segment/entity/tag/BooleanTag.java
+0
-35
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/tag/IntTag.java
...lking/apm/collector/worker/segment/entity/tag/IntTag.java
+0
-31
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/tag/ShortTag.java
...ing/apm/collector/worker/segment/entity/tag/ShortTag.java
+0
-31
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/tag/StringTag.java
...ng/apm/collector/worker/segment/entity/tag/StringTag.java
+0
-21
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/tag/Tags.java
...walking/apm/collector/worker/segment/entity/tag/Tags.java
+0
-97
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/persistence/SegmentSave.java
...apm/collector/worker/segment/persistence/SegmentSave.java
+5
-4
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/persistence/SegmentTopSearch.java
...ollector/worker/segment/persistence/SegmentTopSearch.java
+7
-11
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/span/SpanGetWithId.java
...g/skywalking/apm/collector/worker/span/SpanGetWithId.java
+6
-1
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/span/persistence/SpanSearchWithId.java
...m/collector/worker/span/persistence/SpanSearchWithId.java
+7
-11
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/tools/ClientSpanIsLeafTools.java
...ing/apm/collector/worker/tools/ClientSpanIsLeafTools.java
+0
-27
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/tools/SpanPeersTools.java
...skywalking/apm/collector/worker/tools/SpanPeersTools.java
+5
-10
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/tracedag/TraceDagGetWithTimeSlice.java
...m/collector/worker/tracedag/TraceDagGetWithTimeSlice.java
+7
-2
apm-collector/apm-collector-worker/src/main/resources/META-INF/services/io.grpc.BindableService
.../main/resources/META-INF/services/io.grpc.BindableService
+1
-0
apm-collector/apm-collector-worker/src/main/resources/META-INF/services/org.skywalking.apm.collector.actor.AbstractClusterWorkerProvider
...walking.apm.collector.actor.AbstractClusterWorkerProvider
+1
-0
apm-collector/apm-collector-worker/src/main/resources/META-INF/services/org.skywalking.apm.collector.actor.AbstractLocalWorkerProvider
...kywalking.apm.collector.actor.AbstractLocalWorkerProvider
+1
-0
apm-collector/apm-collector-worker/src/main/resources/META-INF/services/org.skywalking.apm.collector.config.ConfigProvider
...rvices/org.skywalking.apm.collector.config.ConfigProvider
+1
-0
apm-collector/apm-collector-worker/src/main/resources/META-INF/services/org.skywalking.apm.collector.worker.httpserver.AbstractGetProvider
...lking.apm.collector.worker.httpserver.AbstractGetProvider
+3
-1
apm-collector/apm-collector-worker/src/main/resources/META-INF/services/org.skywalking.apm.collector.worker.httpserver.AbstractStreamPostProvider
...pm.collector.worker.httpserver.AbstractStreamPostProvider
+0
-1
apm-collector/apm-collector-worker/src/main/resources/collector.config
.../apm-collector-worker/src/main/resources/collector.config
+6
-2
apm-collector/apm-collector-worker/src/main/resources/log4j2.xml
...lector/apm-collector-worker/src/main/resources/log4j2.xml
+8
-5
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/httpserver/PostWithHttpServletTestCase.java
...lector/worker/httpserver/PostWithHttpServletTestCase.java
+0
-89
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/httpserver/TestAbstractGet.java
...king/apm/collector/worker/httpserver/TestAbstractGet.java
+6
-1
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/httpserver/TestAbstractPost.java
...ing/apm/collector/worker/httpserver/TestAbstractPost.java
+6
-1
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/httpserver/TestAbstractStreamPost.java
...m/collector/worker/httpserver/TestAbstractStreamPost.java
+5
-0
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/SegmentRealPost.java
...walking/apm/collector/worker/segment/SegmentRealPost.java
+33
-15
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/SegmentReceiverTestCase.java
...apm/collector/worker/segment/SegmentReceiverTestCase.java
+16
-17
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/entity/SegmentDeserializeFromFile.java
...tor/worker/segment/entity/SegmentDeserializeFromFile.java
+6
-5
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/entity/tag/BooleanTagTestCase.java
...llector/worker/segment/entity/tag/BooleanTagTestCase.java
+0
-32
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/entity/tag/IntTagTestCase.java
...m/collector/worker/segment/entity/tag/IntTagTestCase.java
+0
-32
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/entity/tag/ShortTagTestCase.java
...collector/worker/segment/entity/tag/ShortTagTestCase.java
+0
-34
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/entity/tag/TagsTestCase.java
...apm/collector/worker/segment/entity/tag/TagsTestCase.java
+0
-29
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/KeyWithStringValueFromJson.java
...ector/worker/segment/mock/KeyWithStringValueFromJson.java
+33
-0
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/LogsFromJson.java
...lking/apm/collector/worker/segment/mock/LogsFromJson.java
+41
-0
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/ReferencesFromJson.java
...apm/collector/worker/segment/mock/ReferencesFromJson.java
+58
-0
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/SegmentFromJson.java
...ng/apm/collector/worker/segment/mock/SegmentFromJson.java
+40
-0
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/SegmentMock.java
...alking/apm/collector/worker/segment/mock/SegmentMock.java
+40
-30
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/SpanFromJson.java
...lking/apm/collector/worker/segment/mock/SpanFromJson.java
+98
-0
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/TagsFromJson.java
...lking/apm/collector/worker/segment/mock/TagsFromJson.java
+16
-0
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/UpstreamSegmentFromJson.java
...ollector/worker/segment/mock/UpstreamSegmentFromJson.java
+34
-0
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/UpstreamSegmentFromJsonTestCase.java
.../worker/segment/mock/UpstreamSegmentFromJsonTestCase.java
+65
-0
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/span/persistence/SpanSearchWithIdTestCase.java
...tor/worker/span/persistence/SpanSearchWithIdTestCase.java
+3
-15
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/tools/JsonFileReader.java
...skywalking/apm/collector/worker/tools/JsonFileReader.java
+5
-0
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/tools/SpanPeersToolsTestCase.java
...ng/apm/collector/worker/tools/SpanPeersToolsTestCase.java
+19
-26
apm-collector/apm-collector-worker/src/test/resources/json/segment/grpc/normal/portal-service.json
...st/resources/json/segment/grpc/normal/portal-service.json
+199
-0
apm-collector/apm-collector-worker/src/test/resources/log4j2.xml
...lector/apm-collector-worker/src/test/resources/log4j2.xml
+0
-26
未找到文件。
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/CollectorSystem.java
浏览文件 @
93a45165
...
@@ -2,14 +2,20 @@ package org.skywalking.apm.collector;
...
@@ -2,14 +2,20 @@ package org.skywalking.apm.collector;
import
akka.actor.ActorSystem
;
import
akka.actor.ActorSystem
;
import
akka.actor.Props
;
import
akka.actor.Props
;
import
java.io.IOException
;
import
java.util.ServiceLoader
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
import
org.skywalking.apm.collector.actor.*
;
import
org.skywalking.apm.collector.actor.AbstractClusterWorkerProvider
;
import
org.skywalking.apm.collector.actor.AbstractLocalWorkerProvider
;
import
org.skywalking.apm.collector.actor.AbstractWorker
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.actor.LookUp
;
import
org.skywalking.apm.collector.actor.ProviderNotFoundException
;
import
org.skywalking.apm.collector.actor.UsedRoleNameException
;
import
org.skywalking.apm.collector.cluster.WorkersListener
;
import
org.skywalking.apm.collector.cluster.WorkersListener
;
import
org.skywalking.apm.collector.config.ConfigInitializer
;
import
org.skywalking.apm.collector.config.ConfigInitializer
;
import
org.skywalking.apm.collector.rpc.RPCAddressListener
;
import
java.io.IOException
;
import
java.util.ServiceLoader
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -38,6 +44,7 @@ public class CollectorSystem {
...
@@ -38,6 +44,7 @@ public class CollectorSystem {
private
void
createListener
()
{
private
void
createListener
()
{
clusterContext
.
getAkkaSystem
().
actorOf
(
Props
.
create
(
WorkersListener
.
class
,
clusterContext
),
WorkersListener
.
WORK_NAME
);
clusterContext
.
getAkkaSystem
().
actorOf
(
Props
.
create
(
WorkersListener
.
class
,
clusterContext
),
WorkersListener
.
WORK_NAME
);
clusterContext
.
getAkkaSystem
().
actorOf
(
Props
.
create
(
RPCAddressListener
.
class
,
clusterContext
),
RPCAddressListener
.
WORK_NAME
);
}
}
private
void
createClusterWorkers
()
throws
ProviderNotFoundException
{
private
void
createClusterWorkers
()
throws
ProviderNotFoundException
{
...
...
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/actor/AbstractClusterWorker.java
浏览文件 @
93a45165
...
@@ -8,6 +8,9 @@ import akka.cluster.MemberStatus;
...
@@ -8,6 +8,9 @@ import akka.cluster.MemberStatus;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
import
org.skywalking.apm.collector.cluster.WorkerListenerMessage
;
import
org.skywalking.apm.collector.cluster.WorkerListenerMessage
;
import
org.skywalking.apm.collector.cluster.WorkersListener
;
import
org.skywalking.apm.collector.cluster.WorkersListener
;
import
org.skywalking.apm.collector.rpc.RPCAddress
;
import
org.skywalking.apm.collector.rpc.RPCAddressListener
;
import
org.skywalking.apm.collector.rpc.RPCAddressListenerMessage
;
import
org.skywalking.apm.collector.log.LogManager
;
import
org.skywalking.apm.collector.log.LogManager
;
/**
/**
...
@@ -56,10 +59,12 @@ public abstract class AbstractClusterWorker extends AbstractWorker {
...
@@ -56,10 +59,12 @@ public abstract class AbstractClusterWorker extends AbstractWorker {
private
Cluster
cluster
;
private
Cluster
cluster
;
private
final
AbstractClusterWorker
ownerWorker
;
private
final
AbstractClusterWorker
ownerWorker
;
private
final
RPCAddress
RPCAddress
;
public
WorkerWithAkka
(
AbstractClusterWorker
ownerWorker
)
{
public
WorkerWithAkka
(
AbstractClusterWorker
ownerWorker
,
RPCAddress
RPCAddress
)
{
this
.
ownerWorker
=
ownerWorker
;
this
.
ownerWorker
=
ownerWorker
;
cluster
=
Cluster
.
get
(
getContext
().
system
());
cluster
=
Cluster
.
get
(
getContext
().
system
());
this
.
RPCAddress
=
RPCAddress
;
}
}
@Override
@Override
...
@@ -108,6 +113,11 @@ public abstract class AbstractClusterWorker extends AbstractWorker {
...
@@ -108,6 +113,11 @@ public abstract class AbstractClusterWorker extends AbstractWorker {
logger
.
info
(
"member address: %s, worker path: %s"
,
member
.
address
().
toString
(),
getSelf
().
path
().
toString
());
logger
.
info
(
"member address: %s, worker path: %s"
,
member
.
address
().
toString
(),
getSelf
().
path
().
toString
());
getContext
().
actorSelection
(
member
.
address
()
+
"/user/"
+
WorkersListener
.
WORK_NAME
).
tell
(
registerMessage
,
getSelf
());
getContext
().
actorSelection
(
member
.
address
()
+
"/user/"
+
WorkersListener
.
WORK_NAME
).
tell
(
registerMessage
,
getSelf
());
}
}
if
(
member
.
hasRole
(
RPCAddressListener
.
WORK_NAME
)
&&
RPCAddress
!=
null
)
{
RPCAddressListenerMessage
.
ConfigMessage
configMessage
=
new
RPCAddressListenerMessage
.
ConfigMessage
(
RPCAddress
);
logger
.
info
(
"member address: %s, worker path: %s"
,
member
.
address
().
toString
(),
getSelf
().
path
().
toString
());
getContext
().
actorSelection
(
member
.
address
()
+
"/user/"
+
RPCAddressListener
.
WORK_NAME
).
tell
(
configMessage
,
getSelf
());
}
}
}
}
}
}
}
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/actor/AbstractClusterWorkerProvider.java
浏览文件 @
93a45165
...
@@ -2,6 +2,7 @@ package org.skywalking.apm.collector.actor;
...
@@ -2,6 +2,7 @@ package org.skywalking.apm.collector.actor;
import
akka.actor.ActorRef
;
import
akka.actor.ActorRef
;
import
akka.actor.Props
;
import
akka.actor.Props
;
import
org.skywalking.apm.collector.rpc.RPCAddress
;
/**
/**
* The <code>AbstractClusterWorkerProvider</code> implementations represent providers,
* The <code>AbstractClusterWorkerProvider</code> implementations represent providers,
...
@@ -20,6 +21,10 @@ public abstract class AbstractClusterWorkerProvider<T extends AbstractClusterWor
...
@@ -20,6 +21,10 @@ public abstract class AbstractClusterWorkerProvider<T extends AbstractClusterWor
*/
*/
public
abstract
int
workerNum
();
public
abstract
int
workerNum
();
public
RPCAddress
config
()
{
return
null
;
}
/**
/**
* Create the worker instance into akka system, the akka system will control the cluster worker life cycle.
* Create the worker instance into akka system, the akka system will control the cluster worker life cycle.
*
*
...
@@ -35,10 +40,14 @@ public abstract class AbstractClusterWorkerProvider<T extends AbstractClusterWor
...
@@ -35,10 +40,14 @@ public abstract class AbstractClusterWorkerProvider<T extends AbstractClusterWor
T
clusterWorker
=
workerInstance
(
getClusterContext
());
T
clusterWorker
=
workerInstance
(
getClusterContext
());
clusterWorker
.
preStart
();
clusterWorker
.
preStart
();
ActorRef
actorRef
=
getClusterContext
().
getAkkaSystem
().
actorOf
(
Props
.
create
(
AbstractClusterWorker
.
WorkerWithAkka
.
class
,
clusterWorker
),
role
().
roleName
()
+
"_"
+
num
);
ActorRef
actorRef
=
getClusterContext
().
getAkkaSystem
().
actorOf
(
Props
.
create
(
AbstractClusterWorker
.
WorkerWithAkka
.
class
,
clusterWorker
,
config
()
),
role
().
roleName
()
+
"_"
+
num
);
ClusterWorkerRef
workerRef
=
new
ClusterWorkerRef
(
actorRef
,
role
());
ClusterWorkerRef
workerRef
=
new
ClusterWorkerRef
(
actorRef
,
role
());
getClusterContext
().
put
(
workerRef
);
getClusterContext
().
put
(
workerRef
);
if
(
config
()
!=
null
)
{
getClusterContext
().
getRpcContext
().
putAddress
(
"Self"
,
config
());
}
return
workerRef
;
return
workerRef
;
}
}
}
}
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/actor/ClusterWorkerContext.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.actor
;
package
org.skywalking.apm.collector.actor
;
import
akka.actor.ActorSystem
;
import
akka.actor.ActorSystem
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.skywalking.apm.collector.rpc.RPCAddressContext
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -15,6 +15,7 @@ public class ClusterWorkerContext extends WorkerContext {
...
@@ -15,6 +15,7 @@ public class ClusterWorkerContext extends WorkerContext {
private
final
ActorSystem
akkaSystem
;
private
final
ActorSystem
akkaSystem
;
private
Map
<
String
,
AbstractWorkerProvider
>
providers
=
new
ConcurrentHashMap
<>();
private
Map
<
String
,
AbstractWorkerProvider
>
providers
=
new
ConcurrentHashMap
<>();
private
RPCAddressContext
rpcContext
=
new
RPCAddressContext
();
public
ClusterWorkerContext
(
ActorSystem
akkaSystem
)
{
public
ClusterWorkerContext
(
ActorSystem
akkaSystem
)
{
this
.
akkaSystem
=
akkaSystem
;
this
.
akkaSystem
=
akkaSystem
;
...
@@ -43,4 +44,8 @@ public class ClusterWorkerContext extends WorkerContext {
...
@@ -43,4 +44,8 @@ public class ClusterWorkerContext extends WorkerContext {
providers
.
put
(
provider
.
role
().
roleName
(),
provider
);
providers
.
put
(
provider
.
role
().
roleName
(),
provider
);
}
}
}
}
public
RPCAddressContext
getRpcContext
()
{
return
rpcContext
;
}
}
}
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/cluster/WorkerListenerMessage.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.cluster
;
package
org.skywalking.apm.collector.cluster
;
import
java.io.Serializable
;
import
org.skywalking.apm.collector.actor.AbstractWorker
;
import
org.skywalking.apm.collector.actor.AbstractWorker
;
import
org.skywalking.apm.collector.actor.Role
;
import
org.skywalking.apm.collector.actor.Role
;
import
java.io.Serializable
;
/**
/**
* <code>WorkerListenerMessage</code> is a message just for the worker
* <code>WorkerListenerMessage</code> is a message just for the worker
* implementation of the {@link AbstractWorker}
* implementation of the {@link AbstractWorker}
...
...
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/cluster/WorkersListener.java
浏览文件 @
93a45165
...
@@ -30,7 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
...
@@ -30,7 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
public
class
WorkersListener
extends
UntypedActor
{
public
class
WorkersListener
extends
UntypedActor
{
public
static
final
String
WORK_NAME
=
"WorkersListener"
;
public
static
final
String
WORK_NAME
=
"WorkersListener"
;
private
static
final
Logger
logger
=
LogManager
.
getFormatterLogger
(
WorkersListener
.
class
);
private
final
Logger
logger
=
LogManager
.
getFormatterLogger
(
WorkersListener
.
class
);
private
final
ClusterWorkerContext
clusterContext
;
private
final
ClusterWorkerContext
clusterContext
;
private
Cluster
cluster
=
Cluster
.
get
(
getContext
().
system
());
private
Cluster
cluster
=
Cluster
.
get
(
getContext
().
system
());
private
Map
<
ActorRef
,
ClusterWorkerRef
>
relation
=
new
ConcurrentHashMap
<>();
private
Map
<
ActorRef
,
ClusterWorkerRef
>
relation
=
new
ConcurrentHashMap
<>();
...
...
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/rpc/RPCAddress.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.rpc
;
/**
* @author pengys5
*/
public
class
RPCAddress
{
private
final
String
address
;
private
final
int
port
;
public
RPCAddress
(
String
address
,
int
port
)
{
this
.
address
=
address
;
this
.
port
=
port
;
}
public
String
getAddress
()
{
return
address
;
}
public
int
getPort
()
{
return
port
;
}
}
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/rpc/RPCAddressContext.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.rpc
;
import
java.util.Collection
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
* @author pengys5
*/
public
class
RPCAddressContext
{
private
Map
<
String
,
RPCAddress
>
rpcAddresses
=
new
ConcurrentHashMap
<>();
public
Collection
<
RPCAddress
>
rpcAddressCollection
()
{
return
rpcAddresses
.
values
();
}
public
void
putAddress
(
String
ownerAddress
,
RPCAddress
rpcAddress
)
{
rpcAddresses
.
put
(
ownerAddress
,
rpcAddress
);
}
public
void
removeAddress
(
String
ownerAddress
)
{
rpcAddresses
.
remove
(
ownerAddress
);
}
}
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/rpc/RPCAddressListener.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.rpc
;
import
akka.actor.ActorRef
;
import
akka.actor.Terminated
;
import
akka.actor.UntypedActor
;
import
akka.cluster.Cluster
;
import
akka.cluster.ClusterEvent
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
/**
* @author pengys5
*/
public
class
RPCAddressListener
extends
UntypedActor
{
private
final
Logger
logger
=
LogManager
.
getFormatterLogger
(
RPCAddressListener
.
class
);
public
static
final
String
WORK_NAME
=
"RPCAddressListener"
;
private
final
ClusterWorkerContext
clusterContext
;
private
Cluster
cluster
=
Cluster
.
get
(
getContext
().
system
());
public
RPCAddressListener
(
ClusterWorkerContext
clusterContext
)
{
this
.
clusterContext
=
clusterContext
;
}
@Override
public
void
preStart
()
throws
Exception
{
cluster
.
subscribe
(
getSelf
(),
ClusterEvent
.
UnreachableMember
.
class
);
}
@Override
public
void
onReceive
(
Object
message
)
throws
Throwable
{
if
(
message
instanceof
RPCAddressListenerMessage
.
ConfigMessage
)
{
RPCAddressListenerMessage
.
ConfigMessage
configMessage
=
(
RPCAddressListenerMessage
.
ConfigMessage
)
message
;
ActorRef
sender
=
getSender
();
logger
.
info
(
"address: %s, port: %s"
,
configMessage
.
getConfig
().
getAddress
(),
configMessage
.
getConfig
().
getPort
());
String
ownerAddress
=
sender
.
path
().
address
().
hostPort
();
clusterContext
.
getRpcContext
().
putAddress
(
ownerAddress
,
configMessage
.
getConfig
());
}
else
if
(
message
instanceof
Terminated
)
{
Terminated
terminated
=
(
Terminated
)
message
;
clusterContext
.
getRpcContext
().
removeAddress
(
terminated
.
getActor
().
path
().
address
().
hostPort
());
}
else
if
(
message
instanceof
ClusterEvent
.
UnreachableMember
)
{
ClusterEvent
.
UnreachableMember
unreachableMember
=
(
ClusterEvent
.
UnreachableMember
)
message
;
clusterContext
.
getRpcContext
().
removeAddress
(
unreachableMember
.
member
().
address
().
hostPort
());
}
else
{
unhandled
(
message
);
}
}
}
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/rpc/RPCAddressListenerMessage.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.rpc
;
import
java.io.Serializable
;
/**
* @author pengys5
*/
public
class
RPCAddressListenerMessage
{
public
static
class
ConfigMessage
implements
Serializable
{
private
final
RPCAddress
config
;
public
ConfigMessage
(
RPCAddress
config
)
{
this
.
config
=
config
;
}
public
RPCAddress
getConfig
()
{
return
config
;
}
}
}
apm-collector/apm-collector-commons/src/main/java/org/skywalking/apm/collector/commons/serializer/JsonSerializer.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.commons.serializer
;
import
akka.serialization.JSerializer
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
/**
* @author pengys5
*/
public
class
JsonSerializer
extends
JSerializer
{
@Override
public
boolean
includeManifest
()
{
return
false
;
}
@Override
public
int
identifier
()
{
return
31
;
}
@Override
public
byte
[]
toBinary
(
Object
o
)
{
JsonObject
jsonObject
=
(
JsonObject
)
o
;
return
jsonObject
.
toString
().
getBytes
();
}
@Override
public
Object
fromBinaryJava
(
byte
[]
bytes
,
Class
<?>
manifest
)
{
Gson
gson
=
new
Gson
();
return
gson
.
fromJson
(
new
String
(
bytes
),
JsonObject
.
class
);
}
}
apm-collector/apm-collector-commons/src/main/resources/application.conf
浏览文件 @
93a45165
...
@@ -6,14 +6,14 @@ akka {
...
@@ -6,14 +6,14 @@ akka {
java
=
"akka.serialization.JavaSerializer"
java
=
"akka.serialization.JavaSerializer"
proto
=
"akka.remote.serialization.ProtobufSerializer"
proto
=
"akka.remote.serialization.ProtobufSerializer"
//
TraceSegment
=
"org.skywalking.apm.collector.worker.TraceSegmentSerializer"
//
TraceSegment
=
"org.skywalking.apm.collector.worker.TraceSegmentSerializer"
json
=
"org.skywalking.apm.collector.commons.serializer.JsonSerializer"
//
json
=
"org.skywalking.apm.collector.commons.serializer.JsonSerializer"
}
}
serialization
-
bindings
{
serialization
-
bindings
{
"java.lang.String"
=
java
"java.lang.String"
=
java
"com.google.protobuf.Message"
=
proto
"com.google.protobuf.Message"
=
proto
//
"TraceSegment"
=
TraceSegment
//
"TraceSegment"
=
TraceSegment
"com.google.gson.JsonObject"
=
json
//
"com.google.gson.JsonObject"
=
json
}
}
warn
-
about
-
java
-
serializer
-
usage
=
on
warn
-
about
-
java
-
serializer
-
usage
=
on
...
...
apm-collector/apm-collector-worker/pom.xml
浏览文件 @
93a45165
...
@@ -30,6 +30,11 @@
...
@@ -30,6 +30,11 @@
<artifactId>
apm-collector-commons
</artifactId>
<artifactId>
apm-collector-commons
</artifactId>
<version>
${project.version}
</version>
<version>
${project.version}
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.skywalking
</groupId>
<artifactId>
apm-network
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<dependency>
<groupId>
org.eclipse.jetty
</groupId>
<groupId>
org.eclipse.jetty
</groupId>
<artifactId>
jetty-server
</artifactId>
<artifactId>
jetty-server
</artifactId>
...
@@ -43,7 +48,7 @@
...
@@ -43,7 +48,7 @@
<dependency>
<dependency>
<groupId>
org.elasticsearch.client
</groupId>
<groupId>
org.elasticsearch.client
</groupId>
<artifactId>
transport
</artifactId>
<artifactId>
transport
</artifactId>
<version>
5.
2.2
</version>
<version>
5.
4.3
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.skywalking
</groupId>
<groupId>
org.skywalking
</groupId>
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/CollectorBootStartUp.java
浏览文件 @
93a45165
...
@@ -4,6 +4,7 @@ import org.apache.logging.log4j.LogManager;
...
@@ -4,6 +4,7 @@ import org.apache.logging.log4j.LogManager;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
import
org.skywalking.apm.collector.CollectorSystem
;
import
org.skywalking.apm.collector.CollectorSystem
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.worker.grpcserver.GRPCServer
;
import
org.skywalking.apm.collector.worker.httpserver.HttpServer
;
import
org.skywalking.apm.collector.worker.httpserver.HttpServer
;
import
org.skywalking.apm.collector.worker.storage.EsClient
;
import
org.skywalking.apm.collector.worker.storage.EsClient
;
import
org.skywalking.apm.collector.worker.storage.IndexCreator
;
import
org.skywalking.apm.collector.worker.storage.IndexCreator
;
...
@@ -23,5 +24,6 @@ public class CollectorBootStartUp {
...
@@ -23,5 +24,6 @@ public class CollectorBootStartUp {
IndexCreator
.
INSTANCE
.
create
();
IndexCreator
.
INSTANCE
.
create
();
PersistenceTimer
.
INSTANCE
.
boot
();
PersistenceTimer
.
INSTANCE
.
boot
();
HttpServer
.
INSTANCE
.
boot
((
ClusterWorkerContext
)
collectorSystem
.
getClusterContext
());
HttpServer
.
INSTANCE
.
boot
((
ClusterWorkerContext
)
collectorSystem
.
getClusterContext
());
GRPCServer
.
INSTANCE
.
boot
((
ClusterWorkerContext
)
collectorSystem
.
getClusterContext
());
}
}
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/config/GRPCConfig.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.config
;
/**
* @author pengys5
*/
public
class
GRPCConfig
{
public
static
class
GRPC
{
public
static
String
HOSTNAME
=
""
;
public
static
String
PORT
=
""
;
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/config/GRPCConfigProvider.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.config
;
import
org.skywalking.apm.collector.config.ConfigProvider
;
import
org.skywalking.apm.util.StringUtil
;
/**
* @author pengys5
*/
public
class
GRPCConfigProvider
implements
ConfigProvider
{
@Override
public
Class
configClass
()
{
return
GRPCConfig
.
class
;
}
@Override
public
void
cliArgs
()
{
if
(!
StringUtil
.
isEmpty
(
System
.
getProperty
(
"grpc.HOSTNAME"
)))
{
GRPCConfig
.
GRPC
.
HOSTNAME
=
System
.
getProperty
(
"grpc.HOSTNAME"
);
}
if
(!
StringUtil
.
isEmpty
(
System
.
getProperty
(
"grpc.PORT"
)))
{
GRPCConfig
.
GRPC
.
PORT
=
System
.
getProperty
(
"grpc.PORT"
);
}
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/config/WorkerConfig.java
浏览文件 @
93a45165
...
@@ -6,6 +6,12 @@ package org.skywalking.apm.collector.worker.config;
...
@@ -6,6 +6,12 @@ package org.skywalking.apm.collector.worker.config;
public
class
WorkerConfig
{
public
class
WorkerConfig
{
public
static
class
WorkerNum
{
public
static
class
WorkerNum
{
public
static
class
GRPC
{
public
static
class
GRPCAddressRegister
{
public
static
int
VALUE
=
1
;
}
}
public
static
class
Node
{
public
static
class
Node
{
public
static
class
NodeCompAgg
{
public
static
class
NodeCompAgg
{
public
static
int
VALUE
=
2
;
public
static
int
VALUE
=
2
;
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/globaltrace/GlobalTraceGetWithGlobalId.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.globaltrace
;
package
org.skywalking.apm.collector.worker.globaltrace
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -30,13 +31,17 @@ public class GlobalTraceGetWithGlobalId extends AbstractGet {
...
@@ -30,13 +31,17 @@ public class GlobalTraceGetWithGlobalId extends AbstractGet {
super
(
role
,
clusterContext
,
selfContext
);
super
(
role
,
clusterContext
,
selfContext
);
}
}
@Override
protected
Class
<?
extends
JsonElement
>
responseClass
()
{
return
JsonObject
.
class
;
}
@Override
@Override
public
void
preStart
()
throws
ProviderNotFoundException
{
public
void
preStart
()
throws
ProviderNotFoundException
{
getClusterContext
().
findProvider
(
GlobalTraceSearchWithGlobalId
.
WorkerRole
.
INSTANCE
).
create
(
this
);
getClusterContext
().
findProvider
(
GlobalTraceSearchWithGlobalId
.
WorkerRole
.
INSTANCE
).
create
(
this
);
}
}
@Override
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
@Override
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
Json
Objec
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
Json
Elemen
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
if
(!
parameter
.
containsKey
(
"globalId"
))
{
if
(!
parameter
.
containsKey
(
"globalId"
))
{
throw
new
IllegalArgumentException
(
"the request parameter must contains globalId"
);
throw
new
IllegalArgumentException
(
"the request parameter must contains globalId"
);
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/globaltrace/analysis/GlobalTraceAnalysis.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.globaltrace.analysis
;
package
org.skywalking.apm.collector.worker.globaltrace.analysis
;
import
java.util.List
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
import
org.skywalking.apm.collector.actor.AbstractLocalAsyncWorkerProvider
;
import
org.skywalking.apm.collector.actor.AbstractLocalAsyncWorkerProvider
;
...
@@ -14,9 +13,8 @@ import org.skywalking.apm.collector.worker.JoinAndSplitAnalysisMember;
...
@@ -14,9 +13,8 @@ import org.skywalking.apm.collector.worker.JoinAndSplitAnalysisMember;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.globaltrace.GlobalTraceIndex
;
import
org.skywalking.apm.collector.worker.globaltrace.GlobalTraceIndex
;
import
org.skywalking.apm.collector.worker.globaltrace.persistence.GlobalTraceAgg
;
import
org.skywalking.apm.collector.worker.globaltrace.persistence.GlobalTraceAgg
;
import
org.skywalking.apm.collector.worker.segment.SegmentPost
;
import
org.skywalking.apm.collector.worker.segment.SegmentReceiver
;
import
org.skywalking.apm.collector.worker.segment.entity.Segment
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
import
org.skywalking.apm.collector.worker.tools.CollectionTools
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -31,18 +29,16 @@ public class GlobalTraceAnalysis extends JoinAndSplitAnalysisMember {
...
@@ -31,18 +29,16 @@ public class GlobalTraceAnalysis extends JoinAndSplitAnalysisMember {
@Override
@Override
public
void
analyse
(
Object
message
)
{
public
void
analyse
(
Object
message
)
{
if
(
message
instanceof
Segment
Post
.
SegmentWithTimeSlice
)
{
if
(
message
instanceof
Segment
Receiver
.
SegmentWithTimeSlice
)
{
Segment
Post
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentPost
.
SegmentWithTimeSlice
)
message
;
Segment
Receiver
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentReceiver
.
SegmentWithTimeSlice
)
message
;
Segmen
t
segment
=
segmentWithTimeSlice
.
getSegment
();
TraceSegmentObjec
t
segment
=
segmentWithTimeSlice
.
getSegment
();
String
subSegmentId
=
segment
.
getTraceSegmentId
();
String
subSegmentId
=
segment
.
getTraceSegmentId
();
List
<
String
>
globalTraceIdList
=
segment
.
getRelatedGlobalTraces
().
get
();
if
(
CollectionTools
.
isNotEmpty
(
globalTraceIdList
))
{
segmentWithTimeSlice
.
getGlobalTraceIds
().
forEach
(
globalTraceId
->
{
for
(
String
globalTraceId
:
globalTraceIdList
)
{
set
(
globalTraceId
,
GlobalTraceIndex
.
SUB_SEG_IDS
,
subSegmentId
);
set
(
globalTraceId
,
GlobalTraceIndex
.
SUB_SEG_IDS
,
subSegmentId
);
});
}
}
}
else
{
}
else
{
logger
.
error
(
"unhandled message, message instance must Segment
Post
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
logger
.
error
(
"unhandled message, message instance must Segment
Receiver
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
}
}
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/globaltrace/persistence/GlobalTraceSearchWithGlobalId.java
浏览文件 @
93a45165
...
@@ -2,12 +2,12 @@ package org.skywalking.apm.collector.worker.globaltrace.persistence;
...
@@ -2,12 +2,12 @@ package org.skywalking.apm.collector.worker.globaltrace.persistence;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.skywalking.apm.collector.actor.AbstractLocalSyncWorker
;
import
org.skywalking.apm.collector.actor.AbstractLocalSyncWorker
;
import
org.skywalking.apm.collector.actor.AbstractLocalSyncWorkerProvider
;
import
org.skywalking.apm.collector.actor.AbstractLocalSyncWorkerProvider
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
...
@@ -18,14 +18,14 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
...
@@ -18,14 +18,14 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.worker.globaltrace.GlobalTraceIndex
;
import
org.skywalking.apm.collector.worker.globaltrace.GlobalTraceIndex
;
import
org.skywalking.apm.collector.worker.segment.SegmentIndex
;
import
org.skywalking.apm.collector.worker.segment.SegmentIndex
;
import
org.skywalking.apm.collector.worker.segment.entity.Segment
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentDeserialize
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentDeserialize
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
import
org.skywalking.apm.collector.worker.segment.entity.SpanView
;
import
org.skywalking.apm.collector.worker.segment.entity.SpanView
;
import
org.skywalking.apm.collector.worker.segment.entity.TraceSegmentRef
;
import
org.skywalking.apm.collector.worker.storage.GetResponseFromEs
;
import
org.skywalking.apm.collector.worker.storage.GetResponseFromEs
;
import
org.skywalking.apm.collector.worker.storage.JoinAndSplitData
;
import
org.skywalking.apm.collector.worker.storage.JoinAndSplitData
;
import
org.skywalking.apm.collector.worker.tools.CollectionTools
;
import
org.skywalking.apm.collector.worker.tools.CollectionTools
;
import
org.skywalking.apm.network.proto.SpanObject
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
import
org.skywalking.apm.network.proto.TraceSegmentReference
;
import
org.skywalking.apm.util.StringUtil
;
import
org.skywalking.apm.util.StringUtil
;
/**
/**
...
@@ -56,20 +56,16 @@ public class GlobalTraceSearchWithGlobalId extends AbstractLocalSyncWorker {
...
@@ -56,20 +56,16 @@ public class GlobalTraceSearchWithGlobalId extends AbstractLocalSyncWorker {
List
<
SpanView
>
spanViewList
=
new
ArrayList
<>();
List
<
SpanView
>
spanViewList
=
new
ArrayList
<>();
for
(
String
subSegId
:
subSegIds
)
{
for
(
String
subSegId
:
subSegIds
)
{
logger
.
debug
(
"subSegId: %s"
,
subSegId
);
logger
.
debug
(
"subSegId: %s"
,
subSegId
);
String
segmentSource
=
GetResponseFromEs
.
INSTANCE
.
get
(
SegmentIndex
.
INDEX
,
SegmentIndex
.
TYPE_RECORD
,
subSegId
).
getSourceAsString
();
GetResponse
getResponse
=
GetResponseFromEs
.
INSTANCE
.
get
(
SegmentIndex
.
INDEX
,
SegmentIndex
.
TYPE_RECORD
,
subSegId
);
logger
.
debug
(
"segmentSource: %s"
,
segmentSource
);
String
segmentObjBlob
=
(
String
)
getResponse
.
getSource
().
get
(
SegmentIndex
.
SEGMENT_OBJ_BLOB
);
Segment
segment
=
null
;
try
{
TraceSegmentObject
segment
=
SegmentDeserialize
.
INSTANCE
.
deserializeSingle
(
segmentObjBlob
);
segment
=
SegmentDeserialize
.
INSTANCE
.
deserializeSingle
(
segmentSource
);
}
catch
(
IOException
e
)
{
throw
new
WorkerException
(
e
.
getMessage
(),
e
);
}
String
segmentId
=
segment
.
getTraceSegmentId
();
String
segmentId
=
segment
.
getTraceSegmentId
();
List
<
TraceSegmentRef
>
refsList
=
segment
.
getRefs
();
List
<
TraceSegmentRef
erence
>
refsList
=
segment
.
getRefsList
();
for
(
Span
span
:
segment
.
getSpans
())
{
for
(
Span
Object
span
:
segment
.
getSpansList
())
{
logger
.
debug
(
span
.
getOperationName
());
logger
.
debug
(
span
.
getOperationName
());
spansDataBuild
(
span
,
segment
.
get
ApplicationCode
(),
segmentId
,
spanViewList
,
refsList
);
spansDataBuild
(
span
,
segment
.
get
TraceSegmentId
(),
segmentId
,
spanViewList
,
refsList
);
}
}
}
}
...
@@ -128,8 +124,8 @@ public class GlobalTraceSearchWithGlobalId extends AbstractLocalSyncWorker {
...
@@ -128,8 +124,8 @@ public class GlobalTraceSearchWithGlobalId extends AbstractLocalSyncWorker {
return
tempList
;
return
tempList
;
}
}
private
void
spansDataBuild
(
Span
span
,
String
appCode
,
String
segmentId
,
List
<
SpanView
>
spanViewList
,
private
void
spansDataBuild
(
Span
Object
span
,
String
appCode
,
String
segmentId
,
List
<
SpanView
>
spanViewList
,
List
<
TraceSegmentRef
>
refsList
)
{
List
<
TraceSegmentRef
erence
>
refsList
)
{
int
spanId
=
span
.
getSpanId
();
int
spanId
=
span
.
getSpanId
();
String
spanSegId
=
segmentId
+
"--"
+
String
.
valueOf
(
spanId
);
String
spanSegId
=
segmentId
+
"--"
+
String
.
valueOf
(
spanId
);
...
@@ -152,9 +148,9 @@ public class GlobalTraceSearchWithGlobalId extends AbstractLocalSyncWorker {
...
@@ -152,9 +148,9 @@ public class GlobalTraceSearchWithGlobalId extends AbstractLocalSyncWorker {
if
(
refsList
.
size
()
>
1
)
{
if
(
refsList
.
size
()
>
1
)
{
throw
new
UnsupportedOperationException
(
"not support batch call"
);
throw
new
UnsupportedOperationException
(
"not support batch call"
);
}
else
{
}
else
{
TraceSegmentRef
segmentRef
=
refsList
.
get
(
0
);
TraceSegmentRef
erence
segmentRef
=
refsList
.
get
(
0
);
int
parentSpanId
=
segmentRef
.
getSpanId
();
int
parentSpanId
=
segmentRef
.
get
Parent
SpanId
();
String
parentSegId
=
segmentRef
.
getTraceSegmentId
();
String
parentSegId
=
segmentRef
.
get
Parent
TraceSegmentId
();
String
parentSpanSegId
=
parentSegId
+
"--"
+
String
.
valueOf
(
parentSpanId
);
String
parentSpanSegId
=
parentSegId
+
"--"
+
String
.
valueOf
(
parentSpanId
);
spanView
.
setParentSpanSegId
(
parentSpanSegId
);
spanView
.
setParentSpanSegId
(
parentSpanSegId
);
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/grpcserver/AbstractReceiver.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.grpcserver
;
import
org.skywalking.apm.collector.actor.AbstractLocalSyncWorker
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.actor.LocalWorkerContext
;
import
org.skywalking.apm.collector.actor.Role
;
import
org.skywalking.apm.collector.actor.WorkerException
;
import
org.skywalking.apm.collector.actor.WorkerInvokeException
;
import
org.skywalking.apm.collector.actor.WorkerNotFoundException
;
import
org.skywalking.apm.collector.worker.httpserver.ArgumentsParseException
;
/**
* @author pengys5
*/
public
abstract
class
AbstractReceiver
extends
AbstractLocalSyncWorker
{
public
AbstractReceiver
(
Role
role
,
ClusterWorkerContext
clusterContext
,
LocalWorkerContext
selfContext
)
{
super
(
role
,
clusterContext
,
selfContext
);
}
final
@Override
protected
void
onWork
(
Object
request
,
Object
response
)
throws
WorkerException
{
onReceive
(
request
);
}
protected
abstract
void
onReceive
(
Object
request
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
;
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/grpcserver/AbstractReceiverProvider.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.grpcserver
;
import
org.skywalking.apm.collector.actor.AbstractLocalSyncWorker
;
import
org.skywalking.apm.collector.actor.AbstractLocalSyncWorkerProvider
;
/**
* @author pengys5
*/
public
abstract
class
AbstractReceiverProvider
<
T
extends
AbstractLocalSyncWorker
>
extends
AbstractLocalSyncWorkerProvider
<
T
>
{
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/grpcserver/GRPCAddressGet.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.grpcserver
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonElement
;
import
java.util.Map
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.actor.LocalWorkerContext
;
import
org.skywalking.apm.collector.actor.WorkerInvokeException
;
import
org.skywalking.apm.collector.actor.WorkerNotFoundException
;
import
org.skywalking.apm.collector.actor.selector.RollingSelector
;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.worker.httpserver.AbstractGet
;
import
org.skywalking.apm.collector.worker.httpserver.AbstractGetProvider
;
import
org.skywalking.apm.collector.worker.httpserver.ArgumentsParseException
;
/**
* @author pengys5
*/
public
class
GRPCAddressGet
extends
AbstractGet
{
protected
GRPCAddressGet
(
org
.
skywalking
.
apm
.
collector
.
actor
.
Role
role
,
ClusterWorkerContext
clusterContext
,
LocalWorkerContext
selfContext
)
{
super
(
role
,
clusterContext
,
selfContext
);
}
@Override
protected
Class
<
JsonArray
>
responseClass
()
{
return
JsonArray
.
class
;
}
@Override
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
JsonElement
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
((
ClusterWorkerContext
)
getClusterContext
()).
getRpcContext
().
rpcAddressCollection
().
forEach
(
rpcAddress
->
{
((
JsonArray
)
response
).
add
(
rpcAddress
.
getAddress
()
+
":"
+
rpcAddress
.
getPort
());
});
}
public
static
class
Factory
extends
AbstractGetProvider
<
GRPCAddressGet
>
{
public
static
Factory
INSTANCE
=
new
Factory
();
@Override
public
Role
role
()
{
return
Role
.
INSTANCE
;
}
@Override
public
GRPCAddressGet
workerInstance
(
ClusterWorkerContext
clusterContext
)
{
return
new
GRPCAddressGet
(
role
(),
clusterContext
,
new
LocalWorkerContext
());
}
@Override
public
String
servletPath
()
{
return
"/grpc/addresses"
;
}
}
public
enum
Role
implements
org
.
skywalking
.
apm
.
collector
.
actor
.
Role
{
INSTANCE
;
@Override
public
String
roleName
()
{
return
GRPCAddressGet
.
class
.
getSimpleName
();
}
@Override
public
WorkerSelector
workerSelector
()
{
return
new
RollingSelector
();
}
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/grpcserver/GRPCAddressRegister.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.grpcserver
;
import
org.skywalking.apm.collector.actor.AbstractClusterWorker
;
import
org.skywalking.apm.collector.actor.AbstractClusterWorkerProvider
;
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.WorkerException
;
import
org.skywalking.apm.collector.actor.selector.RollingSelector
;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.rpc.RPCAddress
;
import
org.skywalking.apm.collector.worker.config.GRPCConfig
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
/**
* @author pengys5
*/
public
class
GRPCAddressRegister
extends
AbstractClusterWorker
{
GRPCAddressRegister
(
Role
role
,
ClusterWorkerContext
clusterContext
,
LocalWorkerContext
selfContext
)
{
super
(
role
,
clusterContext
,
selfContext
);
}
@Override
public
void
preStart
()
throws
ProviderNotFoundException
{
}
@Override
protected
void
onWork
(
Object
message
)
throws
WorkerException
{
}
public
static
class
Factory
extends
AbstractClusterWorkerProvider
<
GRPCAddressRegister
>
{
public
static
Factory
INSTANCE
=
new
Factory
();
@Override
public
GRPCAddressRegister
.
Role
role
()
{
return
Role
.
INSTANCE
;
}
@Override
public
int
workerNum
()
{
return
WorkerConfig
.
WorkerNum
.
GRPC
.
GRPCAddressRegister
.
VALUE
;
}
@Override
public
RPCAddress
config
()
{
return
new
RPCAddress
(
GRPCConfig
.
GRPC
.
HOSTNAME
,
Integer
.
valueOf
(
GRPCConfig
.
GRPC
.
PORT
));
}
@Override
public
GRPCAddressRegister
workerInstance
(
ClusterWorkerContext
clusterContext
)
{
return
new
GRPCAddressRegister
(
role
(),
clusterContext
,
new
LocalWorkerContext
());
}
}
public
enum
Role
implements
org
.
skywalking
.
apm
.
collector
.
actor
.
Role
{
INSTANCE
;
@Override
public
String
roleName
()
{
return
GRPCAddressRegister
.
class
.
getSimpleName
();
}
@Override
public
WorkerSelector
workerSelector
()
{
return
new
RollingSelector
();
}
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/grpcserver/GRPCServer.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.grpcserver
;
import
io.grpc.Server
;
import
io.grpc.netty.NettyServerBuilder
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.worker.config.GRPCConfig
;
/**
* @author pengys5
*/
public
enum
GRPCServer
{
INSTANCE
;
private
Logger
logger
=
LogManager
.
getFormatterLogger
(
GRPCServer
.
class
);
private
Server
server
;
public
void
boot
(
ClusterWorkerContext
clusterContext
)
throws
Exception
{
start
(
clusterContext
);
blockUntilShutdown
();
}
private
void
start
(
ClusterWorkerContext
clusterContext
)
throws
Exception
{
int
port
=
Integer
.
valueOf
(
GRPCConfig
.
GRPC
.
PORT
);
NettyServerBuilder
nettyServerBuilder
=
NettyServerBuilder
.
forPort
(
port
);
ServicesCreator
.
INSTANCE
.
boot
(
nettyServerBuilder
,
clusterContext
);
server
=
nettyServerBuilder
.
build
().
start
();
logger
.
info
(
"Server started, listening on "
+
port
);
}
/**
* Await termination on the main thread since the grpc library uses daemon threads.
*/
private
void
blockUntilShutdown
()
throws
InterruptedException
{
if
(
server
!=
null
)
{
server
.
awaitTermination
();
}
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/grpcserver/ServicesCreator.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.grpcserver
;
import
io.grpc.BindableService
;
import
io.grpc.netty.NettyServerBuilder
;
import
java.util.ServiceLoader
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.actor.ProviderNotFoundException
;
/**
* @author pengys5
*/
public
enum
ServicesCreator
{
INSTANCE
;
private
Logger
logger
=
LogManager
.
getFormatterLogger
(
ServicesCreator
.
class
);
public
void
boot
(
NettyServerBuilder
nettyServerBuilder
,
ClusterWorkerContext
clusterContext
)
throws
IllegalArgumentException
,
ProviderNotFoundException
{
ServiceLoader
<
BindableService
>
grpcServiceLoader
=
java
.
util
.
ServiceLoader
.
load
(
BindableService
.
class
);
for
(
BindableService
service
:
grpcServiceLoader
)
{
logger
.
info
(
"add grpc service %s into netty server builder "
,
service
.
getClass
().
getSimpleName
());
nettyServerBuilder
.
addService
(
service
);
((
WorkerCaller
)
service
).
inject
(
clusterContext
);
((
WorkerCaller
)
service
).
preStart
();
}
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/grpcserver/TraceSegmentServiceImpl.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.grpcserver
;
import
io.grpc.stub.StreamObserver
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.skywalking.apm.collector.actor.AbstractWorker
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.actor.ProviderNotFoundException
;
import
org.skywalking.apm.collector.actor.WorkerInvokeException
;
import
org.skywalking.apm.collector.actor.WorkerRef
;
import
org.skywalking.apm.collector.worker.segment.SegmentReceiver
;
import
org.skywalking.apm.network.proto.Downstream
;
import
org.skywalking.apm.network.proto.TraceSegmentServiceGrpc
;
import
org.skywalking.apm.network.proto.UpstreamSegment
;
/**
* @author pengys5
*/
public
class
TraceSegmentServiceImpl
extends
TraceSegmentServiceGrpc
.
TraceSegmentServiceImplBase
implements
WorkerCaller
{
private
Logger
logger
=
LogManager
.
getFormatterLogger
(
TraceSegmentServiceImpl
.
class
);
private
ClusterWorkerContext
clusterWorkerContext
;
private
WorkerRef
segmentReceiverWorkRef
;
@Override
public
void
preStart
()
throws
ProviderNotFoundException
{
segmentReceiverWorkRef
=
clusterWorkerContext
.
findProvider
(
SegmentReceiver
.
WorkerRole
.
INSTANCE
).
create
(
AbstractWorker
.
noOwner
());
}
@Override
public
StreamObserver
<
UpstreamSegment
>
collect
(
StreamObserver
<
Downstream
>
responseObserver
)
{
return
new
StreamObserver
<
UpstreamSegment
>()
{
@Override
public
void
onNext
(
UpstreamSegment
segment
)
{
if
(
logger
.
isDebugEnabled
())
{
StringBuffer
globalTraceIds
=
new
StringBuffer
();
logger
.
debug
(
"global trace ids count: %s"
,
segment
.
getGlobalTraceIdsList
().
size
());
segment
.
getGlobalTraceIdsList
().
forEach
(
globalTraceId
->
{
globalTraceIds
.
append
(
globalTraceId
).
append
(
","
);
});
logger
.
debug
(
"receive segment, global trace ids: %s, segment byte size: %s"
,
globalTraceIds
,
segment
.
getSegment
().
size
());
try
{
segmentReceiverWorkRef
.
tell
(
segment
);
}
catch
(
WorkerInvokeException
e
)
{
onError
(
e
);
}
}
}
@Override
public
void
onError
(
Throwable
throwable
)
{
logger
.
error
(
throwable
.
getMessage
(),
throwable
);
}
@Override
public
void
onCompleted
()
{
responseObserver
.
onCompleted
();
}
};
}
@Override
public
void
inject
(
ClusterWorkerContext
clusterWorkerContext
)
{
this
.
clusterWorkerContext
=
clusterWorkerContext
;
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/grpcserver/WorkerCaller.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.grpcserver
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.actor.ProviderNotFoundException
;
/**
* @author pengys5
*/
public
interface
WorkerCaller
{
void
preStart
()
throws
ProviderNotFoundException
;
void
inject
(
ClusterWorkerContext
clusterWorkerContext
);
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/httpserver/AbstractGet.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.httpserver
;
package
org.skywalking.apm.collector.worker.httpserver
;
import
com.google.gson.Json
Objec
t
;
import
com.google.gson.Json
Elemen
t
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Map
;
import
java.util.Map
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletException
;
...
@@ -20,7 +20,7 @@ import org.skywalking.apm.collector.actor.WorkerNotFoundException;
...
@@ -20,7 +20,7 @@ import org.skywalking.apm.collector.actor.WorkerNotFoundException;
* The <code>AbstractGet</code> implementations represent workers, which called by the server to allow a servlet to
* The <code>AbstractGet</code> implementations represent workers, which called by the server to allow a servlet to
* handle a GET request.
* handle a GET request.
*
*
* <p>verride the {@link #onReceive(Map, Json
Objec
t)} method to support a search service.
* <p>verride the {@link #onReceive(Map, Json
Elemen
t)} method to support a search service.
*
*
* @author pengys5
* @author pengys5
* @since v3.0-2017
* @since v3.0-2017
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/httpserver/AbstractServlet.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.httpserver
;
package
org.skywalking.apm.collector.worker.httpserver
;
import
com.google.gson.Json
Objec
t
;
import
com.google.gson.Json
Elemen
t
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -31,6 +31,8 @@ public abstract class AbstractServlet extends AbstractLocalSyncWorker {
...
@@ -31,6 +31,8 @@ public abstract class AbstractServlet extends AbstractLocalSyncWorker {
super
(
role
,
clusterContext
,
selfContext
);
super
(
role
,
clusterContext
,
selfContext
);
}
}
protected
abstract
Class
<?
extends
JsonElement
>
responseClass
();
/**
/**
* Override this method to implementing business logic.
* Override this method to implementing business logic.
*
*
...
@@ -42,12 +44,16 @@ public abstract class AbstractServlet extends AbstractLocalSyncWorker {
...
@@ -42,12 +44,16 @@ public abstract class AbstractServlet extends AbstractLocalSyncWorker {
*/
*/
@Override
protected
void
onWork
(
Object
parameter
,
@Override
protected
void
onWork
(
Object
parameter
,
Object
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
Object
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
JsonObject
resJson
=
new
JsonObject
();
try
{
try
{
JsonElement
resJson
=
responseClass
().
newInstance
();
onReceive
((
Map
<
String
,
String
[]>)
parameter
,
resJson
);
onReceive
((
Map
<
String
,
String
[]>)
parameter
,
resJson
);
onSuccessResponse
((
HttpServletResponse
)
response
,
resJson
);
onSuccessResponse
((
HttpServletResponse
)
response
,
resJson
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
logger
.
error
(
e
.
getMessage
(),
e
);
}
catch
(
InstantiationException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
catch
(
IllegalAccessException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
}
...
@@ -55,23 +61,22 @@ public abstract class AbstractServlet extends AbstractLocalSyncWorker {
...
@@ -55,23 +61,22 @@ public abstract class AbstractServlet extends AbstractLocalSyncWorker {
* Override this method to implementing business logic.
* Override this method to implementing business logic.
*
*
* @param parameter {@link Map}, get the request parameter by key.
* @param parameter {@link Map}, get the request parameter by key.
* @param response {@link Json
Objec
t}, set the response data as json object.
* @param response {@link Json
Elemen
t}, set the response data as json object.
* @throws ArgumentsParseException if the key could not contains in parameter
* @throws ArgumentsParseException if the key could not contains in parameter
* @throws WorkerInvokeException if any error is detected when call(or ask) worker
* @throws WorkerInvokeException if any error is detected when call(or ask) worker
* @throws WorkerNotFoundException if the worker reference could not found in context.
* @throws WorkerNotFoundException if the worker reference could not found in context.
*/
*/
protected
abstract
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
protected
abstract
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
Json
Objec
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
;
Json
Elemen
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
;
/**
/**
* Set the worker response and the success status into the servlet response object
* Set the worker response and the success status into the servlet response object
*
*
* @param response {@link HttpServletResponse} object that contains the response the servlet reply to the client
* @param response {@link HttpServletResponse} object that contains the response the servlet reply to the client
* @param resJson {@link Json
Object} object
that contains the response from worker
* @param resJson {@link Json
Element}
that contains the response from worker
* @throws IOException if any error is detected when the servlet handles the response.
* @throws IOException if any error is detected when the servlet handles the response.
*/
*/
protected
void
onSuccessResponse
(
HttpServletResponse
response
,
JsonObject
resJson
)
throws
IOException
{
protected
void
onSuccessResponse
(
HttpServletResponse
response
,
JsonElement
resJson
)
throws
IOException
{
resJson
.
addProperty
(
"isSuccess"
,
true
);
reply
(
response
,
resJson
,
HttpServletResponse
.
SC_OK
);
reply
(
response
,
resJson
,
HttpServletResponse
.
SC_OK
);
}
}
...
@@ -82,14 +87,15 @@ public abstract class AbstractServlet extends AbstractLocalSyncWorker {
...
@@ -82,14 +87,15 @@ public abstract class AbstractServlet extends AbstractLocalSyncWorker {
* @param response {@link HttpServletResponse} object that contains the response the servlet reply to the client
* @param response {@link HttpServletResponse} object that contains the response the servlet reply to the client
*/
*/
protected
void
onErrorResponse
(
Exception
exception
,
HttpServletResponse
response
)
{
protected
void
onErrorResponse
(
Exception
exception
,
HttpServletResponse
response
)
{
JsonObject
resJson
=
new
JsonObject
();
response
.
setHeader
(
"reason"
,
exception
.
getMessage
());
resJson
.
addProperty
(
"isSuccess"
,
false
);
resJson
.
addProperty
(
"reason"
,
exception
.
getMessage
());
try
{
try
{
reply
(
response
,
res
Json
,
HttpServletResponse
.
SC_INTERNAL_SERVER_ERROR
);
reply
(
response
,
res
ponseClass
().
newInstance
()
,
HttpServletResponse
.
SC_INTERNAL_SERVER_ERROR
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
logger
.
error
(
e
.
getMessage
(),
e
);
}
catch
(
IllegalAccessException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
catch
(
InstantiationException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
}
...
@@ -97,11 +103,11 @@ public abstract class AbstractServlet extends AbstractLocalSyncWorker {
...
@@ -97,11 +103,11 @@ public abstract class AbstractServlet extends AbstractLocalSyncWorker {
* Build the response head and body
* Build the response head and body
*
*
* @param response {@link HttpServletResponse} object that contains the response the servlet reply to the client
* @param response {@link HttpServletResponse} object that contains the response the servlet reply to the client
* @param resJson {@link Json
Object} object
that contains the response from worker
* @param resJson {@link Json
Element}
that contains the response from worker
* @param status http status code
* @param status http status code
* @throws IOException if an input or output error is detected when the servlet handles the response
* @throws IOException if an input or output error is detected when the servlet handles the response
*/
*/
private
void
reply
(
HttpServletResponse
response
,
Json
Objec
t
resJson
,
int
status
)
throws
IOException
{
private
void
reply
(
HttpServletResponse
response
,
Json
Elemen
t
resJson
,
int
status
)
throws
IOException
{
response
.
setContentType
(
"text/json"
);
response
.
setContentType
(
"text/json"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setStatus
(
status
);
response
.
setStatus
(
status
);
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/httpserver/AbstractStreamPost.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.httpserver
;
package
org.skywalking.apm.collector.worker.httpserver
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -58,13 +59,13 @@ public abstract class AbstractStreamPost extends AbstractServlet {
...
@@ -58,13 +59,13 @@ public abstract class AbstractStreamPost extends AbstractServlet {
* Override the default implementation, forbidden to call this method.
* Override the default implementation, forbidden to call this method.
*
*
* @param parameter {@link Map}, get the request parameter by key.
* @param parameter {@link Map}, get the request parameter by key.
* @param response {@link Json
Objec
t}, set the response data as json object.
* @param response {@link Json
Elemen
t}, set the response data as json object.
* @throws ArgumentsParseException if the key could not contains in parameter
* @throws ArgumentsParseException if the key could not contains in parameter
* @throws WorkerInvokeException if any error is detected when call(or ask) worker
* @throws WorkerInvokeException if any error is detected when call(or ask) worker
* @throws WorkerNotFoundException if the worker reference could not found in context.
* @throws WorkerNotFoundException if the worker reference could not found in context.
*/
*/
@Override
final
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
@Override
final
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
Json
Objec
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
Json
Elemen
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
throw
new
WorkerInvokeException
(
"Use the other method with buffer reader parameter"
);
throw
new
WorkerInvokeException
(
"Use the other method with buffer reader parameter"
);
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/httpserver/HttpServer.java
浏览文件 @
93a45165
...
@@ -29,6 +29,5 @@ public enum HttpServer {
...
@@ -29,6 +29,5 @@ public enum HttpServer {
server
.
setHandler
(
servletContextHandler
);
server
.
setHandler
(
servletContextHandler
);
server
.
start
();
server
.
start
();
server
.
join
();
}
}
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/node/analysis/AbstractNodeCompAnalysis.java
浏览文件 @
93a45165
...
@@ -9,12 +9,11 @@ import org.skywalking.apm.collector.actor.LocalWorkerContext;
...
@@ -9,12 +9,11 @@ import org.skywalking.apm.collector.actor.LocalWorkerContext;
import
org.skywalking.apm.collector.actor.Role
;
import
org.skywalking.apm.collector.actor.Role
;
import
org.skywalking.apm.collector.worker.RecordAnalysisMember
;
import
org.skywalking.apm.collector.worker.RecordAnalysisMember
;
import
org.skywalking.apm.collector.worker.node.NodeCompIndex
;
import
org.skywalking.apm.collector.worker.node.NodeCompIndex
;
import
org.skywalking.apm.collector.worker.segment.entity.Segment
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
import
org.skywalking.apm.collector.worker.segment.entity.tag.Tags
;
import
org.skywalking.apm.collector.worker.tools.ClientSpanIsLeafTools
;
import
org.skywalking.apm.collector.worker.tools.CollectionTools
;
import
org.skywalking.apm.collector.worker.tools.CollectionTools
;
import
org.skywalking.apm.collector.worker.tools.SpanPeersTools
;
import
org.skywalking.apm.collector.worker.tools.SpanPeersTools
;
import
org.skywalking.apm.network.proto.SpanObject
;
import
org.skywalking.apm.network.proto.SpanType
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -28,30 +27,29 @@ abstract class AbstractNodeCompAnalysis extends RecordAnalysisMember {
...
@@ -28,30 +27,29 @@ abstract class AbstractNodeCompAnalysis extends RecordAnalysisMember {
super
(
role
,
clusterContext
,
selfContext
);
super
(
role
,
clusterContext
,
selfContext
);
}
}
final
void
analyseSpans
(
Segmen
t
segment
)
{
final
void
analyseSpans
(
TraceSegmentObjec
t
segment
)
{
List
<
Span
>
spanList
=
segment
.
getSpans
();
List
<
Span
Object
>
spanList
=
segment
.
getSpansList
();
logger
.
debug
(
"node analysis span isNotEmpty %s"
,
CollectionTools
.
isNotEmpty
(
spanList
));
logger
.
debug
(
"node analysis span isNotEmpty %s"
,
CollectionTools
.
isNotEmpty
(
spanList
));
if
(
CollectionTools
.
isNotEmpty
(
spanList
))
{
if
(
CollectionTools
.
isNotEmpty
(
spanList
))
{
logger
.
debug
(
"node analysis span list SIZE: %s"
,
spanList
.
size
());
logger
.
debug
(
"node analysis span list SIZE: %s"
,
spanList
.
size
());
for
(
Span
span
:
spanList
)
{
for
(
SpanObject
span
:
spanList
)
{
String
kind
=
Tags
.
SPAN_KIND
.
get
(
span
);
if
(
SpanType
.
Exit
.
equals
(
span
.
getSpanType
()))
{
if
(
Tags
.
SPAN_KIND_CLIENT
.
equals
(
kind
)
&&
ClientSpanIsLeafTools
.
isLeaf
(
span
.
getSpanId
(),
spanList
))
{
int
peers
=
SpanPeersTools
.
INSTANCE
.
getPeers
(
span
);
String
peers
=
SpanPeersTools
.
INSTANCE
.
getPeers
(
span
);
JsonObject
compJsonObj
=
new
JsonObject
();
JsonObject
compJsonObj
=
new
JsonObject
();
compJsonObj
.
addProperty
(
NodeCompIndex
.
PEERS
,
peers
);
compJsonObj
.
addProperty
(
NodeCompIndex
.
PEERS
,
peers
);
compJsonObj
.
addProperty
(
NodeCompIndex
.
NAME
,
Tags
.
COMPONENT
.
get
(
span
));
compJsonObj
.
addProperty
(
NodeCompIndex
.
NAME
,
span
.
getComponent
(
));
set
(
peers
,
compJsonObj
);
set
(
String
.
valueOf
(
peers
)
,
compJsonObj
);
}
else
if
(
Tags
.
SPAN_KIND_SERVER
.
equals
(
kind
)
&&
span
.
getParentSpanId
()
==
-
1
)
{
}
else
if
(
SpanType
.
Entry
.
equals
(
span
.
getSpanType
()
)
&&
span
.
getParentSpanId
()
==
-
1
)
{
String
peers
=
segment
.
getApplicationCode
();
int
peers
=
segment
.
getApplicationId
();
JsonObject
compJsonObj
=
new
JsonObject
();
JsonObject
compJsonObj
=
new
JsonObject
();
compJsonObj
.
addProperty
(
NodeCompIndex
.
PEERS
,
peers
);
compJsonObj
.
addProperty
(
NodeCompIndex
.
PEERS
,
peers
);
compJsonObj
.
addProperty
(
NodeCompIndex
.
NAME
,
Tags
.
COMPONENT
.
get
(
span
));
compJsonObj
.
addProperty
(
NodeCompIndex
.
NAME
,
span
.
getComponent
(
));
set
(
peers
,
compJsonObj
);
set
(
String
.
valueOf
(
peers
)
,
compJsonObj
);
}
}
}
}
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/node/analysis/AbstractNodeMappingAnalysis.java
浏览文件 @
93a45165
...
@@ -10,9 +10,9 @@ import org.skywalking.apm.collector.actor.Role;
...
@@ -10,9 +10,9 @@ import org.skywalking.apm.collector.actor.Role;
import
org.skywalking.apm.collector.worker.Const
;
import
org.skywalking.apm.collector.worker.Const
;
import
org.skywalking.apm.collector.worker.RecordAnalysisMember
;
import
org.skywalking.apm.collector.worker.RecordAnalysisMember
;
import
org.skywalking.apm.collector.worker.node.NodeMappingIndex
;
import
org.skywalking.apm.collector.worker.node.NodeMappingIndex
;
import
org.skywalking.apm.collector.worker.segment.entity.Segment
;
import
org.skywalking.apm.collector.worker.segment.entity.TraceSegmentRef
;
import
org.skywalking.apm.collector.worker.tools.CollectionTools
;
import
org.skywalking.apm.collector.worker.tools.CollectionTools
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
import
org.skywalking.apm.network.proto.TraceSegmentReference
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -26,15 +26,15 @@ abstract class AbstractNodeMappingAnalysis extends RecordAnalysisMember {
...
@@ -26,15 +26,15 @@ abstract class AbstractNodeMappingAnalysis extends RecordAnalysisMember {
super
(
role
,
clusterContext
,
selfContext
);
super
(
role
,
clusterContext
,
selfContext
);
}
}
final
void
analyseRefs
(
Segmen
t
segment
,
long
timeSlice
)
{
final
void
analyseRefs
(
TraceSegmentObjec
t
segment
,
long
timeSlice
)
{
List
<
TraceSegmentRef
>
segmentRefList
=
segment
.
getRefs
();
List
<
TraceSegmentRef
erence
>
segmentRefList
=
segment
.
getRefsList
();
logger
.
debug
(
"node mapping analysis refs isNotEmpty %s"
,
CollectionTools
.
isNotEmpty
(
segmentRefList
));
logger
.
debug
(
"node mapping analysis refs isNotEmpty %s"
,
CollectionTools
.
isNotEmpty
(
segmentRefList
));
if
(
CollectionTools
.
isNotEmpty
(
segmentRefList
))
{
if
(
CollectionTools
.
isNotEmpty
(
segmentRefList
))
{
logger
.
debug
(
"node mapping analysis refs list SIZE: %s"
,
segmentRefList
.
size
());
logger
.
debug
(
"node mapping analysis refs list SIZE: %s"
,
segmentRefList
.
size
());
for
(
TraceSegmentRef
segmentRef
:
segmentRefList
)
{
for
(
TraceSegmentRef
erence
segmentRef
:
segmentRefList
)
{
String
peers
=
Const
.
PEERS_FRONT_SPLIT
+
segmentRef
.
get
PeerHost
()
+
Const
.
PEERS_BEHIND_SPLIT
;
String
peers
=
Const
.
PEERS_FRONT_SPLIT
+
segmentRef
.
get
NetworkAddress
()
+
Const
.
PEERS_BEHIND_SPLIT
;
String
code
=
segment
.
getApplicationCode
();
int
code
=
segment
.
getApplicationId
();
JsonObject
nodeMappingJsonObj
=
new
JsonObject
();
JsonObject
nodeMappingJsonObj
=
new
JsonObject
();
nodeMappingJsonObj
.
addProperty
(
NodeMappingIndex
.
CODE
,
code
);
nodeMappingJsonObj
.
addProperty
(
NodeMappingIndex
.
CODE
,
code
);
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/node/analysis/NodeCompAnalysis.java
浏览文件 @
93a45165
...
@@ -11,8 +11,8 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
...
@@ -11,8 +11,8 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.node.persistence.NodeCompAgg
;
import
org.skywalking.apm.collector.worker.node.persistence.NodeCompAgg
;
import
org.skywalking.apm.collector.worker.segment.Segment
Post
;
import
org.skywalking.apm.collector.worker.segment.Segment
Receiver
;
import
org.skywalking.apm.
collector.worker.segment.entity.Segmen
t
;
import
org.skywalking.apm.
network.proto.TraceSegmentObjec
t
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -28,12 +28,12 @@ public class NodeCompAnalysis extends AbstractNodeCompAnalysis {
...
@@ -28,12 +28,12 @@ public class NodeCompAnalysis extends AbstractNodeCompAnalysis {
@Override
@Override
public
void
analyse
(
Object
message
)
{
public
void
analyse
(
Object
message
)
{
if
(
message
instanceof
Segment
Post
.
SegmentWithTimeSlice
)
{
if
(
message
instanceof
Segment
Receiver
.
SegmentWithTimeSlice
)
{
Segment
Post
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentPost
.
SegmentWithTimeSlice
)
message
;
Segment
Receiver
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentReceiver
.
SegmentWithTimeSlice
)
message
;
Segmen
t
segment
=
segmentWithTimeSlice
.
getSegment
();
TraceSegmentObjec
t
segment
=
segmentWithTimeSlice
.
getSegment
();
analyseSpans
(
segment
);
analyseSpans
(
segment
);
}
else
{
}
else
{
logger
.
error
(
"unhandled message, message instance must Segment
Post
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
logger
.
error
(
"unhandled message, message instance must Segment
Receiver
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
}
}
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/node/analysis/NodeMappingDayAnalysis.java
浏览文件 @
93a45165
...
@@ -11,8 +11,8 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
...
@@ -11,8 +11,8 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.node.persistence.NodeMappingDayAgg
;
import
org.skywalking.apm.collector.worker.node.persistence.NodeMappingDayAgg
;
import
org.skywalking.apm.collector.worker.segment.Segment
Post
;
import
org.skywalking.apm.collector.worker.segment.Segment
Receiver
;
import
org.skywalking.apm.
collector.worker.segment.entity.Segmen
t
;
import
org.skywalking.apm.
network.proto.TraceSegmentObjec
t
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -28,12 +28,12 @@ public class NodeMappingDayAnalysis extends AbstractNodeMappingAnalysis {
...
@@ -28,12 +28,12 @@ public class NodeMappingDayAnalysis extends AbstractNodeMappingAnalysis {
@Override
@Override
public
void
analyse
(
Object
message
)
{
public
void
analyse
(
Object
message
)
{
if
(
message
instanceof
Segment
Post
.
SegmentWithTimeSlice
)
{
if
(
message
instanceof
Segment
Receiver
.
SegmentWithTimeSlice
)
{
Segment
Post
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentPost
.
SegmentWithTimeSlice
)
message
;
Segment
Receiver
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentReceiver
.
SegmentWithTimeSlice
)
message
;
Segmen
t
segment
=
segmentWithTimeSlice
.
getSegment
();
TraceSegmentObjec
t
segment
=
segmentWithTimeSlice
.
getSegment
();
analyseRefs
(
segment
,
segmentWithTimeSlice
.
getDay
());
analyseRefs
(
segment
,
segmentWithTimeSlice
.
getDay
());
}
else
{
}
else
{
logger
.
error
(
"unhandled message, message instance must Segment
Post
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
logger
.
error
(
"unhandled message, message instance must Segment
Receiver
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
}
}
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/node/analysis/NodeMappingHourAnalysis.java
浏览文件 @
93a45165
...
@@ -11,8 +11,8 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
...
@@ -11,8 +11,8 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.node.persistence.NodeMappingHourAgg
;
import
org.skywalking.apm.collector.worker.node.persistence.NodeMappingHourAgg
;
import
org.skywalking.apm.collector.worker.segment.Segment
Post
;
import
org.skywalking.apm.collector.worker.segment.Segment
Receiver
;
import
org.skywalking.apm.
collector.worker.segment.entity.Segmen
t
;
import
org.skywalking.apm.
network.proto.TraceSegmentObjec
t
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -28,12 +28,12 @@ public class NodeMappingHourAnalysis extends AbstractNodeMappingAnalysis {
...
@@ -28,12 +28,12 @@ public class NodeMappingHourAnalysis extends AbstractNodeMappingAnalysis {
@Override
@Override
public
void
analyse
(
Object
message
)
{
public
void
analyse
(
Object
message
)
{
if
(
message
instanceof
Segment
Post
.
SegmentWithTimeSlice
)
{
if
(
message
instanceof
Segment
Receiver
.
SegmentWithTimeSlice
)
{
Segment
Post
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentPost
.
SegmentWithTimeSlice
)
message
;
Segment
Receiver
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentReceiver
.
SegmentWithTimeSlice
)
message
;
Segmen
t
segment
=
segmentWithTimeSlice
.
getSegment
();
TraceSegmentObjec
t
segment
=
segmentWithTimeSlice
.
getSegment
();
analyseRefs
(
segment
,
segmentWithTimeSlice
.
getHour
());
analyseRefs
(
segment
,
segmentWithTimeSlice
.
getHour
());
}
else
{
}
else
{
logger
.
error
(
"unhandled message, message instance must Segment
Post
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
logger
.
error
(
"unhandled message, message instance must Segment
Receiver
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
}
}
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/node/analysis/NodeMappingMinuteAnalysis.java
浏览文件 @
93a45165
...
@@ -11,8 +11,8 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
...
@@ -11,8 +11,8 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.node.persistence.NodeMappingMinuteAgg
;
import
org.skywalking.apm.collector.worker.node.persistence.NodeMappingMinuteAgg
;
import
org.skywalking.apm.collector.worker.segment.Segment
Post
;
import
org.skywalking.apm.collector.worker.segment.Segment
Receiver
;
import
org.skywalking.apm.
collector.worker.segment.entity.Segmen
t
;
import
org.skywalking.apm.
network.proto.TraceSegmentObjec
t
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -28,12 +28,12 @@ public class NodeMappingMinuteAnalysis extends AbstractNodeMappingAnalysis {
...
@@ -28,12 +28,12 @@ public class NodeMappingMinuteAnalysis extends AbstractNodeMappingAnalysis {
@Override
@Override
public
void
analyse
(
Object
message
)
{
public
void
analyse
(
Object
message
)
{
if
(
message
instanceof
Segment
Post
.
SegmentWithTimeSlice
)
{
if
(
message
instanceof
Segment
Receiver
.
SegmentWithTimeSlice
)
{
Segment
Post
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentPost
.
SegmentWithTimeSlice
)
message
;
Segment
Receiver
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentReceiver
.
SegmentWithTimeSlice
)
message
;
Segmen
t
segment
=
segmentWithTimeSlice
.
getSegment
();
TraceSegmentObjec
t
segment
=
segmentWithTimeSlice
.
getSegment
();
analyseRefs
(
segment
,
segmentWithTimeSlice
.
getMinute
());
analyseRefs
(
segment
,
segmentWithTimeSlice
.
getMinute
());
}
else
{
}
else
{
logger
.
error
(
"unhandled message, message instance must Segment
Post
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
logger
.
error
(
"unhandled message, message instance must Segment
Receiver
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
}
}
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/noderef/NodeRefResSumGetGroupWithTimeSlice.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.noderef
;
package
org.skywalking.apm.collector.worker.noderef
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -30,13 +31,17 @@ public class NodeRefResSumGetGroupWithTimeSlice extends AbstractGet {
...
@@ -30,13 +31,17 @@ public class NodeRefResSumGetGroupWithTimeSlice extends AbstractGet {
super
(
role
,
clusterContext
,
selfContext
);
super
(
role
,
clusterContext
,
selfContext
);
}
}
@Override
protected
Class
<?
extends
JsonElement
>
responseClass
()
{
return
JsonObject
.
class
;
}
@Override
@Override
public
void
preStart
()
throws
ProviderNotFoundException
{
public
void
preStart
()
throws
ProviderNotFoundException
{
getClusterContext
().
findProvider
(
NodeRefResSumGroupWithTimeSlice
.
WorkerRole
.
INSTANCE
).
create
(
this
);
getClusterContext
().
findProvider
(
NodeRefResSumGroupWithTimeSlice
.
WorkerRole
.
INSTANCE
).
create
(
this
);
}
}
@Override
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
@Override
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
Json
Objec
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
Json
Elemen
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
if
(!
parameter
.
containsKey
(
"startTime"
)
||
!
parameter
.
containsKey
(
"endTime"
)
||
!
parameter
.
containsKey
(
"timeSliceType"
))
{
if
(!
parameter
.
containsKey
(
"startTime"
)
||
!
parameter
.
containsKey
(
"endTime"
)
||
!
parameter
.
containsKey
(
"timeSliceType"
))
{
throw
new
ArgumentsParseException
(
"the request parameter must contains startTime,endTime,timeSliceType"
);
throw
new
ArgumentsParseException
(
"the request parameter must contains startTime,endTime,timeSliceType"
);
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/noderef/analysis/AbstractNodeRefAnalysis.java
浏览文件 @
93a45165
...
@@ -10,12 +10,11 @@ import org.skywalking.apm.collector.actor.Role;
...
@@ -10,12 +10,11 @@ import org.skywalking.apm.collector.actor.Role;
import
org.skywalking.apm.collector.worker.Const
;
import
org.skywalking.apm.collector.worker.Const
;
import
org.skywalking.apm.collector.worker.RecordAnalysisMember
;
import
org.skywalking.apm.collector.worker.RecordAnalysisMember
;
import
org.skywalking.apm.collector.worker.noderef.NodeRefIndex
;
import
org.skywalking.apm.collector.worker.noderef.NodeRefIndex
;
import
org.skywalking.apm.collector.worker.segment.entity.Segment
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
import
org.skywalking.apm.collector.worker.segment.entity.tag.Tags
;
import
org.skywalking.apm.collector.worker.tools.ClientSpanIsLeafTools
;
import
org.skywalking.apm.collector.worker.tools.CollectionTools
;
import
org.skywalking.apm.collector.worker.tools.CollectionTools
;
import
org.skywalking.apm.collector.worker.tools.SpanPeersTools
;
import
org.skywalking.apm.collector.worker.tools.SpanPeersTools
;
import
org.skywalking.apm.network.proto.SpanObject
;
import
org.skywalking.apm.network.proto.SpanType
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -29,21 +28,21 @@ abstract class AbstractNodeRefAnalysis extends RecordAnalysisMember {
...
@@ -29,21 +28,21 @@ abstract class AbstractNodeRefAnalysis extends RecordAnalysisMember {
super
(
role
,
clusterContext
,
selfContext
);
super
(
role
,
clusterContext
,
selfContext
);
}
}
final
void
analyseNodeRef
(
Segmen
t
segment
,
long
timeSlice
,
long
minute
,
long
hour
,
long
day
,
final
void
analyseNodeRef
(
TraceSegmentObjec
t
segment
,
long
timeSlice
,
long
minute
,
long
hour
,
long
day
,
int
second
)
{
int
second
)
{
List
<
Span
>
spanList
=
segment
.
getSpans
();
List
<
Span
Object
>
spanList
=
segment
.
getSpansList
();
if
(
CollectionTools
.
isNotEmpty
(
spanList
))
{
if
(
CollectionTools
.
isNotEmpty
(
spanList
))
{
for
(
Span
span
:
spanList
)
{
for
(
Span
Object
span
:
spanList
)
{
JsonObject
dataJsonObj
=
new
JsonObject
();
JsonObject
dataJsonObj
=
new
JsonObject
();
dataJsonObj
.
addProperty
(
NodeRefIndex
.
TIME_SLICE
,
timeSlice
);
dataJsonObj
.
addProperty
(
NodeRefIndex
.
TIME_SLICE
,
timeSlice
);
dataJsonObj
.
addProperty
(
NodeRefIndex
.
FRONT_IS_REAL_CODE
,
true
);
dataJsonObj
.
addProperty
(
NodeRefIndex
.
FRONT_IS_REAL_CODE
,
true
);
dataJsonObj
.
addProperty
(
NodeRefIndex
.
BEHIND_IS_REAL_CODE
,
true
);
dataJsonObj
.
addProperty
(
NodeRefIndex
.
BEHIND_IS_REAL_CODE
,
true
);
if
(
Tags
.
SPAN_KIND_CLIENT
.
equals
(
Tags
.
SPAN_KIND
.
get
(
span
))
&&
ClientSpanIsLeafTools
.
isLeaf
(
span
.
getSpanId
(),
spanList
))
{
if
(
SpanType
.
Exit
.
equals
(
span
.
getSpanType
()
))
{
String
front
=
segment
.
getApplicationCode
();
int
front
=
segment
.
getApplicationId
();
dataJsonObj
.
addProperty
(
NodeRefIndex
.
FRONT
,
front
);
dataJsonObj
.
addProperty
(
NodeRefIndex
.
FRONT
,
front
);
String
behind
=
SpanPeersTools
.
INSTANCE
.
getPeers
(
span
);
int
behind
=
SpanPeersTools
.
INSTANCE
.
getPeers
(
span
);
dataJsonObj
.
addProperty
(
NodeRefIndex
.
BEHIND
,
behind
);
dataJsonObj
.
addProperty
(
NodeRefIndex
.
BEHIND
,
behind
);
dataJsonObj
.
addProperty
(
NodeRefIndex
.
BEHIND_IS_REAL_CODE
,
false
);
dataJsonObj
.
addProperty
(
NodeRefIndex
.
BEHIND_IS_REAL_CODE
,
false
);
...
@@ -51,9 +50,9 @@ abstract class AbstractNodeRefAnalysis extends RecordAnalysisMember {
...
@@ -51,9 +50,9 @@ abstract class AbstractNodeRefAnalysis extends RecordAnalysisMember {
logger
.
debug
(
"dag node ref: %s"
,
dataJsonObj
.
toString
());
logger
.
debug
(
"dag node ref: %s"
,
dataJsonObj
.
toString
());
set
(
id
,
dataJsonObj
);
set
(
id
,
dataJsonObj
);
buildNodeRefResRecordData
(
id
,
span
,
minute
,
hour
,
day
,
second
);
buildNodeRefResRecordData
(
id
,
span
,
minute
,
hour
,
day
,
second
);
}
else
if
(
Tags
.
SPAN_KIND_SERVER
.
equals
(
Tags
.
SPAN_KIND
.
get
(
span
)))
{
}
else
if
(
SpanType
.
Entry
.
equals
(
span
.
getSpanType
(
)))
{
if
(
span
.
getParentSpanId
()
==
-
1
&&
CollectionTools
.
isEmpty
(
segment
.
getRefs
())
)
{
if
(
span
.
getParentSpanId
()
==
-
1
&&
segment
.
getRefsCount
()
==
0
)
{
String
behind
=
segment
.
getApplicationCode
();
int
behind
=
segment
.
getApplicationId
();
dataJsonObj
.
addProperty
(
NodeRefIndex
.
BEHIND
,
behind
);
dataJsonObj
.
addProperty
(
NodeRefIndex
.
BEHIND
,
behind
);
String
front
=
Const
.
USER_CODE
;
String
front
=
Const
.
USER_CODE
;
...
@@ -68,13 +67,13 @@ abstract class AbstractNodeRefAnalysis extends RecordAnalysisMember {
...
@@ -68,13 +67,13 @@ abstract class AbstractNodeRefAnalysis extends RecordAnalysisMember {
}
}
}
}
private
void
buildNodeRefResRecordData
(
String
nodeRefId
,
Span
span
,
long
minute
,
long
hour
,
long
day
,
private
void
buildNodeRefResRecordData
(
String
nodeRefId
,
Span
Object
span
,
long
minute
,
long
hour
,
long
day
,
int
second
)
{
int
second
)
{
AbstractNodeRefResSumAnalysis
.
NodeRefResRecord
refResRecord
=
new
AbstractNodeRefResSumAnalysis
.
NodeRefResRecord
(
minute
,
hour
,
day
,
second
);
AbstractNodeRefResSumAnalysis
.
NodeRefResRecord
refResRecord
=
new
AbstractNodeRefResSumAnalysis
.
NodeRefResRecord
(
minute
,
hour
,
day
,
second
);
refResRecord
.
setStartTime
(
span
.
getStartTime
());
refResRecord
.
setStartTime
(
span
.
getStartTime
());
refResRecord
.
setEndTime
(
span
.
getEndTime
());
refResRecord
.
setEndTime
(
span
.
getEndTime
());
refResRecord
.
setNodeRefId
(
nodeRefId
);
refResRecord
.
setNodeRefId
(
nodeRefId
);
refResRecord
.
setError
(
Tags
.
ERROR
.
get
(
span
));
refResRecord
.
setError
(
span
.
getIsError
(
));
sendToResSumAnalysis
(
refResRecord
);
sendToResSumAnalysis
(
refResRecord
);
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/noderef/analysis/NodeRefDayAnalysis.java
浏览文件 @
93a45165
...
@@ -13,8 +13,8 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
...
@@ -13,8 +13,8 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.noderef.persistence.NodeRefDayAgg
;
import
org.skywalking.apm.collector.worker.noderef.persistence.NodeRefDayAgg
;
import
org.skywalking.apm.collector.worker.segment.Segment
Post
;
import
org.skywalking.apm.collector.worker.segment.Segment
Receiver
;
import
org.skywalking.apm.
collector.worker.segment.entity.Segmen
t
;
import
org.skywalking.apm.
network.proto.TraceSegmentObjec
t
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -36,9 +36,9 @@ public class NodeRefDayAnalysis extends AbstractNodeRefAnalysis {
...
@@ -36,9 +36,9 @@ public class NodeRefDayAnalysis extends AbstractNodeRefAnalysis {
@Override
@Override
public
void
analyse
(
Object
message
)
{
public
void
analyse
(
Object
message
)
{
if
(
message
instanceof
Segment
Post
.
SegmentWithTimeSlice
)
{
if
(
message
instanceof
Segment
Receiver
.
SegmentWithTimeSlice
)
{
Segment
Post
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentPost
.
SegmentWithTimeSlice
)
message
;
Segment
Receiver
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentReceiver
.
SegmentWithTimeSlice
)
message
;
Segmen
t
segment
=
segmentWithTimeSlice
.
getSegment
();
TraceSegmentObjec
t
segment
=
segmentWithTimeSlice
.
getSegment
();
long
minute
=
segmentWithTimeSlice
.
getMinute
();
long
minute
=
segmentWithTimeSlice
.
getMinute
();
long
hour
=
segmentWithTimeSlice
.
getHour
();
long
hour
=
segmentWithTimeSlice
.
getHour
();
...
@@ -46,7 +46,7 @@ public class NodeRefDayAnalysis extends AbstractNodeRefAnalysis {
...
@@ -46,7 +46,7 @@ public class NodeRefDayAnalysis extends AbstractNodeRefAnalysis {
int
second
=
segmentWithTimeSlice
.
getSecond
();
int
second
=
segmentWithTimeSlice
.
getSecond
();
analyseNodeRef
(
segment
,
segmentWithTimeSlice
.
getDay
(),
minute
,
hour
,
day
,
second
);
analyseNodeRef
(
segment
,
segmentWithTimeSlice
.
getDay
(),
minute
,
hour
,
day
,
second
);
}
else
{
}
else
{
logger
.
error
(
"unhandled message, message instance must Segment
Post
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
logger
.
error
(
"unhandled message, message instance must Segment
Receiver
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
}
}
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/noderef/analysis/NodeRefHourAnalysis.java
浏览文件 @
93a45165
...
@@ -13,8 +13,8 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
...
@@ -13,8 +13,8 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.noderef.persistence.NodeRefHourAgg
;
import
org.skywalking.apm.collector.worker.noderef.persistence.NodeRefHourAgg
;
import
org.skywalking.apm.collector.worker.segment.Segment
Post
;
import
org.skywalking.apm.collector.worker.segment.Segment
Receiver
;
import
org.skywalking.apm.
collector.worker.segment.entity.Segmen
t
;
import
org.skywalking.apm.
network.proto.TraceSegmentObjec
t
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -36,9 +36,9 @@ public class NodeRefHourAnalysis extends AbstractNodeRefAnalysis {
...
@@ -36,9 +36,9 @@ public class NodeRefHourAnalysis extends AbstractNodeRefAnalysis {
@Override
@Override
public
void
analyse
(
Object
message
)
{
public
void
analyse
(
Object
message
)
{
if
(
message
instanceof
Segment
Post
.
SegmentWithTimeSlice
)
{
if
(
message
instanceof
Segment
Receiver
.
SegmentWithTimeSlice
)
{
Segment
Post
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentPost
.
SegmentWithTimeSlice
)
message
;
Segment
Receiver
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentReceiver
.
SegmentWithTimeSlice
)
message
;
Segmen
t
segment
=
segmentWithTimeSlice
.
getSegment
();
TraceSegmentObjec
t
segment
=
segmentWithTimeSlice
.
getSegment
();
long
minute
=
segmentWithTimeSlice
.
getMinute
();
long
minute
=
segmentWithTimeSlice
.
getMinute
();
long
hour
=
segmentWithTimeSlice
.
getHour
();
long
hour
=
segmentWithTimeSlice
.
getHour
();
...
@@ -46,7 +46,7 @@ public class NodeRefHourAnalysis extends AbstractNodeRefAnalysis {
...
@@ -46,7 +46,7 @@ public class NodeRefHourAnalysis extends AbstractNodeRefAnalysis {
int
second
=
segmentWithTimeSlice
.
getSecond
();
int
second
=
segmentWithTimeSlice
.
getSecond
();
analyseNodeRef
(
segment
,
segmentWithTimeSlice
.
getHour
(),
minute
,
hour
,
day
,
second
);
analyseNodeRef
(
segment
,
segmentWithTimeSlice
.
getHour
(),
minute
,
hour
,
day
,
second
);
}
else
{
}
else
{
logger
.
error
(
"unhandled message, message instance must Segment
Post
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
logger
.
error
(
"unhandled message, message instance must Segment
Receiver
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
}
}
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/noderef/analysis/NodeRefMinuteAnalysis.java
浏览文件 @
93a45165
...
@@ -13,8 +13,8 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
...
@@ -13,8 +13,8 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.noderef.persistence.NodeRefMinuteAgg
;
import
org.skywalking.apm.collector.worker.noderef.persistence.NodeRefMinuteAgg
;
import
org.skywalking.apm.collector.worker.segment.Segment
Post
;
import
org.skywalking.apm.collector.worker.segment.Segment
Receiver
;
import
org.skywalking.apm.
collector.worker.segment.entity.Segmen
t
;
import
org.skywalking.apm.
network.proto.TraceSegmentObjec
t
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -36,16 +36,16 @@ public class NodeRefMinuteAnalysis extends AbstractNodeRefAnalysis {
...
@@ -36,16 +36,16 @@ public class NodeRefMinuteAnalysis extends AbstractNodeRefAnalysis {
@Override
@Override
public
void
analyse
(
Object
message
)
{
public
void
analyse
(
Object
message
)
{
if
(
message
instanceof
Segment
Post
.
SegmentWithTimeSlice
)
{
if
(
message
instanceof
Segment
Receiver
.
SegmentWithTimeSlice
)
{
Segment
Post
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentPost
.
SegmentWithTimeSlice
)
message
;
Segment
Receiver
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentReceiver
.
SegmentWithTimeSlice
)
message
;
Segmen
t
segment
=
segmentWithTimeSlice
.
getSegment
();
TraceSegmentObjec
t
segment
=
segmentWithTimeSlice
.
getSegment
();
long
minute
=
segmentWithTimeSlice
.
getMinute
();
long
minute
=
segmentWithTimeSlice
.
getMinute
();
long
hour
=
segmentWithTimeSlice
.
getHour
();
long
hour
=
segmentWithTimeSlice
.
getHour
();
long
day
=
segmentWithTimeSlice
.
getDay
();
long
day
=
segmentWithTimeSlice
.
getDay
();
int
second
=
segmentWithTimeSlice
.
getSecond
();
int
second
=
segmentWithTimeSlice
.
getSecond
();
analyseNodeRef
(
segment
,
segmentWithTimeSlice
.
getMinute
(),
minute
,
hour
,
day
,
second
);
analyseNodeRef
(
segment
,
segmentWithTimeSlice
.
getMinute
(),
minute
,
hour
,
day
,
second
);
}
else
{
}
else
{
logger
.
error
(
"unhandled message, message instance must Segment
Post
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
logger
.
error
(
"unhandled message, message instance must Segment
Receiver
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
}
}
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/SegmentIndex.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.segment
;
package
org.skywalking.apm.collector.worker.segment
;
import
java.io.IOException
;
import
org.elasticsearch.common.xcontent.XContentBuilder
;
import
org.elasticsearch.common.xcontent.XContentBuilder
;
import
org.elasticsearch.common.xcontent.XContentFactory
;
import
org.elasticsearch.common.xcontent.XContentFactory
;
import
org.skywalking.apm.collector.worker.config.EsConfig
;
import
org.skywalking.apm.collector.worker.config.EsConfig
;
import
org.skywalking.apm.collector.worker.storage.AbstractIndex
;
import
org.skywalking.apm.collector.worker.storage.AbstractIndex
;
import
java.io.IOException
;
/**
/**
* @author pengys5
* @author pengys5
*/
*/
public
class
SegmentIndex
extends
AbstractIndex
{
public
class
SegmentIndex
extends
AbstractIndex
{
public
static
final
String
INDEX
=
"segment_idx"
;
public
static
final
String
INDEX
=
"segment_idx"
;
public
static
final
String
TRACE_SEGMENT_ID
=
"traceSegmentId"
;
public
static
final
String
SEGMENT_OBJ_BLOB
=
"segmentObjBlob"
;
@Override
@Override
public
String
index
()
{
public
String
index
()
{
...
@@ -34,31 +35,20 @@ public class SegmentIndex extends AbstractIndex {
...
@@ -34,31 +35,20 @@ public class SegmentIndex extends AbstractIndex {
return
XContentFactory
.
jsonBuilder
()
return
XContentFactory
.
jsonBuilder
()
.
startObject
()
.
startObject
()
.
startObject
(
"properties"
)
.
startObject
(
"properties"
)
.
startObject
(
"traceSegmentId"
)
.
startObject
(
TRACE_SEGMENT_ID
)
.
field
(
"type"
,
"keyword"
)
.
endObject
()
.
startObject
(
"startTime"
)
.
field
(
"type"
,
"date"
)
.
field
(
"index"
,
"not_analyzed"
)
.
endObject
()
.
startObject
(
"endTime"
)
.
field
(
"type"
,
"date"
)
.
field
(
"index"
,
"not_analyzed"
)
.
endObject
()
.
startObject
(
"applicationCode"
)
.
field
(
"type"
,
"keyword"
)
.
field
(
"type"
,
"keyword"
)
.
endObject
()
.
endObject
()
.
startObject
(
"minute"
)
.
startObject
(
TYPE_MINUTE
)
.
field
(
"type"
,
"long"
)
.
field
(
"type"
,
"long"
)
.
field
(
"index"
,
"not_analyzed"
)
.
endObject
()
.
endObject
()
.
startObject
(
"hour"
)
.
startObject
(
TYPE_HOUR
)
.
field
(
"type"
,
"long"
)
.
field
(
"type"
,
"long"
)
.
field
(
"index"
,
"not_analyzed"
)
.
endObject
()
.
endObject
()
.
startObject
(
"day"
)
.
startObject
(
TYPE_DAY
)
.
field
(
"type"
,
"long"
)
.
field
(
"type"
,
"long"
)
.
field
(
"index"
,
"not_analyzed"
)
.
endObject
()
.
startObject
(
SEGMENT_OBJ_BLOB
)
.
field
(
"type"
,
"binary"
)
.
endObject
()
.
endObject
()
.
endObject
()
.
endObject
()
.
endObject
();
.
endObject
();
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/Segment
Post
.java
→
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/Segment
Receiver
.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.segment
;
package
org.skywalking.apm.collector.worker.segment
;
import
com.google.gson.JsonObject
;
import
com.google.protobuf.ByteString
;
import
java.io.BufferedReader
;
import
com.google.protobuf.InvalidProtocolBufferException
;
import
java.io.IOException
;
import
java.util.List
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
import
org.skywalking.apm.collector.actor.AbstractLocalSyncWorkerProvider
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.actor.LocalWorkerContext
;
import
org.skywalking.apm.collector.actor.LocalWorkerContext
;
import
org.skywalking.apm.collector.actor.ProviderNotFoundException
;
import
org.skywalking.apm.collector.actor.ProviderNotFoundException
;
...
@@ -14,8 +16,7 @@ import org.skywalking.apm.collector.actor.WorkerNotFoundException;
...
@@ -14,8 +16,7 @@ import org.skywalking.apm.collector.actor.WorkerNotFoundException;
import
org.skywalking.apm.collector.actor.selector.RollingSelector
;
import
org.skywalking.apm.collector.actor.selector.RollingSelector
;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.worker.globaltrace.analysis.GlobalTraceAnalysis
;
import
org.skywalking.apm.collector.worker.globaltrace.analysis.GlobalTraceAnalysis
;
import
org.skywalking.apm.collector.worker.httpserver.AbstractStreamPost
;
import
org.skywalking.apm.collector.worker.grpcserver.AbstractReceiver
;
import
org.skywalking.apm.collector.worker.httpserver.AbstractStreamPostProvider
;
import
org.skywalking.apm.collector.worker.httpserver.ArgumentsParseException
;
import
org.skywalking.apm.collector.worker.httpserver.ArgumentsParseException
;
import
org.skywalking.apm.collector.worker.node.analysis.NodeCompAnalysis
;
import
org.skywalking.apm.collector.worker.node.analysis.NodeCompAnalysis
;
import
org.skywalking.apm.collector.worker.node.analysis.NodeMappingDayAnalysis
;
import
org.skywalking.apm.collector.worker.node.analysis.NodeMappingDayAnalysis
;
...
@@ -27,20 +28,21 @@ import org.skywalking.apm.collector.worker.noderef.analysis.NodeRefMinuteAnalysi
...
@@ -27,20 +28,21 @@ import org.skywalking.apm.collector.worker.noderef.analysis.NodeRefMinuteAnalysi
import
org.skywalking.apm.collector.worker.segment.analysis.SegmentAnalysis
;
import
org.skywalking.apm.collector.worker.segment.analysis.SegmentAnalysis
;
import
org.skywalking.apm.collector.worker.segment.analysis.SegmentCostAnalysis
;
import
org.skywalking.apm.collector.worker.segment.analysis.SegmentCostAnalysis
;
import
org.skywalking.apm.collector.worker.segment.analysis.SegmentExceptionAnalysis
;
import
org.skywalking.apm.collector.worker.segment.analysis.SegmentExceptionAnalysis
;
import
org.skywalking.apm.collector.worker.segment.entity.Segment
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentAndBase64
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentAndJson
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentDeserialize
;
import
org.skywalking.apm.collector.worker.storage.AbstractTimeSlice
;
import
org.skywalking.apm.collector.worker.storage.AbstractTimeSlice
;
import
org.skywalking.apm.collector.worker.tools.DateTools
;
import
org.skywalking.apm.collector.worker.tools.DateTools
;
import
org.skywalking.apm.network.proto.SpanObject
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
import
org.skywalking.apm.network.proto.UpstreamSegment
;
import
org.skywalking.apm.util.StringUtil
;
import
org.skywalking.apm.util.StringUtil
;
/**
/**
* @author pengys5
* @author pengys5
*/
*/
public
class
Segment
Post
extends
AbstractStreamPost
{
public
class
Segment
Receiver
extends
AbstractReceiver
{
private
static
final
Logger
logger
=
LogManager
.
getFormatterLogger
(
Segment
Post
.
class
);
private
static
final
Logger
logger
=
LogManager
.
getFormatterLogger
(
Segment
Receiver
.
class
);
public
Segment
Post
(
Role
role
,
ClusterWorkerContext
clusterContext
,
LocalWorkerContext
selfContext
)
{
public
Segment
Receiver
(
Role
role
,
ClusterWorkerContext
clusterContext
,
LocalWorkerContext
selfContext
)
{
super
(
role
,
clusterContext
,
selfContext
);
super
(
role
,
clusterContext
,
selfContext
);
}
}
...
@@ -67,59 +69,47 @@ public class SegmentPost extends AbstractStreamPost {
...
@@ -67,59 +69,47 @@ public class SegmentPost extends AbstractStreamPost {
* Read segment's buffer from buffer reader by stream mode. when finish read one segment then send to analysis.
* Read segment's buffer from buffer reader by stream mode. when finish read one segment then send to analysis.
* This method in there, so post servlet just can receive segments data.
* This method in there, so post servlet just can receive segments data.
*/
*/
@Override
protected
void
onReceive
(
BufferedReader
bufferedReader
,
@Override
protected
void
onReceive
(
JsonObject
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
Object
request
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
Segment
segment
;
if
(
request
instanceof
UpstreamSegment
)
{
try
{
UpstreamSegment
upstreamSegment
=
(
UpstreamSegment
)
request
;
do
{
ByteString
segmentByte
=
upstreamSegment
.
getSegment
();
int
character
;
List
<
String
>
globalTraceIds
=
upstreamSegment
.
getGlobalTraceIdsList
();
StringBuilder
builder
=
new
StringBuilder
();
while
((
character
=
bufferedReader
.
read
())
!=
' '
)
{
String
segmentBase64
=
new
String
(
Base64
.
encodeBase64
(
segmentByte
.
toByteArray
()));
if
(
character
==
-
1
)
{
return
;
TraceSegmentObject
segment
;
}
try
{
builder
.
append
((
char
)
character
);
segment
=
TraceSegmentObject
.
parseFrom
(
segmentByte
);
}
}
catch
(
InvalidProtocolBufferException
e
)
{
throw
new
ArgumentsParseException
(
e
.
getMessage
(),
e
);
int
length
=
Integer
.
valueOf
(
builder
.
toString
());
builder
=
new
StringBuilder
();
char
[]
buffer
=
new
char
[
length
];
int
readLength
=
bufferedReader
.
read
(
buffer
,
0
,
length
);
if
(
readLength
!=
length
)
{
logger
.
error
(
"The actual data length was different from the length in data head! "
);
return
;
}
builder
.
append
(
buffer
);
String
segmentJsonStr
=
builder
.
toString
();
segment
=
SegmentDeserialize
.
INSTANCE
.
deserializeSingle
(
segmentJsonStr
);
tellWorkers
(
new
SegmentAndJson
(
segment
,
segmentJsonStr
));
}
}
while
(
segment
!=
null
);
tellWorkers
(
new
SegmentAndBase64
(
segment
,
segmentBase64
),
globalTraceIds
);
}
catch
(
IOException
e
)
{
throw
new
ArgumentsParseException
(
e
.
getMessage
(),
e
);
}
}
}
}
private
void
tellWorkers
(
SegmentAndJson
segmentAndJson
)
throws
WorkerNotFoundException
,
WorkerInvokeException
{
private
void
tellWorkers
(
Segment
segment
=
segmentAndJson
.
getSegment
();
SegmentAndBase64
segmentAndBase64
,
List
<
String
>
globalTraceIds
)
throws
WorkerNotFoundException
,
WorkerInvokeException
{
TraceSegmentObject
segment
=
segmentAndBase64
.
getObject
();
try
{
try
{
validateData
(
segment
);
validateData
(
segment
);
}
catch
(
IllegalArgumentException
e
)
{
}
catch
(
ArgumentsParseException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
return
;
return
;
}
}
logger
.
debug
(
"receive message instanceof TraceSegment, traceSegmentId is %s"
,
segment
.
getTraceSegmentId
());
logger
.
debug
(
"receive message instanceof TraceSegment, traceSegmentId is %s"
,
segment
.
getTraceSegmentId
());
SpanObject
firstSpan
=
segment
.
getSpans
(
segment
.
getSpansCount
()
-
1
);
long
minuteSlice
=
DateTools
.
getMinuteSlice
(
segment
.
getStartTime
());
long
minuteSlice
=
DateTools
.
getMinuteSlice
(
firstSpan
.
getStartTime
());
long
hourSlice
=
DateTools
.
getHourSlice
(
segment
.
getStartTime
());
long
hourSlice
=
DateTools
.
getHourSlice
(
firstSpan
.
getStartTime
());
long
daySlice
=
DateTools
.
getDaySlice
(
segment
.
getStartTime
());
long
daySlice
=
DateTools
.
getDaySlice
(
firstSpan
.
getStartTime
());
int
second
=
DateTools
.
getSecond
(
segment
.
getStartTime
());
int
second
=
DateTools
.
getSecond
(
firstSpan
.
getStartTime
());
logger
.
debug
(
"minuteSlice: %s, hourSlice: %s, daySlice: %s, second:%s"
,
minuteSlice
,
hourSlice
,
daySlice
,
second
);
logger
.
debug
(
"minuteSlice: %s, hourSlice: %s, daySlice: %s, second:%s"
,
minuteSlice
,
hourSlice
,
daySlice
,
second
);
SegmentWithTimeSlice
segmentWithTimeSlice
=
new
SegmentWithTimeSlice
(
segment
,
minuteSlice
,
hourSlice
,
daySlice
,
second
);
SegmentWithTimeSlice
segmentWithTimeSlice
=
new
SegmentWithTimeSlice
(
segment
,
globalTraceIds
,
minuteSlice
,
hourSlice
,
daySlice
,
second
);
getSelfContext
().
lookup
(
SegmentAnalysis
.
Role
.
INSTANCE
).
tell
(
segmentAnd
Json
);
getSelfContext
().
lookup
(
SegmentAnalysis
.
Role
.
INSTANCE
).
tell
(
segmentAnd
Base64
);
getSelfContext
().
lookup
(
SegmentCostAnalysis
.
Role
.
INSTANCE
).
tell
(
segmentWithTimeSlice
);
getSelfContext
().
lookup
(
SegmentCostAnalysis
.
Role
.
INSTANCE
).
tell
(
segmentWithTimeSlice
);
getSelfContext
().
lookup
(
GlobalTraceAnalysis
.
Role
.
INSTANCE
).
tell
(
segmentWithTimeSlice
);
getSelfContext
().
lookup
(
GlobalTraceAnalysis
.
Role
.
INSTANCE
).
tell
(
segmentWithTimeSlice
);
...
@@ -145,29 +135,31 @@ public class SegmentPost extends AbstractStreamPost {
...
@@ -145,29 +135,31 @@ public class SegmentPost extends AbstractStreamPost {
getSelfContext
().
lookup
(
NodeMappingDayAnalysis
.
Role
.
INSTANCE
).
tell
(
segmentWithTimeSlice
);
getSelfContext
().
lookup
(
NodeMappingDayAnalysis
.
Role
.
INSTANCE
).
tell
(
segmentWithTimeSlice
);
}
}
private
void
validateData
(
Segment
segment
)
{
private
void
validateData
(
TraceSegmentObject
segment
)
throws
ArgumentsParseException
{
if
(
StringUtil
.
isEmpty
(
segment
.
getTraceSegmentId
()))
{
if
(
StringUtil
.
isEmpty
(
segment
.
getTraceSegmentId
()))
{
throw
new
IllegalArgument
Exception
(
"traceSegmentId required"
);
throw
new
ArgumentsParse
Exception
(
"traceSegmentId required"
);
}
}
if
(
0
==
segment
.
getStartTime
()
)
{
if
(
segment
.
getSpansCount
()
<
1
)
{
throw
new
IllegalArgumentException
(
"startTime required
"
);
throw
new
ArgumentsParseException
(
"must contain at least one span
"
);
}
}
}
SpanObject
firstSpan
=
segment
.
getSpans
(
segment
.
getSpansCount
()
-
1
);
if
(
firstSpan
.
getSpanId
()
!=
0
&&
firstSpan
.
getParentSpanId
()
!=
-
1
)
{
public
static
class
Factory
extends
AbstractStreamPostProvider
<
SegmentPost
>
{
throw
new
ArgumentsParseException
(
"first span id must equals 0 and parent span id must equals -1"
);
@Override
}
public
String
servletPath
(
)
{
if
(
0
==
firstSpan
.
getStartTime
()
)
{
return
"/segments"
;
throw
new
ArgumentsParseException
(
"startTime required"
)
;
}
}
}
public
static
class
Factory
extends
AbstractLocalSyncWorkerProvider
<
SegmentReceiver
>
{
@Override
@Override
public
Role
role
()
{
public
Role
role
()
{
return
WorkerRole
.
INSTANCE
;
return
WorkerRole
.
INSTANCE
;
}
}
@Override
@Override
public
Segment
Post
workerInstance
(
ClusterWorkerContext
clusterContext
)
{
public
Segment
Receiver
workerInstance
(
ClusterWorkerContext
clusterContext
)
{
return
new
Segment
Post
(
role
(),
clusterContext
,
new
LocalWorkerContext
());
return
new
Segment
Receiver
(
role
(),
clusterContext
,
new
LocalWorkerContext
());
}
}
}
}
...
@@ -176,7 +168,7 @@ public class SegmentPost extends AbstractStreamPost {
...
@@ -176,7 +168,7 @@ public class SegmentPost extends AbstractStreamPost {
@Override
@Override
public
String
roleName
()
{
public
String
roleName
()
{
return
Segment
Post
.
class
.
getSimpleName
();
return
Segment
Receiver
.
class
.
getSimpleName
();
}
}
@Override
@Override
...
@@ -186,15 +178,23 @@ public class SegmentPost extends AbstractStreamPost {
...
@@ -186,15 +178,23 @@ public class SegmentPost extends AbstractStreamPost {
}
}
public
static
class
SegmentWithTimeSlice
extends
AbstractTimeSlice
{
public
static
class
SegmentWithTimeSlice
extends
AbstractTimeSlice
{
private
final
Segment
segment
;
private
final
TraceSegmentObject
segment
;
private
final
List
<
String
>
globalTraceIds
;
public
SegmentWithTimeSlice
(
Segment
segment
,
long
minute
,
long
hour
,
long
day
,
int
second
)
{
public
SegmentWithTimeSlice
(
TraceSegmentObject
segment
,
List
<
String
>
globalTraceIds
,
long
minute
,
long
hour
,
long
day
,
int
second
)
{
super
(
minute
,
hour
,
day
,
second
);
super
(
minute
,
hour
,
day
,
second
);
this
.
segment
=
segment
;
this
.
segment
=
segment
;
this
.
globalTraceIds
=
globalTraceIds
;
}
}
public
Segmen
t
getSegment
()
{
public
TraceSegmentObjec
t
getSegment
()
{
return
segment
;
return
segment
;
}
}
public
List
<
String
>
getGlobalTraceIds
()
{
return
globalTraceIds
;
}
}
}
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/SegmentTopGet.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.segment
;
package
org.skywalking.apm.collector.worker.segment
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -30,13 +31,17 @@ public class SegmentTopGet extends AbstractGet {
...
@@ -30,13 +31,17 @@ public class SegmentTopGet extends AbstractGet {
super
(
role
,
clusterContext
,
selfContext
);
super
(
role
,
clusterContext
,
selfContext
);
}
}
@Override
protected
Class
<?
extends
JsonElement
>
responseClass
()
{
return
JsonObject
.
class
;
}
@Override
@Override
public
void
preStart
()
throws
ProviderNotFoundException
{
public
void
preStart
()
throws
ProviderNotFoundException
{
getClusterContext
().
findProvider
(
SegmentTopSearch
.
WorkerRole
.
INSTANCE
).
create
(
this
);
getClusterContext
().
findProvider
(
SegmentTopSearch
.
WorkerRole
.
INSTANCE
).
create
(
this
);
}
}
@Override
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
@Override
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
Json
Objec
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
Json
Elemen
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
if
(!
parameter
.
containsKey
(
"startTime"
)
||
!
parameter
.
containsKey
(
"endTime"
)
||
!
parameter
.
containsKey
(
"from"
)
||
!
parameter
.
containsKey
(
"limit"
))
{
if
(!
parameter
.
containsKey
(
"startTime"
)
||
!
parameter
.
containsKey
(
"endTime"
)
||
!
parameter
.
containsKey
(
"from"
)
||
!
parameter
.
containsKey
(
"limit"
))
{
throw
new
ArgumentsParseException
(
"the request parameter must contains startTime, endTime, from, limit"
);
throw
new
ArgumentsParseException
(
"the request parameter must contains startTime, endTime, from, limit"
);
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/analysis/SegmentAnalysis.java
浏览文件 @
93a45165
...
@@ -13,7 +13,7 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
...
@@ -13,7 +13,7 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.worker.RecordAnalysisMember
;
import
org.skywalking.apm.collector.worker.RecordAnalysisMember
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentAnd
Json
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentAnd
Base64
;
import
org.skywalking.apm.collector.worker.segment.persistence.SegmentSave
;
import
org.skywalking.apm.collector.worker.segment.persistence.SegmentSave
;
/**
/**
...
@@ -34,11 +34,11 @@ public class SegmentAnalysis extends RecordAnalysisMember {
...
@@ -34,11 +34,11 @@ public class SegmentAnalysis extends RecordAnalysisMember {
@Override
@Override
public
void
analyse
(
Object
message
)
{
public
void
analyse
(
Object
message
)
{
if
(
message
instanceof
SegmentAnd
Json
)
{
if
(
message
instanceof
SegmentAnd
Base64
)
{
SegmentAnd
Json
segmentAndJson
=
(
SegmentAndJson
)
message
;
SegmentAnd
Base64
segmentAndBase64
=
(
SegmentAndBase64
)
message
;
try
{
try
{
getSelfContext
().
lookup
(
SegmentSave
.
Role
.
INSTANCE
).
tell
(
segmentAnd
Json
);
getSelfContext
().
lookup
(
SegmentSave
.
Role
.
INSTANCE
).
tell
(
segmentAnd
Base64
);
}
catch
(
WorkerInvokeException
|
WorkerNotFoundException
e
)
{
}
catch
(
WorkerInvokeException
|
WorkerNotFoundException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
logger
.
error
(
e
.
getMessage
(),
e
);
logger
.
error
(
e
.
getMessage
(),
e
);
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/analysis/SegmentCostAnalysis.java
浏览文件 @
93a45165
...
@@ -14,11 +14,11 @@ import org.skywalking.apm.collector.actor.selector.WorkerSelector;
...
@@ -14,11 +14,11 @@ import org.skywalking.apm.collector.actor.selector.WorkerSelector;
import
org.skywalking.apm.collector.worker.RecordAnalysisMember
;
import
org.skywalking.apm.collector.worker.RecordAnalysisMember
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.segment.SegmentCostIndex
;
import
org.skywalking.apm.collector.worker.segment.SegmentCostIndex
;
import
org.skywalking.apm.collector.worker.segment.SegmentPost
;
import
org.skywalking.apm.collector.worker.segment.SegmentReceiver
;
import
org.skywalking.apm.collector.worker.segment.entity.Segment
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
import
org.skywalking.apm.collector.worker.segment.persistence.SegmentCostSave
;
import
org.skywalking.apm.collector.worker.segment.persistence.SegmentCostSave
;
import
org.skywalking.apm.collector.worker.tools.CollectionTools
;
import
org.skywalking.apm.collector.worker.tools.CollectionTools
;
import
org.skywalking.apm.network.proto.SpanObject
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -38,36 +38,37 @@ public class SegmentCostAnalysis extends RecordAnalysisMember {
...
@@ -38,36 +38,37 @@ public class SegmentCostAnalysis extends RecordAnalysisMember {
@Override
@Override
public
void
analyse
(
Object
message
)
{
public
void
analyse
(
Object
message
)
{
if
(
message
instanceof
Segment
Post
.
SegmentWithTimeSlice
)
{
if
(
message
instanceof
Segment
Receiver
.
SegmentWithTimeSlice
)
{
Segment
Post
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentPost
.
SegmentWithTimeSlice
)
message
;
Segment
Receiver
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentReceiver
.
SegmentWithTimeSlice
)
message
;
Segmen
t
segment
=
segmentWithTimeSlice
.
getSegment
();
TraceSegmentObjec
t
segment
=
segmentWithTimeSlice
.
getSegment
();
if
(
CollectionTools
.
isNotEmpty
(
segment
.
getSpans
()))
{
if
(
CollectionTools
.
isNotEmpty
(
segment
.
getSpans
List
()))
{
for
(
Span
span
:
segment
.
getSpans
())
{
for
(
Span
Object
span
:
segment
.
getSpansList
())
{
if
(
span
.
getParentSpanId
()
==
-
1
)
{
if
(
span
.
getParentSpanId
()
==
-
1
)
{
JsonObject
dataJsonObj
=
new
JsonObject
();
for
(
String
globalTraceId
:
segmentWithTimeSlice
.
getGlobalTraceIds
())
{
dataJsonObj
.
addProperty
(
SegmentCostIndex
.
SEG_ID
,
segment
.
getTraceSegmentId
()
);
segment
.
getGlobalTraceIdsList
(
);
dataJsonObj
.
addProperty
(
SegmentCostIndex
.
START_TIME
,
span
.
getStartTime
()
);
JsonObject
dataJsonObj
=
new
JsonObject
(
);
dataJsonObj
.
addProperty
(
SegmentCostIndex
.
END_TIME
,
span
.
getEndTime
());
dataJsonObj
.
addProperty
(
SegmentCostIndex
.
SEG_ID
,
segment
.
getTraceSegmentId
());
if
(
segment
.
getRelatedGlobalTraces
().
get
()
!=
null
&&
segment
.
getRelatedGlobalTraces
().
get
().
size
()
>
0
)
{
dataJsonObj
.
addProperty
(
SegmentCostIndex
.
START_TIME
,
span
.
getStartTime
());
dataJsonObj
.
addProperty
(
SegmentCostIndex
.
GLOBAL_TRACE_ID
,
segment
.
getRelatedGlobalTraces
().
get
().
get
(
0
));
dataJsonObj
.
addProperty
(
SegmentCostIndex
.
END_TIME
,
span
.
getEndTime
(
));
}
dataJsonObj
.
addProperty
(
SegmentCostIndex
.
GLOBAL_TRACE_ID
,
globalTraceId
);
dataJsonObj
.
addProperty
(
SegmentCostIndex
.
OPERATION_NAME
,
span
.
getOperationName
());
dataJsonObj
.
addProperty
(
SegmentCostIndex
.
OPERATION_NAME
,
span
.
getOperationName
());
dataJsonObj
.
addProperty
(
SegmentCostIndex
.
TIME_SLICE
,
segmentWithTimeSlice
.
getMinute
());
dataJsonObj
.
addProperty
(
SegmentCostIndex
.
TIME_SLICE
,
segmentWithTimeSlice
.
getMinute
());
long
startTime
=
span
.
getStartTime
();
long
startTime
=
span
.
getStartTime
();
long
endTime
=
span
.
getEndTime
();
long
endTime
=
span
.
getEndTime
();
long
cost
=
endTime
-
startTime
;
long
cost
=
endTime
-
startTime
;
if
(
cost
==
0
)
{
if
(
cost
==
0
)
{
cost
=
1
;
cost
=
1
;
}
dataJsonObj
.
addProperty
(
SegmentCostIndex
.
COST
,
cost
);
set
(
segment
.
getTraceSegmentId
(),
dataJsonObj
);
}
}
dataJsonObj
.
addProperty
(
SegmentCostIndex
.
COST
,
cost
);
set
(
segment
.
getTraceSegmentId
(),
dataJsonObj
);
}
}
}
}
}
}
}
else
{
}
else
{
logger
.
error
(
"unhandled message, message instance must Segment
Post
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
logger
.
error
(
"unhandled message, message instance must Segment
Receiver
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
}
}
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/analysis/SegmentExceptionAnalysis.java
浏览文件 @
93a45165
...
@@ -16,13 +16,12 @@ import org.skywalking.apm.collector.actor.selector.WorkerSelector;
...
@@ -16,13 +16,12 @@ import org.skywalking.apm.collector.actor.selector.WorkerSelector;
import
org.skywalking.apm.collector.worker.RecordAnalysisMember
;
import
org.skywalking.apm.collector.worker.RecordAnalysisMember
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.config.WorkerConfig
;
import
org.skywalking.apm.collector.worker.segment.SegmentExceptionIndex
;
import
org.skywalking.apm.collector.worker.segment.SegmentExceptionIndex
;
import
org.skywalking.apm.collector.worker.segment.SegmentPost
;
import
org.skywalking.apm.collector.worker.segment.SegmentReceiver
;
import
org.skywalking.apm.collector.worker.segment.entity.LogData
;
import
org.skywalking.apm.collector.worker.segment.entity.Segment
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
import
org.skywalking.apm.collector.worker.segment.entity.tag.Tags
;
import
org.skywalking.apm.collector.worker.segment.persistence.SegmentExceptionSave
;
import
org.skywalking.apm.collector.worker.segment.persistence.SegmentExceptionSave
;
import
org.skywalking.apm.collector.worker.tools.CollectionTools
;
import
org.skywalking.apm.collector.worker.tools.CollectionTools
;
import
org.skywalking.apm.network.proto.LogMessage
;
import
org.skywalking.apm.network.proto.SpanObject
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -42,13 +41,13 @@ public class SegmentExceptionAnalysis extends RecordAnalysisMember {
...
@@ -42,13 +41,13 @@ public class SegmentExceptionAnalysis extends RecordAnalysisMember {
@Override
@Override
public
void
analyse
(
Object
message
)
{
public
void
analyse
(
Object
message
)
{
if
(
message
instanceof
Segment
Post
.
SegmentWithTimeSlice
)
{
if
(
message
instanceof
Segment
Receiver
.
SegmentWithTimeSlice
)
{
Segment
Post
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentPost
.
SegmentWithTimeSlice
)
message
;
Segment
Receiver
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
(
SegmentReceiver
.
SegmentWithTimeSlice
)
message
;
Segmen
t
segment
=
segmentWithTimeSlice
.
getSegment
();
TraceSegmentObjec
t
segment
=
segmentWithTimeSlice
.
getSegment
();
if
(
CollectionTools
.
isNotEmpty
(
segment
.
getSpans
()))
{
if
(
CollectionTools
.
isNotEmpty
(
segment
.
getSpans
List
()))
{
for
(
Span
span
:
segment
.
getSpans
())
{
for
(
Span
Object
span
:
segment
.
getSpansList
())
{
boolean
isError
=
Tags
.
ERROR
.
get
(
span
);
boolean
isError
=
span
.
getIsError
(
);
JsonObject
dataJsonObj
=
new
JsonObject
();
JsonObject
dataJsonObj
=
new
JsonObject
();
dataJsonObj
.
addProperty
(
SegmentExceptionIndex
.
IS_ERROR
,
isError
);
dataJsonObj
.
addProperty
(
SegmentExceptionIndex
.
IS_ERROR
,
isError
);
...
@@ -56,11 +55,11 @@ public class SegmentExceptionAnalysis extends RecordAnalysisMember {
...
@@ -56,11 +55,11 @@ public class SegmentExceptionAnalysis extends RecordAnalysisMember {
JsonArray
errorKind
=
new
JsonArray
();
JsonArray
errorKind
=
new
JsonArray
();
if
(
isError
)
{
if
(
isError
)
{
List
<
Log
Data
>
logDataList
=
span
.
getLogs
();
List
<
Log
Message
>
logMessages
=
span
.
getLogsList
();
for
(
Log
Data
logData
:
logDataList
)
{
for
(
Log
Message
logMessage
:
logMessages
)
{
if
(
logData
.
getFields
().
containsKey
(
"error.kind"
))
{
// if (logMessage
.getFields().containsKey("error.kind")) {
errorKind
.
add
(
String
.
valueOf
(
logData
.
getFields
().
get
(
"error.kind"
)));
//
errorKind.add(String.valueOf(logData.getFields().get("error.kind")));
}
//
}
}
}
}
}
dataJsonObj
.
add
(
SegmentExceptionIndex
.
ERROR_KIND
,
errorKind
);
dataJsonObj
.
add
(
SegmentExceptionIndex
.
ERROR_KIND
,
errorKind
);
...
@@ -68,7 +67,7 @@ public class SegmentExceptionAnalysis extends RecordAnalysisMember {
...
@@ -68,7 +67,7 @@ public class SegmentExceptionAnalysis extends RecordAnalysisMember {
}
}
}
}
}
else
{
}
else
{
logger
.
error
(
"unhandled message, message instance must Segment
Post
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
logger
.
error
(
"unhandled message, message instance must Segment
Receiver
.SegmentWithTimeSlice, but is %s"
,
message
.
getClass
().
toString
());
}
}
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/GlobalTraceId.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.segment.entity
;
import
com.google.gson.TypeAdapter
;
import
com.google.gson.annotations.JsonAdapter
;
import
com.google.gson.stream.JsonReader
;
import
com.google.gson.stream.JsonWriter
;
import
java.io.IOException
;
import
java.util.LinkedList
;
import
java.util.List
;
/**
* @author pengys5
*/
@JsonAdapter
(
GlobalTraceId
.
Serializer
.
class
)
public
class
GlobalTraceId
{
public
GlobalTraceId
()
{
globalTraceIds
=
new
LinkedList
<>();
}
private
LinkedList
<
String
>
globalTraceIds
;
public
LinkedList
<
String
>
get
()
{
return
globalTraceIds
;
}
public
static
class
Serializer
extends
TypeAdapter
<
GlobalTraceId
>
{
@Override
public
void
write
(
JsonWriter
out
,
GlobalTraceId
value
)
throws
IOException
{
List
<
String
>
globalTraceIds
=
value
.
globalTraceIds
;
if
(
globalTraceIds
.
size
()
>
0
)
{
out
.
beginArray
();
for
(
String
globalTraceId
:
globalTraceIds
)
{
out
.
value
(
globalTraceId
);
}
out
.
endArray
();
}
}
@Override
public
GlobalTraceId
read
(
JsonReader
in
)
throws
IOException
{
GlobalTraceId
globalTraceId
=
new
GlobalTraceId
();
in
.
beginArray
();
try
{
while
(
in
.
hasNext
())
{
globalTraceId
.
get
().
add
(
in
.
nextString
());
}
}
finally
{
in
.
endArray
();
}
return
globalTraceId
;
}
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/LogData.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.segment.entity
;
import
com.google.gson.annotations.SerializedName
;
import
java.util.Map
;
/**
* @author pengys5
*/
public
class
LogData
{
@SerializedName
(
"tm"
)
private
long
time
;
@SerializedName
(
"fi"
)
private
Map
<
String
,
String
>
fields
;
public
long
getTime
()
{
return
time
;
}
public
Map
<
String
,
String
>
getFields
()
{
return
fields
;
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/Segment.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.segment.entity
;
import
com.google.gson.annotations.SerializedName
;
import
java.util.List
;
/**
* @author pengys5
*/
public
class
Segment
{
@SerializedName
(
"ts"
)
private
String
traceSegmentId
;
@SerializedName
(
"st"
)
private
long
startTime
;
@SerializedName
(
"et"
)
private
long
endTime
;
@SerializedName
(
"rs"
)
private
List
<
TraceSegmentRef
>
refs
;
@SerializedName
(
"ss"
)
private
List
<
Span
>
spans
;
@SerializedName
(
"ac"
)
private
String
applicationCode
;
@SerializedName
(
"gt"
)
private
GlobalTraceId
relatedGlobalTraces
;
public
String
getTraceSegmentId
()
{
return
traceSegmentId
;
}
public
long
getStartTime
()
{
return
startTime
;
}
public
long
getEndTime
()
{
return
endTime
;
}
public
String
getApplicationCode
()
{
return
applicationCode
;
}
public
List
<
TraceSegmentRef
>
getRefs
()
{
return
refs
;
}
public
List
<
Span
>
getSpans
()
{
return
spans
;
}
public
GlobalTraceId
getRelatedGlobalTraces
()
{
return
relatedGlobalTraces
;
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/SegmentAndBase64.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.segment.entity
;
import
com.google.gson.JsonObject
;
import
org.skywalking.apm.collector.worker.segment.SegmentIndex
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
/**
* @author pengys5
*/
public
class
SegmentAndBase64
{
private
final
TraceSegmentObject
object
;
private
final
String
base64
;
public
SegmentAndBase64
(
TraceSegmentObject
object
,
String
base64
)
{
this
.
object
=
object
;
this
.
base64
=
base64
;
}
public
TraceSegmentObject
getObject
()
{
return
object
;
}
public
String
getBase64
()
{
return
base64
;
}
public
String
getSegmentJsonStr
()
{
JsonObject
segmentJson
=
new
JsonObject
();
segmentJson
.
addProperty
(
SegmentIndex
.
TRACE_SEGMENT_ID
,
object
.
getTraceSegmentId
());
segmentJson
.
addProperty
(
SegmentIndex
.
SEGMENT_OBJ_BLOB
,
base64
);
return
segmentJson
.
toString
();
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/SegmentAndJson.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.segment.entity
;
/**
* @author pengys5
*/
public
class
SegmentAndJson
{
private
final
Segment
segment
;
private
final
String
jsonStr
;
public
SegmentAndJson
(
Segment
segment
,
String
jsonStr
)
{
this
.
segment
=
segment
;
this
.
jsonStr
=
jsonStr
;
}
public
Segment
getSegment
()
{
return
segment
;
}
public
String
getJsonStr
()
{
return
jsonStr
;
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/SegmentDeserialize.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.segment.entity
;
package
org.skywalking.apm.collector.worker.segment.entity
;
import
com.
google.gson.Gson
;
import
com.
sun.org.apache.xml.internal.security.utils.Base64
;
import
java.io.IOException
;
import
java.io.IOException
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
/**
/**
* The <code>SegmentDeserialize</code> provides single segment json string deserialize and segment array file
* The <code>SegmentDeserialize</code> provides single segment json string deserialize and segment array file
...
@@ -13,17 +16,21 @@ import java.io.IOException;
...
@@ -13,17 +16,21 @@ import java.io.IOException;
public
enum
SegmentDeserialize
{
public
enum
SegmentDeserialize
{
INSTANCE
;
INSTANCE
;
private
final
Gson
gson
=
new
Gson
(
);
private
final
Logger
logger
=
LogManager
.
getFormatterLogger
(
SegmentDeserialize
.
class
);
/**
/**
* S
ingle segment json
string deserialize.
* S
egment object binary value as a base64 encoded
string deserialize.
*
*
* @param singleSegmentJsonStr a segment json string
* @param segmentObjBlob , to be a binary value as a base64 encoded string
* @return an {@link Segment}
* @return an {@link TraceSegmentObject}
* @throws IOException if json string illegal or file broken.
*/
*/
public
Segment
deserializeSingle
(
String
singleSegmentJsonStr
)
throws
IOException
{
public
TraceSegmentObject
deserializeSingle
(
String
segmentObjBlob
)
{
Segment
segment
=
gson
.
fromJson
(
singleSegmentJsonStr
,
Segment
.
class
);
try
{
return
segment
;
byte
[]
decode
=
Base64
.
decode
(
segmentObjBlob
);
return
TraceSegmentObject
.
parseFrom
(
decode
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
}
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/Span.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.segment.entity
;
import
com.google.gson.annotations.SerializedName
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author pengys5
*/
public
class
Span
{
@SerializedName
(
"si"
)
private
int
spanId
;
@SerializedName
(
"ps"
)
private
int
parentSpanId
;
@SerializedName
(
"st"
)
private
long
startTime
;
@SerializedName
(
"et"
)
private
long
endTime
;
@SerializedName
(
"on"
)
private
String
operationName
;
@SerializedName
(
"ts"
)
private
Map
<
String
,
String
>
tagsWithStr
;
@SerializedName
(
"tb"
)
private
Map
<
String
,
Boolean
>
tagsWithBool
;
@SerializedName
(
"ti"
)
private
Map
<
String
,
Integer
>
tagsWithInt
;
@SerializedName
(
"lo"
)
private
List
<
LogData
>
logs
;
public
int
getSpanId
()
{
return
spanId
;
}
public
int
getParentSpanId
()
{
return
parentSpanId
;
}
public
long
getStartTime
()
{
return
startTime
;
}
public
long
getEndTime
()
{
return
endTime
;
}
public
String
getOperationName
()
{
return
operationName
;
}
public
String
getStrTag
(
String
key
)
{
return
tagsWithStr
.
get
(
key
);
}
public
Boolean
getBoolTag
(
String
key
)
{
return
tagsWithBool
.
get
(
key
);
}
public
Integer
getIntTag
(
String
key
)
{
return
tagsWithInt
.
get
(
key
);
}
public
List
<
LogData
>
getLogs
()
{
return
logs
;
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/TraceSegmentRef.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.segment.entity
;
import
com.google.gson.annotations.SerializedName
;
/**
* @author pengys5
*/
public
class
TraceSegmentRef
{
@SerializedName
(
"ts"
)
private
String
traceSegmentId
;
@SerializedName
(
"si"
)
private
int
spanId
=
-
1
;
@SerializedName
(
"ac"
)
private
String
applicationCode
;
@SerializedName
(
"ph"
)
private
String
peerHost
;
public
String
getTraceSegmentId
()
{
return
traceSegmentId
;
}
public
int
getSpanId
()
{
return
spanId
;
}
public
String
getApplicationCode
()
{
return
applicationCode
;
}
public
String
getPeerHost
()
{
return
peerHost
;
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/tag/AbstractTag.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.segment.entity.tag
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
public
abstract
class
AbstractTag
<
T
>
{
/**
* The key of this Tag.
*/
protected
final
String
key
;
public
AbstractTag
(
String
tagKey
)
{
this
.
key
=
tagKey
;
}
public
abstract
T
get
(
Span
span
);
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/tag/BooleanTag.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.segment.entity.tag
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
/**
* Do the same thing as {@link StringTag}, just with a {@link Boolean} value.
* <p>
* Created by wusheng on 2017/2/17.
*/
public
class
BooleanTag
extends
AbstractTag
<
Boolean
>
{
private
boolean
defaultValue
;
public
BooleanTag
(
String
key
,
boolean
defaultValue
)
{
super
(
key
);
this
.
defaultValue
=
defaultValue
;
}
/**
* Get a tag value, type of {@link Boolean}. After akka-message/serialize, all tags values are type of {@link
* String}, convert to {@link Boolean}, if necessary.
*
* @param span
* @return tag value
*/
@Override
public
Boolean
get
(
Span
span
)
{
Boolean
tagValue
=
span
.
getBoolTag
(
super
.
key
);
if
(
tagValue
==
null
)
{
return
defaultValue
;
}
else
{
return
tagValue
;
}
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/tag/IntTag.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.segment.entity.tag
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
/**
* Do the same thing as {@link StringTag}, just with a {@link Integer} value.
* <p>
* Created by wusheng on 2017/2/18.
*/
public
class
IntTag
extends
AbstractTag
<
Integer
>
{
public
IntTag
(
String
key
)
{
super
(
key
);
}
/**
* Get a tag value, type of {@link Integer}.
* After akka-message/serialize, all tags values are type of {@link String}, convert to {@link Integer}, if necessary.
*
* @param span
* @return tag value
*/
@Override
public
Integer
get
(
Span
span
)
{
Integer
tagValue
=
span
.
getIntTag
(
super
.
key
);
if
(
tagValue
==
null
)
{
return
null
;
}
else
{
return
tagValue
;
}
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/tag/ShortTag.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.segment.entity.tag
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
/**
* Do the same thing as {@link StringTag}, just with a {@link Short} value.
* <p>
* Created by wusheng on 2017/2/17.
*/
public
class
ShortTag
extends
AbstractTag
<
Short
>
{
public
ShortTag
(
String
key
)
{
super
(
key
);
}
/**
* Get a tag value, type of {@link Short}.
* After akka-message/serialize, all tags values are type of {@link String}, convert to {@link Short}, if necessary.
*
* @param span
* @return tag value
*/
@Override
public
Short
get
(
Span
span
)
{
Integer
tagValue
=
span
.
getIntTag
(
super
.
key
);
if
(
tagValue
==
null
)
{
return
null
;
}
else
{
return
Short
.
valueOf
(
tagValue
.
toString
());
}
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/tag/StringTag.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.segment.entity.tag
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
/**
* A subclass of {@link AbstractTag},
* represent a tag with a {@link String} value.
* <p>
* Created by wusheng on 2017/2/17.
*/
public
class
StringTag
extends
AbstractTag
<
String
>
{
public
StringTag
(
String
tagKey
)
{
super
(
tagKey
);
}
@Override
public
String
get
(
Span
span
)
{
return
span
.
getStrTag
(
super
.
key
);
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/tag/Tags.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.segment.entity.tag
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
/**
* The span tags are supported by sky-walking engine.
* As default, all tags will be stored, but these ones have particular meanings.
* <p>
* Created by wusheng on 2017/2/17.
*/
public
final
class
Tags
{
private
Tags
()
{
}
/**
* URL records the url of the incoming request.
*/
public
static
final
StringTag
URL
=
new
StringTag
(
"url"
);
/**
* STATUS_CODE records the http status code of the response.
*/
public
static
final
IntTag
STATUS_CODE
=
new
IntTag
(
"status_code"
);
/**
* SPAN_KIND hints at the relationship between spans, e.g. client/server.
*/
public
static
final
StringTag
SPAN_KIND
=
new
StringTag
(
"span.kind"
);
/**
* A constant for setting the span kind to indicate that it represents a server span.
*/
public
static
final
String
SPAN_KIND_SERVER
=
"server"
;
/**
* A constant for setting the span kind to indicate that it represents a client span.
*/
public
static
final
String
SPAN_KIND_CLIENT
=
"client"
;
/**
* SPAN_LAYER represents the kind of span.
* <p>
* e.g.
* db=database;
* rpc=Remote Procedure Call Framework, like motan, thift;
* nosql=something like redis/memcache
*/
public
static
final
class
SPAN_LAYER
{
private
static
StringTag
SPAN_LAYER_TAG
=
new
StringTag
(
"span.layer"
);
public
static
String
get
(
Span
span
)
{
return
SPAN_LAYER_TAG
.
get
(
span
);
}
}
/**
* COMPONENT is a low-cardinality identifier of the module, library, or package that is instrumented.
* Like dubbo/dubbox/motan
*/
public
static
final
StringTag
COMPONENT
=
new
StringTag
(
"component"
);
/**
* ERROR indicates whether a Span ended in an error state.
*/
public
static
final
BooleanTag
ERROR
=
new
BooleanTag
(
"error"
,
false
);
/**
* PEER_HOST records host address (ip:port, or ip1:port1,ip2:port2) of the peer, maybe IPV4, IPV6 or hostname.
*/
public
static
final
StringTag
PEER_HOST
=
new
StringTag
(
"peer.host"
);
/**
* PEER_PORT records remote port of the peer
*/
public
static
final
IntTag
PEER_PORT
=
new
IntTag
(
"peer.port"
);
/**
* PEERS records multiple host address and port of remote
*/
public
static
final
StringTag
PEERS
=
new
StringTag
(
"peers"
);
/**
* DB_TYPE records database type, such as sql, redis, cassandra and so on.
*/
public
static
final
StringTag
DB_TYPE
=
new
StringTag
(
"db.type"
);
/**
* DB_INSTANCE records database instance name.
*/
public
static
final
StringTag
DB_INSTANCE
=
new
StringTag
(
"db.instance"
);
/**
* DB_STATEMENT records the sql statement of the database access.
*/
public
static
final
StringTag
DB_STATEMENT
=
new
StringTag
(
"db.statement"
);
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/persistence/SegmentSave.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.segment.persistence
;
package
org.skywalking.apm.collector.worker.segment.persistence
;
import
com.google.gson.JsonObject
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -13,7 +14,7 @@ import org.skywalking.apm.collector.actor.selector.WorkerSelector;
...
@@ -13,7 +14,7 @@ import org.skywalking.apm.collector.actor.selector.WorkerSelector;
import
org.skywalking.apm.collector.worker.PersistenceMember
;
import
org.skywalking.apm.collector.worker.PersistenceMember
;
import
org.skywalking.apm.collector.worker.config.CacheSizeConfig
;
import
org.skywalking.apm.collector.worker.config.CacheSizeConfig
;
import
org.skywalking.apm.collector.worker.segment.SegmentIndex
;
import
org.skywalking.apm.collector.worker.segment.SegmentIndex
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentAnd
Json
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentAnd
Base64
;
import
org.skywalking.apm.collector.worker.storage.AbstractIndex
;
import
org.skywalking.apm.collector.worker.storage.AbstractIndex
;
import
org.skywalking.apm.collector.worker.storage.EsClient
;
import
org.skywalking.apm.collector.worker.storage.EsClient
;
import
org.skywalking.apm.collector.worker.storage.PersistenceWorkerListener
;
import
org.skywalking.apm.collector.worker.storage.PersistenceWorkerListener
;
...
@@ -46,11 +47,11 @@ public class SegmentSave extends PersistenceMember<SegmentPersistenceData, Segme
...
@@ -46,11 +47,11 @@ public class SegmentSave extends PersistenceMember<SegmentPersistenceData, Segme
}
}
@Override
final
public
void
analyse
(
Object
message
)
{
@Override
final
public
void
analyse
(
Object
message
)
{
if
(
message
instanceof
SegmentAnd
Json
)
{
if
(
message
instanceof
SegmentAnd
Base64
)
{
SegmentAnd
Json
segmentAndJson
=
(
SegmentAndJson
)
message
;
SegmentAnd
Base64
segmentAndBase64
=
(
SegmentAndBase64
)
message
;
SegmentPersistenceData
data
=
getPersistenceData
();
SegmentPersistenceData
data
=
getPersistenceData
();
data
.
hold
();
data
.
hold
();
data
.
getOrCreate
(
segmentAnd
Json
.
getSegment
().
getTraceSegmentId
()).
setSegmentStr
(
segmentAndJson
.
ge
tJsonStr
());
data
.
getOrCreate
(
segmentAnd
Base64
.
getObject
().
getTraceSegmentId
()).
setSegmentStr
(
segmentAndBase64
.
getSegmen
tJsonStr
());
if
(
data
.
size
()
>=
CacheSizeConfig
.
Cache
.
Persistence
.
SIZE
)
{
if
(
data
.
size
()
>=
CacheSizeConfig
.
Cache
.
Persistence
.
SIZE
)
{
persistence
(
data
.
asMap
());
persistence
(
data
.
asMap
());
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/persistence/SegmentTopSearch.java
浏览文件 @
93a45165
...
@@ -2,8 +2,8 @@ package org.skywalking.apm.collector.worker.segment.persistence;
...
@@ -2,8 +2,8 @@ package org.skywalking.apm.collector.worker.segment.persistence;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchType
;
import
org.elasticsearch.action.search.SearchType
;
...
@@ -25,10 +25,10 @@ import org.skywalking.apm.collector.actor.selector.WorkerSelector;
...
@@ -25,10 +25,10 @@ import org.skywalking.apm.collector.actor.selector.WorkerSelector;
import
org.skywalking.apm.collector.worker.segment.SegmentCostIndex
;
import
org.skywalking.apm.collector.worker.segment.SegmentCostIndex
;
import
org.skywalking.apm.collector.worker.segment.SegmentExceptionIndex
;
import
org.skywalking.apm.collector.worker.segment.SegmentExceptionIndex
;
import
org.skywalking.apm.collector.worker.segment.SegmentIndex
;
import
org.skywalking.apm.collector.worker.segment.SegmentIndex
;
import
org.skywalking.apm.collector.worker.segment.entity.Segment
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentDeserialize
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentDeserialize
;
import
org.skywalking.apm.collector.worker.storage.EsClient
;
import
org.skywalking.apm.collector.worker.storage.EsClient
;
import
org.skywalking.apm.collector.worker.tools.CollectionTools
;
import
org.skywalking.apm.collector.worker.tools.CollectionTools
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
import
org.skywalking.apm.util.StringUtil
;
import
org.skywalking.apm.util.StringUtil
;
/**
/**
...
@@ -102,15 +102,11 @@ public class SegmentTopSearch extends AbstractLocalSyncWorker {
...
@@ -102,15 +102,11 @@ public class SegmentTopSearch extends AbstractLocalSyncWorker {
topSegmentJson
.
addProperty
(
SegmentCostIndex
.
OPERATION_NAME
,
(
String
)
searchHit
.
getSource
().
get
(
SegmentCostIndex
.
OPERATION_NAME
));
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
.
COST
,
(
Number
)
searchHit
.
getSource
().
get
(
SegmentCostIndex
.
COST
));
String
segmentSource
=
EsClient
.
INSTANCE
.
getClient
().
prepareGet
(
SegmentIndex
.
INDEX
,
SegmentIndex
.
TYPE_RECORD
,
segId
).
get
().
getSourceAsString
();
GetResponse
getResponse
=
EsClient
.
INSTANCE
.
getClient
().
prepareGet
(
SegmentIndex
.
INDEX
,
SegmentIndex
.
TYPE_RECORD
,
segId
).
get
();
logger
().
debug
(
"segmentSource:"
+
segmentSource
);
String
segmentObjBlob
=
(
String
)
getResponse
.
getSource
().
get
(
SegmentIndex
.
SEGMENT_OBJ_BLOB
);
Segment
segment
;
try
{
TraceSegmentObject
segment
=
SegmentDeserialize
.
INSTANCE
.
deserializeSingle
(
segmentObjBlob
);
segment
=
SegmentDeserialize
.
INSTANCE
.
deserializeSingle
(
segmentSource
);
List
<
String
>
distributedTraceIdList
=
segment
.
getGlobalTraceIdsList
();
}
catch
(
IOException
e
)
{
throw
new
WorkerException
(
e
.
getMessage
(),
e
);
}
List
<
String
>
distributedTraceIdList
=
segment
.
getRelatedGlobalTraces
().
get
();
JsonArray
distributedTraceIdArray
=
new
JsonArray
();
JsonArray
distributedTraceIdArray
=
new
JsonArray
();
if
(
CollectionTools
.
isNotEmpty
(
distributedTraceIdList
))
{
if
(
CollectionTools
.
isNotEmpty
(
distributedTraceIdList
))
{
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/span/SpanGetWithId.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.span
;
package
org.skywalking.apm.collector.worker.span
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -30,13 +31,17 @@ public class SpanGetWithId extends AbstractGet {
...
@@ -30,13 +31,17 @@ public class SpanGetWithId extends AbstractGet {
super
(
role
,
clusterContext
,
selfContext
);
super
(
role
,
clusterContext
,
selfContext
);
}
}
@Override
protected
Class
<?
extends
JsonElement
>
responseClass
()
{
return
JsonObject
.
class
;
}
@Override
@Override
public
void
preStart
()
throws
ProviderNotFoundException
{
public
void
preStart
()
throws
ProviderNotFoundException
{
getClusterContext
().
findProvider
(
SpanSearchWithId
.
WorkerRole
.
INSTANCE
).
create
(
this
);
getClusterContext
().
findProvider
(
SpanSearchWithId
.
WorkerRole
.
INSTANCE
).
create
(
this
);
}
}
@Override
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
@Override
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
Json
Objec
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
Json
Elemen
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
if
(!
parameter
.
containsKey
(
"segId"
)
||
!
parameter
.
containsKey
(
"spanId"
))
{
if
(!
parameter
.
containsKey
(
"segId"
)
||
!
parameter
.
containsKey
(
"spanId"
))
{
throw
new
ArgumentsParseException
(
"the request parameter must contains segId, spanId"
);
throw
new
ArgumentsParseException
(
"the request parameter must contains segId, spanId"
);
}
}
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/span/persistence/SpanSearchWithId.java
浏览文件 @
93a45165
...
@@ -2,7 +2,6 @@ package org.skywalking.apm.collector.worker.span.persistence;
...
@@ -2,7 +2,6 @@ package org.skywalking.apm.collector.worker.span.persistence;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.skywalking.apm.collector.actor.AbstractLocalSyncWorker
;
import
org.skywalking.apm.collector.actor.AbstractLocalSyncWorker
;
...
@@ -15,10 +14,10 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
...
@@ -15,10 +14,10 @@ import org.skywalking.apm.collector.actor.selector.RollingSelector;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.actor.selector.WorkerSelector
;
import
org.skywalking.apm.collector.worker.Const
;
import
org.skywalking.apm.collector.worker.Const
;
import
org.skywalking.apm.collector.worker.segment.SegmentIndex
;
import
org.skywalking.apm.collector.worker.segment.SegmentIndex
;
import
org.skywalking.apm.collector.worker.segment.entity.Segment
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentDeserialize
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentDeserialize
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
import
org.skywalking.apm.collector.worker.storage.GetResponseFromEs
;
import
org.skywalking.apm.collector.worker.storage.GetResponseFromEs
;
import
org.skywalking.apm.network.proto.SpanObject
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -36,18 +35,15 @@ public class SpanSearchWithId extends AbstractLocalSyncWorker {
...
@@ -36,18 +35,15 @@ public class SpanSearchWithId extends AbstractLocalSyncWorker {
if
(
request
instanceof
RequestEntity
)
{
if
(
request
instanceof
RequestEntity
)
{
RequestEntity
search
=
(
RequestEntity
)
request
;
RequestEntity
search
=
(
RequestEntity
)
request
;
GetResponse
getResponse
=
GetResponseFromEs
.
INSTANCE
.
get
(
SegmentIndex
.
INDEX
,
SegmentIndex
.
TYPE_RECORD
,
search
.
segId
);
GetResponse
getResponse
=
GetResponseFromEs
.
INSTANCE
.
get
(
SegmentIndex
.
INDEX
,
SegmentIndex
.
TYPE_RECORD
,
search
.
segId
);
Segment
segment
;
String
segmentObjBlob
=
(
String
)
getResponse
.
getSource
().
get
(
SegmentIndex
.
SEGMENT_OBJ_BLOB
);
try
{
segment
=
SegmentDeserialize
.
INSTANCE
.
deserializeSingle
(
getResponse
.
getSourceAsString
());
TraceSegmentObject
segment
=
SegmentDeserialize
.
INSTANCE
.
deserializeSingle
(
segmentObjBlob
);
}
catch
(
IOException
e
)
{
List
<
SpanObject
>
spanList
=
segment
.
getSpansList
();
throw
new
WorkerException
(
e
.
getMessage
(),
e
);
}
List
<
Span
>
spanList
=
segment
.
getSpans
();
getResponse
.
getSource
();
getResponse
.
getSource
();
JsonObject
dataJson
=
new
JsonObject
();
JsonObject
dataJson
=
new
JsonObject
();
for
(
Span
span
:
spanList
)
{
for
(
Span
Object
span
:
spanList
)
{
if
(
String
.
valueOf
(
span
.
getSpanId
()).
equals
(
search
.
spanId
))
{
if
(
String
.
valueOf
(
span
.
getSpanId
()).
equals
(
search
.
spanId
))
{
String
spanJsonStr
=
gson
.
toJson
(
span
);
String
spanJsonStr
=
gson
.
toJson
(
span
);
dataJson
=
gson
.
fromJson
(
spanJsonStr
,
JsonObject
.
class
);
dataJson
=
gson
.
fromJson
(
spanJsonStr
,
JsonObject
.
class
);
...
...
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/tools/ClientSpanIsLeafTools.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.tools
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
import
org.skywalking.apm.collector.worker.segment.entity.tag.Tags
;
import
java.util.List
;
/**
* @author pengys5
*/
public
class
ClientSpanIsLeafTools
{
private
static
final
Logger
logger
=
LogManager
.
getFormatterLogger
(
ClientSpanIsLeafTools
.
class
);
public
static
boolean
isLeaf
(
int
spanId
,
List
<
Span
>
spanList
)
{
boolean
isLeaf
=
true
;
for
(
Span
span
:
spanList
)
{
if
(
span
.
getParentSpanId
()
==
spanId
&&
Tags
.
SPAN_KIND_CLIENT
.
equals
(
Tags
.
SPAN_KIND
.
get
(
span
)))
{
logger
.
debug
(
"current spanId=%s, merge spanId=%s, span kind=%s"
,
spanId
,
span
.
getSpanId
(),
Tags
.
SPAN_KIND
.
get
(
span
));
isLeaf
=
false
;
}
}
return
isLeaf
;
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/tools/SpanPeersTools.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.tools
;
package
org.skywalking.apm.collector.worker.tools
;
import
org.skywalking.apm.util.StringUtil
;
import
org.skywalking.apm.network.proto.SpanObject
;
import
org.skywalking.apm.collector.worker.Const
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
import
org.skywalking.apm.collector.worker.segment.entity.tag.Tags
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -11,13 +8,11 @@ import org.skywalking.apm.collector.worker.segment.entity.tag.Tags;
...
@@ -11,13 +8,11 @@ import org.skywalking.apm.collector.worker.segment.entity.tag.Tags;
public
enum
SpanPeersTools
{
public
enum
SpanPeersTools
{
INSTANCE
;
INSTANCE
;
public
String
getPeers
(
Span
span
)
{
public
int
getPeers
(
SpanObject
span
)
{
if
(
StringUtil
.
isEmpty
(
Tags
.
PEERS
.
get
(
span
)))
{
if
(
span
.
getPeerId
()
==
0
)
{
String
host
=
Tags
.
PEER_HOST
.
get
(
span
);
return
0
;
//TODO exchange peer to peer id
int
port
=
Tags
.
PEER_PORT
.
get
(
span
);
return
Const
.
PEERS_FRONT_SPLIT
+
host
+
":"
+
port
+
Const
.
PEERS_BEHIND_SPLIT
;
}
else
{
}
else
{
return
Const
.
PEERS_FRONT_SPLIT
+
Tags
.
PEERS
.
get
(
span
)
+
Const
.
PEERS_BEHIND_SPLIT
;
return
span
.
getPeerId
()
;
}
}
}
}
}
}
apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/tracedag/TraceDagGetWithTimeSlice.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.tracedag
;
package
org.skywalking.apm.collector.worker.tracedag
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -34,6 +35,10 @@ public class TraceDagGetWithTimeSlice extends AbstractGet {
...
@@ -34,6 +35,10 @@ public class TraceDagGetWithTimeSlice extends AbstractGet {
super
(
role
,
clusterContext
,
selfContext
);
super
(
role
,
clusterContext
,
selfContext
);
}
}
@Override
protected
Class
<?
extends
JsonElement
>
responseClass
()
{
return
JsonObject
.
class
;
}
@Override
@Override
public
void
preStart
()
throws
ProviderNotFoundException
{
public
void
preStart
()
throws
ProviderNotFoundException
{
getClusterContext
().
findProvider
(
NodeCompLoad
.
WorkerRole
.
INSTANCE
).
create
(
this
);
getClusterContext
().
findProvider
(
NodeCompLoad
.
WorkerRole
.
INSTANCE
).
create
(
this
);
...
@@ -43,7 +48,7 @@ public class TraceDagGetWithTimeSlice extends AbstractGet {
...
@@ -43,7 +48,7 @@ public class TraceDagGetWithTimeSlice extends AbstractGet {
}
}
@Override
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
@Override
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
Json
Objec
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
Json
Elemen
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
if
(!
parameter
.
containsKey
(
"startTime"
)
||
!
parameter
.
containsKey
(
"endTime"
)
||
!
parameter
.
containsKey
(
"timeSliceType"
))
{
if
(!
parameter
.
containsKey
(
"startTime"
)
||
!
parameter
.
containsKey
(
"endTime"
)
||
!
parameter
.
containsKey
(
"timeSliceType"
))
{
throw
new
ArgumentsParseException
(
"the request parameter must contains startTime,endTime,timeSliceType"
);
throw
new
ArgumentsParseException
(
"the request parameter must contains startTime,endTime,timeSliceType"
);
}
}
...
@@ -87,7 +92,7 @@ public class TraceDagGetWithTimeSlice extends AbstractGet {
...
@@ -87,7 +92,7 @@ public class TraceDagGetWithTimeSlice extends AbstractGet {
JsonObject
result
=
getBuilder
().
build
(
compResponse
.
get
(
Const
.
RESULT
).
getAsJsonArray
(),
nodeMappingResponse
.
get
(
Const
.
RESULT
).
getAsJsonArray
(),
JsonObject
result
=
getBuilder
().
build
(
compResponse
.
get
(
Const
.
RESULT
).
getAsJsonArray
(),
nodeMappingResponse
.
get
(
Const
.
RESULT
).
getAsJsonArray
(),
nodeRefResponse
.
get
(
Const
.
RESULT
).
getAsJsonArray
(),
resSumResponse
.
get
(
Const
.
RESULT
).
getAsJsonArray
());
nodeRefResponse
.
get
(
Const
.
RESULT
).
getAsJsonArray
(),
resSumResponse
.
get
(
Const
.
RESULT
).
getAsJsonArray
());
response
.
add
(
Const
.
RESULT
,
result
);
((
JsonObject
)
response
)
.
add
(
Const
.
RESULT
,
result
);
}
}
private
JsonObject
getNewResponse
()
{
private
JsonObject
getNewResponse
()
{
...
...
apm-collector/apm-collector-worker/src/main/resources/META-INF/services/io.grpc.BindableService
0 → 100644
浏览文件 @
93a45165
org.skywalking.apm.collector.worker.grpcserver.TraceSegmentServiceImpl
\ No newline at end of file
apm-collector/apm-collector-worker/src/main/resources/META-INF/services/org.skywalking.apm.collector.actor.AbstractClusterWorkerProvider
浏览文件 @
93a45165
org.skywalking.apm.collector.worker.grpcserver.GRPCAddressRegister$Factory
org.skywalking.apm.collector.worker.globaltrace.persistence.GlobalTraceAgg$Factory
org.skywalking.apm.collector.worker.globaltrace.persistence.GlobalTraceAgg$Factory
org.skywalking.apm.collector.worker.noderef.persistence.NodeRefDayAgg$Factory
org.skywalking.apm.collector.worker.noderef.persistence.NodeRefDayAgg$Factory
...
...
apm-collector/apm-collector-worker/src/main/resources/META-INF/services/org.skywalking.apm.collector.actor.AbstractLocalWorkerProvider
浏览文件 @
93a45165
...
@@ -2,6 +2,7 @@ org.skywalking.apm.collector.worker.segment.analysis.SegmentAnalysis$Factory
...
@@ -2,6 +2,7 @@ org.skywalking.apm.collector.worker.segment.analysis.SegmentAnalysis$Factory
org.skywalking.apm.collector.worker.segment.analysis.SegmentCostAnalysis$Factory
org.skywalking.apm.collector.worker.segment.analysis.SegmentCostAnalysis$Factory
org.skywalking.apm.collector.worker.segment.analysis.SegmentExceptionAnalysis$Factory
org.skywalking.apm.collector.worker.segment.analysis.SegmentExceptionAnalysis$Factory
org.skywalking.apm.collector.worker.segment.SegmentReceiver$Factory
org.skywalking.apm.collector.worker.segment.persistence.SegmentSave$Factory
org.skywalking.apm.collector.worker.segment.persistence.SegmentSave$Factory
org.skywalking.apm.collector.worker.segment.persistence.SegmentCostSave$Factory
org.skywalking.apm.collector.worker.segment.persistence.SegmentCostSave$Factory
org.skywalking.apm.collector.worker.segment.persistence.SegmentExceptionSave$Factory
org.skywalking.apm.collector.worker.segment.persistence.SegmentExceptionSave$Factory
...
...
apm-collector/apm-collector-worker/src/main/resources/META-INF/services/org.skywalking.apm.collector.config.ConfigProvider
浏览文件 @
93a45165
org.skywalking.apm.collector.cluster.ClusterConfigProvider
org.skywalking.apm.collector.cluster.ClusterConfigProvider
org.skywalking.apm.collector.worker.config.EsConfigProvider
org.skywalking.apm.collector.worker.config.EsConfigProvider
org.skywalking.apm.collector.worker.config.HttpConfigProvider
org.skywalking.apm.collector.worker.config.HttpConfigProvider
org.skywalking.apm.collector.worker.config.GRPCConfigProvider
org.skywalking.apm.collector.worker.config.CacheSizeConfigProvider
org.skywalking.apm.collector.worker.config.CacheSizeConfigProvider
org.skywalking.apm.collector.worker.config.WorkerConfigProvider
org.skywalking.apm.collector.worker.config.WorkerConfigProvider
\ No newline at end of file
apm-collector/apm-collector-worker/src/main/resources/META-INF/services/org.skywalking.apm.collector.worker.httpserver.AbstractGetProvider
浏览文件 @
93a45165
...
@@ -2,4 +2,6 @@ org.skywalking.apm.collector.worker.noderef.NodeRefResSumGetGroupWithTimeSlice$F
...
@@ -2,4 +2,6 @@ org.skywalking.apm.collector.worker.noderef.NodeRefResSumGetGroupWithTimeSlice$F
org.skywalking.apm.collector.worker.segment.SegmentTopGet$Factory
org.skywalking.apm.collector.worker.segment.SegmentTopGet$Factory
org.skywalking.apm.collector.worker.globaltrace.GlobalTraceGetWithGlobalId$Factory
org.skywalking.apm.collector.worker.globaltrace.GlobalTraceGetWithGlobalId$Factory
org.skywalking.apm.collector.worker.span.SpanGetWithId$Factory
org.skywalking.apm.collector.worker.span.SpanGetWithId$Factory
org.skywalking.apm.collector.worker.tracedag.TraceDagGetWithTimeSlice$Factory
org.skywalking.apm.collector.worker.tracedag.TraceDagGetWithTimeSlice$Factory
\ No newline at end of file
org.skywalking.apm.collector.worker.grpcserver.GRPCAddressGet$Factory
\ No newline at end of file
apm-collector/apm-collector-worker/src/main/resources/META-INF/services/org.skywalking.apm.collector.worker.httpserver.AbstractStreamPostProvider
浏览文件 @
93a45165
org.skywalking.apm.collector.worker.segment.SegmentPost$Factory
\ No newline at end of file
apm-collector/apm-collector-worker/src/main/resources/collector.config
浏览文件 @
93a45165
...
@@ -6,7 +6,7 @@ cluster.current.port = 11800
...
@@ -6,7 +6,7 @@ cluster.current.port = 11800
# In this version, all members have same roles, and everyone of them is listening the status of others.
# In this version, all members have same roles, and everyone of them is listening the status of others.
#The routers do not send message to nodes, which is unreachable, caused by network trouble, jvm crash or any other reasons.
#The routers do not send message to nodes, which is unreachable, caused by network trouble, jvm crash or any other reasons.
cluster
.
current
.
roles
=
WorkersListener
cluster
.
current
.
roles
=
WorkersListener
,
RPCAddressListener
#Initial contact points of the cluster, e.g. seed_nodes = 127.0.0.1:11800, 127.0.0.1:11801.
#Initial contact points of the cluster, e.g. seed_nodes = 127.0.0.1:11800, 127.0.0.1:11801.
#The nodes to join automatically at startup.
#The nodes to join automatically at startup.
...
@@ -27,7 +27,7 @@ es.cluster.nodes=127.0.0.1:9300
...
@@ -27,7 +27,7 @@ es.cluster.nodes=127.0.0.1:9300
#auto: create index when it doesn't exist.
#auto: create index when it doesn't exist.
# forced: delete and create.
# forced: delete and create.
# manual: do nothing.
# manual: do nothing.
es
.
index
.
initialize
.
mode
=
auto
es
.
index
.
initialize
.
mode
=
forced
# Config of shards or replicas in Elasticsearch.
# Config of shards or replicas in Elasticsearch.
es
.
index
.
shards
.
number
=
2
es
.
index
.
shards
.
number
=
2
es
.
index
.
replicas
.
number
=
0
es
.
index
.
replicas
.
number
=
0
...
@@ -39,6 +39,10 @@ http.port=12800
...
@@ -39,6 +39,10 @@ http.port=12800
# Web context path
# Web context path
http
.
contextPath
=/
http
.
contextPath
=/
# GRPC services
grpc
.
hostname
=
127
.
0
.
0
.
1
grpc
.
port
=
22800
# Cache size of analysis worker. The value determines whether sending to next worker and clear, or not.
# Cache size of analysis worker. The value determines whether sending to next worker and clear, or not.
cache
.
analysis
.
size
=
1024
cache
.
analysis
.
size
=
1024
# Cache size of persistence worker. The value determines whether save data and clear, or not.
# Cache size of persistence worker. The value determines whether save data and clear, or not.
...
...
apm-collector/apm-collector-worker/src/main/resources/log4j2.xml
浏览文件 @
93a45165
...
@@ -14,16 +14,19 @@
...
@@ -14,16 +14,19 @@
</Policies>
</Policies>
<DefaultRolloverStrategy
max=
"30"
/>
<DefaultRolloverStrategy
max=
"30"
/>
</RollingFile>
</RollingFile>
<Console
name=
"Console"
target=
"SYSTEM_OUT"
>
<PatternLayout
pattern=
"%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"
/>
</Console>
</Appenders>
</Appenders>
<Loggers>
<Loggers>
<logger
name=
"org.skywalking.apm.collector"
level=
"debug"
>
<logger
name=
"org.skywalking.apm.collector"
level=
"debug"
additivity=
"false"
>
<AppenderRef
ref=
"
RollingFi
le"
/>
<AppenderRef
ref=
"
Conso
le"
/>
</logger>
</logger>
<logger
name=
"org.skywalking.apm.collector.worker.storage"
level=
"error"
>
<logger
name=
"org.skywalking.apm.collector.worker.storage"
level=
"error"
additivity=
"false"
>
<AppenderRef
ref=
"
RollingFi
le"
/>
<AppenderRef
ref=
"
Conso
le"
/>
</logger>
</logger>
<Root
level=
"INFO"
>
<Root
level=
"INFO"
>
<AppenderRef
ref=
"
RollingFi
le"
/>
<AppenderRef
ref=
"
Conso
le"
/>
</Root>
</Root>
</Loggers>
</Loggers>
</Configuration>
</Configuration>
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/httpserver/PostWithHttpServletTestCase.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.httpserver
;
import
java.io.BufferedReader
;
import
java.io.PrintWriter
;
import
java.io.StringReader
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.mockito.invocation.InvocationOnMock
;
import
org.mockito.stubbing.Answer
;
import
org.skywalking.apm.collector.actor.LocalSyncWorkerRef
;
import
org.skywalking.apm.collector.actor.WorkerInvokeException
;
import
org.skywalking.apm.collector.worker.segment.entity.Segment
;
import
static
org
.
mockito
.
Matchers
.
anyInt
;
import
static
org
.
mockito
.
Mockito
.
any
;
import
static
org
.
mockito
.
Mockito
.
anyString
;
import
static
org
.
mockito
.
Mockito
.
doAnswer
;
import
static
org
.
mockito
.
Mockito
.
doThrow
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
/**
* @author pengys5
*/
public
class
PostWithHttpServletTestCase
{
private
LocalSyncWorkerRef
workerRef
;
private
AbstractPost
.
PostWithHttpServlet
servlet
;
private
HttpServletRequest
request
;
private
HttpServletResponse
response
;
private
PrintWriter
writer
;
@Before
public
void
init
()
throws
Exception
{
workerRef
=
mock
(
LocalSyncWorkerRef
.
class
);
servlet
=
new
AbstractPost
.
PostWithHttpServlet
(
workerRef
);
request
=
mock
(
HttpServletRequest
.
class
);
response
=
mock
(
HttpServletResponse
.
class
);
writer
=
mock
(
PrintWriter
.
class
);
when
(
response
.
getWriter
()).
thenReturn
(
writer
);
}
@Test
public
void
testDoPost
()
throws
Exception
{
doAnswer
(
new
Answer
()
{
@Override
public
Object
answer
(
InvocationOnMock
invocation
)
throws
Throwable
{
Integer
status
=
(
Integer
)
invocation
.
getArguments
()[
0
];
Assert
.
assertEquals
(
new
Integer
(
200
),
status
);
return
null
;
}
}).
when
(
response
).
setStatus
(
anyInt
());
doAnswer
(
new
Answer
()
{
@Override
public
Object
answer
(
InvocationOnMock
invocation
)
throws
Throwable
{
Segment
segment
=
(
Segment
)
invocation
.
getArguments
()[
0
];
Assert
.
assertEquals
(
"TestTest2"
,
segment
.
getTraceSegmentId
());
return
null
;
}
}).
when
(
workerRef
).
tell
(
any
(
Segment
.
class
));
BufferedReader
bufferedReader
=
new
BufferedReader
(
new
StringReader
(
"[{\"ts\":\"TestTest2\"}]"
));
when
(
request
.
getReader
()).
thenReturn
(
bufferedReader
);
servlet
.
doPost
(
request
,
response
);
}
@Test
public
void
testDoPostError
()
throws
Exception
{
doAnswer
(
new
Answer
()
{
@Override
public
Object
answer
(
InvocationOnMock
invocation
)
throws
Throwable
{
Integer
status
=
(
Integer
)
invocation
.
getArguments
()[
0
];
Assert
.
assertEquals
(
new
Integer
(
500
),
status
);
return
null
;
}
}).
when
(
response
).
setStatus
(
anyInt
());
doThrow
(
new
WorkerInvokeException
(
""
)).
when
(
workerRef
).
tell
(
anyString
());
servlet
.
doPost
(
request
,
response
);
}
}
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/httpserver/TestAbstractGet.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.httpserver
;
package
org.skywalking.apm.collector.worker.httpserver
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
java.util.Map
;
import
java.util.Map
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
...
@@ -19,13 +20,17 @@ public class TestAbstractGet extends AbstractGet {
...
@@ -19,13 +20,17 @@ public class TestAbstractGet extends AbstractGet {
super
(
role
,
clusterContext
,
selfContext
);
super
(
role
,
clusterContext
,
selfContext
);
}
}
@Override
protected
Class
<?
extends
JsonElement
>
responseClass
()
{
return
JsonObject
.
class
;
}
@Override
@Override
public
void
preStart
()
throws
ProviderNotFoundException
{
public
void
preStart
()
throws
ProviderNotFoundException
{
super
.
preStart
();
super
.
preStart
();
}
}
@Override
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
@Override
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
Json
Objec
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
Json
Elemen
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
}
}
...
...
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/httpserver/TestAbstractPost.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.httpserver
;
package
org.skywalking.apm.collector.worker.httpserver
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
java.util.Map
;
import
java.util.Map
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
...
@@ -19,13 +20,17 @@ public class TestAbstractPost extends AbstractPost {
...
@@ -19,13 +20,17 @@ public class TestAbstractPost extends AbstractPost {
super
(
role
,
clusterContext
,
selfContext
);
super
(
role
,
clusterContext
,
selfContext
);
}
}
@Override
protected
Class
<?
extends
JsonElement
>
responseClass
()
{
return
JsonObject
.
class
;
}
@Override
@Override
public
void
preStart
()
throws
ProviderNotFoundException
{
public
void
preStart
()
throws
ProviderNotFoundException
{
super
.
preStart
();
super
.
preStart
();
}
}
@Override
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
@Override
protected
void
onReceive
(
Map
<
String
,
String
[]>
parameter
,
Json
Objec
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
Json
Elemen
t
response
)
throws
ArgumentsParseException
,
WorkerInvokeException
,
WorkerNotFoundException
{
}
}
...
...
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/httpserver/TestAbstractStreamPost.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.httpserver
;
package
org.skywalking.apm.collector.worker.httpserver
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
import
org.skywalking.apm.collector.actor.ClusterWorkerContext
;
...
@@ -19,6 +20,10 @@ public class TestAbstractStreamPost extends AbstractStreamPost {
...
@@ -19,6 +20,10 @@ public class TestAbstractStreamPost extends AbstractStreamPost {
super
(
role
,
clusterContext
,
selfContext
);
super
(
role
,
clusterContext
,
selfContext
);
}
}
@Override
protected
Class
<?
extends
JsonElement
>
responseClass
()
{
return
JsonObject
.
class
;
}
@Override
@Override
public
void
preStart
()
throws
ProviderNotFoundException
{
public
void
preStart
()
throws
ProviderNotFoundException
{
super
.
preStart
();
super
.
preStart
();
...
...
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/SegmentRealPost.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.segment
;
package
org.skywalking.apm.collector.worker.segment
;
import
io.grpc.ManagedChannel
;
import
io.grpc.ManagedChannelBuilder
;
import
io.grpc.stub.StreamObserver
;
import
java.util.List
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.skywalking.apm.collector.worker.segment.mock.SegmentMock
;
import
org.skywalking.apm.collector.worker.segment.mock.SegmentMock
;
import
org.skywalking.apm.network.proto.Downstream
;
import
org.skywalking.apm.network.proto.TraceSegmentServiceGrpc
;
import
org.skywalking.apm.network.proto.UpstreamSegment
;
/**
/**
* @author pengys5
* @author pengys5
*/
*/
public
class
SegmentRealPost
{
public
class
SegmentRealPost
{
private
static
Logger
logger
=
LogManager
.
getFormatterLogger
(
SegmentRealPost
.
class
);
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SegmentMock
mock
=
new
SegmentMock
();
ManagedChannel
channel
=
ManagedChannelBuilder
.
forAddress
(
"localhost"
,
22800
)
// String cacheServiceExceptionSegmentAsString = mock.mockCacheServiceExceptionSegmentAsString();
.
usePlaintext
(
true
)
// HttpClientTools.INSTANCE.post("http://localhost:7001/segments", cacheServiceExceptionSegmentAsString);
.
build
();
//
// String portalServiceExceptionSegmentAsString = mock.mockPortalServiceExceptionSegmentAsString();
TraceSegmentServiceGrpc
.
TraceSegmentServiceStub
stub
=
TraceSegmentServiceGrpc
.
newStub
(
channel
);
// HttpClientTools.INSTANCE.post("http://localhost:7001/segments", portalServiceExceptionSegmentAsString);
StreamObserver
<
UpstreamSegment
>
observer
=
stub
.
collect
(
new
StreamObserver
<
Downstream
>()
{
@Override
public
void
onNext
(
Downstream
downstream
)
{
}
@Override
public
void
onError
(
Throwable
throwable
)
{
String
cacheServiceSegmentAsString
=
mock
.
mockCacheServiceSegmentAsString
();
}
System
.
out
.
println
(
cacheServiceSegmentAsString
);
HttpClientTools
.
INSTANCE
.
post
(
"http://localhost:12800/segments"
,
cacheServiceSegmentAsString
);
String
persistenceServiceSegmentAsString
=
mock
.
mockPersistenceServiceSegmentAsString
();
@Override
public
void
onCompleted
()
{
HttpClientTools
.
INSTANCE
.
post
(
"http://localhost:12800/segments"
,
persistenceServiceSegmentAsString
);
String
portalServiceSegmentAsString
=
mock
.
mockPortalServiceSegmentAsString
();
}
HttpClientTools
.
INSTANCE
.
post
(
"http://localhost:12800/segments"
,
portalServiceSegmentAsString
);
}
);
// String specialSegmentAsString = mock.mockSpecialSegmentAsString();
List
<
UpstreamSegment
>
upstreamSegmentList
=
SegmentMock
.
mockPortalServiceSegment
();
// HttpClientTools.INSTANCE.post("http://localhost:7001/segments", specialSegmentAsString);
logger
.
debug
(
"upstreamSegmentList size: %s"
,
upstreamSegmentList
.
size
());
upstreamSegmentList
.
forEach
(
upstreamSegment
->
{
observer
.
onNext
(
upstreamSegment
);
});
observer
.
onCompleted
();
Thread
.
sleep
(
2000
);
}
}
}
}
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/Segment
Post
TestCase.java
→
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/Segment
Receiver
TestCase.java
浏览文件 @
93a45165
...
@@ -58,12 +58,12 @@ import static org.powermock.api.mockito.PowerMockito.mock;
...
@@ -58,12 +58,12 @@ import static org.powermock.api.mockito.PowerMockito.mock;
@RunWith
(
PowerMockRunner
.
class
)
@RunWith
(
PowerMockRunner
.
class
)
@PrepareForTest
({
LocalWorkerContext
.
class
,
WorkerRef
.
class
})
@PrepareForTest
({
LocalWorkerContext
.
class
,
WorkerRef
.
class
})
@PowerMockIgnore
({
"javax.management.*"
})
@PowerMockIgnore
({
"javax.management.*"
})
public
class
Segment
Post
TestCase
{
public
class
Segment
Receiver
TestCase
{
private
Logger
logger
=
LogManager
.
getFormatterLogger
(
Segment
Post
TestCase
.
class
);
private
Logger
logger
=
LogManager
.
getFormatterLogger
(
Segment
Receiver
TestCase
.
class
);
private
SegmentMock
segmentMock
;
private
SegmentMock
segmentMock
;
private
Segment
Post
segmentPost
;
private
Segment
Receiver
segmentReceiver
;
private
LocalWorkerContext
localWorkerContext
;
private
LocalWorkerContext
localWorkerContext
;
private
ClusterWorkerContext
clusterWorkerContext
;
private
ClusterWorkerContext
clusterWorkerContext
;
...
@@ -76,7 +76,7 @@ public class SegmentPostTestCase {
...
@@ -76,7 +76,7 @@ public class SegmentPostTestCase {
clusterWorkerContext
=
PowerMockito
.
mock
(
ClusterWorkerContext
.
class
);
clusterWorkerContext
=
PowerMockito
.
mock
(
ClusterWorkerContext
.
class
);
localWorkerContext
=
new
LocalWorkerContext
();
localWorkerContext
=
new
LocalWorkerContext
();
segment
Post
=
new
SegmentPost
(
SegmentPost
.
WorkerRole
.
INSTANCE
,
clusterWorkerContext
,
localWorkerContext
);
segment
Receiver
=
new
SegmentReceiver
(
SegmentReceiver
.
WorkerRole
.
INSTANCE
,
clusterWorkerContext
,
localWorkerContext
);
initNodeNodeMappingAnalysis
();
initNodeNodeMappingAnalysis
();
initNodeCompAnalysis
();
initNodeCompAnalysis
();
...
@@ -89,16 +89,15 @@ public class SegmentPostTestCase {
...
@@ -89,16 +89,15 @@ public class SegmentPostTestCase {
@Test
@Test
public
void
testRole
()
{
public
void
testRole
()
{
Assert
.
assertEquals
(
Segment
Post
.
class
.
getSimpleName
(),
SegmentPost
.
WorkerRole
.
INSTANCE
.
roleName
());
Assert
.
assertEquals
(
Segment
Receiver
.
class
.
getSimpleName
(),
SegmentReceiver
.
WorkerRole
.
INSTANCE
.
roleName
());
Assert
.
assertEquals
(
RollingSelector
.
class
.
getSimpleName
(),
Segment
Post
.
WorkerRole
.
INSTANCE
.
workerSelector
().
getClass
().
getSimpleName
());
Assert
.
assertEquals
(
RollingSelector
.
class
.
getSimpleName
(),
Segment
Receiver
.
WorkerRole
.
INSTANCE
.
workerSelector
().
getClass
().
getSimpleName
());
}
}
@Test
@Test
public
void
testFactory
()
{
public
void
testFactory
()
{
SegmentPost
.
Factory
factory
=
new
SegmentPost
.
Factory
();
SegmentReceiver
.
Factory
factory
=
new
SegmentReceiver
.
Factory
();
Assert
.
assertEquals
(
SegmentPost
.
class
.
getSimpleName
(),
factory
.
role
().
roleName
());
Assert
.
assertEquals
(
SegmentReceiver
.
class
.
getSimpleName
(),
factory
.
role
().
roleName
());
Assert
.
assertEquals
(
SegmentPost
.
class
.
getSimpleName
(),
factory
.
workerInstance
(
null
).
getClass
().
getSimpleName
());
Assert
.
assertEquals
(
SegmentReceiver
.
class
.
getSimpleName
(),
factory
.
workerInstance
(
null
).
getClass
().
getSimpleName
());
Assert
.
assertEquals
(
"/segments"
,
factory
.
servletPath
());
}
}
@Test
@Test
...
@@ -141,7 +140,7 @@ public class SegmentPostTestCase {
...
@@ -141,7 +140,7 @@ public class SegmentPostTestCase {
ArgumentCaptor
<
Role
>
argumentCaptor
=
ArgumentCaptor
.
forClass
(
Role
.
class
);
ArgumentCaptor
<
Role
>
argumentCaptor
=
ArgumentCaptor
.
forClass
(
Role
.
class
);
segment
Post
.
preStart
();
segment
Receiver
.
preStart
();
verify
(
clusterWorkerContext
,
times
(
17
)).
findProvider
(
argumentCaptor
.
capture
());
verify
(
clusterWorkerContext
,
times
(
17
)).
findProvider
(
argumentCaptor
.
capture
());
Assert
.
assertEquals
(
GlobalTraceAnalysis
.
Role
.
INSTANCE
.
roleName
(),
argumentCaptor
.
getAllValues
().
get
(
0
).
roleName
());
Assert
.
assertEquals
(
GlobalTraceAnalysis
.
Role
.
INSTANCE
.
roleName
(),
argumentCaptor
.
getAllValues
().
get
(
0
).
roleName
());
...
@@ -178,7 +177,7 @@ public class SegmentPostTestCase {
...
@@ -178,7 +177,7 @@ public class SegmentPostTestCase {
JsonObject
response
=
new
JsonObject
();
JsonObject
response
=
new
JsonObject
();
BufferedReader
reader
=
new
BufferedReader
(
new
StringReader
(
jsonStr
.
length
()
+
" "
+
jsonStr
));
BufferedReader
reader
=
new
BufferedReader
(
new
StringReader
(
jsonStr
.
length
()
+
" "
+
jsonStr
));
segmentPost
.
onReceive
(
reader
,
response
);
// segmentReceiver
.onReceive(reader, response);
}
}
private
SegmentSaveAnswer
segmentSaveAnswer_1
;
private
SegmentSaveAnswer
segmentSaveAnswer_1
;
...
@@ -304,7 +303,7 @@ public class SegmentPostTestCase {
...
@@ -304,7 +303,7 @@ public class SegmentPostTestCase {
public
void
testOnReceive
()
throws
Exception
{
public
void
testOnReceive
()
throws
Exception
{
String
cacheServiceSegmentAsString
=
segmentMock
.
mockCacheServiceSegmentAsString
();
String
cacheServiceSegmentAsString
=
segmentMock
.
mockCacheServiceSegmentAsString
();
segmentPost
.
onReceive
(
new
BufferedReader
(
new
StringReader
(
cacheServiceSegmentAsString
)),
new
JsonObject
());
// segmentReceiver
.onReceive(new BufferedReader(new StringReader(cacheServiceSegmentAsString)), new JsonObject());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310915L
),
segmentSaveAnswer_1
.
minute
);
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310915L
),
segmentSaveAnswer_1
.
minute
);
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310900L
),
segmentSaveAnswer_1
.
hour
);
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310900L
),
segmentSaveAnswer_1
.
hour
);
...
@@ -341,11 +340,11 @@ public class SegmentPostTestCase {
...
@@ -341,11 +340,11 @@ public class SegmentPostTestCase {
public
class
SegmentOtherAnswer
implements
Answer
<
Object
>
{
public
class
SegmentOtherAnswer
implements
Answer
<
Object
>
{
Segment
Post
.
SegmentWithTimeSlice
segmentWithTimeSlice
;
Segment
Receiver
.
SegmentWithTimeSlice
segmentWithTimeSlice
;
@Override
@Override
public
Object
answer
(
InvocationOnMock
invocation
)
throws
Throwable
{
public
Object
answer
(
InvocationOnMock
invocation
)
throws
Throwable
{
segmentWithTimeSlice
=
(
Segment
Post
.
SegmentWithTimeSlice
)
invocation
.
getArguments
()[
0
];
segmentWithTimeSlice
=
(
Segment
Receiver
.
SegmentWithTimeSlice
)
invocation
.
getArguments
()[
0
];
return
null
;
return
null
;
}
}
}
}
...
@@ -384,9 +383,9 @@ public class SegmentPostTestCase {
...
@@ -384,9 +383,9 @@ public class SegmentPostTestCase {
}
}
}
}
class
IsSegmentWithTimeSlice
extends
ArgumentMatcher
<
Segment
Post
.
SegmentWithTimeSlice
>
{
class
IsSegmentWithTimeSlice
extends
ArgumentMatcher
<
Segment
Receiver
.
SegmentWithTimeSlice
>
{
public
boolean
matches
(
Object
para
)
{
public
boolean
matches
(
Object
para
)
{
return
para
instanceof
Segment
Post
.
SegmentWithTimeSlice
;
return
para
instanceof
Segment
Receiver
.
SegmentWithTimeSlice
;
}
}
}
}
}
}
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/entity/SegmentDeserializeFromFile.java
浏览文件 @
93a45165
...
@@ -2,9 +2,11 @@ package org.skywalking.apm.collector.worker.segment.entity;
...
@@ -2,9 +2,11 @@ package org.skywalking.apm.collector.worker.segment.entity;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
java.io.FileReader
;
import
java.io.FileReader
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
/**
/**
* @author pengys5
* @author pengys5
...
@@ -21,17 +23,16 @@ public enum SegmentDeserializeFromFile {
...
@@ -21,17 +23,16 @@ public enum SegmentDeserializeFromFile {
* @return on {@link List <Segment>}
* @return on {@link List <Segment>}
* @throws Exception if json data illegal or file broken.
* @throws Exception if json data illegal or file broken.
*/
*/
public
List
<
Segmen
t
>
deserializeMultiple
(
String
segmentJsonFile
)
throws
Exception
{
public
List
<
TraceSegmentObjec
t
>
deserializeMultiple
(
String
segmentJsonFile
)
throws
Exception
{
List
<
Segmen
t
>
segmentList
=
new
ArrayList
<>();
List
<
TraceSegmentObjec
t
>
segmentList
=
new
ArrayList
<>();
streamReader
(
segmentList
,
new
FileReader
(
segmentJsonFile
));
streamReader
(
segmentList
,
new
FileReader
(
segmentJsonFile
));
return
segmentList
;
return
segmentList
;
}
}
private
void
streamReader
(
List
<
Segmen
t
>
segmentList
,
FileReader
fileReader
)
throws
Exception
{
private
void
streamReader
(
List
<
TraceSegmentObjec
t
>
segmentList
,
FileReader
fileReader
)
throws
Exception
{
JsonArray
segmentArray
=
gson
.
fromJson
(
fileReader
,
JsonArray
.
class
);
JsonArray
segmentArray
=
gson
.
fromJson
(
fileReader
,
JsonArray
.
class
);
for
(
int
i
=
0
;
i
<
segmentArray
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
segmentArray
.
size
();
i
++)
{
Segment
segment
=
gson
.
fromJson
(
segmentArray
.
get
(
i
),
Segment
.
class
);
JsonObject
segmentObj
=
segmentArray
.
get
(
i
).
getAsJsonObject
();
segmentList
.
add
(
segment
);
}
}
}
}
}
}
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/entity/tag/BooleanTagTestCase.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.segment.entity.tag
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
import
java.lang.reflect.Field
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* @author pengys5
*/
public
class
BooleanTagTestCase
{
@Test
public
void
test
()
throws
NoSuchFieldException
,
IllegalAccessException
{
BooleanTag
booleanTag
=
new
BooleanTag
(
"test"
,
false
);
Map
<
String
,
Boolean
>
tagsWithInt
=
new
LinkedHashMap
<>();
Span
span
=
new
Span
();
Field
testAField
=
span
.
getClass
().
getDeclaredField
(
"tagsWithBool"
);
testAField
.
setAccessible
(
true
);
testAField
.
set
(
span
,
tagsWithInt
);
Assert
.
assertEquals
(
false
,
booleanTag
.
get
(
span
));
tagsWithInt
.
put
(
"test"
,
true
);
Assert
.
assertEquals
(
true
,
booleanTag
.
get
(
span
));
}
}
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/entity/tag/IntTagTestCase.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.segment.entity.tag
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
import
java.lang.reflect.Field
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* @author pengys5
*/
public
class
IntTagTestCase
{
@Test
public
void
test
()
throws
NoSuchFieldException
,
IllegalAccessException
{
IntTag
intTag
=
new
IntTag
(
"test"
);
Map
<
String
,
Integer
>
tagsWithInt
=
new
LinkedHashMap
<>();
Span
span
=
new
Span
();
Field
testAField
=
span
.
getClass
().
getDeclaredField
(
"tagsWithInt"
);
testAField
.
setAccessible
(
true
);
testAField
.
set
(
span
,
tagsWithInt
);
Assert
.
assertEquals
(
null
,
intTag
.
get
(
span
));
tagsWithInt
.
put
(
"test"
,
10
);
Assert
.
assertEquals
(
10
,
intTag
.
get
(
span
).
intValue
());
}
}
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/entity/tag/ShortTagTestCase.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.segment.entity.tag
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
import
java.lang.reflect.Field
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* @author pengys5
*/
public
class
ShortTagTestCase
{
@Test
public
void
test
()
throws
NoSuchFieldException
,
IllegalAccessException
{
ShortTag
shortTag
=
new
ShortTag
(
"short"
);
Map
<
String
,
Integer
>
tagsWithInt
=
new
LinkedHashMap
<>();
Span
span
=
new
Span
();
Field
testAField
=
span
.
getClass
().
getDeclaredField
(
"tagsWithInt"
);
testAField
.
setAccessible
(
true
);
testAField
.
set
(
span
,
tagsWithInt
);
Short
tag
=
shortTag
.
get
(
span
);
Assert
.
assertEquals
(
null
,
tag
);
tagsWithInt
.
put
(
"short"
,
10
);
tag
=
shortTag
.
get
(
span
);
Assert
.
assertEquals
(
10
,
tag
.
intValue
());
}
}
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/entity/tag/TagsTestCase.java
已删除
100644 → 0
浏览文件 @
3af55a53
package
org.skywalking.apm.collector.worker.segment.entity.tag
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.skywalking.apm.collector.worker.segment.entity.Span
;
import
java.lang.reflect.Field
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* @author pengys5
*/
public
class
TagsTestCase
{
@Test
public
void
test
()
throws
NoSuchFieldException
,
IllegalAccessException
{
Span
span
=
new
Span
();
Map
<
String
,
String
>
tagsWithStr
=
new
LinkedHashMap
<>();
tagsWithStr
.
put
(
"span.layer"
,
"db"
);
Field
testAField
=
span
.
getClass
().
getDeclaredField
(
"tagsWithStr"
);
testAField
.
setAccessible
(
true
);
testAField
.
set
(
span
,
tagsWithStr
);
Assert
.
assertEquals
(
"db"
,
Tags
.
SPAN_LAYER
.
get
(
span
));
}
}
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/KeyWithStringValueFromJson.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.segment.mock
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.skywalking.apm.network.proto.KeyWithStringValue
;
/**
* @author pengys5
*/
public
enum
KeyWithStringValueFromJson
{
INSTANCE
;
private
static
final
String
key
=
"key"
;
private
static
final
String
value
=
"value"
;
public
List
<
KeyWithStringValue
.
Builder
>
build
(
JsonArray
kvArray
)
{
List
<
KeyWithStringValue
.
Builder
>
kv
=
new
LinkedList
<>();
for
(
int
i
=
0
;
i
<
kvArray
.
size
();
i
++)
{
JsonObject
tagJson
=
kvArray
.
get
(
i
).
getAsJsonObject
();
KeyWithStringValue
.
Builder
builder
=
KeyWithStringValue
.
newBuilder
();
buildKV
(
builder
,
tagJson
);
kv
.
add
(
builder
);
}
return
kv
;
}
private
void
buildKV
(
KeyWithStringValue
.
Builder
builder
,
JsonObject
tagJson
)
{
builder
.
setKey
(
tagJson
.
get
(
key
).
getAsString
());
builder
.
setValue
(
tagJson
.
get
(
value
).
getAsString
());
}
}
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/LogsFromJson.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.segment.mock
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.skywalking.apm.network.proto.KeyWithStringValue
;
import
org.skywalking.apm.network.proto.LogMessage
;
/**
* @author pengys5
*/
public
enum
LogsFromJson
{
INSTANCE
;
private
static
final
String
time
=
"time"
;
private
static
final
String
data
=
"data"
;
public
List
<
LogMessage
.
Builder
>
build
(
JsonArray
logsArray
)
{
List
<
LogMessage
.
Builder
>
logs
=
new
LinkedList
<>();
for
(
int
i
=
0
;
i
<
logsArray
.
size
();
i
++)
{
JsonObject
logJson
=
logsArray
.
get
(
i
).
getAsJsonObject
();
LogMessage
.
Builder
builder
=
LogMessage
.
newBuilder
();
buildLogMessage
(
builder
,
logJson
);
logs
.
add
(
builder
);
}
return
logs
;
}
private
void
buildLogMessage
(
LogMessage
.
Builder
builder
,
JsonObject
logJson
)
{
if
(
logJson
.
has
(
time
))
{
builder
.
setTime
(
logJson
.
get
(
time
).
getAsLong
());
}
if
(
logJson
.
has
(
data
))
{
List
<
KeyWithStringValue
.
Builder
>
logsBuilders
=
TagsFromJson
.
INSTANCE
.
build
(
logJson
.
get
(
data
).
getAsJsonArray
());
logsBuilders
.
forEach
(
logsBuilder
->
{
builder
.
addData
(
logsBuilder
);
});
}
}
}
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/ReferencesFromJson.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.segment.mock
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.skywalking.apm.network.proto.TraceSegmentReference
;
/**
* @author pengys5
*/
public
enum
ReferencesFromJson
{
INSTANCE
;
private
static
final
String
parentTraceSegmentId
=
"parentTraceSegmentId"
;
private
static
final
String
parentSpanId
=
"parentSpanId"
;
private
static
final
String
parentApplicationId
=
"parentApplicationId"
;
private
static
final
String
networkAddress
=
"networkAddress"
;
private
static
final
String
networkAddressId
=
"networkAddressId"
;
private
static
final
String
entryServiceName
=
"entryServiceName"
;
private
static
final
String
entryServiceId
=
"entryServiceId"
;
public
List
<
TraceSegmentReference
.
Builder
>
build
(
JsonArray
spanArray
)
{
List
<
TraceSegmentReference
.
Builder
>
references
=
new
LinkedList
<>();
for
(
int
i
=
0
;
i
<
spanArray
.
size
();
i
++)
{
JsonObject
spanJson
=
spanArray
.
get
(
i
).
getAsJsonObject
();
TraceSegmentReference
.
Builder
builder
=
TraceSegmentReference
.
newBuilder
();
buildRef
(
builder
,
spanJson
);
references
.
add
(
builder
);
}
return
references
;
}
private
void
buildRef
(
TraceSegmentReference
.
Builder
builder
,
JsonObject
referenceJsonObj
)
{
if
(
referenceJsonObj
.
has
(
parentTraceSegmentId
))
{
builder
.
setParentTraceSegmentId
(
referenceJsonObj
.
get
(
parentTraceSegmentId
).
getAsString
());
}
if
(
referenceJsonObj
.
has
(
parentSpanId
))
{
builder
.
setParentSpanId
(
referenceJsonObj
.
get
(
parentSpanId
).
getAsInt
());
}
if
(
referenceJsonObj
.
has
(
parentApplicationId
))
{
builder
.
setParentApplicationId
(
referenceJsonObj
.
get
(
parentApplicationId
).
getAsInt
());
}
if
(
referenceJsonObj
.
has
(
networkAddress
))
{
builder
.
setNetworkAddress
(
referenceJsonObj
.
get
(
networkAddress
).
getAsString
());
}
if
(
referenceJsonObj
.
has
(
networkAddressId
))
{
builder
.
setNetworkAddressId
(
referenceJsonObj
.
get
(
networkAddressId
).
getAsInt
());
}
if
(
referenceJsonObj
.
has
(
entryServiceName
))
{
builder
.
setEntryServiceName
(
referenceJsonObj
.
get
(
entryServiceName
).
getAsString
());
}
if
(
referenceJsonObj
.
has
(
entryServiceId
))
{
builder
.
setEntryServiceId
(
referenceJsonObj
.
get
(
entryServiceId
).
getAsInt
());
}
}
}
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/SegmentFromJson.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.segment.mock
;
import
com.google.gson.JsonObject
;
import
java.util.List
;
import
org.skywalking.apm.network.proto.SpanObject
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
import
org.skywalking.apm.network.proto.TraceSegmentReference
;
/**
* @author pengys5
*/
public
enum
SegmentFromJson
{
INSTANCE
;
private
static
final
String
traceSegmentId
=
"traceSegmentId"
;
private
static
final
String
refs
=
"refs"
;
private
static
final
String
spans
=
"spans"
;
private
static
final
String
applicationId
=
"applicationId"
;
private
static
final
String
applicationInstanceId
=
"applicationInstanceId"
;
public
TraceSegmentObject
build
(
JsonObject
segmentJsonObj
)
{
TraceSegmentObject
.
Builder
builder
=
TraceSegmentObject
.
newBuilder
();
buildSegment
(
builder
,
segmentJsonObj
);
return
builder
.
build
();
}
private
void
buildSegment
(
TraceSegmentObject
.
Builder
builder
,
JsonObject
segmentJsonObj
)
{
builder
.
setTraceSegmentId
(
segmentJsonObj
.
get
(
traceSegmentId
).
getAsString
());
builder
.
setApplicationId
(
segmentJsonObj
.
get
(
applicationId
).
getAsInt
());
builder
.
setApplicationInstanceId
(
segmentJsonObj
.
get
(
applicationInstanceId
).
getAsInt
());
if
(
segmentJsonObj
.
has
(
refs
))
{
List
<
TraceSegmentReference
.
Builder
>
refBuilders
=
ReferencesFromJson
.
INSTANCE
.
build
(
segmentJsonObj
.
get
(
refs
).
getAsJsonArray
());
refBuilders
.
forEach
(
refBuilder
->
builder
.
addRefs
(
refBuilder
));
}
List
<
SpanObject
.
Builder
>
spanBuilders
=
SpanFromJson
.
INSTANCE
.
build
(
segmentJsonObj
.
get
(
spans
).
getAsJsonArray
());
spanBuilders
.
forEach
(
spanBuilder
->
builder
.
addSpans
(
spanBuilder
));
}
}
\ No newline at end of file
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/SegmentMock.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.segment.mock
;
package
org.skywalking.apm.collector.worker.segment.mock
;
import
com.google.gson.JsonArray
;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.List
;
import
org.skywalking.apm.collector.queue.EndOfBatchCommand
;
import
org.skywalking.apm.collector.queue.EndOfBatchCommand
;
import
org.skywalking.apm.collector.worker.AnalysisMember
;
import
org.skywalking.apm.collector.worker.AnalysisMember
;
import
org.skywalking.apm.collector.worker.segment.SegmentPost
;
import
org.skywalking.apm.collector.worker.segment.SegmentReceiver
;
import
org.skywalking.apm.collector.worker.segment.entity.Segment
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentDeserializeFromFile
;
import
org.skywalking.apm.collector.worker.segment.entity.SegmentDeserializeFromFile
;
import
org.skywalking.apm.collector.worker.tools.DateTools
;
import
org.skywalking.apm.collector.worker.tools.JsonFileReader
;
import
org.skywalking.apm.collector.worker.tools.JsonFileReader
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
import
org.skywalking.apm.network.proto.UpstreamSegment
;
/**
/**
* @author pengys5
* @author pengys5
*/
*/
public
class
SegmentMock
{
public
class
SegmentMock
{
private
String
path
=
this
.
getClass
()
.
getResource
(
"/"
).
getPath
();
private
static
String
path
=
SegmentMock
.
class
.
getResource
(
"/"
).
getPath
();
private
final
String
CacheServiceJsonFile
=
path
+
"/json/segment/post/normal/cache-service.json"
;
private
final
String
CacheServiceJsonFile
=
path
+
"/json/segment/post/normal/cache-service.json"
;
private
final
String
PersistenceServiceJsonFile
=
path
+
"/json/segment/post/normal/persistence-service.json"
;
private
final
String
PersistenceServiceJsonFile
=
path
+
"/json/segment/post/normal/persistence-service.json"
;
p
rivate
final
String
PortalServiceJsonFile
=
path
+
"/json/segment/post
/normal/portal-service.json"
;
p
ublic
static
final
String
PortalServiceJsonFile
=
path
+
"/json/segment/grpc
/normal/portal-service.json"
;
private
final
String
CacheServiceExceptionJsonFile
=
path
+
"/json/segment/post/exception/cache-service.json"
;
private
final
String
CacheServiceExceptionJsonFile
=
path
+
"/json/segment/post/exception/cache-service.json"
;
private
final
String
PortalServiceExceptionJsonFile
=
path
+
"/json/segment/post/exception/portal-service.json"
;
private
final
String
PortalServiceExceptionJsonFile
=
path
+
"/json/segment/post/exception/portal-service.json"
;
...
@@ -42,65 +44,73 @@ public class SegmentMock {
...
@@ -42,65 +44,73 @@ public class SegmentMock {
return
JsonFileReader
.
INSTANCE
.
read
(
PersistenceServiceJsonFile
);
return
JsonFileReader
.
INSTANCE
.
read
(
PersistenceServiceJsonFile
);
}
}
public
String
mockPortalServiceSegmentAsString
()
throws
FileNotFoundException
{
public
static
List
<
UpstreamSegment
>
mockPortalServiceSegment
()
throws
FileNotFoundException
{
return
JsonFileReader
.
INSTANCE
.
read
(
PortalServiceJsonFile
);
List
<
UpstreamSegment
>
upstreamSegmentList
=
new
LinkedList
<>();
JsonArray
segmentArray
=
JsonFileReader
.
INSTANCE
.
parse
(
PortalServiceJsonFile
).
getAsJsonArray
();
segmentArray
.
forEach
(
segmentObj
->
{
UpstreamSegment
upstreamSegment
=
UpstreamSegmentFromJson
.
INSTANCE
.
build
(
segmentObj
.
getAsJsonObject
());
upstreamSegmentList
.
add
(
upstreamSegment
);
});
return
upstreamSegmentList
;
}
}
public
List
<
Segment
Post
.
SegmentWithTimeSlice
>
mockCacheServiceExceptionSegmentTimeSlice
()
throws
Exception
{
public
List
<
Segment
Receiver
.
SegmentWithTimeSlice
>
mockCacheServiceExceptionSegmentTimeSlice
()
throws
Exception
{
return
createSegmentWithTimeSliceList
(
CacheServiceExceptionJsonFile
);
return
createSegmentWithTimeSliceList
(
CacheServiceExceptionJsonFile
);
}
}
public
List
<
Segment
Post
.
SegmentWithTimeSlice
>
mockPortalServiceExceptionSegmentTimeSlice
()
throws
Exception
{
public
List
<
Segment
Receiver
.
SegmentWithTimeSlice
>
mockPortalServiceExceptionSegmentTimeSlice
()
throws
Exception
{
return
createSegmentWithTimeSliceList
(
PortalServiceExceptionJsonFile
);
return
createSegmentWithTimeSliceList
(
PortalServiceExceptionJsonFile
);
}
}
public
List
<
Segment
Post
.
SegmentWithTimeSlice
>
mockCacheServiceSegmentSegmentTimeSlice
()
throws
Exception
{
public
List
<
Segment
Receiver
.
SegmentWithTimeSlice
>
mockCacheServiceSegmentSegmentTimeSlice
()
throws
Exception
{
return
createSegmentWithTimeSliceList
(
CacheServiceJsonFile
);
return
createSegmentWithTimeSliceList
(
CacheServiceJsonFile
);
}
}
public
List
<
Segment
Post
.
SegmentWithTimeSlice
>
mockPersistenceServiceSegmentTimeSlice
()
throws
Exception
{
public
List
<
Segment
Receiver
.
SegmentWithTimeSlice
>
mockPersistenceServiceSegmentTimeSlice
()
throws
Exception
{
return
createSegmentWithTimeSliceList
(
PersistenceServiceJsonFile
);
return
createSegmentWithTimeSliceList
(
PersistenceServiceJsonFile
);
}
}
public
List
<
Segment
Post
.
SegmentWithTimeSlice
>
mockPortalServiceSegmentSegmentTimeSlice
()
throws
Exception
{
public
List
<
Segment
Receiver
.
SegmentWithTimeSlice
>
mockPortalServiceSegmentSegmentTimeSlice
()
throws
Exception
{
return
createSegmentWithTimeSliceList
(
PortalServiceJsonFile
);
return
createSegmentWithTimeSliceList
(
PortalServiceJsonFile
);
}
}
private
List
<
Segment
Post
.
SegmentWithTimeSlice
>
createSegmentWithTimeSliceList
(
private
List
<
Segment
Receiver
.
SegmentWithTimeSlice
>
createSegmentWithTimeSliceList
(
String
jsonFilePath
)
throws
Exception
{
String
jsonFilePath
)
throws
Exception
{
List
<
Segmen
t
>
segmentList
=
SegmentDeserializeFromFile
.
INSTANCE
.
deserializeMultiple
(
jsonFilePath
);
List
<
TraceSegmentObjec
t
>
segmentList
=
SegmentDeserializeFromFile
.
INSTANCE
.
deserializeMultiple
(
jsonFilePath
);
List
<
Segment
Post
.
SegmentWithTimeSlice
>
segmentWithTimeSliceList
=
new
ArrayList
<>();
List
<
Segment
Receiver
.
SegmentWithTimeSlice
>
segmentWithTimeSliceList
=
new
ArrayList
<>();
for
(
Segmen
t
segment
:
segmentList
)
{
for
(
TraceSegmentObjec
t
segment
:
segmentList
)
{
Segment
Post
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
createSegmentWithTimeSlice
(
segment
);
Segment
Receiver
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
createSegmentWithTimeSlice
(
segment
);
segmentWithTimeSliceList
.
add
(
segmentWithTimeSlice
);
segmentWithTimeSliceList
.
add
(
segmentWithTimeSlice
);
}
}
return
segmentWithTimeSliceList
;
return
segmentWithTimeSliceList
;
}
}
private
Segment
Post
.
SegmentWithTimeSlice
createSegmentWithTimeSlice
(
Segmen
t
segment
)
{
private
Segment
Receiver
.
SegmentWithTimeSlice
createSegmentWithTimeSlice
(
TraceSegmentObjec
t
segment
)
{
long
minuteSlice
=
DateTools
.
getMinuteSlice
(
segment
.
getStartTime
());
//
long minuteSlice = DateTools.getMinuteSlice(segment.getStartTime());
long
hourSlice
=
DateTools
.
getHourSlice
(
segment
.
getStartTime
());
//
long hourSlice = DateTools.getHourSlice(segment.getStartTime());
long
daySlice
=
DateTools
.
getDaySlice
(
segment
.
getStartTime
());
//
long daySlice = DateTools.getDaySlice(segment.getStartTime());
int
second
=
DateTools
.
getSecond
(
segment
.
getStartTime
());
//
int second = DateTools.getSecond(segment.getStartTime());
SegmentPost
.
SegmentWithTimeSlice
segmentWithTimeSlice
=
new
SegmentPost
.
SegmentWithTimeSlice
(
segment
,
minuteSlice
,
hourSlice
,
daySlice
,
second
);
// SegmentReceiver.SegmentWithTimeSlice segmentWithTimeSlice = new SegmentReceiver.SegmentWithTimeSlice(segment, minuteSlice, hourSlice, daySlice, second);
return
segmentWithTimeSlice
;
// return segmentWithTimeSlice;
return
null
;
}
}
public
void
executeAnalysis
(
AnalysisMember
analysis
)
throws
Exception
{
public
void
executeAnalysis
(
AnalysisMember
analysis
)
throws
Exception
{
List
<
Segment
Post
.
SegmentWithTimeSlice
>
cacheServiceSegment
=
this
.
mockCacheServiceSegmentSegmentTimeSlice
();
List
<
Segment
Receiver
.
SegmentWithTimeSlice
>
cacheServiceSegment
=
this
.
mockCacheServiceSegmentSegmentTimeSlice
();
for
(
Segment
Post
.
SegmentWithTimeSlice
segmentWithTimeSlice
:
cacheServiceSegment
)
{
for
(
Segment
Receiver
.
SegmentWithTimeSlice
segmentWithTimeSlice
:
cacheServiceSegment
)
{
analysis
.
analyse
(
segmentWithTimeSlice
);
analysis
.
analyse
(
segmentWithTimeSlice
);
}
}
List
<
Segment
Post
.
SegmentWithTimeSlice
>
portalServiceSegment
=
this
.
mockPortalServiceSegmentSegmentTimeSlice
();
List
<
Segment
Receiver
.
SegmentWithTimeSlice
>
portalServiceSegment
=
this
.
mockPortalServiceSegmentSegmentTimeSlice
();
for
(
Segment
Post
.
SegmentWithTimeSlice
segmentWithTimeSlice
:
portalServiceSegment
)
{
for
(
Segment
Receiver
.
SegmentWithTimeSlice
segmentWithTimeSlice
:
portalServiceSegment
)
{
analysis
.
analyse
(
segmentWithTimeSlice
);
analysis
.
analyse
(
segmentWithTimeSlice
);
}
}
List
<
Segment
Post
.
SegmentWithTimeSlice
>
persistenceServiceSegment
=
this
.
mockPersistenceServiceSegmentTimeSlice
();
List
<
Segment
Receiver
.
SegmentWithTimeSlice
>
persistenceServiceSegment
=
this
.
mockPersistenceServiceSegmentTimeSlice
();
for
(
Segment
Post
.
SegmentWithTimeSlice
segmentWithTimeSlice
:
persistenceServiceSegment
)
{
for
(
Segment
Receiver
.
SegmentWithTimeSlice
segmentWithTimeSlice
:
persistenceServiceSegment
)
{
analysis
.
analyse
(
segmentWithTimeSlice
);
analysis
.
analyse
(
segmentWithTimeSlice
);
}
}
...
...
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/SpanFromJson.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.segment.mock
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.skywalking.apm.network.proto.KeyWithStringValue
;
import
org.skywalking.apm.network.proto.LogMessage
;
import
org.skywalking.apm.network.proto.SpanObject
;
/**
* @author pengys5
*/
public
enum
SpanFromJson
{
INSTANCE
;
private
static
final
String
spanId
=
"spanId"
;
private
static
final
String
parentSpanId
=
"parentSpanId"
;
private
static
final
String
startTime
=
"startTime"
;
private
static
final
String
endTime
=
"endTime"
;
private
static
final
String
operationNameId
=
"operationNameId"
;
private
static
final
String
operationName
=
"operationName"
;
private
static
final
String
peerId
=
"peerId"
;
private
static
final
String
peer
=
"peer"
;
private
static
final
String
spanType
=
"spanType"
;
private
static
final
String
spanLayer
=
"spanLayer"
;
private
static
final
String
componentId
=
"componentId"
;
private
static
final
String
component
=
"component"
;
private
static
final
String
isError
=
"isError"
;
private
static
final
String
tags
=
"tags"
;
private
static
final
String
logs
=
"logs"
;
public
List
<
SpanObject
.
Builder
>
build
(
JsonArray
spanArray
)
{
List
<
SpanObject
.
Builder
>
spans
=
new
LinkedList
<>();
for
(
int
i
=
0
;
i
<
spanArray
.
size
();
i
++)
{
JsonObject
spanJson
=
spanArray
.
get
(
i
).
getAsJsonObject
();
SpanObject
.
Builder
builder
=
SpanObject
.
newBuilder
();
buildSpan
(
builder
,
spanJson
);
spans
.
add
(
builder
);
}
return
spans
;
}
private
void
buildSpan
(
SpanObject
.
Builder
builder
,
JsonObject
spanJsonObj
)
{
if
(
spanJsonObj
.
has
(
spanId
))
{
builder
.
setSpanId
(
spanJsonObj
.
get
(
spanId
).
getAsInt
());
}
if
(
spanJsonObj
.
has
(
parentSpanId
))
{
builder
.
setParentSpanId
(
spanJsonObj
.
get
(
parentSpanId
).
getAsInt
());
}
if
(
spanJsonObj
.
has
(
startTime
))
{
builder
.
setStartTime
(
spanJsonObj
.
get
(
startTime
).
getAsLong
());
}
if
(
spanJsonObj
.
has
(
endTime
))
{
builder
.
setEndTime
(
spanJsonObj
.
get
(
endTime
).
getAsLong
());
}
if
(
spanJsonObj
.
has
(
operationNameId
))
{
builder
.
setOperationNameId
(
spanJsonObj
.
get
(
operationNameId
).
getAsInt
());
}
if
(
spanJsonObj
.
has
(
operationName
))
{
builder
.
setOperationName
(
spanJsonObj
.
get
(
operationName
).
getAsString
());
}
if
(
spanJsonObj
.
has
(
peerId
))
{
builder
.
setPeerId
(
spanJsonObj
.
get
(
peerId
).
getAsInt
());
}
if
(
spanJsonObj
.
has
(
peer
))
{
builder
.
setPeer
(
spanJsonObj
.
get
(
peer
).
getAsString
());
}
if
(
spanJsonObj
.
has
(
spanType
))
{
builder
.
setSpanTypeValue
(
spanJsonObj
.
get
(
spanType
).
getAsInt
());
}
if
(
spanJsonObj
.
has
(
spanLayer
))
{
builder
.
setSpanLayerValue
(
spanJsonObj
.
get
(
spanLayer
).
getAsInt
());
}
if
(
spanJsonObj
.
has
(
component
))
{
builder
.
setComponent
(
spanJsonObj
.
get
(
component
).
getAsString
());
}
if
(
spanJsonObj
.
has
(
componentId
))
{
builder
.
setComponentId
(
spanJsonObj
.
get
(
componentId
).
getAsInt
());
}
if
(
spanJsonObj
.
has
(
isError
))
{
builder
.
setIsError
(
spanJsonObj
.
get
(
isError
).
getAsBoolean
());
}
if
(
spanJsonObj
.
has
(
tags
))
{
List
<
KeyWithStringValue
.
Builder
>
tagsBuilders
=
TagsFromJson
.
INSTANCE
.
build
(
spanJsonObj
.
get
(
tags
).
getAsJsonArray
());
tagsBuilders
.
forEach
(
tagsBuilder
->
{
builder
.
addTags
(
tagsBuilder
);
});
}
if
(
spanJsonObj
.
has
(
logs
))
{
List
<
LogMessage
.
Builder
>
logsBuilders
=
LogsFromJson
.
INSTANCE
.
build
(
spanJsonObj
.
get
(
logs
).
getAsJsonArray
());
logsBuilders
.
forEach
(
logsBuilder
->
{
builder
.
addLogs
(
logsBuilder
);
});
}
}
}
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/TagsFromJson.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.segment.mock
;
import
com.google.gson.JsonArray
;
import
java.util.List
;
import
org.skywalking.apm.network.proto.KeyWithStringValue
;
/**
* @author pengys5
*/
public
enum
TagsFromJson
{
INSTANCE
;
public
List
<
KeyWithStringValue
.
Builder
>
build
(
JsonArray
tagsArray
)
{
return
KeyWithStringValueFromJson
.
INSTANCE
.
build
(
tagsArray
);
}
}
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/UpstreamSegmentFromJson.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.segment.mock
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
import
org.skywalking.apm.network.proto.UpstreamSegment
;
/**
* @author pengys5
*/
public
enum
UpstreamSegmentFromJson
{
INSTANCE
;
private
static
final
String
globalTraceIds
=
"globalTraceIds"
;
private
static
final
String
segment
=
"segment"
;
public
UpstreamSegment
build
(
JsonObject
upstreamJsonObj
)
{
UpstreamSegment
.
Builder
builder
=
UpstreamSegment
.
newBuilder
();
buildUpStream
(
builder
,
upstreamJsonObj
);
return
builder
.
build
();
}
private
void
buildUpStream
(
UpstreamSegment
.
Builder
builder
,
JsonObject
upstreamJsonObj
)
{
if
(
upstreamJsonObj
.
has
(
globalTraceIds
))
{
JsonArray
globalTraceIdArray
=
upstreamJsonObj
.
get
(
globalTraceIds
).
getAsJsonArray
();
globalTraceIdArray
.
forEach
(
globalTraceIdElement
->
{
builder
.
addGlobalTraceIds
(
globalTraceIdElement
.
getAsString
());
});
}
TraceSegmentObject
segmentObject
=
SegmentFromJson
.
INSTANCE
.
build
(
upstreamJsonObj
.
get
(
segment
).
getAsJsonObject
());
builder
.
setSegment
(
segmentObject
.
toByteString
());
}
}
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/segment/mock/UpstreamSegmentFromJsonTestCase.java
0 → 100644
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.segment.mock
;
import
com.google.gson.JsonArray
;
import
com.google.protobuf.InvalidProtocolBufferException
;
import
java.io.FileNotFoundException
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.skywalking.apm.collector.worker.tools.JsonFileReader
;
import
org.skywalking.apm.network.proto.KeyWithStringValue
;
import
org.skywalking.apm.network.proto.SpanObject
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
import
org.skywalking.apm.network.proto.UpstreamSegment
;
/**
* @author pengys5
*/
public
class
UpstreamSegmentFromJsonTestCase
{
@Test
public
void
testBuild
()
throws
FileNotFoundException
,
InvalidProtocolBufferException
{
JsonArray
segmentArray
=
JsonFileReader
.
INSTANCE
.
parse
(
SegmentMock
.
PortalServiceJsonFile
).
getAsJsonArray
();
List
<
UpstreamSegment
>
upstreamSegmentList
=
new
LinkedList
<>();
segmentArray
.
forEach
(
segmentJsonObj
->
{
UpstreamSegment
upstreamSegment
=
UpstreamSegmentFromJson
.
INSTANCE
.
build
(
segmentJsonObj
.
getAsJsonObject
());
upstreamSegmentList
.
add
(
upstreamSegment
);
});
Assert
.
assertEquals
(
1
,
upstreamSegmentList
.
size
());
UpstreamSegment
upstreamSegment_1
=
upstreamSegmentList
.
get
(
0
);
Assert
.
assertEquals
(
1
,
upstreamSegment_1
.
getGlobalTraceIdsCount
());
Assert
.
assertEquals
(
"Trace.1490922929254.1797892356.6003.69.2"
,
upstreamSegment_1
.
getGlobalTraceIds
(
0
));
TraceSegmentObject
segmentObject
=
TraceSegmentObject
.
parseFrom
(
upstreamSegment_1
.
getSegment
());
Assert
.
assertEquals
(
"Segment.1490922929254.1797892356.6003.69.1"
,
segmentObject
.
getTraceSegmentId
());
Assert
.
assertEquals
(
1
,
segmentObject
.
getApplicationId
());
Assert
.
assertEquals
(
1
,
segmentObject
.
getApplicationInstanceId
());
Assert
.
assertEquals
(
1
,
segmentObject
.
getSpansCount
());
SpanObject
span_0
=
segmentObject
.
getSpans
(
0
);
Assert
.
assertEquals
(
0
,
span_0
.
getSpanId
());
Assert
.
assertEquals
(-
1
,
span_0
.
getParentSpanId
());
Assert
.
assertEquals
(
0
,
span_0
.
getOperationNameId
());
Assert
.
assertEquals
(
"/portal/"
,
span_0
.
getOperationName
());
Assert
.
assertEquals
(
0
,
span_0
.
getPeerId
());
Assert
.
assertEquals
(
"0:0:0:0:0:0:0:1:57837"
,
span_0
.
getPeer
());
Assert
.
assertEquals
(
0
,
span_0
.
getSpanTypeValue
());
Assert
.
assertEquals
(
2
,
span_0
.
getSpanLayerValue
());
Assert
.
assertEquals
(
0
,
span_0
.
getComponentId
());
Assert
.
assertEquals
(
"Tomcat"
,
span_0
.
getComponent
());
Assert
.
assertEquals
(
false
,
span_0
.
getIsError
());
Assert
.
assertEquals
(
2
,
span_0
.
getTagsCount
());
KeyWithStringValue
tag_0
=
span_0
.
getTags
(
0
);
Assert
.
assertEquals
(
"key_1"
,
tag_0
.
getKey
());
Assert
.
assertEquals
(
"value_1"
,
tag_0
.
getValue
());
KeyWithStringValue
tag_1
=
span_0
.
getTags
(
1
);
Assert
.
assertEquals
(
"key_2"
,
tag_1
.
getKey
());
Assert
.
assertEquals
(
"value_2"
,
tag_1
.
getValue
());
}
}
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/span/persistence/SpanSearchWithIdTestCase.java
浏览文件 @
93a45165
package
org.skywalking.apm.collector.worker.span.persistence
;
package
org.skywalking.apm.collector.worker.span.persistence
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
java.util.TimeZone
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Before
;
...
@@ -18,9 +19,6 @@ import org.skywalking.apm.collector.worker.Const;
...
@@ -18,9 +19,6 @@ import org.skywalking.apm.collector.worker.Const;
import
org.skywalking.apm.collector.worker.segment.SegmentIndex
;
import
org.skywalking.apm.collector.worker.segment.SegmentIndex
;
import
org.skywalking.apm.collector.worker.segment.mock.SegmentMock
;
import
org.skywalking.apm.collector.worker.segment.mock.SegmentMock
;
import
org.skywalking.apm.collector.worker.storage.GetResponseFromEs
;
import
org.skywalking.apm.collector.worker.storage.GetResponseFromEs
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
import
java.util.TimeZone
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
mockito
.
Mockito
.
when
;
...
@@ -29,8 +27,8 @@ import static org.mockito.Mockito.when;
...
@@ -29,8 +27,8 @@ import static org.mockito.Mockito.when;
* @author pengys5
* @author pengys5
*/
*/
@RunWith
(
PowerMockRunner
.
class
)
@RunWith
(
PowerMockRunner
.
class
)
@PrepareForTest
(
{
GetResponseFromEs
.
class
})
@PrepareForTest
({
GetResponseFromEs
.
class
})
@PowerMockIgnore
(
{
"javax.management.*"
})
@PowerMockIgnore
({
"javax.management.*"
})
public
class
SpanSearchWithIdTestCase
{
public
class
SpanSearchWithIdTestCase
{
private
GetResponseFromEs
getResponseFromEs
;
private
GetResponseFromEs
getResponseFromEs
;
...
@@ -78,14 +76,4 @@ public class SpanSearchWithIdTestCase {
...
@@ -78,14 +76,4 @@ public class SpanSearchWithIdTestCase {
Assert
.
assertEquals
(
"/portal/"
,
value
);
Assert
.
assertEquals
(
"/portal/"
,
value
);
}
}
private
TraceSegment
create
()
{
TraceSegment
segment
=
new
TraceSegment
();
Span
span
=
new
Span
();
span
.
setTag
(
"Tag"
,
"VALUE"
);
span
.
finish
(
segment
);
segment
.
finish
();
return
segment
;
}
}
}
apm-collector/apm-collector-worker/src/
main
/java/org/skywalking/apm/collector/worker/tools/JsonFileReader.java
→
apm-collector/apm-collector-worker/src/
test
/java/org/skywalking/apm/collector/worker/tools/JsonFileReader.java
浏览文件 @
93a45165
...
@@ -18,6 +18,11 @@ public enum JsonFileReader {
...
@@ -18,6 +18,11 @@ public enum JsonFileReader {
return
jsonElement
.
toString
();
return
jsonElement
.
toString
();
}
}
public
JsonElement
parse
(
String
path
)
throws
FileNotFoundException
{
JsonParser
jsonParser
=
new
JsonParser
();
return
jsonParser
.
parse
(
new
FileReader
(
path
));
}
public
String
readSegment
(
String
path
)
throws
FileNotFoundException
{
public
String
readSegment
(
String
path
)
throws
FileNotFoundException
{
JsonParser
jsonParser
=
new
JsonParser
();
JsonParser
jsonParser
=
new
JsonParser
();
JsonElement
jsonElement
=
jsonParser
.
parse
(
new
FileReader
(
path
));
JsonElement
jsonElement
=
jsonParser
.
parse
(
new
FileReader
(
path
));
...
...
apm-collector/apm-collector-worker/src/test/java/org/skywalking/apm/collector/worker/tools/SpanPeersToolsTestCase.java
浏览文件 @
93a45165
此差异已折叠。
点击以展开。
apm-collector/apm-collector-worker/src/test/resources/json/segment/grpc/normal/portal-service.json
0 → 100644
浏览文件 @
93a45165
此差异已折叠。
点击以展开。
apm-collector/apm-collector-worker/src/test/resources/log4j2.xml
已删除
100644 → 0
浏览文件 @
3af55a53
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录