This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
commit ef42dbac08477ee36cdf484159584935daf455d1 Author: liubao <[email protected]> AuthorDate: Sun Oct 8 16:32:19 2023 +0800 [SCB-2008]remove deployment module --- core/pom.xml | 4 - coverage-reports/pom.xml | 6 - dependencies/bom/pom.xml | 7 - deployment/README.md | 13 - deployment/pom.xml | 71 ----- .../apache/servicecomb/deployment/Deployment.java | 35 --- .../servicecomb/deployment/DeploymentProvider.java | 27 -- .../deployment/SystemBootstrapInfo.java | 47 --- .../deployment/CustomDeploymentProvider.java | 48 --- .../servicecomb/deployment/TestDeployment.java | 37 --- ...pache.servicecomb.deployment.DeploymentProvider | 18 -- distribution/pom.xml | 6 - dynamic-config/config-cc/pom.xml | 4 - .../servicecomb/config/cc/ConfigCenterConfig.java | 11 +- .../cc/ConfigCenterDefaultDeploymentProvider.java | 53 ---- .../cc/ConfigCenterDynamicPropertiesSource.java | 4 +- .../cc/ConfigCenterInformationCollector.java | 18 +- ...pache.servicecomb.deployment.DeploymentProvider | 17 -- .../TestConfigCenterDefaultDeploymentProvider.java | 67 ----- dynamic-config/config-kie/pom.xml | 4 - .../KieCenterDefaultDeploymentProvider.java | 53 ---- .../kie/collect/KieClientInformationCollector.java | 19 +- ...pache.servicecomb.deployment.DeploymentProvider | 17 -- .../TestKieCenterDefaultDeploymentProvider.java | 69 ----- .../servicecomb/config/DynamicProperties.java | 4 - .../apache/servicecomb/config/TestConfigUtil.java | 335 --------------------- .../sources/TestYAMLConfigurationSource.java | 4 +- .../src/test/resources/microservice.yaml | 6 - huawei-cloud/dashboard/pom.xml | 4 - .../monitor/DefaultMonitorDataPublisher.java | 20 +- .../monitor/MonitorDefaultDeploymentProvider.java | 56 ---- .../monitor/MonitorInformationCollector.java | 22 +- ...pache.servicecomb.deployment.DeploymentProvider | 17 -- pom.xml | 1 - service-registry/registry-local/pom.xml | 4 - service-registry/registry-service-center/pom.xml | 4 - 36 files changed, 50 insertions(+), 1082 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index d0c3933a7..0b40ab80e 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -28,10 +28,6 @@ <name>Java Chassis::Core</name> <dependencies> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>deployment</artifactId> - </dependency> <dependency> <groupId>org.apache.servicecomb</groupId> <artifactId>foundation-vertx</artifactId> diff --git a/coverage-reports/pom.xml b/coverage-reports/pom.xml index 8e672de7e..6fea27342 100644 --- a/coverage-reports/pom.xml +++ b/coverage-reports/pom.xml @@ -77,12 +77,6 @@ <artifactId>java-chassis-core</artifactId> </dependency> - <!-- deployment --> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>deployment</artifactId> - </dependency> - <!-- dynamic-config --> <dependency> <groupId>org.apache.servicecomb</groupId> diff --git a/dependencies/bom/pom.xml b/dependencies/bom/pom.xml index 4268ac285..f6febb1fa 100644 --- a/dependencies/bom/pom.xml +++ b/dependencies/bom/pom.xml @@ -90,13 +90,6 @@ <version>${project.version}</version> </dependency> - <!-- ServiceComb: deployment --> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>deployment</artifactId> - <version>${project.version}</version> - </dependency> - <!-- ServiceComb: dynamic-config --> <dependency> <groupId>org.apache.servicecomb</groupId> diff --git a/deployment/README.md b/deployment/README.md deleted file mode 100644 index b2764cc0a..000000000 --- a/deployment/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# About Deployment Module - -Deployment is a mechanism to manage how microservics interact with external services. When running a microservice in a Cloud Native environment, it will interact with many external services, like service center, config center, an APM service to report tracing data, a dashboard service to report health data, etc. Deployment Service manages the meta data of these services. Deployment queries the addresses , the parameters, the authentication information of these services and so on. - -Deployment Service is some kind of service like service center, they are differ from two aspects: -1. All microservics will report their information to service center. But Deployment Service acts as a management system and knows the meta information in deploy time. -2. Service center provide some other functions like instance management and heartbeat, while Deployment Service only provides metadata query services and it is simple. - -This module does not provide a Deployment Service, it provides the interface to interacts with Deployment Service. Service providers can implement the interface. - -They are some design constraints need to be considered when implement Deployment interface: -1. Deployment can only read configurations of environment, microservics.yaml. It can not read dynamic configurations. -2. Deployment is initialized before bean initialization. diff --git a/deployment/pom.xml b/deployment/pom.xml deleted file mode 100644 index eb09e8728..000000000 --- a/deployment/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ 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. - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <groupId>org.apache.servicecomb</groupId> - <artifactId>java-chassis-parent</artifactId> - <version>3.0.0-SNAPSHOT</version> - <relativePath>../parents/default</relativePath> - </parent> - <modelVersion>4.0.0</modelVersion> - - <artifactId>deployment</artifactId> - <name>Java Chassis::Deployment</name> - - <dependencies> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>foundation-config</artifactId> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>foundation-vertx</artifactId> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>foundation-common</artifactId> - </dependency> - - <dependency> - <groupId>io.vertx</groupId> - <artifactId>vertx-codegen</artifactId> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-slf4j-impl</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>foundation-test-scaffolding</artifactId> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - </dependency> - </dependencies> -</project> diff --git a/deployment/src/main/java/org/apache/servicecomb/deployment/Deployment.java b/deployment/src/main/java/org/apache/servicecomb/deployment/Deployment.java deleted file mode 100644 index 2a35110d9..000000000 --- a/deployment/src/main/java/org/apache/servicecomb/deployment/Deployment.java +++ /dev/null @@ -1,35 +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.servicecomb.deployment; - -import java.util.List; - -import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils; - -public class Deployment { - private static final List<DeploymentProvider> providerList = SPIServiceUtils.getSortedService(DeploymentProvider.class); - - public static SystemBootstrapInfo getSystemBootStrapInfo(String systemKey) { - for (DeploymentProvider provider : providerList) { - if (provider.getSystemBootStrapInfo(systemKey) != null) { - return provider.getSystemBootStrapInfo(systemKey); - } - } - return null; - } -} diff --git a/deployment/src/main/java/org/apache/servicecomb/deployment/DeploymentProvider.java b/deployment/src/main/java/org/apache/servicecomb/deployment/DeploymentProvider.java deleted file mode 100644 index e2e5396e5..000000000 --- a/deployment/src/main/java/org/apache/servicecomb/deployment/DeploymentProvider.java +++ /dev/null @@ -1,27 +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.servicecomb.deployment; - -public interface DeploymentProvider { - - default int getOrder() { - return 100; - } - - SystemBootstrapInfo getSystemBootStrapInfo(String systemKey); -} diff --git a/deployment/src/main/java/org/apache/servicecomb/deployment/SystemBootstrapInfo.java b/deployment/src/main/java/org/apache/servicecomb/deployment/SystemBootstrapInfo.java deleted file mode 100644 index c98f93e6a..000000000 --- a/deployment/src/main/java/org/apache/servicecomb/deployment/SystemBootstrapInfo.java +++ /dev/null @@ -1,47 +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.servicecomb.deployment; - -import java.util.List; -import java.util.Map; - -public class SystemBootstrapInfo { - private List<String> accessURL; - - private Map<String, Object> properties; - - public List<String> getAccessURL() { - return accessURL; - } - - public void setAccessURL(List<String> accessURL) { - this.accessURL = accessURL; - } - - public Map<String, Object> getProperties() { - return properties; - } - - public void setProperties(Map<String, Object> properties) { - this.properties = properties; - } - - public Object getProperty(String key) { - return properties.get(key); - } -} diff --git a/deployment/src/test/java/org/apache/servicecomb/deployment/CustomDeploymentProvider.java b/deployment/src/test/java/org/apache/servicecomb/deployment/CustomDeploymentProvider.java deleted file mode 100644 index 43c0a7177..000000000 --- a/deployment/src/test/java/org/apache/servicecomb/deployment/CustomDeploymentProvider.java +++ /dev/null @@ -1,48 +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.servicecomb.deployment; - -import com.google.common.annotations.VisibleForTesting; -import org.apache.commons.configuration.AbstractConfiguration; -import org.apache.servicecomb.config.ConfigUtil; - -import java.util.Arrays; - -public class CustomDeploymentProvider implements DeploymentProvider { - private static AbstractConfiguration configuration = ConfigUtil.createLocalConfig(); - - @Override - public int getOrder() { - return 0; - } - - @Override - public SystemBootstrapInfo getSystemBootStrapInfo(String systemKey) { - if (!systemKey.equals("TestCenter")) { - return null; - } - SystemBootstrapInfo cc = new SystemBootstrapInfo(); - cc.setAccessURL(Arrays.asList("http://localhost/custom")); - return cc; - } - - @VisibleForTesting - public static void setConfiguration(AbstractConfiguration configuration) { - CustomDeploymentProvider.configuration = configuration; - } -} diff --git a/deployment/src/test/java/org/apache/servicecomb/deployment/TestDeployment.java b/deployment/src/test/java/org/apache/servicecomb/deployment/TestDeployment.java deleted file mode 100644 index 99637c4eb..000000000 --- a/deployment/src/test/java/org/apache/servicecomb/deployment/TestDeployment.java +++ /dev/null @@ -1,37 +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.servicecomb.deployment; - -import org.apache.servicecomb.config.ConfigUtil; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -public class TestDeployment { - @AfterEach - public void tearDown() { - } - - @Test - public void testConfiguration() { - CustomDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig()); - SystemBootstrapInfo info = Deployment.getSystemBootStrapInfo("TestCenter"); - Assertions.assertEquals("http://localhost/custom", info.getAccessURL().get(0)); - Assertions.assertNull(Deployment.getSystemBootStrapInfo("wrong")); - } -} diff --git a/deployment/src/test/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider b/deployment/src/test/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider deleted file mode 100644 index d07cc1e76..000000000 --- a/deployment/src/test/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider +++ /dev/null @@ -1,18 +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. -# - -org.apache.servicecomb.deployment.CustomDeploymentProvider diff --git a/distribution/pom.xml b/distribution/pom.xml index 947433068..df56de4a5 100644 --- a/distribution/pom.xml +++ b/distribution/pom.xml @@ -79,12 +79,6 @@ <artifactId>java-chassis-core</artifactId> </dependency> - <!-- deployment --> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>deployment</artifactId> - </dependency> - <!-- dynamic-config --> <dependency> <groupId>org.apache.servicecomb</groupId> diff --git a/dynamic-config/config-cc/pom.xml b/dynamic-config/config-cc/pom.xml index a841532d7..42786bce1 100644 --- a/dynamic-config/config-cc/pom.xml +++ b/dynamic-config/config-cc/pom.xml @@ -33,10 +33,6 @@ <groupId>org.apache.servicecomb</groupId> <artifactId>foundation-config</artifactId> </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>deployment</artifactId> - </dependency> <dependency> <groupId>org.apache.servicecomb</groupId> <artifactId>foundation-ssl</artifactId> diff --git a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/cc/ConfigCenterConfig.java b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/cc/ConfigCenterConfig.java index 0522f5b43..3476bb2e6 100644 --- a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/cc/ConfigCenterConfig.java +++ b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/cc/ConfigCenterConfig.java @@ -20,7 +20,7 @@ package org.apache.servicecomb.config.cc; import java.util.Collections; import java.util.List; -import org.apache.servicecomb.deployment.Deployment; +import org.apache.servicecomb.config.ConfigUtil; import org.apache.servicecomb.foundation.vertx.VertxConst; import org.springframework.core.env.Environment; @@ -33,6 +33,8 @@ public final class ConfigCenterConfig { private static final String AUTO_DISCOVERY_ENABLED = "servicecomb.service.registry.autodiscovery"; + private static final String ADDRESS = "servicecomb.config.client.serverUri"; + private static final String DOMAIN_NAME = "servicecomb.config.client.domainName"; private static final String REFRESH_INTERVAL = "servicecomb.config.client.refresh_interval"; @@ -96,11 +98,6 @@ public final class ConfigCenterConfig { } public List<String> getServerUri() { - return Deployment.getSystemBootStrapInfo(ConfigCenterDefaultDeploymentProvider.SYSTEM_KEY_CONFIG_CENTER) - .getAccessURL(); - } - - public boolean getAutoDiscoveryEnabled() { - return environment.getProperty(AUTO_DISCOVERY_ENABLED, boolean.class, false); + return ConfigUtil.parseArrayValue(environment.getProperty(ADDRESS, "")); } } diff --git a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/cc/ConfigCenterDefaultDeploymentProvider.java b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/cc/ConfigCenterDefaultDeploymentProvider.java deleted file mode 100644 index e6e836c47..000000000 --- a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/cc/ConfigCenterDefaultDeploymentProvider.java +++ /dev/null @@ -1,53 +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.servicecomb.config.cc; - -import java.util.List; - -import org.apache.commons.configuration.AbstractConfiguration; -import org.apache.servicecomb.config.ConfigUtil; -import org.apache.servicecomb.deployment.DeploymentProvider; -import org.apache.servicecomb.deployment.SystemBootstrapInfo; - -import com.google.common.annotations.VisibleForTesting; - -public class ConfigCenterDefaultDeploymentProvider implements DeploymentProvider { - public static final String SYSTEM_KEY_CONFIG_CENTER = "ConfigCenter"; - - private static AbstractConfiguration configuration = ConfigUtil.createLocalConfig(); - - @Override - public SystemBootstrapInfo getSystemBootStrapInfo(String systemKey) { - if (!systemKey.equals(SYSTEM_KEY_CONFIG_CENTER)) { - return null; - } - List<String> ccAddresses = ConfigUtil - .parseArrayValue(configuration.getString("servicecomb.config.client.serverUri")); - if (ccAddresses.isEmpty()) { - return null; - } - SystemBootstrapInfo cc = new SystemBootstrapInfo(); - cc.setAccessURL(ccAddresses); - return cc; - } - - @VisibleForTesting - public static void setConfiguration(AbstractConfiguration configuration) { - ConfigCenterDefaultDeploymentProvider.configuration = configuration; - } -} diff --git a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/cc/ConfigCenterDynamicPropertiesSource.java b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/cc/ConfigCenterDynamicPropertiesSource.java index 089741159..22de503db 100644 --- a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/cc/ConfigCenterDynamicPropertiesSource.java +++ b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/cc/ConfigCenterDynamicPropertiesSource.java @@ -37,7 +37,6 @@ import org.apache.servicecomb.config.center.client.model.QueryConfigurationsRequ import org.apache.servicecomb.config.center.client.model.QueryConfigurationsResponse; import org.apache.servicecomb.config.common.ConfigConverter; import org.apache.servicecomb.config.common.ConfigurationChangedEvent; -import org.apache.servicecomb.deployment.Deployment; import org.apache.servicecomb.foundation.auth.AuthHeaderProvider; import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx; import org.apache.servicecomb.foundation.common.event.EventManager; @@ -182,8 +181,7 @@ public class ConfigCenterDynamicPropertiesSource implements DynamicPropertiesSou private ConfigCenterAddressManager configKieAddressManager() { return new ConfigCenterAddressManager(configCenterConfig.getDomainName(), - Deployment - .getSystemBootStrapInfo(ConfigCenterDefaultDeploymentProvider.SYSTEM_KEY_CONFIG_CENTER).getAccessURL(), + configCenterConfig.getServerUri(), EventManager.getEventBus()); } diff --git a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/cc/ConfigCenterInformationCollector.java b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/cc/ConfigCenterInformationCollector.java index 76cc6fa19..e5b774129 100644 --- a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/cc/ConfigCenterInformationCollector.java +++ b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/cc/ConfigCenterInformationCollector.java @@ -18,24 +18,24 @@ package org.apache.servicecomb.config.cc; import org.apache.servicecomb.core.bootup.BootUpInformationCollector; -import org.apache.servicecomb.deployment.Deployment; -import org.apache.servicecomb.deployment.SystemBootstrapInfo; - -import java.util.Objects; +import org.springframework.beans.factory.annotation.Autowired; public class ConfigCenterInformationCollector implements BootUpInformationCollector { + private ConfigCenterConfig configCenterConfig; + + @Autowired + public void setConfigCenterConfig(ConfigCenterConfig configCenterConfig) { + this.configCenterConfig = configCenterConfig; + } + @Override public String collect() { - return "Config Center: " + getCenterInfo(Deployment.getSystemBootStrapInfo("ConfigCenter")); + return "Config Center: " + configCenterConfig.getServerUri(); } @Override public int getOrder() { return 1; } - - private String getCenterInfo(SystemBootstrapInfo systemBootstrapInfo) { - return Objects.isNull(systemBootstrapInfo) ? "not exist" : systemBootstrapInfo.getAccessURL().toString(); - } } diff --git a/dynamic-config/config-cc/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider b/dynamic-config/config-cc/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider deleted file mode 100644 index bd9118aff..000000000 --- a/dynamic-config/config-cc/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider +++ /dev/null @@ -1,17 +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. -# -org.apache.servicecomb.config.cc.ConfigCenterDefaultDeploymentProvider \ No newline at end of file diff --git a/dynamic-config/config-cc/src/test/java/org/apache/servicecomb/config/cc/TestConfigCenterDefaultDeploymentProvider.java b/dynamic-config/config-cc/src/test/java/org/apache/servicecomb/config/cc/TestConfigCenterDefaultDeploymentProvider.java deleted file mode 100644 index 51af1da3f..000000000 --- a/dynamic-config/config-cc/src/test/java/org/apache/servicecomb/config/cc/TestConfigCenterDefaultDeploymentProvider.java +++ /dev/null @@ -1,67 +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.servicecomb.config.cc; - -import org.apache.servicecomb.config.ConfigUtil; -import org.apache.servicecomb.deployment.Deployment; -import org.apache.servicecomb.deployment.SystemBootstrapInfo; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -public class TestConfigCenterDefaultDeploymentProvider { - @BeforeEach - public void start() { - } - - @AfterEach - public void tearDown() { - } - - @Test - public void testConfiguration() { - ConfigCenterDefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig()); - SystemBootstrapInfo info = Deployment.getSystemBootStrapInfo( - ConfigCenterDefaultDeploymentProvider.SYSTEM_KEY_CONFIG_CENTER); - Assertions.assertEquals("https://172.16.8.7:30103", info.getAccessURL().get(0)); - Assertions.assertNull(Deployment.getSystemBootStrapInfo("wrong")); - } - - @Test - public void testConfigurationEnv() { - System.setProperty("servicecomb.config.client.serverUri", "https://localhost:9988"); - ConfigCenterDefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig()); - SystemBootstrapInfo info = Deployment.getSystemBootStrapInfo( - ConfigCenterDefaultDeploymentProvider.SYSTEM_KEY_CONFIG_CENTER); - Assertions.assertEquals("https://localhost:9988", info.getAccessURL().get(0)); - System.getProperties().remove("servicecomb.config.client.serverUri"); - } - - @Test - public void testConfigurationEnvTwo() { - System.setProperty("servicecomb.config.client.serverUri", "https://localhost:9988,https://localhost:9987"); - ConfigCenterDefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig()); - SystemBootstrapInfo info = Deployment.getSystemBootStrapInfo( - ConfigCenterDefaultDeploymentProvider.SYSTEM_KEY_CONFIG_CENTER); - Assertions.assertEquals(2, info.getAccessURL().size()); - Assertions.assertEquals("https://localhost:9988", info.getAccessURL().get(0)); - Assertions.assertEquals("https://localhost:9987", info.getAccessURL().get(1)); - System.getProperties().remove("servicecomb.config.client.serverUri"); - } -} diff --git a/dynamic-config/config-kie/pom.xml b/dynamic-config/config-kie/pom.xml index 513c0641f..4a3a7f2cd 100644 --- a/dynamic-config/config-kie/pom.xml +++ b/dynamic-config/config-kie/pom.xml @@ -35,10 +35,6 @@ <groupId>org.apache.servicecomb</groupId> <artifactId>foundation-config</artifactId> </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>deployment</artifactId> - </dependency> <dependency> <groupId>org.apache.servicecomb</groupId> <artifactId>foundation-ssl</artifactId> diff --git a/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/collect/KieCenterDefaultDeploymentProvider.java b/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/collect/KieCenterDefaultDeploymentProvider.java deleted file mode 100644 index 9412314d4..000000000 --- a/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/collect/KieCenterDefaultDeploymentProvider.java +++ /dev/null @@ -1,53 +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.servicecomb.config.kie.collect; - -import java.util.List; - -import org.apache.commons.configuration.AbstractConfiguration; -import org.apache.servicecomb.config.ConfigUtil; -import org.apache.servicecomb.deployment.DeploymentProvider; -import org.apache.servicecomb.deployment.SystemBootstrapInfo; - -import com.google.common.annotations.VisibleForTesting; - -public class KieCenterDefaultDeploymentProvider implements DeploymentProvider { - public static final String SYSTEM_KEY_KIE_CENTER = "KieCenter"; - - private static AbstractConfiguration configuration = ConfigUtil.createLocalConfig(); - - @Override - public SystemBootstrapInfo getSystemBootStrapInfo(String systemKey) { - if (!systemKey.equals(SYSTEM_KEY_KIE_CENTER)) { - return null; - } - List<String> kieAddresses = ConfigUtil - .parseArrayValue(configuration.getString("servicecomb.kie.serverUri")); - if (kieAddresses.isEmpty()) { - return null; - } - SystemBootstrapInfo kie = new SystemBootstrapInfo(); - kie.setAccessURL(kieAddresses); - return kie; - } - - @VisibleForTesting - public static void setConfiguration(AbstractConfiguration configuration) { - KieCenterDefaultDeploymentProvider.configuration = configuration; - } -} diff --git a/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/collect/KieClientInformationCollector.java b/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/collect/KieClientInformationCollector.java index eed0c9d4c..135f0319a 100644 --- a/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/collect/KieClientInformationCollector.java +++ b/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/collect/KieClientInformationCollector.java @@ -17,25 +17,26 @@ package org.apache.servicecomb.config.kie.collect; +import org.apache.servicecomb.config.kie.KieConfig; import org.apache.servicecomb.core.bootup.BootUpInformationCollector; -import org.apache.servicecomb.deployment.Deployment; -import org.apache.servicecomb.deployment.SystemBootstrapInfo; - -import java.util.Objects; +import org.springframework.beans.factory.annotation.Autowired; public class KieClientInformationCollector implements BootUpInformationCollector { + private KieConfig kieConfig; + + @Autowired + public void setKieConfig(KieConfig kieConfig) { + this.kieConfig = kieConfig; + } + @Override public String collect() { - return "Kie Center: " + getCenterInfo(Deployment.getSystemBootStrapInfo("KieCenter")); + return "Kie Center: " + kieConfig.getServerUri(); } @Override public int getOrder() { return 2; } - - private String getCenterInfo(SystemBootstrapInfo systemBootstrapInfo) { - return Objects.isNull(systemBootstrapInfo) ? "not exist" : systemBootstrapInfo.getAccessURL().toString(); - } } diff --git a/dynamic-config/config-kie/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider b/dynamic-config/config-kie/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider deleted file mode 100644 index c712d01e3..000000000 --- a/dynamic-config/config-kie/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider +++ /dev/null @@ -1,17 +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. -# -org.apache.servicecomb.config.kie.collect.KieCenterDefaultDeploymentProvider \ No newline at end of file diff --git a/dynamic-config/config-kie/src/test/java/org/apache/servicecomb/config/kie/collect/TestKieCenterDefaultDeploymentProvider.java b/dynamic-config/config-kie/src/test/java/org/apache/servicecomb/config/kie/collect/TestKieCenterDefaultDeploymentProvider.java deleted file mode 100644 index fa659843d..000000000 --- a/dynamic-config/config-kie/src/test/java/org/apache/servicecomb/config/kie/collect/TestKieCenterDefaultDeploymentProvider.java +++ /dev/null @@ -1,69 +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.servicecomb.config.kie.collect; - -import org.apache.servicecomb.config.ConfigUtil; -import org.apache.servicecomb.deployment.Deployment; -import org.apache.servicecomb.deployment.SystemBootstrapInfo; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -public class TestKieCenterDefaultDeploymentProvider { - @BeforeEach - public void start() { - } - - @AfterEach - public void tearDown() { - } - - @Test - public void testConfiguration() { - KieCenterDefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig()); - SystemBootstrapInfo info = Deployment.getSystemBootStrapInfo( - KieCenterDefaultDeploymentProvider.SYSTEM_KEY_KIE_CENTER); - Assertions.assertEquals("https://172.16.8.7:30110", info.getAccessURL().get(0)); - Assertions.assertNull(Deployment.getSystemBootStrapInfo("wrong")); - } - - @Test - public void testConfigurationEnv() { - System.setProperty("servicecomb.kie.serverUri", "https://localhost:30110"); - KieCenterDefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig()); - SystemBootstrapInfo info = Deployment.getSystemBootStrapInfo( - KieCenterDefaultDeploymentProvider.SYSTEM_KEY_KIE_CENTER); - Assertions.assertEquals("https://localhost:30110", info.getAccessURL().get(0)); - System.getProperties().remove("servicecomb.kie.serverUri"); - } - - @Test - public void testConfigurationEnvTwo() { - System.setProperty("servicecomb.kie.serverUri", "http://127.0.0.1:30110,http://127.0.0.2:30110"); - KieCenterDefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig()); - - SystemBootstrapInfo info = Deployment.getSystemBootStrapInfo( - KieCenterDefaultDeploymentProvider.SYSTEM_KEY_KIE_CENTER); - Assertions.assertEquals(2, info.getAccessURL().size()); - Assertions.assertEquals("http://127.0.0.1:30110", info.getAccessURL().get(0)); - Assertions.assertEquals("http://127.0.0.2:30110", info.getAccessURL().get(1)); - - System.getProperties().remove("servicecomb.kie.serverUri"); - } -} diff --git a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/DynamicProperties.java b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/DynamicProperties.java index 47e060af7..58f84dd97 100644 --- a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/DynamicProperties.java +++ b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/DynamicProperties.java @@ -23,10 +23,6 @@ import java.util.function.IntConsumer; import java.util.function.LongConsumer; public interface DynamicProperties { - - DynamicProperties DEFAULT_PROPERTY_OBSERVATION = new DynamicProperties() { - }; - default String getStringProperty(String propertyName, Consumer<String> consumer, String defaultValue) { return defaultValue; } diff --git a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestConfigUtil.java b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestConfigUtil.java deleted file mode 100644 index 08c409f3e..000000000 --- a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/TestConfigUtil.java +++ /dev/null @@ -1,335 +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.servicecomb.config; - -import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; -import static org.hamcrest.CoreMatchers.equalTo; - -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.commons.configuration.AbstractConfiguration; -import org.apache.commons.configuration.Configuration; -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.core.config.Configurator; -import org.apache.servicecomb.config.spi.ConfigCenterConfigurationSource; -import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx; -import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils; -import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils; -import org.hamcrest.MatcherAssert; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.netflix.config.ConcurrentCompositeConfiguration; -import com.netflix.config.DynamicConfiguration; -import com.netflix.config.DynamicPropertyFactory; -import com.netflix.config.DynamicWatchedConfiguration; - -import mockit.Expectations; -import mockit.Mock; -import mockit.MockUp; - -import org.junit.jupiter.api.Assertions; - -public class TestConfigUtil { - private static final String systemPropertyName = "servicecomb.cse.servicecomb.system.setting"; - - private static final String systemExpected = uniquify("ran"); - - private static final String environmentPropertyName = "servicecomb.cse.servicecomb.environment.setting"; - - private static final String environmentExpected = uniquify("ran"); - - private final MapBasedConfigurationSource configurationSource = new MapBasedConfigurationSource(); - - @BeforeClass - public static void beforeTest() { - Configurator.setRootLevel(Level.OFF); - - ArchaiusUtils.resetConfig(); - - System.setProperty(systemPropertyName, systemExpected); - try { - setEnv(environmentPropertyName, environmentExpected); - setEnv("MY_SERVICES_ENDPOINT", "https://myhost:8888"); - } catch (Exception e) { - throw new IllegalStateException(e); - } - - ConfigUtil.installDynamicConfig(); - - Configurator.setRootLevel(Level.INFO); - } - - @AfterClass - public static void tearDown() { - ArchaiusUtils.resetConfig(); - } - - @Test - public void testArrayData() { - Configuration configuration = ConfigUtil.createLocalConfig(); - Assertions.assertEquals("a,b,c", configuration.getString("test.commonSeparatedString")); - Assertions.assertEquals(1, configuration.getStringArray("test.commonSeparatedString").length); - Assertions.assertEquals("a,b,c", configuration.getStringArray("test.commonSeparatedString")[0]); - - Assertions.assertEquals("b,c,d", configuration.getString("test.commonSeparatedStringHolder")); - Assertions.assertEquals(1, configuration.getStringArray("test.commonSeparatedStringHolder").length); - Assertions.assertEquals("b,c,d", configuration.getStringArray("test.commonSeparatedStringHolder")[0]); - - Assertions.assertEquals("m", configuration.getString("test.stringArray")); // first element - Assertions.assertEquals(2, configuration.getStringArray("test.stringArray").length); - Assertions.assertEquals("m", configuration.getStringArray("test.stringArray")[0]); - Assertions.assertEquals("n", configuration.getStringArray("test.stringArray")[1]); - } - - @Test - public void testAddConfig() { - Map<String, Object> config = new HashMap<>(); - config.put("service_description.name", "service_name_test"); - ConfigUtil.setConfigs(config); - ConfigUtil.addConfig("service_description.version", "1.0.2"); - ConfigUtil.addConfig("cse.test.enabled", true); - ConfigUtil.addConfig("cse.test.num", 10); - AbstractConfiguration configuration = ConfigUtil.createLocalConfig(); - Assertions.assertEquals(configuration.getString("service_description.name"), "service_name_test"); - Assertions.assertTrue(configuration.getBoolean("cse.test.enabled")); - Assertions.assertEquals(configuration.getInt("cse.test.num"), 10); - } - - @Test - public void testCreateDynamicConfigNoConfigCenterSPI() { - AbstractConfiguration dynamicConfig = ConfigUtil.createLocalConfig(); - Assertions.assertNotEquals(DynamicWatchedConfiguration.class, - ((ConcurrentCompositeConfiguration) dynamicConfig).getConfiguration(0).getClass()); - } - - @Test - public void testGetPropertyInvalidConfig() { - Assertions.assertNull(ConfigUtil.getProperty(null, "any")); - Assertions.assertNull(ConfigUtil.getProperty(new Object(), "any")); - } - - @Test - public void propertiesFromFileIsDuplicatedToCse() { - String expected = "value"; - - Assertions.assertNull(DynamicPropertyFactory - .getInstance() - .getStringProperty("cse.cse.servicecomb.file", null) - .get()); - - Assertions.assertEquals(expected, DynamicPropertyFactory - .getInstance() - .getStringProperty("servicecomb.cse.servicecomb.file", null) - .get()); - } - - @Test - public void propertiesFromSystemIsDuplicatedToCse() { - MatcherAssert.assertThat(DynamicPropertyFactory - .getInstance() - .getStringProperty(systemPropertyName, null) - .get(), - equalTo(systemExpected)); - - MatcherAssert.assertThat(DynamicPropertyFactory - .getInstance() - .getStringProperty("servicecomb.cse.servicecomb.system.setting", null) - .get(), - equalTo(systemExpected)); - } - - @Test - public void propertiesFromEnvironmentIsDuplicatedToCse() { - MatcherAssert.assertThat(DynamicPropertyFactory - .getInstance() - .getStringProperty(environmentPropertyName, null) - .get(), - equalTo(environmentExpected)); - - MatcherAssert.assertThat(DynamicPropertyFactory - .getInstance() - .getStringProperty("servicecomb.cse.servicecomb.environment.setting", null) - .get(), - equalTo(environmentExpected)); - } - - @Test - public void propertiesAddFromDynamicConfigSourceIsDuplicated() { - String expected = uniquify("ran"); - String someProperty = "cse.cse.servicecomb.add"; - - configurationSource.addProperty(someProperty, expected); - - MatcherAssert.assertThat(DynamicPropertyFactory.getInstance().getStringProperty(someProperty, null).get(), - equalTo(expected)); - - String changed = uniquify("changed"); - configurationSource.addProperty(someProperty, changed); - - MatcherAssert.assertThat(DynamicPropertyFactory.getInstance().getStringProperty(someProperty, null).get(), - equalTo(changed)); - - expected = uniquify("ran"); - someProperty = "cse.servicecomb.cse.add"; - - configurationSource.addProperty(someProperty, expected); - - MatcherAssert.assertThat(DynamicPropertyFactory.getInstance().getStringProperty(someProperty, null).get(), - equalTo(expected)); - - changed = uniquify("changed"); - configurationSource.addProperty(someProperty, changed); - - MatcherAssert.assertThat(DynamicPropertyFactory.getInstance().getStringProperty(someProperty, null).get(), - equalTo(changed)); - } - - @Test - public void propertiesChangeFromDynamicConfigSourceIsDuplicated() { - String expected = uniquify("ran"); - String someProperty = "cse.cse.servicecomb.change"; - configurationSource.addProperty(someProperty, expected); - - MatcherAssert.assertThat(DynamicPropertyFactory.getInstance().getStringProperty(someProperty, null).get(), - equalTo(expected)); - - String changed = uniquify("changed"); - configurationSource.setProperty(someProperty, changed); - - MatcherAssert.assertThat(DynamicPropertyFactory.getInstance().getStringProperty(someProperty, null).get(), - equalTo(changed)); - - expected = uniquify("ran"); - someProperty = "cse.servicecomb.cse.change"; - - configurationSource.addProperty(someProperty, expected); - MatcherAssert.assertThat(DynamicPropertyFactory.getInstance().getStringProperty(someProperty, null).get(), - equalTo(expected)); - - changed = uniquify("changed"); - configurationSource.setProperty(someProperty, changed); - - MatcherAssert.assertThat(DynamicPropertyFactory.getInstance().getStringProperty(someProperty, null).get(), - equalTo(changed)); - } - - @Test - public void propertiesDeleteFromDynamicConfigSourceIsDuplicated() { - String expected = uniquify("ran"); - String someProperty = "cse.cse.servicecomb.delete"; - - configurationSource.addProperty(someProperty, expected); - - MatcherAssert.assertThat(DynamicPropertyFactory.getInstance().getStringProperty(someProperty, null).get(), - equalTo(expected)); - - configurationSource.deleteProperty(someProperty); - - MatcherAssert.assertThat(DynamicPropertyFactory.getInstance().getStringProperty(someProperty, null).get(), - equalTo(null)); - - expected = uniquify("ran"); - someProperty = "cse.servicecomb.cse.delete"; - - configurationSource.addProperty(someProperty, expected); - - MatcherAssert.assertThat(DynamicPropertyFactory.getInstance().getStringProperty(someProperty, null).get(), - equalTo(expected)); - - configurationSource.deleteProperty(someProperty); - - MatcherAssert.assertThat(DynamicPropertyFactory.getInstance().getStringProperty(someProperty, null).get(), - equalTo(null)); - } - - @Test - public void testConvertEnvVariable() { - String someProperty = "cse_service_registry_address"; - AbstractConfiguration config = new DynamicConfiguration(); - config.addProperty(someProperty, "testing"); - AbstractConfiguration result = ConfigUtil.convertEnvVariable(config); - Assertions.assertEquals("testing", result.getString("cse.service.registry.address")); - } - - @Test - public void testCreateLocalConfigWithExtraConfig() { - Map<String, Object> extraConfig = new ConcurrentHashMapEx<>(1); - String extraConfigKey = "extraConfigKey"; - String extraConfigValue = "value"; - String overriddenConfigKey = "servicecomb.cse.servicecomb.file"; - extraConfig.put(extraConfigKey, extraConfigValue); - final String propertyHigherPriority = "higher_priority"; - String mapedKey1 = "servicecomb.service.mapping.address"; - String mapedKey2 = "servicecomb.service1.mapping.address"; - extraConfig.put(overriddenConfigKey, propertyHigherPriority); - - ConfigUtil.addExtraConfig("testExtraConfig", extraConfig); - - ConcurrentCompositeConfiguration localConfiguration = ConfigUtil.createLocalConfig(); - - Assertions.assertEquals(extraConfigValue, localConfiguration.getProperty(extraConfigKey)); - Assertions.assertEquals(propertyHigherPriority, localConfiguration.getString(overriddenConfigKey)); - // Test mapping key/value from self mappfing.xml - Assertions.assertEquals("https://myhost:8888", localConfiguration.getString(mapedKey1)); - Assertions.assertEquals("https://myhost:8888", localConfiguration.getString(mapedKey2)); - } - - @SuppressWarnings("unchecked") - private static void setEnv(String key, String value) throws IllegalAccessException, NoSuchFieldException { - Class<?>[] classes = Collections.class.getDeclaredClasses(); - Map<String, String> env = System.getenv(); - for (Class<?> cl : classes) { - if ("java.util.Collections$UnmodifiableMap".equals(cl.getName())) { - Field field = cl.getDeclaredField("m"); - field.setAccessible(true); - Object obj = field.get(env); - Map<String, String> map = (Map<String, String>) obj; - map.put(key, value); - } - } - } - - @Test - public void destroyConfigCenterConfigurationSource() { - AtomicInteger count = new AtomicInteger(); - ConfigCenterConfigurationSource source = new MockUp<ConfigCenterConfigurationSource>() { - @Mock - void destroy() { - count.incrementAndGet(); - } - }.getMockInstance(); - - new Expectations(SPIServiceUtils.class) { - { - SPIServiceUtils.getAllService(ConfigCenterConfigurationSource.class); - result = Arrays.asList(source, source); - } - }; - - ConfigUtil.destroyConfigCenterConfigurationSource(); - - Assertions.assertEquals(2, count.get()); - } -} diff --git a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/archaius/sources/TestYAMLConfigurationSource.java b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/archaius/sources/TestYAMLConfigurationSource.java index 533c7e79b..34fbea2cd 100644 --- a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/archaius/sources/TestYAMLConfigurationSource.java +++ b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/archaius/sources/TestYAMLConfigurationSource.java @@ -45,7 +45,7 @@ public class TestYAMLConfigurationSource { PollResult result = configSource.poll(true, null); Map<String, Object> configMap = result.getComplete(); Assertions.assertNotNull(configMap); - Assertions.assertEquals(24, configMap.size()); + Assertions.assertEquals(23, configMap.size()); Assertions.assertNotNull(configMap.get("trace.handler.sampler.percent")); Assertions.assertEquals(0.5, configMap.get("trace.handler.sampler.percent")); } @@ -65,7 +65,7 @@ public class TestYAMLConfigurationSource { Assertions.assertEquals(3, configSource.getConfigModels().size()); Assertions.assertNotNull(configMap); - Assertions.assertEquals(35, configMap.size()); + Assertions.assertEquals(34, configMap.size()); Assertions.assertNotNull(configMap.get("trace.handler.sampler.percent")); Assertions.assertEquals(0.5, configMap.get("trace.handler.sampler.percent")); diff --git a/foundations/foundation-config/src/test/resources/microservice.yaml b/foundations/foundation-config/src/test/resources/microservice.yaml index d820050cf..f8f6825d8 100644 --- a/foundations/foundation-config/src/test/resources/microservice.yaml +++ b/foundations/foundation-config/src/test/resources/microservice.yaml @@ -60,12 +60,6 @@ cse: service_description: name: testDemo - -servicecomb: - cse: - servicecomb: - file: value # this is a config for TestConfigUtil.testCreateLocalConfigWithExtraConfig() - holder: b,c,d test: commonSeparatedString: a,b,c diff --git a/huawei-cloud/dashboard/pom.xml b/huawei-cloud/dashboard/pom.xml index 165ce0042..5d9f67982 100644 --- a/huawei-cloud/dashboard/pom.xml +++ b/huawei-cloud/dashboard/pom.xml @@ -31,10 +31,6 @@ <groupId>org.apache.servicecomb</groupId> <artifactId>foundation-common</artifactId> </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>deployment</artifactId> - </dependency> <dependency> <groupId>org.apache.servicecomb</groupId> <artifactId>java-chassis-core</artifactId> diff --git a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/DefaultMonitorDataPublisher.java b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/DefaultMonitorDataPublisher.java index 8846a760e..330bd0d09 100644 --- a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/DefaultMonitorDataPublisher.java +++ b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/DefaultMonitorDataPublisher.java @@ -17,7 +17,6 @@ package org.apache.servicecomb.huaweicloud.dashboard.monitor; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -33,8 +32,6 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.servicecomb.config.ConfigUtil; import org.apache.servicecomb.dashboard.client.DashboardAddressManager; import org.apache.servicecomb.dashboard.client.DashboardClient; -import org.apache.servicecomb.deployment.Deployment; -import org.apache.servicecomb.deployment.SystemBootstrapInfo; import org.apache.servicecomb.foundation.auth.AuthHeaderProvider; import org.apache.servicecomb.foundation.common.event.EventManager; import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils; @@ -45,6 +42,7 @@ import org.apache.servicecomb.huaweicloud.dashboard.monitor.data.MonitorConstant import org.apache.servicecomb.huaweicloud.dashboard.monitor.model.MonitorDataProvider; import org.apache.servicecomb.huaweicloud.dashboard.monitor.model.MonitorDataPublisher; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; public class DefaultMonitorDataPublisher implements MonitorDataPublisher { private static final String SSL_KEY = "mc.consumer"; @@ -53,11 +51,18 @@ public class DefaultMonitorDataPublisher implements MonitorDataPublisher { private MonitorConstant monitorConstant; + private Environment environment; + @Autowired public void setMonitorConstant(MonitorConstant monitorConstant) { this.monitorConstant = monitorConstant; } + @Autowired + public void setEnvironment(Environment environment) { + this.environment = environment; + } + @Override public void init() { DashboardAddressManager addressManager = createDashboardAddressManager(); @@ -72,13 +77,10 @@ public class DefaultMonitorDataPublisher implements MonitorDataPublisher { dashboardClient = new DashboardClient(addressManager, httpTransport); } + @SuppressWarnings("unchecked") private DashboardAddressManager createDashboardAddressManager() { - List<String> addresses = new ArrayList<>(); - SystemBootstrapInfo info = Deployment.getSystemBootStrapInfo( - MonitorConstant.SYSTEM_KEY_DASHBOARD_SERVICE); - if (info != null && info.getAccessURL() != null) { - addresses.addAll(info.getAccessURL()); - } + List<String> addresses = ConfigUtil.parseArrayValue( + environment.getProperty(MonitorConstant.SYSTEM_KEY_DASHBOARD_SERVICE, "")); if (addresses.isEmpty()) { throw new IllegalStateException("dashboard address is not configured."); diff --git a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorDefaultDeploymentProvider.java b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorDefaultDeploymentProvider.java deleted file mode 100644 index 35a5ff232..000000000 --- a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorDefaultDeploymentProvider.java +++ /dev/null @@ -1,56 +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.servicecomb.huaweicloud.dashboard.monitor; - -import java.util.List; - -import org.apache.commons.configuration.AbstractConfiguration; -import org.apache.servicecomb.config.ConfigUtil; -import org.apache.servicecomb.deployment.DeploymentProvider; -import org.apache.servicecomb.deployment.SystemBootstrapInfo; -import org.apache.servicecomb.huaweicloud.dashboard.monitor.data.MonitorConstant; - -import com.google.common.annotations.VisibleForTesting; - -public class MonitorDefaultDeploymentProvider implements DeploymentProvider { - private static AbstractConfiguration configuration = ConfigUtil.createLocalConfig(); - - @Override - public int getOrder() { - return 3; - } - - @Override - public SystemBootstrapInfo getSystemBootStrapInfo(String systemKey) { - if (!systemKey.equals(MonitorConstant.SYSTEM_KEY_DASHBOARD_SERVICE)) { - return null; - } - List<String> msAddresses = ConfigUtil.parseArrayValue(configuration.getString(MonitorConstant.MONITOR_URI)); - if (msAddresses.isEmpty()) { - return null; - } - SystemBootstrapInfo ms = new SystemBootstrapInfo(); - ms.setAccessURL(msAddresses); - return ms; - } - - @VisibleForTesting - public static void setConfiguration(AbstractConfiguration configuration) { - MonitorDefaultDeploymentProvider.configuration = configuration; - } -} diff --git a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorInformationCollector.java b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorInformationCollector.java index 30f765d30..ef8b03a13 100644 --- a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorInformationCollector.java +++ b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorInformationCollector.java @@ -17,25 +17,29 @@ package org.apache.servicecomb.huaweicloud.dashboard.monitor; +import org.apache.servicecomb.config.ConfigUtil; import org.apache.servicecomb.core.bootup.BootUpInformationCollector; -import org.apache.servicecomb.deployment.Deployment; -import org.apache.servicecomb.deployment.SystemBootstrapInfo; import org.apache.servicecomb.huaweicloud.dashboard.monitor.data.MonitorConstant; - -import java.util.Objects; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; public class MonitorInformationCollector implements BootUpInformationCollector { + private Environment environment; + + @Autowired + public void setEnvironment(Environment environment) { + this.environment = environment; + } + @Override public String collect() { - return "monitor center: " + getCenterInfo(Deployment.getSystemBootStrapInfo(MonitorConstant.SYSTEM_KEY_DASHBOARD_SERVICE)); + return "monitor center: " + + ConfigUtil.parseArrayValue( + environment.getProperty(MonitorConstant.SYSTEM_KEY_DASHBOARD_SERVICE, "")); } @Override public int getOrder() { return 100; } - - private String getCenterInfo(SystemBootstrapInfo systemBootstrapInfo) { - return Objects.isNull(systemBootstrapInfo) ? "not exist" : systemBootstrapInfo.getAccessURL().toString(); - } } diff --git a/huawei-cloud/dashboard/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider b/huawei-cloud/dashboard/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider deleted file mode 100644 index 38547076b..000000000 --- a/huawei-cloud/dashboard/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider +++ /dev/null @@ -1,17 +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. -# -org.apache.servicecomb.huaweicloud.dashboard.monitor.MonitorDefaultDeploymentProvider \ No newline at end of file diff --git a/pom.xml b/pom.xml index b5c2f97fb..b9f6d13d1 100644 --- a/pom.xml +++ b/pom.xml @@ -139,7 +139,6 @@ <module>parents</module> <module>common</module> <module>foundations</module> - <module>deployment</module> <module>handlers</module> <module>providers</module> <module>transports</module> diff --git a/service-registry/registry-local/pom.xml b/service-registry/registry-local/pom.xml index 30b78653b..9118bde3f 100644 --- a/service-registry/registry-local/pom.xml +++ b/service-registry/registry-local/pom.xml @@ -29,10 +29,6 @@ <name>Java Chassis::Java Chassis::Service Registry::Local</name> <dependencies> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>deployment</artifactId> - </dependency> <dependency> <groupId>org.apache.servicecomb</groupId> <artifactId>foundation-vertx</artifactId> diff --git a/service-registry/registry-service-center/pom.xml b/service-registry/registry-service-center/pom.xml index 20e38d555..a68676302 100644 --- a/service-registry/registry-service-center/pom.xml +++ b/service-registry/registry-service-center/pom.xml @@ -29,10 +29,6 @@ <name>Java Chassis::Service Registry::Service Center</name> <dependencies> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>deployment</artifactId> - </dependency> <dependency> <groupId>org.apache.servicecomb</groupId> <artifactId>foundation-vertx</artifactId>
