This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch refactor/component-id
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git


The following commit(s) were added to refs/heads/refactor/component-id by this 
push:
     new 6df6045  Support don't uplink componentId, but componentName in 
segment.
6df6045 is described below

commit 6df6045d09fbae8dadceacfa07744618cfd2a89b
Author: wusheng <wu.sh...@foxmail.com>
AuthorDate: Mon Apr 16 15:50:18 2018 +0800

    Support don't uplink componentId, but componentName in segment.
---
 .../segment-parser-define/pom.xml                    |  7 ++++++-
 .../parser/define/decorator/SegmentDecorator.java    |  7 ++++---
 .../parser/define/decorator/SpanDecorator.java       | 20 ++++++++++++++++----
 .../segment/parser/provider/parser/SegmentParse.java |  4 ++--
 4 files changed, 28 insertions(+), 10 deletions(-)

diff --git 
a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-define/pom.xml
 
b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-define/pom.xml
index 9c27dc9..cc4985e 100644
--- 
a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-define/pom.xml
+++ 
b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-define/pom.xml
@@ -35,5 +35,10 @@
             <artifactId>apm-network</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.skywalking</groupId>
+            <artifactId>collector-configuration-define</artifactId>
+            <version>${project.version}</version>
+        </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git 
a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-define/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/define/decorator/SegmentDecorator.java
 
b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-define/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/define/decorator/SegmentDecorator.java
index 531aef8..0b85acd 100644
--- 
a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-define/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/define/decorator/SegmentDecorator.java
+++ 
b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-define/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/define/decorator/SegmentDecorator.java
@@ -18,6 +18,7 @@
 
 package 
org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator;
 
+import org.apache.skywalking.apm.collector.core.module.ModuleManager;
 import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
 import org.apache.skywalking.apm.network.proto.TraceSegmentObject;
 import org.apache.skywalking.apm.network.proto.UniqueId;
@@ -52,12 +53,12 @@ public class SegmentDecorator implements StandardBuilder {
         return segmentObject.getSpansCount();
     }
 
-    public SpanDecorator getSpans(int index) {
+    public SpanDecorator getSpans(int index, ModuleManager moduleManager) {
         if (ObjectUtils.isEmpty(spanDecorators[index])) {
             if (isOrigin) {
-                spanDecorators[index] = new 
SpanDecorator(segmentObject.getSpans(index), this);
+                spanDecorators[index] = new 
SpanDecorator(segmentObject.getSpans(index), this, moduleManager);
             } else {
-                spanDecorators[index] = new 
SpanDecorator(segmentBuilder.getSpansBuilder(index), this);
+                spanDecorators[index] = new 
SpanDecorator(segmentBuilder.getSpansBuilder(index), this, moduleManager);
             }
         }
         return spanDecorators[index];
diff --git 
a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-define/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/define/decorator/SpanDecorator.java
 
b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-define/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/define/decorator/SpanDecorator.java
index a504add..9d1a903 100644
--- 
a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-define/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/define/decorator/SpanDecorator.java
+++ 
b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-define/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/define/decorator/SpanDecorator.java
@@ -18,6 +18,9 @@
 
 package 
org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator;
 
+import org.apache.skywalking.apm.collector.configuration.ConfigurationModule;
+import 
org.apache.skywalking.apm.collector.configuration.service.IComponentLibraryCatalogService;
+import org.apache.skywalking.apm.collector.core.module.ModuleManager;
 import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
 import org.apache.skywalking.apm.network.proto.SpanLayer;
 import org.apache.skywalking.apm.network.proto.SpanObject;
@@ -33,18 +36,21 @@ public class SpanDecorator implements StandardBuilder {
     private SpanObject.Builder spanBuilder;
     private long startTimeMinuteTimeBucket = 0;
     private final ReferenceDecorator[] referenceDecorators;
+    private final IComponentLibraryCatalogService 
componentLibraryCatalogService;
 
-    public SpanDecorator(SpanObject spanObject, StandardBuilder 
standardBuilder) {
+    public SpanDecorator(SpanObject spanObject, StandardBuilder 
standardBuilder, ModuleManager moduleManager) {
         this.spanObject = spanObject;
         this.standardBuilder = standardBuilder;
         this.referenceDecorators = new 
ReferenceDecorator[spanObject.getRefsCount()];
+        this.componentLibraryCatalogService = 
moduleManager.find(ConfigurationModule.NAME).getService(IComponentLibraryCatalogService.class);
     }
 
-    public SpanDecorator(SpanObject.Builder spanBuilder, StandardBuilder 
standardBuilder) {
+    public SpanDecorator(SpanObject.Builder spanBuilder, StandardBuilder 
standardBuilder, ModuleManager moduleManager) {
         this.spanBuilder = spanBuilder;
         this.standardBuilder = standardBuilder;
         this.isOrigin = false;
         this.referenceDecorators = new 
ReferenceDecorator[spanBuilder.getRefsCount()];
+        this.componentLibraryCatalogService = 
moduleManager.find(ConfigurationModule.NAME).getService(IComponentLibraryCatalogService.class);
     }
 
     public int getSpanId() {
@@ -120,11 +126,17 @@ public class SpanDecorator implements StandardBuilder {
     }
 
     public int getComponentId() {
+        int componentId = 0;
         if (isOrigin) {
-            return spanObject.getComponentId();
+            componentId = spanObject.getComponentId();
         } else {
-            return spanBuilder.getComponentId();
+            componentId = spanBuilder.getComponentId();
         }
+
+        if(componentId == 0){
+            componentId = 
componentLibraryCatalogService.getComponentId(getComponent());
+        }
+        return componentId;
     }
 
     public String getComponent() {
diff --git 
a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/SegmentParse.java
 
b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/SegmentParse.java
index a7b5f2b..8d5d8f3 100644
--- 
a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/SegmentParse.java
+++ 
b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/SegmentParse.java
@@ -125,7 +125,7 @@ public class SegmentParse {
 
         int entrySpanCount = 0;
         for (int i = 0; i < segmentDecorator.getSpansCount(); i++) {
-            SpanDecorator spanDecorator = segmentDecorator.getSpans(i);
+            SpanDecorator spanDecorator = segmentDecorator.getSpans(i, 
moduleManager);
 
             if 
(!SpanIdExchanger.getInstance(moduleManager).exchange(spanDecorator, 
applicationId)) {
                 return false;
@@ -148,7 +148,7 @@ public class SegmentParse {
         }
 
         for (int i = 0; i < segmentDecorator.getSpansCount(); i++) {
-            SpanDecorator spanDecorator = segmentDecorator.getSpans(i);
+            SpanDecorator spanDecorator = segmentDecorator.getSpans(i, 
moduleManager);
 
             if (spanDecorator.getSpanId() == 0) {
                 timeBucket = 
TimeBucketUtils.INSTANCE.getMinuteTimeBucket(spanDecorator.getStartTime());

-- 
To stop receiving notification emails like this one, please contact
wush...@apache.org.

Reply via email to