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 1122083 SCB-2256 The address of the config center of the service
startup log is printed automatically according to the component type (#2358)
1122083 is described below
commit 1122083198d59c972a1c06d2591efb93fda10a82
Author: zyl <[email protected]>
AuthorDate: Tue Apr 27 14:32:59 2021 +0800
SCB-2256 The address of the config center of the service startup log is
printed automatically according to the component type (#2358)
* SCB-2256 The address of the config center of the service startup log is
printed automatically according to the component type
* SCB-2256 The address of the config center of the service startup log is
printed automatically according to the component type
#add UT
#move ServicesCenter info to registry-service-center.
* SCB-2256 回退误修改的测试用例
* #2256 reviews
---
...vicecomb.core.bootup.BootUpInformationCollector | 1 -
.../servicecomb/deployment/DeploymentProvider.java | 2 -
.../deployment/CustomDeploymentProvider.java | 23 +++++---
.../servicecomb/deployment/TestDeployment.java | 42 +------------
dynamic-config/config-cc/pom.xml | 9 +++
.../ConfigCenterConfigurationSourceImpl.java | 10 +---
.../config/client/ConfigCenterConfig.java | 28 +++++----
.../client/ConfigCenterHttpClientOptionsSPI.java | 4 +-
.../ConfigCenterDefaultDeploymentProvider.java | 44 ++++++--------
.../collect/ConfigCenterInformationCollector.java | 17 +++---
...vicecomb.core.bootup.BootUpInformationCollector | 3 +-
...pache.servicecomb.deployment.DeploymentProvider | 3 +-
.../TestConfigCenterDefaultDeploymentProvder.java | 48 +++++++--------
dynamic-config/config-kie/pom.xml | 9 +++
.../KieCenterDefaultDeploymentProvider.java | 35 +++++------
.../kie/collect/KieClientInformationCollector.java | 17 +++---
...vicecomb.core.bootup.BootUpInformationCollector | 3 +-
...pache.servicecomb.deployment.DeploymentProvider | 3 +-
.../config/kie/client/TestKieClient.java | 2 +-
.../config/kie/client/TestKieConfig.java | 2 +-
.../TestKieCenterDefaultDeploymentProvider.java | 69 ++++++++++++++++++++++
.../src/test/resources/microservice.yaml | 2 +-
.../monitor/MonitorDefaultDeploymentProvider.java | 23 ++++----
.../monitor/MonitorInformationCollector.java | 7 +--
service-registry/registry-service-center/pom.xml | 4 ++
.../ServiceCenterDefaultDeploymentProvider.java | 35 +++++------
.../collect/ServiceCenterInformationCollector.java | 17 +++---
.../config/ServiceRegistryConfigBuilder.java | 4 +-
...vicecomb.core.bootup.BootUpInformationCollector | 2 +-
...pache.servicecomb.deployment.DeploymentProvider | 2 +-
...TestServiceCenterDefaultDeploymentProvider.java | 49 +++++++--------
.../config/TestServiceRegistryConfig.java | 4 +-
32 files changed, 271 insertions(+), 252 deletions(-)
diff --git
a/core/src/main/resources/META-INF/services/org.apache.servicecomb.core.bootup.BootUpInformationCollector
b/core/src/main/resources/META-INF/services/org.apache.servicecomb.core.bootup.BootUpInformationCollector
index 0490161..c33b0de 100644
---
a/core/src/main/resources/META-INF/services/org.apache.servicecomb.core.bootup.BootUpInformationCollector
+++
b/core/src/main/resources/META-INF/services/org.apache.servicecomb.core.bootup.BootUpInformationCollector
@@ -16,5 +16,4 @@
#
org.apache.servicecomb.core.bootup.ServiceInformationCollector
-org.apache.servicecomb.core.bootup.AddressInformationCollector
org.apache.servicecomb.core.bootup.FilterChainCollector
\ No newline at end of file
diff --git
a/deployment/src/main/java/org/apache/servicecomb/deployment/DeploymentProvider.java
b/deployment/src/main/java/org/apache/servicecomb/deployment/DeploymentProvider.java
index 703af6d..e2e5396 100644
---
a/deployment/src/main/java/org/apache/servicecomb/deployment/DeploymentProvider.java
+++
b/deployment/src/main/java/org/apache/servicecomb/deployment/DeploymentProvider.java
@@ -18,8 +18,6 @@
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;
diff --git
a/deployment/src/test/java/org/apache/servicecomb/deployment/CustomDeploymentProvider.java
b/deployment/src/test/java/org/apache/servicecomb/deployment/CustomDeploymentProvider.java
index df7e226..43c0a71 100644
---
a/deployment/src/test/java/org/apache/servicecomb/deployment/CustomDeploymentProvider.java
+++
b/deployment/src/test/java/org/apache/servicecomb/deployment/CustomDeploymentProvider.java
@@ -17,9 +17,15 @@
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;
@@ -27,13 +33,16 @@ public class CustomDeploymentProvider implements
DeploymentProvider {
@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;
+ 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
index 48d6bd3..b626381 100644
---
a/deployment/src/test/java/org/apache/servicecomb/deployment/TestDeployment.java
+++
b/deployment/src/test/java/org/apache/servicecomb/deployment/TestDeployment.java
@@ -31,45 +31,9 @@ public class TestDeployment {
@Test
public void testConfiguration() {
- DefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
- SystemBootstrapInfo info =
Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_SERVICE_CENTER);
- Assert.assertEquals(info.getAccessURL().get(0), "http://127.0.0.1:30100");
- info =
Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_CONFIG_CENTER);
- Assert.assertEquals(info.getAccessURL().get(0), "http://lcalhost/custom");
-
+ CustomDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
+ SystemBootstrapInfo info = Deployment.getSystemBootStrapInfo("TestCenter");
+ Assert.assertEquals(info.getAccessURL().get(0), "http://localhost/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/dynamic-config/config-cc/pom.xml b/dynamic-config/config-cc/pom.xml
index 042faf6..1ab6d3f 100644
--- a/dynamic-config/config-cc/pom.xml
+++ b/dynamic-config/config-cc/pom.xml
@@ -50,6 +50,15 @@
<artifactId>vertx-codegen</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>foundation-test-scaffolding</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
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 5e047cc..04b53a7 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
@@ -19,7 +19,6 @@ package org.apache.servicecomb.config.archaius.sources;
import static com.netflix.config.WatchedUpdateResult.createIncremental;
-import java.io.ByteArrayInputStream;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -29,9 +28,9 @@ import org.apache.servicecomb.config.ConfigMapping;
import org.apache.servicecomb.config.YAMLUtil;
import org.apache.servicecomb.config.client.ConfigCenterClient;
import org.apache.servicecomb.config.client.ConfigCenterConfig;
+import
org.apache.servicecomb.config.collect.ConfigCenterDefaultDeploymentProvider;
import org.apache.servicecomb.config.spi.ConfigCenterConfigurationSource;
import org.apache.servicecomb.deployment.Deployment;
-import org.apache.servicecomb.deployment.DeploymentProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -65,10 +64,7 @@ public class ConfigCenterConfigurationSourceImpl implements
ConfigCenterConfigur
@Override
public boolean isValidSource(Configuration localConfiguration) {
- if
(Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_CONFIG_CENTER)
== null) {
- return false;
- }
- return true;
+ return
Deployment.getSystemBootStrapInfo(ConfigCenterDefaultDeploymentProvider.SYSTEM_KEY_CONFIG_CENTER)
!= null;
}
private void init() {
@@ -128,7 +124,7 @@ public class ConfigCenterConfigurationSourceImpl implements
ConfigCenterConfigur
if (parseConfigs == null || parseConfigs.isEmpty()) {
return;
}
-
+
Map<String, Object> configuration =
ConfigMapping.getConvertedMap(parseConfigs);
if (configCenterClient != null) {
List<String> fileSourceList = configCenterClient.getFileSources();
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 6ff5747..219329b 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
@@ -20,11 +20,12 @@ package org.apache.servicecomb.config.client;
import com.google.common.base.Joiner;
import com.netflix.config.ConcurrentCompositeConfiguration;
import org.apache.servicecomb.config.BootStrapProperties;
+import
org.apache.servicecomb.config.collect.ConfigCenterDefaultDeploymentProvider;
import org.apache.servicecomb.deployment.Deployment;
-import org.apache.servicecomb.deployment.DeploymentProvider;
import org.apache.servicecomb.foundation.vertx.VertxConst;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
public final class ConfigCenterConfig {
@@ -53,7 +54,7 @@ public final class ConfigCenterConfig {
public static final String CONNECTION_TIME_OUT =
"servicecomb.config.client.timeout.connection";
public static final String EVENT_LOOP_SIZE =
"servicecomb.config.client.eventLoopSize";
-
+
public static final String FILE_SOURCE =
"servicecomb.config.client.fileSource";
public static final String VERTICAL_INSTANCE_COUNT =
"servicecomb.config.client.verticalInstanceCount";
@@ -102,18 +103,19 @@ public final class ConfigCenterConfig {
public String getApiVersion() {
return finalConfig.getString(URI_API_VERSION, "v3");
}
-
+
@SuppressWarnings("unchecked")
public List<String> getFileSources() {
- Object property = finalConfig.getProperty(FILE_SOURCE);
- if (property instanceof String) {
- List<String> result = new ArrayList<>();
- result.add((String) property);
- return result;
- } else if (property instanceof List) {
- return (List<String>) property;
- }
- return new ArrayList<>();
+ Object property = finalConfig.getProperty(FILE_SOURCE);
+ if (property instanceof String) {
+ List<String> result = new ArrayList<>();
+ result.add((String) property);
+ return result;
+ }
+ if (property instanceof List) {
+ return (List<String>) property;
+ }
+ return Collections.EMPTY_LIST;
}
public int getRefreshInterval() {
@@ -172,7 +174,7 @@ public final class ConfigCenterConfig {
}
public List<String> getServerUri() {
- return
Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_CONFIG_CENTER).getAccessURL();
+ return
Deployment.getSystemBootStrapInfo(ConfigCenterDefaultDeploymentProvider.SYSTEM_KEY_CONFIG_CENTER).getAccessURL();
}
public boolean getAutoDiscoveryEnabled() {
diff --git
a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/client/ConfigCenterHttpClientOptionsSPI.java
b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/client/ConfigCenterHttpClientOptionsSPI.java
index 5a6feda..e9980f2 100644
---
a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/client/ConfigCenterHttpClientOptionsSPI.java
+++
b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/client/ConfigCenterHttpClientOptionsSPI.java
@@ -17,8 +17,8 @@
package org.apache.servicecomb.config.client;
+import
org.apache.servicecomb.config.collect.ConfigCenterDefaultDeploymentProvider;
import org.apache.servicecomb.deployment.Deployment;
-import org.apache.servicecomb.deployment.DeploymentProvider;
import
org.apache.servicecomb.foundation.vertx.client.http.HttpClientOptionsSPI;
import com.netflix.config.ConcurrentCompositeConfiguration;
@@ -42,7 +42,7 @@ public class ConfigCenterHttpClientOptionsSPI implements
HttpClientOptionsSPI {
@Override
public boolean enabled() {
- return
Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_CONFIG_CENTER)
!= null;
+ return
Deployment.getSystemBootStrapInfo(ConfigCenterDefaultDeploymentProvider.SYSTEM_KEY_CONFIG_CENTER)
!= null;
}
@Override
diff --git
a/deployment/src/main/java/org/apache/servicecomb/deployment/DefaultDeploymentProvider.java
b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/collect/ConfigCenterDefaultDeploymentProvider.java
similarity index 56%
rename from
deployment/src/main/java/org/apache/servicecomb/deployment/DefaultDeploymentProvider.java
rename to
dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/collect/ConfigCenterDefaultDeploymentProvider.java
index 6b89d87..a7c5ca8 100644
---
a/deployment/src/main/java/org/apache/servicecomb/deployment/DefaultDeploymentProvider.java
+++
b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/collect/ConfigCenterDefaultDeploymentProvider.java
@@ -15,44 +15,38 @@
* limitations under the License.
*/
-package org.apache.servicecomb.deployment;
-
-import java.util.Arrays;
+package org.apache.servicecomb.config.collect;
+import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.configuration.AbstractConfiguration;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.servicecomb.config.ConfigUtil;
+import org.apache.servicecomb.deployment.DeploymentProvider;
+import org.apache.servicecomb.deployment.SystemBootstrapInfo;
-import com.google.common.annotations.VisibleForTesting;
+import java.util.Arrays;
+
+public class ConfigCenterDefaultDeploymentProvider implements
DeploymentProvider {
+ public static final String SYSTEM_KEY_CONFIG_CENTER = "ConfigCenter";
-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[] {"http://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;
+ if (!systemKey.equals(SYSTEM_KEY_CONFIG_CENTER)) {
+ return null;
+ }
+ String[] ccAddresses =
configuration.getStringArray("servicecomb.config.client.serverUri");
+ if (ArrayUtils.isEmpty(ccAddresses)) {
+ return null;
}
+ SystemBootstrapInfo cc = new SystemBootstrapInfo();
+ cc.setAccessURL(Arrays.asList(ccAddresses));
+ return cc;
}
@VisibleForTesting
public static void setConfiguration(AbstractConfiguration configuration) {
- DefaultDeploymentProvider.configuration = configuration;
+ ConfigCenterDefaultDeploymentProvider.configuration = configuration;
}
}
diff --git
a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorInformationCollector.java
b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/collect/ConfigCenterInformationCollector.java
similarity index 69%
copy from
huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorInformationCollector.java
copy to
dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/collect/ConfigCenterInformationCollector.java
index 289c8a5..89568de 100644
---
a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorInformationCollector.java
+++
b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/collect/ConfigCenterInformationCollector.java
@@ -15,28 +15,27 @@
* limitations under the License.
*/
-package org.apache.servicecomb.huaweicloud.dashboard.monitor;
+package org.apache.servicecomb.config.collect;
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;
-public class MonitorInformationCollector implements BootUpInformationCollector
{
+import java.util.Objects;
+
+
+public class ConfigCenterInformationCollector implements
BootUpInformationCollector {
@Override
public String collect() {
- return "monitor center: " +
getCenterInfo(Deployment.getSystemBootStrapInfo(MonitorConstant.SYSTEM_KEY_DASHBOARD_SERVICE));
+ return "Config Center: " +
getCenterInfo(Deployment.getSystemBootStrapInfo("ConfigCenter"));
}
@Override
public int getOrder() {
- return 100;
+ return 1;
}
private String getCenterInfo(SystemBootstrapInfo systemBootstrapInfo) {
- if (systemBootstrapInfo == null) {
- return ("not exist");
- }
- return systemBootstrapInfo.getAccessURL().toString();
+ return Objects.isNull(systemBootstrapInfo) ? "not exist" :
systemBootstrapInfo.getAccessURL().toString();
}
}
diff --git
a/deployment/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.core.bootup.BootUpInformationCollector
similarity index 91%
copy from
deployment/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
copy to
dynamic-config/config-cc/src/main/resources/META-INF/services/org.apache.servicecomb.core.bootup.BootUpInformationCollector
index 49e32f1..5806257 100644
---
a/deployment/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.core.bootup.BootUpInformationCollector
@@ -14,5 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
-org.apache.servicecomb.deployment.DefaultDeploymentProvider
+org.apache.servicecomb.config.collect.ConfigCenterInformationCollector
\ No newline at end of file
diff --git
a/deployment/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
similarity index 91%
copy from
deployment/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
copy to
dynamic-config/config-cc/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
index 49e32f1..39efa46 100644
---
a/deployment/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
@@ -14,5 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
-org.apache.servicecomb.deployment.DefaultDeploymentProvider
+org.apache.servicecomb.config.collect.ConfigCenterDefaultDeploymentProvider
\ No newline at end of file
diff --git
a/deployment/src/test/java/org/apache/servicecomb/deployment/TestDeployment.java
b/dynamic-config/config-cc/src/test/java/org/apache/servicecomb/config/collect/TestConfigCenterDefaultDeploymentProvder.java
similarity index 58%
copy from
deployment/src/test/java/org/apache/servicecomb/deployment/TestDeployment.java
copy to
dynamic-config/config-cc/src/test/java/org/apache/servicecomb/config/collect/TestConfigCenterDefaultDeploymentProvder.java
index 48d6bd3..486cade 100644
---
a/deployment/src/test/java/org/apache/servicecomb/deployment/TestDeployment.java
+++
b/dynamic-config/config-cc/src/test/java/org/apache/servicecomb/config/collect/TestConfigCenterDefaultDeploymentProvder.java
@@ -15,15 +15,23 @@
* limitations under the License.
*/
-package org.apache.servicecomb.deployment;
+package org.apache.servicecomb.config.collect;
import org.apache.servicecomb.config.ConfigUtil;
+import org.apache.servicecomb.deployment.Deployment;
+import org.apache.servicecomb.deployment.SystemBootstrapInfo;
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
-public class TestDeployment {
+public class TestConfigCenterDefaultDeploymentProvder {
+ @Before
+ public void start() {
+ ArchaiusUtils.resetConfig();
+ }
+
@After
public void tearDown() {
ArchaiusUtils.resetConfig();
@@ -31,45 +39,29 @@ public class TestDeployment {
@Test
public void testConfiguration() {
- DefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
- SystemBootstrapInfo info =
Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_SERVICE_CENTER);
- Assert.assertEquals(info.getAccessURL().get(0), "http://127.0.0.1:30100");
- info =
Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_CONFIG_CENTER);
- Assert.assertEquals(info.getAccessURL().get(0), "http://lcalhost/custom");
-
+
ConfigCenterDefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
+ SystemBootstrapInfo info =
Deployment.getSystemBootStrapInfo(ConfigCenterDefaultDeploymentProvider.SYSTEM_KEY_CONFIG_CENTER);
+ Assert.assertEquals(info.getAccessURL().get(0),
"https://172.16.8.7:30103");
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");
+
ConfigCenterDefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
+ SystemBootstrapInfo info =
Deployment.getSystemBootStrapInfo(ConfigCenterDefaultDeploymentProvider.SYSTEM_KEY_CONFIG_CENTER);
+ Assert.assertEquals(info.getAccessURL().get(0), "https://localhost:9988");
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);
+
ConfigCenterDefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
+ SystemBootstrapInfo info =
Deployment.getSystemBootStrapInfo(ConfigCenterDefaultDeploymentProvider.SYSTEM_KEY_CONFIG_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");
+ Assert.assertEquals(info.getAccessURL().get(0), "https://localhost:9988");
+ Assert.assertEquals(info.getAccessURL().get(1), "https://localhost:9987");
System.getProperties().remove("servicecomb.config.client.serverUri");
}
}
diff --git a/dynamic-config/config-kie/pom.xml
b/dynamic-config/config-kie/pom.xml
index f014856..7a6c3b5 100644
--- a/dynamic-config/config-kie/pom.xml
+++ b/dynamic-config/config-kie/pom.xml
@@ -52,5 +52,14 @@
<artifactId>vertx-codegen</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>foundation-test-scaffolding</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git
a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorDefaultDeploymentProvider.java
b/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/collect/KieCenterDefaultDeploymentProvider.java
similarity index 64%
copy from
huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorDefaultDeploymentProvider.java
copy to
dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/collect/KieCenterDefaultDeploymentProvider.java
index 643696d..9488b67 100644
---
a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorDefaultDeploymentProvider.java
+++
b/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/collect/KieCenterDefaultDeploymentProvider.java
@@ -15,43 +15,38 @@
* limitations under the License.
*/
-package org.apache.servicecomb.huaweicloud.dashboard.monitor;
+package org.apache.servicecomb.config.kie.collect;
import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.configuration.AbstractConfiguration;
+import org.apache.commons.lang3.ArrayUtils;
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 java.util.Arrays;
-public class MonitorDefaultDeploymentProvider implements DeploymentProvider {
- private static AbstractConfiguration configuration =
ConfigUtil.createLocalConfig();
+public class KieCenterDefaultDeploymentProvider implements DeploymentProvider {
+ public static final String SYSTEM_KEY_KIE_CENTER = "KieCenter";
- @Override
- public int getOrder() {
- return 2;
- }
+ private static AbstractConfiguration configuration =
ConfigUtil.createLocalConfig();
@Override
public SystemBootstrapInfo getSystemBootStrapInfo(String systemKey) {
- switch (systemKey) {
- case MonitorConstant.SYSTEM_KEY_DASHBOARD_SERVICE:
- String[] msAddresses =
configuration.getStringArray(MonitorConstant.MONITOR_URI);
- if (msAddresses == null || msAddresses.length == 0) {
- return null;
- }
- SystemBootstrapInfo ms = new SystemBootstrapInfo();
- ms.setAccessURL(Arrays.asList(msAddresses));
- return ms;
- default:
- return null;
+ if (!systemKey.equals(SYSTEM_KEY_KIE_CENTER)) {
+ return null;
+ }
+ String[] kieAddresses =
configuration.getStringArray("servicecomb.kie.serverUri");
+ if (ArrayUtils.isEmpty(kieAddresses)) {
+ return null;
}
+ SystemBootstrapInfo kie = new SystemBootstrapInfo();
+ kie.setAccessURL(Arrays.asList(kieAddresses));
+ return kie;
}
@VisibleForTesting
public static void setConfiguration(AbstractConfiguration configuration) {
- MonitorDefaultDeploymentProvider.configuration = configuration;
+ KieCenterDefaultDeploymentProvider.configuration = configuration;
}
}
diff --git
a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorInformationCollector.java
b/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/collect/KieClientInformationCollector.java
similarity index 69%
copy from
huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorInformationCollector.java
copy to
dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/collect/KieClientInformationCollector.java
index 289c8a5..eed0c9d 100644
---
a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorInformationCollector.java
+++
b/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/collect/KieClientInformationCollector.java
@@ -15,28 +15,27 @@
* limitations under the License.
*/
-package org.apache.servicecomb.huaweicloud.dashboard.monitor;
+package org.apache.servicecomb.config.kie.collect;
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;
-public class MonitorInformationCollector implements BootUpInformationCollector
{
+import java.util.Objects;
+
+
+public class KieClientInformationCollector implements
BootUpInformationCollector {
@Override
public String collect() {
- return "monitor center: " +
getCenterInfo(Deployment.getSystemBootStrapInfo(MonitorConstant.SYSTEM_KEY_DASHBOARD_SERVICE));
+ return "Kie Center: " +
getCenterInfo(Deployment.getSystemBootStrapInfo("KieCenter"));
}
@Override
public int getOrder() {
- return 100;
+ return 2;
}
private String getCenterInfo(SystemBootstrapInfo systemBootstrapInfo) {
- if (systemBootstrapInfo == null) {
- return ("not exist");
- }
- return systemBootstrapInfo.getAccessURL().toString();
+ return Objects.isNull(systemBootstrapInfo) ? "not exist" :
systemBootstrapInfo.getAccessURL().toString();
}
}
diff --git
a/deployment/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.core.bootup.BootUpInformationCollector
similarity index 91%
copy from
deployment/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
copy to
dynamic-config/config-kie/src/main/resources/META-INF/services/org.apache.servicecomb.core.bootup.BootUpInformationCollector
index 49e32f1..cb357c9 100644
---
a/deployment/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.core.bootup.BootUpInformationCollector
@@ -14,5 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
-org.apache.servicecomb.deployment.DefaultDeploymentProvider
+org.apache.servicecomb.config.kie.collect.KieClientInformationCollector
\ No newline at end of file
diff --git
a/deployment/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
similarity index 91%
copy from
deployment/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
copy to
dynamic-config/config-kie/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
index 49e32f1..c712d01 100644
---
a/deployment/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
@@ -14,5 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
-org.apache.servicecomb.deployment.DefaultDeploymentProvider
+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/client/TestKieClient.java
b/dynamic-config/config-kie/src/test/java/org/apache/servicecomb/config/kie/client/TestKieClient.java
index 0a61f75..4b73db2 100644
---
a/dynamic-config/config-kie/src/test/java/org/apache/servicecomb/config/kie/client/TestKieClient.java
+++
b/dynamic-config/config-kie/src/test/java/org/apache/servicecomb/config/kie/client/TestKieClient.java
@@ -181,7 +181,7 @@ public class TestKieClient {
KieClient kie = new KieClient(updateHandler);
- ConfigRefresh refresh = kie.new
ConfigRefresh("http://configcentertest:30103");
+ ConfigRefresh refresh = kie.new
ConfigRefresh("http://configcentertest:30110");
refresh.run();
Assert.assertEquals("Fail event trigger", map.get("result"));
Mockito.when(event.statusCode()).thenReturn(200);
diff --git
a/dynamic-config/config-kie/src/test/java/org/apache/servicecomb/config/kie/client/TestKieConfig.java
b/dynamic-config/config-kie/src/test/java/org/apache/servicecomb/config/kie/client/TestKieConfig.java
index d0f0676..1f8e6d2 100644
---
a/dynamic-config/config-kie/src/test/java/org/apache/servicecomb/config/kie/client/TestKieConfig.java
+++
b/dynamic-config/config-kie/src/test/java/org/apache/servicecomb/config/kie/client/TestKieConfig.java
@@ -32,7 +32,7 @@ public class TestKieConfig {
@Test
public void getServerUri() {
String servers = KieConfig.INSTANCE.getServerUri();
- Assert.assertEquals("https://172.16.8.7:30103", servers);
+ Assert.assertEquals("https://172.16.8.7:30110", servers);
}
@Test
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
new file mode 100644
index 0000000..852b9dd
--- /dev/null
+++
b/dynamic-config/config-kie/src/test/java/org/apache/servicecomb/config/kie/collect/TestKieCenterDefaultDeploymentProvider.java
@@ -0,0 +1,69 @@
+/*
+ * 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.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestKieCenterDefaultDeploymentProvider {
+ @Before
+ public void start() {
+ ArchaiusUtils.resetConfig();
+ }
+
+ @After
+ public void tearDown() {
+ ArchaiusUtils.resetConfig();
+ }
+
+ @Test
+ public void testConfiguration() {
+
KieCenterDefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
+ SystemBootstrapInfo info =
Deployment.getSystemBootStrapInfo(KieCenterDefaultDeploymentProvider.SYSTEM_KEY_KIE_CENTER);
+ Assert.assertEquals(info.getAccessURL().get(0),
"https://172.16.8.7:30110");
+ Assert.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);
+ Assert.assertEquals(info.getAccessURL().get(0), "https://localhost:30110");
+ 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);
+ Assert.assertEquals(info.getAccessURL().size(), 2);
+ Assert.assertEquals(info.getAccessURL().get(0), "http://127.0.0.1:30110");
+ Assert.assertEquals(info.getAccessURL().get(1), "http://127.0.0.2:30110");
+
+ System.getProperties().remove("servicecomb.kie.serverUri");
+ }
+}
diff --git a/dynamic-config/config-kie/src/test/resources/microservice.yaml
b/dynamic-config/config-kie/src/test/resources/microservice.yaml
index 43c4863..4928e22 100644
--- a/dynamic-config/config-kie/src/test/resources/microservice.yaml
+++ b/dynamic-config/config-kie/src/test/resources/microservice.yaml
@@ -44,7 +44,7 @@ eureka:
defaultZone: http://172.16.8.8:30100/
servicecomb:
kie:
- serverUri: https://172.16.8.7:30103
+ serverUri: https://172.16.8.7:30110
service:
registry:
autodiscovery: true
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
index 643696d..7b42567 100644
---
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
@@ -19,6 +19,7 @@ package org.apache.servicecomb.huaweicloud.dashboard.monitor;
import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.configuration.AbstractConfiguration;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.servicecomb.config.ConfigUtil;
import org.apache.servicecomb.deployment.DeploymentProvider;
import org.apache.servicecomb.deployment.SystemBootstrapInfo;
@@ -31,23 +32,21 @@ public class MonitorDefaultDeploymentProvider implements
DeploymentProvider {
@Override
public int getOrder() {
- return 2;
+ return 3;
}
@Override
public SystemBootstrapInfo getSystemBootStrapInfo(String systemKey) {
- switch (systemKey) {
- case MonitorConstant.SYSTEM_KEY_DASHBOARD_SERVICE:
- String[] msAddresses =
configuration.getStringArray(MonitorConstant.MONITOR_URI);
- if (msAddresses == null || msAddresses.length == 0) {
- return null;
- }
- SystemBootstrapInfo ms = new SystemBootstrapInfo();
- ms.setAccessURL(Arrays.asList(msAddresses));
- return ms;
- default:
- return null;
+ if (!systemKey.equals(MonitorConstant.SYSTEM_KEY_DASHBOARD_SERVICE)) {
+ return null;
}
+ String[] msAddresses =
configuration.getStringArray(MonitorConstant.MONITOR_URI);
+ if (ArrayUtils.isEmpty(msAddresses)) {
+ return null;
+ }
+ SystemBootstrapInfo ms = new SystemBootstrapInfo();
+ ms.setAccessURL(Arrays.asList(msAddresses));
+ return ms;
}
@VisibleForTesting
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 289c8a5..30f765d 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
@@ -22,6 +22,8 @@ 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;
+
public class MonitorInformationCollector implements BootUpInformationCollector
{
@Override
public String collect() {
@@ -34,9 +36,6 @@ public class MonitorInformationCollector implements
BootUpInformationCollector {
}
private String getCenterInfo(SystemBootstrapInfo systemBootstrapInfo) {
- if (systemBootstrapInfo == null) {
- return ("not exist");
- }
- return systemBootstrapInfo.getAccessURL().toString();
+ return Objects.isNull(systemBootstrapInfo) ? "not exist" :
systemBootstrapInfo.getAccessURL().toString();
}
}
diff --git a/service-registry/registry-service-center/pom.xml
b/service-registry/registry-service-center/pom.xml
index 64653b8..4a17000 100644
--- a/service-registry/registry-service-center/pom.xml
+++ b/service-registry/registry-service-center/pom.xml
@@ -85,5 +85,9 @@
<groupId>org.apache.servicecomb</groupId>
<artifactId>foundation-test-scaffolding</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-core</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git
a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorDefaultDeploymentProvider.java
b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/collect/ServiceCenterDefaultDeploymentProvider.java
similarity index 64%
copy from
huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorDefaultDeploymentProvider.java
copy to
service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/collect/ServiceCenterDefaultDeploymentProvider.java
index 643696d..ed06281 100644
---
a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MonitorDefaultDeploymentProvider.java
+++
b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/collect/ServiceCenterDefaultDeploymentProvider.java
@@ -15,43 +15,38 @@
* limitations under the License.
*/
-package org.apache.servicecomb.huaweicloud.dashboard.monitor;
+package org.apache.servicecomb.serviceregistry.collect;
import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.configuration.AbstractConfiguration;
+import org.apache.commons.lang3.ArrayUtils;
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 java.util.Arrays;
-public class MonitorDefaultDeploymentProvider implements DeploymentProvider {
- private static AbstractConfiguration configuration =
ConfigUtil.createLocalConfig();
+public class ServiceCenterDefaultDeploymentProvider implements
DeploymentProvider {
+ public static final String SYSTEM_KEY_SERVICE_CENTER = "ServiceCenter";
- @Override
- public int getOrder() {
- return 2;
- }
+ private static AbstractConfiguration configuration =
ConfigUtil.createLocalConfig();
@Override
public SystemBootstrapInfo getSystemBootStrapInfo(String systemKey) {
- switch (systemKey) {
- case MonitorConstant.SYSTEM_KEY_DASHBOARD_SERVICE:
- String[] msAddresses =
configuration.getStringArray(MonitorConstant.MONITOR_URI);
- if (msAddresses == null || msAddresses.length == 0) {
- return null;
- }
- SystemBootstrapInfo ms = new SystemBootstrapInfo();
- ms.setAccessURL(Arrays.asList(msAddresses));
- return ms;
- default:
- return null;
+ if (!systemKey.equals(SYSTEM_KEY_SERVICE_CENTER)) {
+ return null;
+ }
+ SystemBootstrapInfo sc = new SystemBootstrapInfo();
+ String[] urls =
configuration.getStringArray("servicecomb.service.registry.address");
+ if (ArrayUtils.isEmpty(urls)) {
+ urls = new String[]{"http://127.0.0.1:30100"};
}
+ sc.setAccessURL(Arrays.asList(urls));
+ return sc;
}
@VisibleForTesting
public static void setConfiguration(AbstractConfiguration configuration) {
- MonitorDefaultDeploymentProvider.configuration = configuration;
+ ServiceCenterDefaultDeploymentProvider.configuration = configuration;
}
}
diff --git
a/core/src/main/java/org/apache/servicecomb/core/bootup/AddressInformationCollector.java
b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/collect/ServiceCenterInformationCollector.java
similarity index 75%
rename from
core/src/main/java/org/apache/servicecomb/core/bootup/AddressInformationCollector.java
rename to
service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/collect/ServiceCenterInformationCollector.java
index c8f79aa..62c3ef3 100644
---
a/core/src/main/java/org/apache/servicecomb/core/bootup/AddressInformationCollector.java
+++
b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/collect/ServiceCenterInformationCollector.java
@@ -15,18 +15,19 @@
* limitations under the License.
*/
-package org.apache.servicecomb.core.bootup;
+package org.apache.servicecomb.serviceregistry.collect;
+import org.apache.servicecomb.core.bootup.BootUpInformationCollector;
import org.apache.servicecomb.deployment.Deployment;
import org.apache.servicecomb.deployment.SystemBootstrapInfo;
-public class AddressInformationCollector implements BootUpInformationCollector
{
+import java.util.Objects;
+
+public class ServiceCenterInformationCollector implements
BootUpInformationCollector {
@Override
public String collect() {
return "Service Center: "
- + getCenterInfo(Deployment.getSystemBootStrapInfo("ServiceCenter"))
- + "\n" + "Config Center: "
- + getCenterInfo(Deployment.getSystemBootStrapInfo("ConfigCenter"));
+ + getCenterInfo(Deployment.getSystemBootStrapInfo("ServiceCenter"));
}
@Override
@@ -35,10 +36,6 @@ public class AddressInformationCollector implements
BootUpInformationCollector {
}
private String getCenterInfo(SystemBootstrapInfo systemBootstrapInfo) {
- if (systemBootstrapInfo == null) {
- return ("not exist");
- } else {
- return systemBootstrapInfo.getAccessURL().toString();
- }
+ return Objects.isNull(systemBootstrapInfo) ? "not exist" :
systemBootstrapInfo.getAccessURL().toString();
}
}
diff --git
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/config/ServiceRegistryConfigBuilder.java
b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/config/ServiceRegistryConfigBuilder.java
index 48aed79..26f7b9e 100644
---
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/config/ServiceRegistryConfigBuilder.java
+++
b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/config/ServiceRegistryConfigBuilder.java
@@ -23,7 +23,6 @@ import java.util.List;
import java.util.Objects;
import org.apache.servicecomb.deployment.Deployment;
-import org.apache.servicecomb.deployment.DeploymentProvider;
import org.apache.servicecomb.foundation.auth.AuthHeaderProvider;
import org.apache.servicecomb.foundation.common.net.IpPort;
import org.apache.servicecomb.foundation.common.net.NetUtils;
@@ -31,6 +30,7 @@ import
org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
import org.apache.servicecomb.foundation.vertx.VertxConst;
import
org.apache.servicecomb.serviceregistry.client.http.RegistryHttpClientOptionsSPI;
import
org.apache.servicecomb.serviceregistry.client.http.RegistryWatchHttpClientOptionsSPI;
+import
org.apache.servicecomb.serviceregistry.collect.ServiceCenterDefaultDeploymentProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -110,7 +110,7 @@ class ServiceRegistryConfigBuilder {
public ArrayList<IpPort> getIpPort() {
List<String> uriList = Objects
-
.requireNonNull(Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_SERVICE_CENTER),
+
.requireNonNull(Deployment.getSystemBootStrapInfo(ServiceCenterDefaultDeploymentProvider.SYSTEM_KEY_SERVICE_CENTER),
"no sc address found!")
.getAccessURL();
ArrayList<IpPort> ipPortList = new ArrayList<>();
diff --git
a/deployment/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
b/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.core.bootup.BootUpInformationCollector
similarity index 90%
copy from
deployment/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
copy to
service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.core.bootup.BootUpInformationCollector
index 49e32f1..7025b7a 100644
---
a/deployment/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
+++
b/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.core.bootup.BootUpInformationCollector
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.servicecomb.deployment.DefaultDeploymentProvider
+org.apache.servicecomb.serviceregistry.collect.ServiceCenterInformationCollector
\ No newline at end of file
diff --git
a/deployment/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
b/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
similarity index 90%
rename from
deployment/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
rename to
service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
index 49e32f1..a78f1cd 100644
---
a/deployment/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
+++
b/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.deployment.DeploymentProvider
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.servicecomb.deployment.DefaultDeploymentProvider
+org.apache.servicecomb.serviceregistry.collect.ServiceCenterDefaultDeploymentProvider
diff --git
a/deployment/src/test/java/org/apache/servicecomb/deployment/TestDeployment.java
b/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/collect/TestServiceCenterDefaultDeploymentProvider.java
similarity index 54%
copy from
deployment/src/test/java/org/apache/servicecomb/deployment/TestDeployment.java
copy to
service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/collect/TestServiceCenterDefaultDeploymentProvider.java
index 48d6bd3..b58ec09 100644
---
a/deployment/src/test/java/org/apache/servicecomb/deployment/TestDeployment.java
+++
b/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/collect/TestServiceCenterDefaultDeploymentProvider.java
@@ -15,15 +15,24 @@
* limitations under the License.
*/
-package org.apache.servicecomb.deployment;
+package org.apache.servicecomb.serviceregistry.collect;
import org.apache.servicecomb.config.ConfigUtil;
+import org.apache.servicecomb.deployment.Deployment;
+import org.apache.servicecomb.deployment.SystemBootstrapInfo;
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
-public class TestDeployment {
+public class TestServiceCenterDefaultDeploymentProvider {
+
+ @Before
+ public void start() {
+ ArchaiusUtils.resetConfig();
+ }
+
@After
public void tearDown() {
ArchaiusUtils.resetConfig();
@@ -31,45 +40,31 @@ public class TestDeployment {
@Test
public void testConfiguration() {
- DefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
- SystemBootstrapInfo info =
Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_SERVICE_CENTER);
+
ServiceCenterDefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
+ SystemBootstrapInfo info =
Deployment.getSystemBootStrapInfo(ServiceCenterDefaultDeploymentProvider.SYSTEM_KEY_SERVICE_CENTER);
Assert.assertEquals(info.getAccessURL().get(0), "http://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.setProperty("servicecomb.service.registry.address",
"https://localhost:30100");
+
ServiceCenterDefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
+ SystemBootstrapInfo info =
Deployment.getSystemBootStrapInfo(ServiceCenterDefaultDeploymentProvider.SYSTEM_KEY_SERVICE_CENTER);
+ Assert.assertEquals(info.getAccessURL().get(0), "https://localhost:30100");
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());
+ System.setProperty("servicecomb.service.registry.address",
"http://127.0.0.1:30100,http://127.0.0.2:30100");
+
ServiceCenterDefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
- SystemBootstrapInfo info =
Deployment.getSystemBootStrapInfo(DeploymentProvider.SYSTEM_KEY_SERVICE_CENTER);
+ SystemBootstrapInfo info =
Deployment.getSystemBootStrapInfo(ServiceCenterDefaultDeploymentProvider.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);
+ Assert.assertEquals(info.getAccessURL().get(0), "http://127.0.0.1:30100");
+ Assert.assertEquals(info.getAccessURL().get(1), "http://127.0.0.2:30100");
System.getProperties().remove("servicecomb.service.registry.address");
- System.getProperties().remove("servicecomb.config.client.serverUri");
}
}
diff --git
a/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/config/TestServiceRegistryConfig.java
b/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/config/TestServiceRegistryConfig.java
index 3b807e1..865231d 100644
---
a/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/config/TestServiceRegistryConfig.java
+++
b/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/config/TestServiceRegistryConfig.java
@@ -20,9 +20,9 @@ package org.apache.servicecomb.serviceregistry.config;
import java.util.List;
import org.apache.servicecomb.config.ConfigUtil;
-import org.apache.servicecomb.deployment.DefaultDeploymentProvider;
import org.apache.servicecomb.foundation.common.net.IpPort;
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
+import
org.apache.servicecomb.serviceregistry.collect.ServiceCenterDefaultDeploymentProvider;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -33,7 +33,7 @@ public class TestServiceRegistryConfig {
public static void initClass() {
ArchaiusUtils.resetConfig();
System.setProperty("servicecomb.service.registry.address",
"http://127.0.0.1, https://127.0.0.1");
- DefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
+
ServiceCenterDefaultDeploymentProvider.setConfiguration(ConfigUtil.createLocalConfig());
}
@AfterClass