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 9c27dc90126340352387e77f68cec47859a7db64..cc4985e05304044012e77dee24ed9caa3bc9741e 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 @@
apm-network
${project.version}
+
+ org.apache.skywalking
+ collector-configuration-define
+ ${project.version}
+
-
\ No newline at end of file
+
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 a504add101c7a211f9732d2360edc57e18ff02a0..12162da31957c4776502766c0a38af6e6d5c7a0e 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
@@ -127,6 +127,13 @@ public class SpanDecorator implements StandardBuilder {
}
}
+ public void setComponentId(int value) {
+ if (isOrigin) {
+ toBuilder();
+ }
+ spanBuilder.setComponentId(value);
+ }
+
public String getComponent() {
if (isOrigin) {
return spanObject.getComponent();
@@ -135,6 +142,13 @@ public class SpanDecorator implements StandardBuilder {
}
}
+ public void setComponent(String value) {
+ if (isOrigin) {
+ toBuilder();
+ }
+ spanBuilder.setComponent(value);
+ }
+
public int getPeerId() {
if (isOrigin) {
return spanObject.getPeerId();
diff --git a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/pom.xml b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/pom.xml
index 950526a90f291fc7c4e50c71668dfc80d5617b6b..2004c3922b3696a83a8330bbe10bb5e2fad54388 100644
--- a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/pom.xml
+++ b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/pom.xml
@@ -30,6 +30,11 @@
jar
+
+ org.apache.skywalking
+ collector-configuration-define
+ ${project.version}
+
org.apache.skywalking
segment-parser-define
@@ -56,4 +61,4 @@
${project.version}
-
\ No newline at end of file
+
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/AnalysisSegmentParserModuleProvider.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/AnalysisSegmentParserModuleProvider.java
index d1ff36667e0faf34f8faa4efe4b38e740329bddc..d3363b3751aa0c21eaf680723c1d3b55d440373b 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/AnalysisSegmentParserModuleProvider.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/AnalysisSegmentParserModuleProvider.java
@@ -32,6 +32,7 @@ import org.apache.skywalking.apm.collector.analysis.segment.parser.provider.serv
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener;
import org.apache.skywalking.apm.collector.analysis.worker.timer.PersistenceTimer;
import org.apache.skywalking.apm.collector.cache.CacheModule;
+import org.apache.skywalking.apm.collector.configuration.ConfigurationModule;
import org.apache.skywalking.apm.collector.core.module.Module;
import org.apache.skywalking.apm.collector.core.module.ModuleConfig;
import org.apache.skywalking.apm.collector.core.module.ModuleProvider;
@@ -87,7 +88,7 @@ public class AnalysisSegmentParserModuleProvider extends ModuleProvider {
}
@Override public String[] requiredModules() {
- return new String[] {StorageModule.NAME, AnalysisRegisterModule.NAME, CacheModule.NAME};
+ return new String[] {ConfigurationModule.NAME, StorageModule.NAME, AnalysisRegisterModule.NAME, CacheModule.NAME};
}
private void graphCreate(WorkerCreateListener workerCreateListener) {
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/standardization/SpanIdExchanger.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/standardization/SpanIdExchanger.java
index 30ff0c5d50bb5c4a0fe3293ac71519c828ee8ae9..b3b0b599040e5c97023e1cdd39793adb706287a8 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/standardization/SpanIdExchanger.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/standardization/SpanIdExchanger.java
@@ -22,11 +22,12 @@ import org.apache.skywalking.apm.collector.analysis.register.define.AnalysisRegi
import org.apache.skywalking.apm.collector.analysis.register.define.service.INetworkAddressIDService;
import org.apache.skywalking.apm.collector.analysis.register.define.service.IServiceNameService;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SpanDecorator;
+import org.apache.skywalking.apm.collector.configuration.ConfigurationModule;
+import org.apache.skywalking.apm.collector.configuration.service.IComponentLibraryCatalogService;
import org.apache.skywalking.apm.collector.core.annotations.trace.GraphComputingMetric;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.StringUtils;
-import org.apache.skywalking.apm.collector.storage.table.register.ServerTypeDefine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,6 +41,7 @@ public class SpanIdExchanger implements IdExchanger {
private static SpanIdExchanger EXCHANGER;
private final IServiceNameService serviceNameService;
private final INetworkAddressIDService networkAddressIDService;
+ private final IComponentLibraryCatalogService componentLibraryCatalogService;
public static SpanIdExchanger getInstance(ModuleManager moduleManager) {
if (EXCHANGER == null) {
@@ -51,10 +53,24 @@ public class SpanIdExchanger implements IdExchanger {
private SpanIdExchanger(ModuleManager moduleManager) {
this.serviceNameService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IServiceNameService.class);
this.networkAddressIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(INetworkAddressIDService.class);
+ this.componentLibraryCatalogService = moduleManager.find(ConfigurationModule.NAME).getService(IComponentLibraryCatalogService.class);
}
@GraphComputingMetric(name = "/segment/parse/exchange/spanIdExchanger")
@Override public boolean exchange(SpanDecorator standardBuilder, int applicationId) {
+ if (standardBuilder.getComponentId() == 0 && StringUtils.isNotEmpty(standardBuilder.getComponent())) {
+ int componentId = componentLibraryCatalogService.getComponentId(standardBuilder.getComponent());
+
+ if (componentId == 0) {
+ logger.debug("component: {} in application: {} exchange failed", standardBuilder.getComponent(), applicationId);
+ return false;
+ } else {
+ standardBuilder.toBuilder();
+ standardBuilder.setComponentId(componentId);
+ standardBuilder.setComponent(Const.EMPTY_STRING);
+ }
+ }
+
if (standardBuilder.getPeerId() == 0 && StringUtils.isNotEmpty(standardBuilder.getPeer())) {
int peerId = networkAddressIDService.getOrCreate(standardBuilder.getPeer());
@@ -67,7 +83,7 @@ public class SpanIdExchanger implements IdExchanger {
standardBuilder.setPeer(Const.EMPTY_STRING);
int spanLayer = standardBuilder.getSpanLayerValue();
- int serverType = ServerTypeDefine.getInstance().getServerTypeId(standardBuilder.getComponentId());
+ int serverType = componentLibraryCatalogService.getServerIdBasedOnComponent(standardBuilder.getComponentId());
networkAddressIDService.update(peerId, spanLayer, serverType);
}
}
diff --git a/apm-collector/apm-collector-boot/src/main/assembly/assembly.xml b/apm-collector/apm-collector-boot/src/main/assembly/assembly.xml
index 954e720d47b2bc076bd214b16b51b6c22626e81b..0f234cd79633ec159cd4f2c1eef28e537aa574a9 100644
--- a/apm-collector/apm-collector-boot/src/main/assembly/assembly.xml
+++ b/apm-collector/apm-collector-boot/src/main/assembly/assembly.xml
@@ -31,13 +31,6 @@
-
- src/main/resources
- /config
-
- application.yml
-
-
src/main/assembly
/config
@@ -50,6 +43,7 @@
application.yml
log4j2.xml
+ component-libraries.yml
/config
diff --git a/apm-collector/apm-collector-boot/src/main/java/org/apache/skywalking/apm/collector/boot/CollectorBootStartUp.java b/apm-collector/apm-collector-boot/src/main/java/org/apache/skywalking/apm/collector/boot/CollectorBootStartUp.java
index f130f31884c75d568eb87e143cebceb0bd787140..ff9dd5a240d9dd4d056b0a8fee10f0ee61ba9bd6 100644
--- a/apm-collector/apm-collector-boot/src/main/java/org/apache/skywalking/apm/collector/boot/CollectorBootStartUp.java
+++ b/apm-collector/apm-collector-boot/src/main/java/org/apache/skywalking/apm/collector/boot/CollectorBootStartUp.java
@@ -44,6 +44,7 @@ public class CollectorBootStartUp {
manager.init(applicationConfiguration);
} catch (ConfigFileNotFoundException | ModuleNotFoundException | ProviderNotFoundException | ServiceNotProvidedException | ModuleConfigException e) {
logger.error(e.getMessage(), e);
+ System.exit(1);
}
}
}
diff --git a/apm-collector/apm-collector-boot/src/main/resources/component-libraries.yml b/apm-collector/apm-collector-boot/src/main/resources/component-libraries.yml
new file mode 100644
index 0000000000000000000000000000000000000000..3b0069219bc250683384cbc509055b80ab40b17f
--- /dev/null
+++ b/apm-collector/apm-collector-boot/src/main/resources/component-libraries.yml
@@ -0,0 +1,130 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Define all component libraries' names and IDs, used in monitored application.
+# This is a bothway mapping, agent or SDK could use the value(ID) to represent the component name in uplink data.
+#
+# ######
+# id
+# ######
+# We highly recommend DO NOT change the IDs in these file, just append new one, and make sure the ID unique.
+# Any replacement will cause visualization and aggregation error.
+#
+# All IDs in this files are reserved, even some IDs removed by some reasons, those IDs will be abandoned.
+#
+# ######
+# languages
+# ######
+# Languages declare which languages are using this component. Multi languages should be separated by `,`
+
+Tomcat:
+ id: 1
+ languages: Java
+HttpClient:
+ id: 2
+ languages: Java
+Dubbo:
+ id: 3
+ languages: Java
+H2:
+ id: 4
+ languages: Java
+Mysql:
+ id: 5
+ languages: Java
+ORACLE:
+ id: 6
+ languages: Java
+Redis:
+ id: 7
+ languages: Java
+Motan:
+ id: 8
+ languages: Java
+MongoDB:
+ id: 9
+ languages: Java
+Resin:
+ id: 10
+ languages: Java
+Feign:
+ id: 11
+ languages: Java
+OKHttp:
+ id: 12
+ languages: Java
+SpringRestTemplate:
+ id: 13
+ languages: Java
+SpringMVC:
+ id: 14
+ languages: Java
+Struts2:
+ id: 15
+ languages: Java
+NutzMVC:
+ id: 16
+ languages: Java
+NutzHttp:
+ id: 17
+ languages: Java
+JettyClient:
+ id: 18
+ languages: Java
+JettyServer:
+ id: 19
+ languages: Java
+Memcached:
+ id: 20
+ languages: Java
+ShardingJDBC:
+ id: 21
+ languages: Java
+PostgreSQL:
+ id: 22
+ languages: Java
+GRPC:
+ id: 23
+ languages: Java
+ElasticJob:
+ id: 24
+ languages: Java
+RocketMQ:
+ id: 25
+ languages: Java
+httpasyncclient:
+ id: 26
+ languages: Java
+Kafka:
+ id: 27
+ languages: Java
+ServiceComb:
+ id: 28
+ languages: Java
+Hystrix:
+ id: 29
+ languages: Java
+Jedis:
+ id: 30
+ languages: Java
+
+
+# Component Server mapping defines the server display names of some components
+# e.g.
+# Jedis is a client library in Java for Redis server
+Component-Server-Mappings:
+ Jedis: Redis
+
diff --git a/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModule.java b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModule.java
index c4be55fef830670329b87568b610eef293213cc1..18ede2260d99a70aa7f6ebb1ccdefed269b441cf 100644
--- a/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModule.java
+++ b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModule.java
@@ -22,6 +22,7 @@ import org.apache.skywalking.apm.collector.configuration.service.IApdexThreshold
import org.apache.skywalking.apm.collector.configuration.service.IApplicationAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.IApplicationReferenceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.ICollectorConfig;
+import org.apache.skywalking.apm.collector.configuration.service.IComponentLibraryCatalogService;
import org.apache.skywalking.apm.collector.configuration.service.IInstanceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.IInstanceReferenceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.IServiceAlarmRuleConfig;
@@ -44,6 +45,7 @@ public class ConfigurationModule extends Module {
ICollectorConfig.class,
IApdexThresholdService.class,
IServiceAlarmRuleConfig.class, IInstanceAlarmRuleConfig.class, IApplicationAlarmRuleConfig.class,
- IServiceReferenceAlarmRuleConfig.class, IInstanceReferenceAlarmRuleConfig.class, IApplicationReferenceAlarmRuleConfig.class};
+ IServiceReferenceAlarmRuleConfig.class, IInstanceReferenceAlarmRuleConfig.class, IApplicationReferenceAlarmRuleConfig.class,
+ IComponentLibraryCatalogService.class};
}
}
diff --git a/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IComponentLibraryCatalogService.java b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IComponentLibraryCatalogService.java
new file mode 100644
index 0000000000000000000000000000000000000000..e074c9e5a024522cd3a1f2d6e1fa58677e6d268f
--- /dev/null
+++ b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IComponentLibraryCatalogService.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.collector.configuration.service;
+
+import org.apache.skywalking.apm.collector.core.module.Service;
+
+/**
+ * @author wusheng
+ */
+public interface IComponentLibraryCatalogService extends Service {
+ int getComponentId(String componentName);
+
+ int getServerIdBasedOnComponent(int componentId);
+
+ String getComponentName(int componentId);
+
+ String getServerName(int componentServerId);
+}
diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ServerType.java b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/InitialComponentCatalogException.java
similarity index 61%
rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ServerType.java
rename to apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/InitialComponentCatalogException.java
index b7b71a22b68e1c89ed1bf42e64ad5c70e11f25c4..78859a51fb87f12ffb127441175d27f1bd52ec59 100644
--- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ServerType.java
+++ b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/InitialComponentCatalogException.java
@@ -16,31 +16,13 @@
*
*/
-package org.apache.skywalking.apm.collector.storage.table.register;
+package org.apache.skywalking.apm.collector.configuration.service;
/**
- * @author peng-yongsheng
+ * @author wusheng
*/
-public class ServerType {
- private int componentId;
- private int id;
- private String name;
-
- public ServerType(int componentId, int id, String name) {
- this.componentId = componentId;
- this.id = id;
- this.name = name;
- }
-
- public int getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public int getComponentId() {
- return componentId;
+public class InitialComponentCatalogException extends RuntimeException {
+ public InitialComponentCatalogException(String message) {
+ super(message);
}
}
diff --git a/apm-collector/apm-collector-configuration/collector-configuration-provider/pom.xml b/apm-collector/apm-collector-configuration/collector-configuration-provider/pom.xml
index 57dd1d343353b9567a46375275f39741ede47f42..964fe175f6cf069f8a81a66f395073136f723f66 100644
--- a/apm-collector/apm-collector-configuration/collector-configuration-provider/pom.xml
+++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/pom.xml
@@ -35,5 +35,10 @@
collector-configuration-define
${project.version}
+
+
+ org.yaml
+ snakeyaml
+
diff --git a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModuleProvider.java b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModuleProvider.java
index 382f56bdb660f12a5beb40885bc8701bb113bc22..108926b879112bc5f0a4c4e0057b8202a3263ac7 100644
--- a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModuleProvider.java
+++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModuleProvider.java
@@ -22,10 +22,12 @@ import org.apache.skywalking.apm.collector.configuration.service.ApdexThresholdS
import org.apache.skywalking.apm.collector.configuration.service.ApplicationAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.ApplicationReferenceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.CollectorConfigService;
+import org.apache.skywalking.apm.collector.configuration.service.ComponentLibraryCatalogService;
import org.apache.skywalking.apm.collector.configuration.service.IApdexThresholdService;
import org.apache.skywalking.apm.collector.configuration.service.IApplicationAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.IApplicationReferenceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.ICollectorConfig;
+import org.apache.skywalking.apm.collector.configuration.service.IComponentLibraryCatalogService;
import org.apache.skywalking.apm.collector.configuration.service.IInstanceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.IInstanceReferenceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.IServiceAlarmRuleConfig;
@@ -76,6 +78,7 @@ public class ConfigurationModuleProvider extends ModuleProvider {
Integer applicationAverageResponseTimeThreshold = config.getApplicationAverageResponseTimeThreshold() == 0 ? 2000 : config.getApplicationAverageResponseTimeThreshold();
this.registerServiceImplementation(ICollectorConfig.class, new CollectorConfigService(namespace));
+ this.registerServiceImplementation(IComponentLibraryCatalogService.class, new ComponentLibraryCatalogService());
this.registerServiceImplementation(IApdexThresholdService.class, new ApdexThresholdService(applicationApdexThreshold));
this.registerServiceImplementation(IServiceAlarmRuleConfig.class, new ServiceAlarmRuleConfig(serviceErrorRateThreshold, serviceAverageResponseTimeThreshold));
this.registerServiceImplementation(IInstanceAlarmRuleConfig.class, new InstanceAlarmRuleConfig(instanceErrorRateThreshold, instanceAverageResponseTimeThreshold));
diff --git a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ComponentLibraryCatalogService.java b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ComponentLibraryCatalogService.java
new file mode 100644
index 0000000000000000000000000000000000000000..00438513b9fbd6be890acbe18d27ecc35b638dc7
--- /dev/null
+++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ComponentLibraryCatalogService.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.collector.configuration.service;
+
+import java.io.FileNotFoundException;
+import java.io.Reader;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.skywalking.apm.collector.core.util.ResourceUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * Load settings from component-libraries.yml
+ * this file includes all component defines, and the component mappings, which declare the real server type based on client component.
+ *
+ * @author wusheng
+ */
+public class ComponentLibraryCatalogService implements IComponentLibraryCatalogService {
+ private static final Logger logger = LoggerFactory.getLogger(ComponentLibraryCatalogService.class);
+ private static final String COMPONENT_SERVER_MAPPING_SECTION = "Component-Server-Mappings";
+
+ private Map componentName2Id;
+ private Map componentId2Name;
+ private Map componentId2ServerId;
+
+ public ComponentLibraryCatalogService() throws InitialComponentCatalogException {
+ init();
+ }
+
+ @Override
+ public int getComponentId(String componentName) {
+ return componentName2Id.get(componentName);
+ }
+
+ @Override
+ public int getServerIdBasedOnComponent(int componentId) {
+ Integer serverComponentId = componentId2ServerId.get(componentId);
+ return serverComponentId == null ? componentId : serverComponentId;
+ }
+
+ @Override
+ public String getComponentName(int componentId) {
+ String componentName = componentId2Name.get(componentId);
+
+ return componentName == null ? componentId2Name.get(0) : componentName;
+ }
+
+ @Override
+ public String getServerName(int componentServerId) {
+ return getComponentName(componentServerId);
+ }
+
+ private void init() throws InitialComponentCatalogException {
+ componentName2Id = new HashMap<>();
+ componentName2Id.put("N/A", 0);
+ componentId2Name = new HashMap<>();
+ componentId2Name.put(0, "N/A");
+ componentId2ServerId = new HashMap<>();
+
+ Map nameMapping = new HashMap<>();
+ try {
+ Reader applicationReader = ResourceUtils.read("component-libraries.yml");
+ Yaml yaml = new Yaml();
+ Map map = yaml.loadAs(applicationReader, Map.class);
+
+ map.forEach((componentName, settingCollection) -> {
+ Map settings = (Map)settingCollection;
+ if (COMPONENT_SERVER_MAPPING_SECTION.equals(componentName)) {
+ settings.forEach((name, serverName) -> {
+ nameMapping.put((String)name, (String)serverName);
+ });
+ } else {
+ Integer componentId = (Integer)settings.get("id");
+ componentName2Id.put((String)componentName, componentId);
+ componentId2Name.put(componentId, (String)componentName);
+ }
+ });
+
+ nameMapping.forEach((name, serverName) -> {
+ if (!componentName2Id.containsKey(name)) {
+ throw new InitialComponentCatalogException("Component name [" + name + "] in Component-Server-Mappings doesn't exist in component define. ");
+ }
+ if (!componentName2Id.containsKey(serverName)) {
+ throw new InitialComponentCatalogException("Server component name [" + serverName + "] in Component-Server-Mappings doesn't exist in component define. ");
+ }
+
+ componentId2ServerId.put(componentName2Id.get(name), componentName2Id.get(serverName));
+ });
+ nameMapping.clear();
+ } catch (FileNotFoundException e) {
+ logger.error("component-libraries.yml not found.", e);
+ }
+
+ }
+}
diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/test/java/org/apache/skywalking/apm/collector/storage/table/register/ServerTypeDefineTestCase.java b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/test/java/org/apache/skywalking/apm/collector/configuration/service/ComponentLibraryCatalogServiceTest.java
similarity index 52%
rename from apm-collector/apm-collector-storage/collector-storage-define/src/test/java/org/apache/skywalking/apm/collector/storage/table/register/ServerTypeDefineTestCase.java
rename to apm-collector/apm-collector-configuration/collector-configuration-provider/src/test/java/org/apache/skywalking/apm/collector/configuration/service/ComponentLibraryCatalogServiceTest.java
index 015eff79b0c5ce0c16ff67e7ec854feee3d4b714..a8ff28d2eecde45e061c53bafaecf3c73e288345 100644
--- a/apm-collector/apm-collector-storage/collector-storage-define/src/test/java/org/apache/skywalking/apm/collector/storage/table/register/ServerTypeDefineTestCase.java
+++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/test/java/org/apache/skywalking/apm/collector/configuration/service/ComponentLibraryCatalogServiceTest.java
@@ -16,27 +16,21 @@
*
*/
-package org.apache.skywalking.apm.collector.storage.table.register;
+package org.apache.skywalking.apm.collector.configuration.service;
-import java.lang.reflect.Field;
-import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
-import org.apache.skywalking.apm.network.trace.component.OfficialComponent;
+import org.junit.Assert;
import org.junit.Test;
/**
- * @author peng-yongsheng
+ * @author wusheng
*/
-public class ServerTypeDefineTestCase {
-
+public class ComponentLibraryCatalogServiceTest {
@Test
- public void check() throws IllegalAccessException {
- Field[] fields = ComponentsDefine.class.getDeclaredFields();
-
- for (Field field : fields) {
- if (field.getType().equals(OfficialComponent.class)) {
- OfficialComponent component = (OfficialComponent)field.get(ComponentsDefine.getInstance());
- ServerTypeDefine.getInstance().getServerTypeId(component.getId());
- }
- }
+ public void testInitAndSettings() {
+ ComponentLibraryCatalogService service = new ComponentLibraryCatalogService();
+ Assert.assertEquals(1, service.getComponentId("Tomcat"));
+ Assert.assertEquals(7, service.getServerIdBasedOnComponent(30));
+ Assert.assertEquals(21, service.getServerIdBasedOnComponent(21));
+ Assert.assertEquals("Jedis", service.getServerName(30));
}
}
diff --git a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/test/resources/component-libraries.yml b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/test/resources/component-libraries.yml
new file mode 100644
index 0000000000000000000000000000000000000000..267c0d462331b935b38a1f1b827313e1d66cdc3e
--- /dev/null
+++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/test/resources/component-libraries.yml
@@ -0,0 +1,134 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+##########################################
+# This is only a test case define file
+##########################################
+
+# Define all component libraries' names and IDs, used in monitored application.
+# This is a bothway mapping, agent or SDK could use the value(ID) to represent the component name in uplink data.
+#
+# ######
+# id
+# ######
+# We highly recommend DO NOT change the IDs in these file, just append new one, and make sure the ID unique.
+# Any replacement will cause visualization and aggregation error.
+#
+# All IDs in this files are reserved, even some IDs removed by some reasons, those IDs will be abandoned.
+#
+# ######
+# languages
+# ######
+# Languages declare which languages are using this component. Multi languages should be separated by `,`
+
+Tomcat:
+ id: 1
+ languages: Java
+HttpClient:
+ id: 2
+ languages: Java
+Dubbo:
+ id: 3
+ languages: Java
+H2:
+ id: 4
+ languages: Java
+Mysql:
+ id: 5
+ languages: Java
+ORACLE:
+ id: 6
+ languages: Java
+Redis:
+ id: 7
+ languages: Java
+Motan:
+ id: 8
+ languages: Java
+MongoDB:
+ id: 9
+ languages: Java
+Resin:
+ id: 10
+ languages: Java
+Feign:
+ id: 11
+ languages: Java
+OKHttp:
+ id: 12
+ languages: Java
+SpringRestTemplate:
+ id: 13
+ languages: Java
+SpringMVC:
+ id: 14
+ languages: Java
+Struts2:
+ id: 15
+ languages: Java
+NutzMVC:
+ id: 16
+ languages: Java
+NutzHttp:
+ id: 17
+ languages: Java
+JettyClient:
+ id: 18
+ languages: Java
+JettyServer:
+ id: 19
+ languages: Java
+Memcached:
+ id: 20
+ languages: Java
+ShardingJDBC:
+ id: 21
+ languages: Java
+PostgreSQL:
+ id: 22
+ languages: Java
+GRPC:
+ id: 23
+ languages: Java
+ElasticJob:
+ id: 24
+ languages: Java
+RocketMQ:
+ id: 25
+ languages: Java
+httpasyncclient:
+ id: 26
+ languages: Java
+Kafka:
+ id: 27
+ languages: Java
+ServiceComb:
+ id: 28
+ languages: Java
+Hystrix:
+ id: 29
+ languages: Java
+Jedis:
+ id: 30
+ languages: Java
+
+
+# Component Server mapping defines the server display names of some components
+# e.g.
+# Jedis is a client library in Java for Redis server
+Component-Server-Mappings:
+ Jedis: Redis
+
diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ServerTypeDefine.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ServerTypeDefine.java
deleted file mode 100644
index 61a91fb667215187d7b58244615cdfbff85dacbd..0000000000000000000000000000000000000000
--- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ServerTypeDefine.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.skywalking.apm.collector.storage.table.register;
-
-import org.apache.skywalking.apm.collector.core.util.Const;
-import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
-
-/**
- * @author peng-yongsheng
- */
-public class ServerTypeDefine {
-
- private static ServerTypeDefine INSTANCE = new ServerTypeDefine();
-
- private String[] serverTypeNames;
- private ServerType[] serverTypes;
-
- private ServerTypeDefine() {
- this.serverTypes = new ServerType[30];
- this.serverTypeNames = new String[11];
- addServerType(new ServerType(ComponentsDefine.TOMCAT.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.HTTPCLIENT.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.DUBBO.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.H2.getId(), 1, ComponentsDefine.H2.getName()));
- addServerType(new ServerType(ComponentsDefine.MYSQL.getId(), 2, ComponentsDefine.MYSQL.getName()));
- addServerType(new ServerType(ComponentsDefine.ORACLE.getId(), 3, ComponentsDefine.ORACLE.getName()));
- addServerType(new ServerType(ComponentsDefine.REDIS.getId(), 4, ComponentsDefine.REDIS.getName()));
- addServerType(new ServerType(ComponentsDefine.MOTAN.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.MONGODB.getId(), 5, ComponentsDefine.MONGODB.getName()));
- addServerType(new ServerType(ComponentsDefine.RESIN.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.FEIGN.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.OKHTTP.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.SPRING_REST_TEMPLATE.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.SPRING_MVC_ANNOTATION.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.STRUTS2.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.NUTZ_MVC_ANNOTATION.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.NUTZ_HTTP.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.JETTY_CLIENT.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.JETTY_SERVER.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.MEMCACHED.getId(), 6, ComponentsDefine.MEMCACHED.getName()));
- addServerType(new ServerType(ComponentsDefine.SHARDING_JDBC.getId(), 7, ComponentsDefine.SHARDING_JDBC.getName()));
- addServerType(new ServerType(ComponentsDefine.POSTGRESQL.getId(), 8, ComponentsDefine.POSTGRESQL.getName()));
- addServerType(new ServerType(ComponentsDefine.GRPC.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.ELASTIC_JOB.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.ROCKET_MQ.getId(), 9, ComponentsDefine.ROCKET_MQ.getName()));
- addServerType(new ServerType(ComponentsDefine.HTTP_ASYNC_CLIENT.getId(), Const.NONE, Const.EMPTY_STRING));
- addServerType(new ServerType(ComponentsDefine.KAFKA.getId(), 10, ComponentsDefine.KAFKA.getName()));
- addServerType(new ServerType(ComponentsDefine.SERVICECOMB.getId(), Const.NONE, ComponentsDefine.SERVICECOMB.getName()));
- addServerType(new ServerType(ComponentsDefine.HYSTRIX.getId(), Const.NONE, ComponentsDefine.HYSTRIX.getName()));
- }
-
- public static ServerTypeDefine getInstance() {
- return INSTANCE;
- }
-
- private void addServerType(ServerType serverType) {
- serverTypeNames[serverType.getId()] = serverType.getName();
- serverTypes[serverType.getComponentId()] = serverType;
- }
-
- public int getServerTypeId(int componentId) {
- return serverTypes[componentId].getId();
- }
-
- public String getServerType(int serverTypeId) {
- return serverTypeNames[serverTypeId];
- }
-}
diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/pom.xml b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/pom.xml
index 09d44ad9076ba6c66ed7262aac0146c322724515..4336de59ee5a80a8213d300063df4e00d2a02596 100644
--- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/pom.xml
+++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/pom.xml
@@ -30,6 +30,11 @@
jar
+
+ org.apache.skywalking
+ collector-configuration-define
+ ${project.version}
+
org.apache.skywalking
collector-ui-define
diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java
index aedac37e2315439500d7996ddda35359bf23a096..c66a5c6eb805de5ca57f5c2361ff7ae4e15871ec 100644
--- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java
+++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java
@@ -22,6 +22,7 @@ import org.apache.skywalking.apm.collector.cache.CacheModule;
import org.apache.skywalking.apm.collector.cluster.ClusterModule;
import org.apache.skywalking.apm.collector.cluster.service.ModuleListenerService;
import org.apache.skywalking.apm.collector.cluster.service.ModuleRegisterService;
+import org.apache.skywalking.apm.collector.configuration.ConfigurationModule;
import org.apache.skywalking.apm.collector.core.module.Module;
import org.apache.skywalking.apm.collector.core.module.ModuleConfig;
import org.apache.skywalking.apm.collector.core.module.ModuleProvider;
@@ -84,7 +85,7 @@ public class UIModuleJettyProvider extends ModuleProvider {
}
@Override public String[] requiredModules() {
- return new String[] {ClusterModule.NAME, JettyManagerModule.NAME, NamingModule.NAME, CacheModule.NAME, StorageModule.NAME};
+ return new String[] {ConfigurationModule.NAME, ClusterModule.NAME, JettyManagerModule.NAME, NamingModule.NAME, CacheModule.NAME, StorageModule.NAME};
}
private void addHandlers(JettyServer jettyServer) {
diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java
index 8205a5ce343459e31dd66b98a03982053a418e8e..95828f84233a0b220a4f913b73f6050c13f31629 100644
--- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java
+++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java
@@ -23,6 +23,8 @@ import java.util.List;
import org.apache.skywalking.apm.collector.cache.CacheModule;
import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService;
+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.Const;
import org.apache.skywalking.apm.collector.storage.StorageModule;
@@ -31,7 +33,6 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
-import org.apache.skywalking.apm.collector.storage.table.register.ServerTypeDefine;
import org.apache.skywalking.apm.collector.storage.table.register.ServiceName;
import org.apache.skywalking.apm.collector.storage.ui.application.Application;
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
@@ -57,6 +58,7 @@ public class ApplicationService {
private final ApplicationCacheService applicationCacheService;
private final ServiceNameCacheService serviceNameCacheService;
private final SecondBetweenService secondBetweenService;
+ private final IComponentLibraryCatalogService componentLibraryCatalogService;
public ApplicationService(ModuleManager moduleManager) {
this.instanceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class);
@@ -65,6 +67,7 @@ public class ApplicationService {
this.networkAddressUIDAO = moduleManager.find(StorageModule.NAME).getService(INetworkAddressUIDAO.class);
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class);
+ this.componentLibraryCatalogService = moduleManager.find(ConfigurationModule.NAME).getService(IComponentLibraryCatalogService.class);
this.secondBetweenService = new SecondBetweenService(moduleManager);
}
@@ -117,7 +120,7 @@ public class ApplicationService {
long endSecondTimeBucket) throws ParseException {
List conjecturalApps = networkAddressUIDAO.getConjecturalApps();
conjecturalApps.forEach(conjecturalApp -> {
- String serverType = ServerTypeDefine.getInstance().getServerType(conjecturalApp.getId());
+ String serverType = componentLibraryCatalogService.getServerName(conjecturalApp.getId());
conjecturalApp.setName(serverType);
});
diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java
index 86fc10e8b97b0dc885c3fde5b14a0a3c8a0d6c20..b24fef8553e490f4d964dc023d05886d5c6b7c2c 100644
--- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java
+++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java
@@ -24,6 +24,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+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.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO;
@@ -33,7 +35,6 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceM
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
import org.apache.skywalking.apm.collector.storage.ui.common.Topology;
-import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,6 +49,7 @@ public class ApplicationTopologyService {
private final IApplicationMappingUIDAO applicationMappingUIDAO;
private final IApplicationMetricUIDAO applicationMetricUIDAO;
private final IApplicationReferenceMetricUIDAO applicationReferenceMetricUIDAO;
+ private final IComponentLibraryCatalogService componentLibraryCatalogService;
private final ModuleManager moduleManager;
public ApplicationTopologyService(ModuleManager moduleManager) {
@@ -56,6 +58,7 @@ public class ApplicationTopologyService {
this.applicationMappingUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMappingUIDAO.class);
this.applicationMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMetricUIDAO.class);
this.applicationReferenceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationReferenceMetricUIDAO.class);
+ this.componentLibraryCatalogService = moduleManager.find(ConfigurationModule.NAME).getService(IComponentLibraryCatalogService.class);
}
public Topology getApplicationTopology(Step step, int applicationId, long startTimeBucket,
@@ -73,7 +76,7 @@ public class ApplicationTopologyService {
});
Map components = new HashMap<>();
- applicationComponents.forEach(component -> components.put(component.getApplicationId(), ComponentsDefine.getInstance().getComponentName(component.getComponentId())));
+ applicationComponents.forEach(component -> components.put(component.getApplicationId(), this.componentLibraryCatalogService.getComponentName(component.getComponentId())));
List applicationMetrics = applicationMetricUIDAO.getApplications(step, startTimeBucket, endTimeBucket, MetricSource.Callee);
diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ClusterTopologyService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ClusterTopologyService.java
index bb00355b0ed4095f22401640876ae5ea1271bad8..372f15b28952a71fc0b80b4026b408ce54cbb7ca 100644
--- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ClusterTopologyService.java
+++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ClusterTopologyService.java
@@ -22,6 +22,8 @@ import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+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.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO;
@@ -31,7 +33,6 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceM
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
import org.apache.skywalking.apm.collector.storage.ui.common.Topology;
-import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,6 +47,7 @@ public class ClusterTopologyService {
private final IApplicationMappingUIDAO applicationMappingUIDAO;
private final IApplicationMetricUIDAO applicationMetricUIDAO;
private final IApplicationReferenceMetricUIDAO applicationReferenceMetricUIDAO;
+ private final IComponentLibraryCatalogService componentLibraryCatalogService;
private final ModuleManager moduleManager;
public ClusterTopologyService(ModuleManager moduleManager) {
@@ -54,6 +56,7 @@ public class ClusterTopologyService {
this.applicationMappingUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMappingUIDAO.class);
this.applicationMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMetricUIDAO.class);
this.applicationReferenceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationReferenceMetricUIDAO.class);
+ this.componentLibraryCatalogService = moduleManager.find(ConfigurationModule.NAME).getService(IComponentLibraryCatalogService.class);
}
public Topology getClusterTopology(Step step, long startTimeBucket, long endTimeBucket, long startSecondTimeBucket,
@@ -63,7 +66,7 @@ public class ClusterTopologyService {
List applicationMappings = applicationMappingUIDAO.load(step, startTimeBucket, endTimeBucket);
Map components = new HashMap<>();
- applicationComponents.forEach(component -> components.put(component.getApplicationId(), ComponentsDefine.getInstance().getComponentName(component.getComponentId())));
+ applicationComponents.forEach(component -> components.put(component.getApplicationId(), this.componentLibraryCatalogService.getComponentName(component.getComponentId())));
List applicationMetrics = applicationMetricUIDAO.getApplications(step, startTimeBucket, endTimeBucket, MetricSource.Callee);
diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTopologyService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTopologyService.java
index 985e6bb4df0ec0c734543ea105643957b0656204..296bebc8e5c2c48b0eff4a837f7a23aae20331ea 100644
--- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTopologyService.java
+++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTopologyService.java
@@ -27,6 +27,8 @@ import java.util.Map;
import java.util.Set;
import org.apache.skywalking.apm.collector.cache.CacheModule;
import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService;
+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.Const;
import org.apache.skywalking.apm.collector.storage.StorageModule;
@@ -40,7 +42,6 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Node;
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
import org.apache.skywalking.apm.collector.storage.ui.common.Topology;
import org.apache.skywalking.apm.collector.storage.ui.common.VisualUserNode;
-import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,6 +57,7 @@ public class ServiceTopologyService {
private final IServiceReferenceMetricUIDAO serviceReferenceMetricUIDAO;
private final ServiceNameCacheService serviceNameCacheService;
private final SecondBetweenService secondBetweenService;
+ private final IComponentLibraryCatalogService componentLibraryCatalogService;
public ServiceTopologyService(ModuleManager moduleManager) {
this.serviceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IServiceMetricUIDAO.class);
@@ -63,6 +65,7 @@ public class ServiceTopologyService {
this.applicationComponentUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationComponentUIDAO.class);
this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class);
this.secondBetweenService = new SecondBetweenService(moduleManager);
+ this.componentLibraryCatalogService = moduleManager.find(ConfigurationModule.NAME).getService(IComponentLibraryCatalogService.class);
}
public Topology getServiceTopology(Step step, int serviceId, long startTimeBucket,
@@ -71,7 +74,7 @@ public class ServiceTopologyService {
List applicationComponents = applicationComponentUIDAO.load(step, startTimeBucket, endTimeBucket);
Map components = new HashMap<>();
- applicationComponents.forEach(component -> components.put(component.getApplicationId(), ComponentsDefine.getInstance().getComponentName(component.getComponentId())));
+ applicationComponents.forEach(component -> components.put(component.getApplicationId(), this.componentLibraryCatalogService.getComponentName(component.getComponentId())));
List referenceMetrics = serviceReferenceMetricUIDAO.getFrontServices(step, startTimeBucket, endTimeBucket, MetricSource.Callee, serviceId);
referenceMetrics.addAll(serviceReferenceMetricUIDAO.getBehindServices(step, startTimeBucket, endTimeBucket, MetricSource.Caller, serviceId));
diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java
index c149778fefb7e21f0061bab3b42864444e65b926..0d4f26fbf688167437aeb93577872245c378ec7d 100644
--- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java
+++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java
@@ -24,6 +24,8 @@ import java.util.List;
import org.apache.skywalking.apm.collector.cache.CacheModule;
import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService;
+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.StringUtils;
import org.apache.skywalking.apm.collector.storage.StorageModule;
@@ -33,7 +35,6 @@ import org.apache.skywalking.apm.network.proto.KeyWithStringValue;
import org.apache.skywalking.apm.network.proto.LogMessage;
import org.apache.skywalking.apm.network.proto.SpanObject;
import org.apache.skywalking.apm.network.proto.TraceSegmentObject;
-import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
/**
* @author peng-yongsheng
@@ -43,11 +44,13 @@ public class SpanService {
private final ISegmentUIDAO segmentDAO;
private final ServiceNameCacheService serviceNameCacheService;
private final ApplicationCacheService applicationCacheService;
+ private final IComponentLibraryCatalogService componentLibraryCatalogService;
public SpanService(ModuleManager moduleManager) {
this.segmentDAO = moduleManager.find(StorageModule.NAME).getService(ISegmentUIDAO.class);
this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class);
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
+ this.componentLibraryCatalogService = moduleManager.find(ConfigurationModule.NAME).getService(IComponentLibraryCatalogService.class);
}
public JsonObject load(String segmentId, int spanId) {
@@ -98,7 +101,7 @@ public class SpanService {
if (spanObject.getComponentId() == 0) {
componentJson.addProperty("value", spanObject.getComponent());
} else {
- componentJson.addProperty("value", ComponentsDefine.getInstance().getComponentName(spanObject.getComponentId()));
+ componentJson.addProperty("value", this.componentLibraryCatalogService.getComponentName(spanObject.getComponentId()));
}
tagsArray.add(componentJson);
diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java
index 0a4ed183c271c9b039bcd503fdba3dee2467101d..3a3357f579e72b452cbd6fbdd14a882a56419598 100644
--- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java
+++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java
@@ -27,6 +27,8 @@ import java.util.Map;
import java.util.Set;
import org.apache.skywalking.apm.collector.cache.CacheModule;
import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
+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.BooleanUtils;
import org.apache.skywalking.apm.collector.core.util.Const;
@@ -45,7 +47,6 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Topology;
import org.apache.skywalking.apm.collector.storage.ui.common.VisualUserNode;
import org.apache.skywalking.apm.collector.ui.utils.ApdexCalculator;
import org.apache.skywalking.apm.collector.ui.utils.SLACalculator;
-import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,12 +61,14 @@ class TopologyBuilder {
private final ServerService serverService;
private final SecondBetweenService secondBetweenService;
private final AlarmService alarmService;
+ private final IComponentLibraryCatalogService componentLibraryCatalogService;
TopologyBuilder(ModuleManager moduleManager) {
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
this.serverService = new ServerService(moduleManager);
this.secondBetweenService = new SecondBetweenService(moduleManager);
this.alarmService = new AlarmService(moduleManager);
+ this.componentLibraryCatalogService = moduleManager.find(ConfigurationModule.NAME).getService(IComponentLibraryCatalogService.class);
}
Topology build(List applicationComponents,
@@ -256,7 +259,7 @@ class TopologyBuilder {
List applicationComponents) {
Map components = new HashMap<>();
applicationComponents.forEach(applicationComponent -> {
- String componentName = ComponentsDefine.getInstance().getComponentName(applicationComponent.getComponentId());
+ String componentName = this.componentLibraryCatalogService.getComponentName(applicationComponent.getComponentId());
components.put(applicationComponent.getApplicationId(), componentName);
});
return components;
diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java
index 9c5364ad10ab8671e7174fcda7a376faa9325207..21fb3ff6172649503fb54a404660231b2f6e3aa7 100644
--- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java
+++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java
@@ -25,6 +25,8 @@ import org.apache.skywalking.apm.collector.cache.CacheModule;
import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
import org.apache.skywalking.apm.collector.cache.service.NetworkAddressCacheService;
import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService;
+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.CollectionUtils;
import org.apache.skywalking.apm.collector.core.util.Const;
@@ -42,7 +44,6 @@ import org.apache.skywalking.apm.collector.storage.ui.trace.Trace;
import org.apache.skywalking.apm.network.proto.SpanObject;
import org.apache.skywalking.apm.network.proto.TraceSegmentObject;
import org.apache.skywalking.apm.network.proto.UniqueId;
-import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
/**
* @author peng-yongsheng
@@ -54,6 +55,7 @@ public class TraceStackService {
private final ApplicationCacheService applicationCacheService;
private final ServiceNameCacheService serviceNameCacheService;
private final NetworkAddressCacheService networkAddressCacheService;
+ private final IComponentLibraryCatalogService componentLibraryCatalogService;
public TraceStackService(ModuleManager moduleManager) {
this.globalTraceDAO = moduleManager.find(StorageModule.NAME).getService(IGlobalTraceUIDAO.class);
@@ -61,6 +63,7 @@ public class TraceStackService {
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class);
this.networkAddressCacheService = moduleManager.find(CacheModule.NAME).getService(NetworkAddressCacheService.class);
+ this.componentLibraryCatalogService = moduleManager.find(ConfigurationModule.NAME).getService(IComponentLibraryCatalogService.class);
}
public Trace load(String traceId) {
@@ -138,7 +141,7 @@ public class TraceStackService {
if (spanObject.getComponentId() == 0) {
span.setComponent(spanObject.getComponent());
} else {
- span.setComponent(ComponentsDefine.getInstance().getComponentName(spanObject.getComponentId()));
+ span.setComponent(this.componentLibraryCatalogService.getComponentName(spanObject.getComponentId()));
}
spanObject.getRefsList().forEach(reference -> {
diff --git a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
index 40bc356f395b7eb5cfc072282ef99722a2fe23b4..2ecd1e73511bd576538903095c5af8e45adb35bd 100644
--- a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
+++ b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
@@ -128,12 +128,4 @@ public class ComponentsDefine {
private void addComponent(OfficialComponent component) {
components[component.getId()] = component.getName();
}
-
- public String getComponentName(int componentId) {
- if (componentId > components.length - 1 || componentId == 0) {
- return null;
- } else {
- return components[componentId];
- }
- }
}