提交 bd1286aa 编写于 作者: wu-sheng's avatar wu-sheng 提交者: Gao Hongtao

Refactor ServerTypeDefine and ComponentsDefine to be more extendable (#1081)

* Refactor the old ComponentDefine and ComponentsDefine to be based on file for better extenable.

* Support don't uplink componentId, but componentName in segment.

* Fix CI.

* Move component id exchange logic from SpanDecorator to SpanIdExchanger.

* Fixed the compile error cause of class construct changes.
上级 0178acce
......@@ -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>
......@@ -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();
......
......@@ -30,6 +30,11 @@
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>collector-configuration-define</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>segment-parser-define</artifactId>
......@@ -56,4 +61,4 @@
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
</project>
......@@ -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) {
......
......@@ -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<SpanDecorator> {
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<SpanDecorator> {
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<SpanDecorator> {
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);
}
}
......
......@@ -31,13 +31,6 @@
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>src/main/resources</directory>
<outputDirectory>/config</outputDirectory>
<includes>
<include>application.yml</include>
</includes>
</fileSet>
<fileSet>
<directory>src/main/assembly</directory>
<outputDirectory>/config</outputDirectory>
......@@ -50,6 +43,7 @@
<includes>
<include>application.yml</include>
<include>log4j2.xml</include>
<include>component-libraries.yml</include>
</includes>
<outputDirectory>/config</outputDirectory>
</fileSet>
......
......@@ -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);
}
}
}
# 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
......@@ -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};
}
}
/*
* 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);
}
......@@ -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);
}
}
......@@ -35,5 +35,10 @@
<artifactId>collector-configuration-define</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
</dependencies>
</project>
......@@ -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));
......
/*
* 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<String, Integer> componentName2Id;
private Map<Integer, String> componentId2Name;
private Map<Integer, Integer> 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<String, String> 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);
}
}
}
......@@ -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));
}
}
# 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
/*
* 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];
}
}
......@@ -30,6 +30,11 @@
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>collector-configuration-define</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>collector-ui-define</artifactId>
......
......@@ -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) {
......
......@@ -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<ConjecturalApp> conjecturalApps = networkAddressUIDAO.getConjecturalApps();
conjecturalApps.forEach(conjecturalApp -> {
String serverType = ServerTypeDefine.getInstance().getServerType(conjecturalApp.getId());
String serverType = componentLibraryCatalogService.getServerName(conjecturalApp.getId());
conjecturalApp.setName(serverType);
});
......
......@@ -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<Integer, String> 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<IApplicationMetricUIDAO.ApplicationMetric> applicationMetrics = applicationMetricUIDAO.getApplications(step, startTimeBucket, endTimeBucket, MetricSource.Callee);
......
......@@ -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<IApplicationMappingUIDAO.ApplicationMapping> applicationMappings = applicationMappingUIDAO.load(step, startTimeBucket, endTimeBucket);
Map<Integer, String> 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<IApplicationMetricUIDAO.ApplicationMetric> applicationMetrics = applicationMetricUIDAO.getApplications(step, startTimeBucket, endTimeBucket, MetricSource.Callee);
......
......@@ -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<IApplicationComponentUIDAO.ApplicationComponent> applicationComponents = applicationComponentUIDAO.load(step, startTimeBucket, endTimeBucket);
Map<Integer, String> 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<IServiceReferenceMetricUIDAO.ServiceReferenceMetric> referenceMetrics = serviceReferenceMetricUIDAO.getFrontServices(step, startTimeBucket, endTimeBucket, MetricSource.Callee, serviceId);
referenceMetrics.addAll(serviceReferenceMetricUIDAO.getBehindServices(step, startTimeBucket, endTimeBucket, MetricSource.Caller, serviceId));
......
......@@ -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);
......
......@@ -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<IApplicationComponentUIDAO.ApplicationComponent> applicationComponents,
......@@ -256,7 +259,7 @@ class TopologyBuilder {
List<IApplicationComponentUIDAO.ApplicationComponent> applicationComponents) {
Map<Integer, String> 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;
......
......@@ -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 -> {
......
......@@ -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];
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册