You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/12/04 01:20:17 UTC
[servicecomb-java-chassis] branch master updated: [SCB-1048]Provide
a way to configure bootstrap information in Cloud Native enviroment
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
The following commit(s) were added to refs/heads/master by this push:
new 19533e8 [SCB-1048]Provide a way to configure bootstrap information in Cloud Native enviroment
19533e8 is described below
commit 19533e80cfeb9f728bf9dd79b265477c9e3da4fd
Author: liubao <ba...@huawei.com>
AuthorDate: Tue Nov 27 18:09:37 2018 +0800
[SCB-1048]Provide a way to configure bootstrap information in Cloud Native enviroment
---
coverage-reports/pom.xml | 4 ++
deployment/README.md | 13 ++++
{service-registry => deployment}/pom.xml | 10 +--
.../deployment/DefaultDeploymentProvider.java | 58 +++++++++++++++++
.../apache/servicecomb/deployment/Deployment.java | 35 ++++++++++
.../servicecomb/deployment/DeploymentProvider.java | 29 +++++++++
.../deployment/SystemBootstrapInfo.java | 47 ++++++++++++++
...pache.servicecomb.deployment.DeploymentProvider | 18 ++++++
.../deployment/CustomDeploymentProvider.java | 39 +++++++++++
.../servicecomb/deployment/TestDeployment.java | 75 ++++++++++++++++++++++
...pache.servicecomb.deployment.DeploymentProvider | 18 ++++++
dynamic-config/config-cc/pom.xml | 4 ++
.../ConfigCenterConfigurationSourceImpl.java | 7 +-
.../config/client/ConfigCenterConfig.java | 12 ++--
.../org/apache/servicecomb/config/ConfigUtil.java | 2 +-
java-chassis-dependencies/pom.xml | 5 ++
java-chassis-distribution/pom.xml | 4 ++
pom.xml | 1 +
service-registry/pom.xml | 4 ++
.../config/ServiceRegistryConfig.java | 10 +--
.../config/TestServiceRegistryConfig.java | 5 +-
21 files changed, 376 insertions(+), 24 deletions(-)
diff --git a/coverage-reports/pom.xml b/coverage-reports/pom.xml
index 9828587..04396fb 100644
--- a/coverage-reports/pom.xml
+++ b/coverage-reports/pom.xml
@@ -48,6 +48,10 @@
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
+ <artifactId>deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
<artifactId>foundation-vertx</artifactId>
</dependency>
<dependency>
diff --git a/deployment/README.md b/deployment/README.md
new file mode 100644
index 0000000..b2764cc
--- /dev/null
+++ b/deployment/README.md
@@ -0,0 +1,13 @@
+# 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/service-registry/pom.xml b/deployment/pom.xml
similarity index 96%
copy from service-registry/pom.xml
copy to deployment/pom.xml
index 5863536..6dc9c14 100644
--- a/service-registry/pom.xml
+++ b/deployment/pom.xml
@@ -26,17 +26,17 @@
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>service-registry</artifactId>
- <name>Java Chassis::Service Registry</name>
+ <artifactId>deployment</artifactId>
+ <name>Java Chassis::Deployment</name>
<dependencies>
<dependency>
<groupId>org.apache.servicecomb</groupId>
- <artifactId>foundation-vertx</artifactId>
+ <artifactId>foundation-config</artifactId>
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
- <artifactId>foundation-config</artifactId>
+ <artifactId>foundation-vertx</artifactId>
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
@@ -48,7 +48,7 @@
<artifactId>vertx-codegen</artifactId>
<scope>provided</scope>
</dependency>
-
+
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
diff --git a/deployment/src/main/java/org/apache/servicecomb/deployment/DefaultDeploymentProvider.java b/deployment/src/main/java/org/apache/servicecomb/deployment/DefaultDeploymentProvider.java
new file mode 100644
index 0000000..9099735
--- /dev/null
+++ b/deployment/src/main/java/org/apache/servicecomb/deployment/DefaultDeploymentProvider.java
@@ -0,0 +1,58 @@
+/*
+ * 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.Arrays;
+
+import org.apache.commons.configuration.AbstractConfiguration;
+import org.apache.servicecomb.config.ConfigUtil;
+
+import com.google.common.annotations.VisibleForTesting;
+
+public class DefaultDeploymentProvider implements DeploymentProvider {
+ private static AbstractConfiguration configuration = ConfigUtil.createLocalConfig();
+
+ @Override
+ public SystemBootstrapInfo getSystemBootStrapInfo(String systemKey) {
+ switch (systemKey) {
+ case SYSTEM_KEY_SERVICE_CENTER:
+ SystemBootstrapInfo sc = new SystemBootstrapInfo();
+ String[] urls = configuration.getStringArray("servicecomb.service.registry.address");
+ if (urls == null || urls.length == 0) {
+ urls = new String[] {"https://127.0.0.1:30100"};
+ }
+ sc.setAccessURL(Arrays.asList(urls));
+ return sc;
+ case SYSTEM_KEY_CONFIG_CENTER:
+ String[] ccAddresses = configuration.getStringArray("servicecomb.config.client.serverUri");
+ if (ccAddresses == null || ccAddresses.length == 0) {
+ return null;
+ }
+ SystemBootstrapInfo cc = new SystemBootstrapInfo();
+ cc.setAccessURL(Arrays.asList(ccAddresses));
+ return cc;
+ default:
+ return null;
+ }
+ }
+
+ @VisibleForTesting
+ public static void setConfiguration(AbstractConfiguration configuration) {
+ DefaultDeploymentProvider.configuration = configuration;
+ }
+}
diff --git a/deployment/src/main/java/org/apache/servicecomb/deployment/Deployment.java b/deployment/src/main/java/org/apache/servicecomb/deployment/Deployment.java
new file mode 100644
index 0000000..f26980e
--- /dev/null
+++ b/deployment/src/main/java/org/apache/servicecomb/deployment/Deployment.java
@@ -0,0 +1,35 @@
+/*
+ * 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 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
new file mode 100644
index 0000000..703af6d
--- /dev/null
+++ b/deployment/src/main/java/org/apache/servicecomb/deployment/DeploymentProvider.java
@@ -0,0 +1,29 @@
+/*
+ * 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 {
+ String SYSTEM_KEY_SERVICE_CENTER = "ServiceCenter";
+ String SYSTEM_KEY_CONFIG_CENTER = "ConfigCenter";
+
+ 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
new file mode 100644
index 0000000..c98f93e
--- /dev/null
+++ b/deployment/src/main/java/org/apache/servicecomb/deployment/SystemBootstrapInfo.java
@@ -0,0 +1,47 @@
+/*
+ * 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/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider b/deployment/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
new file mode 100644
index 0000000..49e32f1
--- /dev/null
+++ b/deployment/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
@@ -0,0 +1,18 @@
+#
+# 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.DefaultDeploymentProvider
diff --git a/deployment/src/test/java/org/apache/servicecomb/deployment/CustomDeploymentProvider.java b/deployment/src/test/java/org/apache/servicecomb/deployment/CustomDeploymentProvider.java
new file mode 100644
index 0000000..df7e226
--- /dev/null
+++ b/deployment/src/test/java/org/apache/servicecomb/deployment/CustomDeploymentProvider.java
@@ -0,0 +1,39 @@
+/*
+ * 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.Arrays;
+
+public class CustomDeploymentProvider implements DeploymentProvider {
+ @Override
+ public int getOrder() {
+ return 0;
+ }
+
+ @Override
+ public SystemBootstrapInfo getSystemBootStrapInfo(String systemKey) {
+ switch (systemKey) {
+ case DeploymentProvider.SYSTEM_KEY_CONFIG_CENTER:
+ SystemBootstrapInfo cc = new SystemBootstrapInfo();
+ cc.setAccessURL(Arrays.asList("http://lcalhost/custom"));
+ return cc;
+ default:
+ return null;
+ }
+ }
+}
diff --git a/deployment/src/test/java/org/apache/servicecomb/deployment/TestDeployment.java b/deployment/src/test/java/org/apache/servicecomb/deployment/TestDeployment.java
new file mode 100644
index 0000000..497c50e
--- /dev/null
+++ b/deployment/src/test/java/org/apache/servicecomb/deployment/TestDeployment.java
@@ -0,0 +1,75 @@
+/*
+ * 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.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestDeployment {
+ @After
+ public void tearDown() {
+ ArchaiusUtils.resetConfig();
+ }
+
+ @Test
+ public void testConfiguration() {
+ DefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
+ SystemBootstrapInfo info = Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_SERVICE_CENTER);
+ Assert.assertEquals(info.getAccessURL().get(0), "https://127.0.0.1:30100");
+ info = Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_CONFIG_CENTER);
+ Assert.assertEquals(info.getAccessURL().get(0), "http://lcalhost/custom");
+
+ Assert.assertNull(Deployment.getSystemBootStrapInfo("wrong"));
+ }
+
+ @Test
+ public void testConfigurationEnv() {
+ System.setProperty("servicecomb.service.registry.address", "https://localhost:9999");
+ System.setProperty("servicecomb.config.client.serverUri", "https://localhost:9988");
+ DefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
+
+ SystemBootstrapInfo info = Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_SERVICE_CENTER);
+ Assert.assertEquals(info.getAccessURL().get(0), "https://localhost:9999");
+ info = Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_CONFIG_CENTER);
+ Assert.assertEquals(info.getAccessURL().get(0), "http://lcalhost/custom");
+
+ System.getProperties().remove("servicecomb.service.registry.address");
+ System.getProperties().remove("servicecomb.config.client.serverUri");
+ }
+
+ @Test
+ public void testConfigurationEnvTwo() {
+ System.setProperty("servicecomb.service.registry.address", "https://localhost:9999,https://localhost:9998");
+ System.setProperty("servicecomb.config.client.serverUri", "https://localhost:9988,https://localhost:9987");
+ DefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
+
+ SystemBootstrapInfo info = Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_SERVICE_CENTER);
+ Assert.assertEquals(info.getAccessURL().size(), 2);
+ Assert.assertEquals(info.getAccessURL().get(0), "https://localhost:9999");
+ Assert.assertEquals(info.getAccessURL().get(1), "https://localhost:9998");
+ info = Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_CONFIG_CENTER);
+ Assert.assertEquals(info.getAccessURL().get(0), "http://lcalhost/custom");
+ Assert.assertEquals(info.getAccessURL().size(), 1);
+
+ System.getProperties().remove("servicecomb.service.registry.address");
+ System.getProperties().remove("servicecomb.config.client.serverUri");
+ }
+}
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
new file mode 100644
index 0000000..d07cc1e
--- /dev/null
+++ b/deployment/src/test/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
@@ -0,0 +1,18 @@
+#
+# 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/dynamic-config/config-cc/pom.xml b/dynamic-config/config-cc/pom.xml
index 16d211c..8aa24a1 100644
--- a/dynamic-config/config-cc/pom.xml
+++ b/dynamic-config/config-cc/pom.xml
@@ -35,6 +35,10 @@
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
+ <artifactId>deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
<artifactId>foundation-ssl</artifactId>
</dependency>
<dependency>
diff --git a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/archaius/sources/ConfigCenterConfigurationSourceImpl.java b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/archaius/sources/ConfigCenterConfigurationSourceImpl.java
index 8cf1a65..7fd362d 100644
--- a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/archaius/sources/ConfigCenterConfigurationSourceImpl.java
+++ b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/archaius/sources/ConfigCenterConfigurationSourceImpl.java
@@ -24,6 +24,8 @@ import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.commons.configuration.Configuration;
+import org.apache.servicecomb.deployment.Deployment;
+import org.apache.servicecomb.deployment.DeploymentProvider;
import org.apache.servicecomb.config.ConfigMapping;
import org.apache.servicecomb.config.client.ConfigCenterClient;
import org.apache.servicecomb.config.client.ConfigCenterConfig;
@@ -51,15 +53,12 @@ public class ConfigCenterConfigurationSourceImpl implements ConfigCenterConfigur
private ConfigCenterClient configCenterClient;
- private static final String CONFIG_CENTER_URL_KEY = "servicecomb.config.client.serverUri";
-
public ConfigCenterConfigurationSourceImpl() {
}
@Override
public boolean isValidSource(Configuration localConfiguration) {
- if (localConfiguration.getProperty(CONFIG_CENTER_URL_KEY) == null) {
- LOGGER.warn("Config Center configuration source is not configured!");
+ if (Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_CONFIG_CENTER) == null) {
return false;
}
return true;
diff --git a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/client/ConfigCenterConfig.java b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/client/ConfigCenterConfig.java
index f78eee4..3f570ba 100644
--- a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/client/ConfigCenterConfig.java
+++ b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/client/ConfigCenterConfig.java
@@ -23,6 +23,9 @@ import static org.apache.servicecomb.foundation.common.base.ServiceCombConstants
import java.util.ArrayList;
import java.util.List;
+import org.apache.servicecomb.deployment.Deployment;
+import org.apache.servicecomb.deployment.DeploymentProvider;
+
import com.google.common.base.Joiner;
import com.netflix.config.ConcurrentCompositeConfiguration;
@@ -33,8 +36,6 @@ public final class ConfigCenterConfig {
private static final String AUTO_DISCOVERY_ENABLED = "servicecomb.service.registry.autodiscovery";
- private static final String SERVER_URL_KEY = "servicecomb.config.client.serverUri";
-
private static final String REFRESH_MODE = "servicecomb.config.client.refreshMode";
private static final String REFRESH_PORT = "servicecomb.config.client.refreshPort";
@@ -172,12 +173,7 @@ public final class ConfigCenterConfig {
}
public List<String> getServerUri() {
- String[] result = finalConfig.getStringArray(SERVER_URL_KEY);
- List<String> configCenterUris = new ArrayList<>(result.length);
- for (int i = 0; i < result.length; i++) {
- configCenterUris.add(result[i]);
- }
- return configCenterUris;
+ return Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_CONFIG_CENTER).getAccessURL();
}
public boolean getAutoDiscoveryEnabled() {
diff --git a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/ConfigUtil.java b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/ConfigUtil.java
index fd549b5..4c1b65f 100644
--- a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/ConfigUtil.java
+++ b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/ConfigUtil.java
@@ -210,7 +210,7 @@ public final class ConfigUtil {
}
if (!configCenterConfigurationSource.isValidSource(localConfiguration)) {
- LOGGER.info("Config Source serverUri is not correctly configured.");
+ LOGGER.warn("Config Source serverUri is not correctly configured.");
return null;
}
return configCenterConfigurationSource;
diff --git a/java-chassis-dependencies/pom.xml b/java-chassis-dependencies/pom.xml
index c09c5d0..031a6db 100644
--- a/java-chassis-dependencies/pom.xml
+++ b/java-chassis-dependencies/pom.xml
@@ -782,6 +782,11 @@
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
+ <artifactId>deployment</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
<artifactId>config-cc</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
diff --git a/java-chassis-distribution/pom.xml b/java-chassis-distribution/pom.xml
index 3b917f8..7b9b54d 100644
--- a/java-chassis-distribution/pom.xml
+++ b/java-chassis-distribution/pom.xml
@@ -102,6 +102,10 @@
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
+ <artifactId>deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
<artifactId>foundation-metrics</artifactId>
</dependency>
<dependency>
diff --git a/pom.xml b/pom.xml
index b111da2..abeb5a6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,6 +108,7 @@
<module>java-chassis-dependencies</module>
<module>common</module>
<module>foundations</module>
+ <module>deployment</module>
<module>handlers</module>
<module>providers</module>
<module>transports</module>
diff --git a/service-registry/pom.xml b/service-registry/pom.xml
index 5863536..f53e9eb 100644
--- a/service-registry/pom.xml
+++ b/service-registry/pom.xml
@@ -32,6 +32,10 @@
<dependencies>
<dependency>
<groupId>org.apache.servicecomb</groupId>
+ <artifactId>deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
<artifactId>foundation-vertx</artifactId>
</dependency>
<dependency>
diff --git a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/config/ServiceRegistryConfig.java b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/config/ServiceRegistryConfig.java
index 9832735..6a7bc00 100644
--- a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/config/ServiceRegistryConfig.java
+++ b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/config/ServiceRegistryConfig.java
@@ -22,6 +22,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.apache.servicecomb.deployment.Deployment;
+import org.apache.servicecomb.deployment.DeploymentProvider;
import org.apache.servicecomb.foundation.common.net.IpPort;
import org.apache.servicecomb.foundation.common.net.NetUtils;
import org.slf4j.Logger;
@@ -130,10 +132,7 @@ public final class ServiceRegistryConfig {
}
public ArrayList<IpPort> getIpPort() {
- DynamicStringProperty property =
- DynamicPropertyFactory.getInstance()
- .getStringProperty("servicecomb.service.registry.address", "https://127.0.0.1:30100");
- List<String> uriList = Arrays.asList(property.get().split(","));
+ List<String> uriList = Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_SERVICE_CENTER).getAccessURL();
ArrayList<IpPort> ipPortList = new ArrayList<>();
uriList.forEach(anUriList -> {
try {
@@ -189,7 +188,8 @@ public final class ServiceRegistryConfig {
public int getHeartBeatRequestTimeout() {
DynamicIntProperty property =
DynamicPropertyFactory.getInstance()
- .getIntProperty("servicecomb.service.registry.client.timeout.heartbeat", DEFAULT_REQUEST_HEARTBEAT_TIMEOUT_IN_MS);
+ .getIntProperty("servicecomb.service.registry.client.timeout.heartbeat",
+ DEFAULT_REQUEST_HEARTBEAT_TIMEOUT_IN_MS);
int timeout = property.get();
return timeout < 1 ? DEFAULT_REQUEST_HEARTBEAT_TIMEOUT_IN_MS : timeout;
}
diff --git a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/config/TestServiceRegistryConfig.java b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/config/TestServiceRegistryConfig.java
index a40015f..c621163 100644
--- a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/config/TestServiceRegistryConfig.java
+++ b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/config/TestServiceRegistryConfig.java
@@ -20,6 +20,8 @@ package org.apache.servicecomb.serviceregistry.config;
import java.util.List;
import org.apache.commons.configuration.Configuration;
+import org.apache.servicecomb.deployment.DefaultDeploymentProvider;
+import org.apache.servicecomb.config.ConfigUtil;
import org.apache.servicecomb.foundation.common.net.IpPort;
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
import org.junit.AfterClass;
@@ -33,7 +35,8 @@ public class TestServiceRegistryConfig {
@BeforeClass
public static void initClass() {
ArchaiusUtils.resetConfig();
- ArchaiusUtils.setProperty("servicecomb.service.registry.address", "http://127.0.0.1, https://127.0.0.1");
+ System.setProperty("servicecomb.service.registry.address", "http://127.0.0.1, https://127.0.0.1");
+ DefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
}
@AfterClass