You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2020/07/26 14:56:48 UTC
[shardingsphere] branch master updated: Refactor
OrchestrationRepositoryConfiguration's constructor (#6452)
This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 5ad1d91 Refactor OrchestrationRepositoryConfiguration's constructor (#6452)
5ad1d91 is described below
commit 5ad1d9133f0ad191a95a6b68d98f43f626665e84
Author: Liang Zhang <te...@163.com>
AuthorDate: Sun Jul 26 22:55:25 2020 +0800
Refactor OrchestrationRepositoryConfiguration's constructor (#6452)
* Revise javadoc
* Refactor OrchestrationRepositoryConfiguration's constructor
---
.../OrchestrationRepositoryConfigurationUtil.java | 12 ++---
.../core/facade/OrchestrationFacadeTest.java | 6 +--
.../OrchestrationRepositoryConfiguration.java | 16 ++----
.../OrchestrationRepositoryConfigurationTest.java | 61 ----------------------
...strationRepositoryConfigurationYamlSwapper.java | 5 +-
.../OrchestrationConfigurationYamlSwapperTest.java | 5 +-
...tionRepositoryConfigurationYamlSwapperTest.java | 5 +-
.../repository/apollo/ApolloRepositoryTest.java | 5 +-
.../apollo/wrapper/ApolloConfigWrapperTest.java | 6 +--
.../apollo/wrapper/ApolloOpenApiWrapperTest.java | 2 +-
.../repository/etcd/EtcdRepositoryTest.java | 3 --
.../repository/nacos/NacosRepositoryTest.java | 3 +-
.../zookeeper/CuratorZookeeperRepositoryTest.java | 18 +++----
.../OrchestrationShardingSphereDataSourceTest.java | 10 +---
.../parser/InstanceBeanDefinitionParser.java | 18 ++-----
15 files changed, 30 insertions(+), 145 deletions(-)
diff --git a/examples/shardingsphere-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/OrchestrationRepositoryConfigurationUtil.java b/examples/shardingsphere-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/OrchestrationRepositoryConfigurationUtil.java
index 0f5c6c8..701fdbf 100644
--- a/examples/shardingsphere-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/OrchestrationRepositoryConfigurationUtil.java
+++ b/examples/shardingsphere-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/OrchestrationRepositoryConfigurationUtil.java
@@ -36,9 +36,7 @@ public final class OrchestrationRepositoryConfigurationUtil {
public static OrchestrationConfiguration getZooKeeperConfiguration(final String overwrite, final ShardingType shardingType) {
Properties props = new Properties();
props.setProperty("overwrite", overwrite);
- OrchestrationRepositoryConfiguration orchestrationRepositoryConfiguration = new OrchestrationRepositoryConfiguration("zookeeper", props);
- orchestrationRepositoryConfiguration.setServerLists(ZOOKEEPER_CONNECTION_STRING);
- orchestrationRepositoryConfiguration.setNamespace(NAMESPACE);
+ OrchestrationRepositoryConfiguration orchestrationRepositoryConfiguration = new OrchestrationRepositoryConfiguration("zookeeper", ZOOKEEPER_CONNECTION_STRING, NAMESPACE, props);
switch (shardingType) {
case SHARDING_DATABASES_AND_TABLES:
return new OrchestrationConfiguration("orchestration-sharding-data-source", orchestrationRepositoryConfiguration);
@@ -58,14 +56,10 @@ public final class OrchestrationRepositoryConfigurationUtil {
nacosProperties.setProperty("group", "SHARDING_SPHERE_DEFAULT_GROUP");
nacosProperties.setProperty("timeout", "3000");
nacosProperties.setProperty("overwrite", overwrite);
- OrchestrationRepositoryConfiguration nacosResult = new OrchestrationRepositoryConfiguration("nacos", nacosProperties);
- nacosResult.setServerLists(NACOS_CONNECTION_STRING);
- nacosResult.setNamespace(NACOS_NAMESPACE);
+ OrchestrationRepositoryConfiguration nacosResult = new OrchestrationRepositoryConfiguration("nacos", NACOS_CONNECTION_STRING, NACOS_NAMESPACE, nacosProperties);
Properties zookeeperProperties = new Properties();
zookeeperProperties.setProperty("overwrite", overwrite);
- OrchestrationRepositoryConfiguration zookeeperResult = new OrchestrationRepositoryConfiguration("zookeeper", zookeeperProperties);
- zookeeperResult.setServerLists(ZOOKEEPER_CONNECTION_STRING);
- zookeeperResult.setNamespace(NAMESPACE);
+ OrchestrationRepositoryConfiguration zookeeperResult = new OrchestrationRepositoryConfiguration("zookeeper", ZOOKEEPER_CONNECTION_STRING, NAMESPACE, zookeeperProperties);
switch (shardingType) {
case SHARDING_DATABASES_AND_TABLES:
return new OrchestrationConfiguration("orchestration-zookeeper-sharding-data-source", zookeeperResult, nacosResult);
diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/test/java/org/apache/shardingsphere/orchestration/core/facade/OrchestrationFacadeTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/test/java/org/apache/shardingsphere/orchestration/core/facade/OrchestrationFacadeTest.java
index c712514..426c033 100644
--- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/test/java/org/apache/shardingsphere/orchestration/core/facade/OrchestrationFacadeTest.java
+++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/test/java/org/apache/shardingsphere/orchestration/core/facade/OrchestrationFacadeTest.java
@@ -68,10 +68,8 @@ public final class OrchestrationFacadeTest {
@Before
public void setUp() {
- OrchestrationRepositoryConfiguration configuration1 = new OrchestrationRepositoryConfiguration("REG_TEST", new Properties());
- configuration1.setNamespace("namespace_1");
- OrchestrationRepositoryConfiguration configuration2 = new OrchestrationRepositoryConfiguration("CONFIG_TEST", new Properties());
- configuration2.setNamespace("namespace_2");
+ OrchestrationRepositoryConfiguration configuration1 = new OrchestrationRepositoryConfiguration("REG_TEST", "127.0.0.1", "namespace_1", new Properties());
+ OrchestrationRepositoryConfiguration configuration2 = new OrchestrationRepositoryConfiguration("CONFIG_TEST", "127.0.0.1", "namespace_2", new Properties());
OrchestrationConfiguration orchestrationConfiguration = new OrchestrationConfiguration("test_name", configuration1, configuration2);
orchestrationFacade.init(orchestrationConfiguration, Arrays.asList("sharding_db", "masterslave_db"));
FieldUtil.setField(orchestrationFacade, "registryRepository", registryRepository);
diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-api/src/main/java/org/apache/shardingsphere/orchestration/repository/api/config/OrchestrationRepositoryConfiguration.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-api/src/main/java/org/apache/shardingsphere/orchestration/repository/api/config/ [...]
index 024a8dc..af3e2a9 100644
--- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-api/src/main/java/org/apache/shardingsphere/orchestration/repository/api/config/OrchestrationRepositoryConfiguration.java
+++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-api/src/main/java/org/apache/shardingsphere/orchestration/repository/api/config/OrchestrationRepositoryConfiguration.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.orchestration.repository.api.config;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.infra.config.TypedSPIConfiguration;
import java.util.Properties;
@@ -27,20 +26,15 @@ import java.util.Properties;
* Orchestration repository configuration.
*/
@Getter
-@Setter
public final class OrchestrationRepositoryConfiguration extends TypedSPIConfiguration {
- /**
- * Server list of center.
- */
- private String serverLists;
+ private final String serverLists;
- /**
- * Namespace of center.
- */
- private String namespace;
+ private final String namespace;
- public OrchestrationRepositoryConfiguration(final String type, final Properties props) {
+ public OrchestrationRepositoryConfiguration(final String type, final String serverLists, final String namespace, final Properties props) {
super(type, props);
+ this.serverLists = serverLists;
+ this.namespace = namespace;
}
}
diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-api/src/test/java/org/apache/shardingsphere/orchestration/repository/api/config/OrchestrationRepositoryConfigurationTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-api/src/test/java/org/apache/shardingsphere/orchestration/repository/api/con [...]
deleted file mode 100644
index 195aaa8..0000000
--- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-api/src/test/java/org/apache/shardingsphere/orchestration/repository/api/config/OrchestrationRepositoryConfigurationTest.java
+++ /dev/null
@@ -1,61 +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.shardingsphere.orchestration.repository.api.config;
-
-import org.junit.Test;
-
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class OrchestrationRepositoryConfigurationTest {
-
- @Test
- public void assertConstructorWithType() {
- String type = "zookeeper";
- assertThat(new OrchestrationRepositoryConfiguration(type, new Properties()).getType(), is(type));
- }
-
- @Test
- public void assertConstructorWithTypeAndProperties() {
- String type = "zookeeper";
- Properties props = new Properties();
- OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(type, props);
- assertThat(configuration.getType(), is(type));
- assertThat(configuration.getProps(), is(props));
- }
-
- @Test
- public void assertServerLists() {
- String type = "zookeeper";
- String serverLists = "127.0.0.1:2181,127.0.0.1:2182";
- OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(type, new Properties());
- configuration.setServerLists(serverLists);
- assertThat(configuration.getServerLists(), is(serverLists));
- }
-
- @Test
- public void assertNamespace() {
- String type = "zookeeper";
- String namespace = "orchestration";
- OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(type, new Properties());
- configuration.setNamespace(namespace);
- assertThat(configuration.getNamespace(), is(namespace));
- }
-}
diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-common/src/main/java/org/apache/shardingsphere/orchestration/repository/common/configuration/swapper/OrchestrationRepositoryConfigurationYamlSwapper.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-common/src/main/java/org/apache/shardingsphere/o [...]
index 7dfea6e..ec9e74c 100644
--- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-common/src/main/java/org/apache/shardingsphere/orchestration/repository/common/configuration/swapper/OrchestrationRepositoryConfigurationYamlSwapper.java
+++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-common/src/main/java/org/apache/shardingsphere/orchestration/repository/common/configuration/swapper/OrchestrationRepositoryConfigurationYamlSwapper.java
@@ -38,9 +38,6 @@ public final class OrchestrationRepositoryConfigurationYamlSwapper implements Ya
@Override
public OrchestrationRepositoryConfiguration swapToObject(final YamlOrchestrationRepositoryConfiguration yamlConfiguration) {
- OrchestrationRepositoryConfiguration result = new OrchestrationRepositoryConfiguration(yamlConfiguration.getInstanceType(), yamlConfiguration.getProps());
- result.setServerLists(yamlConfiguration.getServerLists());
- result.setNamespace(yamlConfiguration.getNamespace());
- return result;
+ return new OrchestrationRepositoryConfiguration(yamlConfiguration.getInstanceType(), yamlConfiguration.getServerLists(), yamlConfiguration.getNamespace(), yamlConfiguration.getProps());
}
}
diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-common/src/test/java/org/apache/shardingsphere/orchestration/repository/common/configuration/swapper/OrchestrationConfigurationYamlSwapperTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-common/src/test/java/org/apache/shardingsphere/orchest [...]
index 6b45042..786ab7c 100644
--- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-common/src/test/java/org/apache/shardingsphere/orchestration/repository/common/configuration/swapper/OrchestrationConfigurationYamlSwapperTest.java
+++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-common/src/test/java/org/apache/shardingsphere/orchestration/repository/common/configuration/swapper/OrchestrationConfigurationYamlSwapperTest.java
@@ -43,10 +43,7 @@ public final class OrchestrationConfigurationYamlSwapperTest {
}
private OrchestrationConfiguration getOrchestrationConfiguration() {
- OrchestrationRepositoryConfiguration repositoryConfiguration = new OrchestrationRepositoryConfiguration("zookeeper", new Properties());
- repositoryConfiguration.setServerLists("127.0.0.1:2181,127.0.0.1:2182");
- repositoryConfiguration.setNamespace("orchestration");
- return new OrchestrationConfiguration(LOGIC_SCHEMA, repositoryConfiguration);
+ return new OrchestrationConfiguration(LOGIC_SCHEMA, new OrchestrationRepositoryConfiguration("zookeeper", "127.0.0.1:2181,127.0.0.1:2182", "orchestration", new Properties()));
}
@Test
diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-common/src/test/java/org/apache/shardingsphere/orchestration/repository/common/configuration/swapper/OrchestrationRepositoryConfigurationYamlSwapperTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-common/src/test/java/org/apache/shardingsphe [...]
index ced850d..3a7f313 100644
--- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-common/src/test/java/org/apache/shardingsphere/orchestration/repository/common/configuration/swapper/OrchestrationRepositoryConfigurationYamlSwapperTest.java
+++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-common/src/test/java/org/apache/shardingsphere/orchestration/repository/common/configuration/swapper/OrchestrationRepositoryConfigurationYamlSwapperTest.java
@@ -39,10 +39,7 @@ public final class OrchestrationRepositoryConfigurationYamlSwapperTest {
}
private OrchestrationRepositoryConfiguration getConfiguration() {
- OrchestrationRepositoryConfiguration result = new OrchestrationRepositoryConfiguration("zookeeper", new Properties());
- result.setServerLists("127.0.0.1:2181,127.0.0.1:2182");
- result.setNamespace("orchestration");
- return result;
+ return new OrchestrationRepositoryConfiguration("zookeeper", "127.0.0.1:2181,127.0.0.1:2182", "orchestration", new Properties());
}
@Test
diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-apollo/src/test/java/org/apache/shardingsphere/orchestration/repository/apollo/ApolloRepositoryTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository [...]
index dc93a46..cdbf47f 100644
--- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-apollo/src/test/java/org/apache/shardingsphere/orchestration/repository/apollo/ApolloRepositoryTest.java
+++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-apollo/src/test/java/org/apache/shardingsphere/orchestration/repository/apollo/ApolloRepositoryTest.java
@@ -64,12 +64,11 @@ public final class ApolloRepositoryTest {
@SneakyThrows(ReflectiveOperationException.class)
@BeforeClass
public static void init() {
- OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration("apollo", new Properties());
- configuration.setServerLists("http://config-service-url");
- configuration.setNamespace("orchestration");
+
Properties props = new Properties();
props.setProperty(ApolloPropertyKey.PORTAL_URL.getKey(), PORTAL_URL);
props.setProperty(ApolloPropertyKey.TOKEN.getKey(), TOKEN);
+ OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration("apollo", "http://config-service-url", "orchestration", props);
REPOSITORY.setProps(props);
REPOSITORY.init(configuration);
ApolloConfigWrapper configWrapper = new ApolloConfigWrapper(configuration, new ApolloProperties(props));
diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-apollo/src/test/java/org/apache/shardingsphere/orchestration/repository/apollo/wrapper/ApolloConfigWrapperTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration [...]
index 225f6e0..b1d1e74 100644
--- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-apollo/src/test/java/org/apache/shardingsphere/orchestration/repository/apollo/wrapper/ApolloConfigWrapperTest.java
+++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-apollo/src/test/java/org/apache/shardingsphere/orchestration/repository/apollo/wrapper/ApolloConfigWrapperTest.java
@@ -51,10 +51,8 @@ public final class ApolloConfigWrapperTest {
@Before
public void setup() {
- OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration("apollo", new Properties());
- configuration.setServerLists("http://config-service-url");
- configuration.setNamespace("orchestration");
- configWrapper = new ApolloConfigWrapper(configuration, new ApolloProperties(new Properties()));
+ configWrapper = new ApolloConfigWrapper(
+ new OrchestrationRepositoryConfiguration("apollo", "http://config-service-url", "orchestration", new Properties()), new ApolloProperties(new Properties()));
}
@Test
diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-apollo/src/test/java/org/apache/shardingsphere/orchestration/repository/apollo/wrapper/ApolloOpenApiWrapperTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestratio [...]
index 599193d..b77f821 100644
--- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-apollo/src/test/java/org/apache/shardingsphere/orchestration/repository/apollo/wrapper/ApolloOpenApiWrapperTest.java
+++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-apollo/src/test/java/org/apache/shardingsphere/orchestration/repository/apollo/wrapper/ApolloOpenApiWrapperTest.java
@@ -64,7 +64,7 @@ public final class ApolloOpenApiWrapperTest {
Properties props = new Properties();
props.setProperty(ApolloPropertyKey.PORTAL_URL.getKey(), PORTAL_URL);
props.setProperty(ApolloPropertyKey.TOKEN.getKey(), TOKEN);
- apolloOpenApiWrapper = new ApolloOpenApiWrapper(new OrchestrationRepositoryConfiguration("apollo", new Properties()), new ApolloProperties(props));
+ apolloOpenApiWrapper = new ApolloOpenApiWrapper(new OrchestrationRepositoryConfiguration("apollo", "127.0.0.1", null, new Properties()), new ApolloProperties(props));
FieldSetter.setField(apolloOpenApiWrapper, ApolloOpenApiWrapper.class.getDeclaredField("client"), client);
FieldSetter.setField(apolloOpenApiWrapper, ApolloOpenApiWrapper.class.getDeclaredField("namespace"), NAME_SPACE);
FieldSetter.setField(apolloOpenApiWrapper, ApolloOpenApiWrapper.class.getDeclaredField("appId"), ApolloPropertyKey.APP_ID.getDefaultValue());
diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-etcd/src/test/java/org/apache/shardingsphere/orchestration/repository/etcd/EtcdRepositoryTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-etcd/ [...]
index a5651a1..6825293 100644
--- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-etcd/src/test/java/org/apache/shardingsphere/orchestration/repository/etcd/EtcdRepositoryTest.java
+++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-etcd/src/test/java/org/apache/shardingsphere/orchestration/repository/etcd/EtcdRepositoryTest.java
@@ -33,7 +33,6 @@ import io.etcd.jetcd.watch.WatchEvent;
import io.etcd.jetcd.watch.WatchResponse;
import io.grpc.stub.StreamObserver;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationRepositoryConfiguration;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -223,8 +222,6 @@ public final class EtcdRepositoryTest {
@Test
public void assertProperties() {
- OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(CENTER_TYPE, new Properties());
- configuration.setServerLists("127.0.0.1");
Properties props = new Properties();
repository.setProps(props);
assertThat(repository.getProps(), is(props));
diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-nacos/src/test/java/org/apache/shardingsphere/orchestration/repository/nacos/NacosRepositoryTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-na [...]
index fdcbae1..41635b8 100644
--- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-nacos/src/test/java/org/apache/shardingsphere/orchestration/repository/nacos/NacosRepositoryTest.java
+++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-nacos/src/test/java/org/apache/shardingsphere/orchestration/repository/nacos/NacosRepositoryTest.java
@@ -60,8 +60,7 @@ public final class NacosRepositoryTest {
Properties props = new Properties();
props.setProperty("group", group);
props.setProperty("timeout", "3000");
- OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(REPOSITORY.getType(), props);
- configuration.setServerLists("127.0.0.1:8848");
+ OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(REPOSITORY.getType(), "127.0.0.1:8848", "", props);
REPOSITORY.init(configuration);
setConfigService(configService);
}
diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-zookeeper-curator/src/test/java/org/apache/shardingsphere/orchestration/repository/zookeeper/CuratorZookeeperRepositoryTest.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere- [...]
index b3d75e5..f824c37 100644
--- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-zookeeper-curator/src/test/java/org/apache/shardingsphere/orchestration/repository/zookeeper/CuratorZookeeperRepositoryTest.java
+++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-zookeeper-curator/src/test/java/org/apache/shardingsphere/orchestration/repository/zookeeper/CuratorZookeeperRepositoryTest.java
@@ -46,8 +46,7 @@ public final class CuratorZookeeperRepositoryTest {
public static void init() {
EmbedTestingServer.start();
serverLists = EmbedTestingServer.getTestingServerConnectionString();
- OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(REPOSITORY.getType(), new Properties());
- configuration.setServerLists(serverLists);
+ OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(REPOSITORY.getType(), serverLists, null, new Properties());
REPOSITORY.init(configuration);
}
@@ -136,8 +135,7 @@ public final class CuratorZookeeperRepositoryTest {
props.setProperty(ZookeeperPropertyKey.MAX_RETRIES.getKey(), "1");
props.setProperty(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey(), "1000");
props.setProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey(), "2000");
- OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(repository.getType(), new Properties());
- configuration.setServerLists(serverLists);
+ OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(repository.getType(), serverLists, null, new Properties());
repository.setProps(props);
repository.init(configuration);
assertThat(repository.getProps().getProperty(ZookeeperPropertyKey.RETRY_INTERVAL_MILLISECONDS.getKey()), is("1000"));
@@ -153,8 +151,7 @@ public final class CuratorZookeeperRepositoryTest {
final CuratorZookeeperRepository repository = new CuratorZookeeperRepository();
Properties props = new Properties();
props.setProperty(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey(), "0");
- OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(repository.getType(), new Properties());
- configuration.setServerLists(serverLists);
+ OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(repository.getType(), serverLists, null, new Properties());
repository.setProps(props);
repository.init(configuration);
assertThat(repository.getProps().getProperty(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey()), is("0"));
@@ -167,8 +164,7 @@ public final class CuratorZookeeperRepositoryTest {
final CuratorZookeeperRepository repository = new CuratorZookeeperRepository();
Properties props = new Properties();
props.setProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey(), "0");
- OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(repository.getType(), new Properties());
- configuration.setServerLists(serverLists);
+ OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(repository.getType(), serverLists, null, new Properties());
repository.setProps(props);
repository.init(configuration);
assertThat(repository.getProps().getProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey()), is("0"));
@@ -181,8 +177,7 @@ public final class CuratorZookeeperRepositoryTest {
final CuratorZookeeperRepository repository = new CuratorZookeeperRepository();
Properties props = new Properties();
props.setProperty(ZookeeperPropertyKey.DIGEST.getKey(), "any");
- OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(repository.getType(), new Properties());
- configuration.setServerLists(serverLists);
+ OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(repository.getType(), serverLists, null, new Properties());
repository.setProps(props);
repository.init(configuration);
assertThat(repository.getProps().getProperty(ZookeeperPropertyKey.DIGEST.getKey()), is("any"));
@@ -204,10 +199,9 @@ public final class CuratorZookeeperRepositoryTest {
@Test
public void assertZKCloseAndException() {
CuratorZookeeperRepository repository = new CuratorZookeeperRepository();
- OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(repository.getType(), new Properties());
+ OrchestrationRepositoryConfiguration configuration = new OrchestrationRepositoryConfiguration(repository.getType(), serverLists, null, new Properties());
Properties props = new Properties();
props.setProperty(ZookeeperPropertyKey.DIGEST.getKey(), "digest");
- configuration.setServerLists(serverLists);
repository.setProps(props);
repository.init(configuration);
repository.close();
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-orchestration/src/test/java/org/apache/shardingsphere/driver/orchestration/internal/datasource/OrchestrationShardingSphereDataSourceTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-orchestration/src/test/java/org/apache/shardingsphere/driver/orchestration/internal/datasource/OrchestrationShardingSphereDataSourceTest.java
index 46d114f..1a197a8 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-orchestration/src/test/java/org/apache/shardingsphere/driver/orchestration/internal/datasource/OrchestrationShardingSphereDataSourceTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-orchestration/src/test/java/org/apache/shardingsphere/driver/orchestration/internal/datasource/OrchestrationShardingSphereDataSourceTest.java
@@ -77,19 +77,13 @@ public final class OrchestrationShardingSphereDataSourceTest {
private static OrchestrationRepositoryConfiguration getRegistryOrchestrationRepositoryConfiguration() {
Properties properties = new Properties();
properties.setProperty("overwrite", "true");
- OrchestrationRepositoryConfiguration result = new OrchestrationRepositoryConfiguration("REG_TEST", properties);
- result.setNamespace("test_sharding_registry");
- result.setServerLists("localhost:3181");
- return result;
+ return new OrchestrationRepositoryConfiguration("REG_TEST", "localhost:3181", "test_sharding_registry", properties);
}
private static OrchestrationRepositoryConfiguration getConfigOrchestrationRepositoryConfiguration() {
Properties properties = new Properties();
properties.setProperty("overwrite", "true");
- OrchestrationRepositoryConfiguration result = new OrchestrationRepositoryConfiguration("CONFIG_TEST", properties);
- result.setNamespace("test_sharding_config");
- result.setServerLists("localhost:3181");
- return result;
+ return new OrchestrationRepositoryConfiguration("CONFIG_TEST", "localhost:3181", "test_sharding_config", properties);
}
@Test
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-namespace/src/main/java/org/apache/shardingsphere/spring/namespace/orchestration/parser/InstanceBeanDefinitionParser.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-namespace/src/main/java/org/apache/shardingsphere/spring/namespace/orchestration/parser/InstanceBe [...]
index 504b30c..8883c71 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-namespace/src/main/java/org/apache/shardingsphere/spring/namespace/orchestration/parser/InstanceBeanDefinitionParser.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-namespace/src/main/java/org/apache/shardingsphere/spring/namespace/orchestration/parser/InstanceBeanDefinitionParser.java
@@ -17,9 +17,8 @@
package org.apache.shardingsphere.spring.namespace.orchestration.parser;
-import com.google.common.base.Strings;
-import org.apache.shardingsphere.spring.namespace.orchestration.constants.InstanceBeanDefinitionTag;
import org.apache.shardingsphere.orchestration.repository.api.config.OrchestrationRepositoryConfiguration;
+import org.apache.shardingsphere.spring.namespace.orchestration.constants.InstanceBeanDefinitionTag;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
@@ -34,27 +33,16 @@ import java.util.Properties;
*/
public final class InstanceBeanDefinitionParser extends AbstractBeanDefinitionParser {
- private static final String PROPERTY_SERVER_LIST = "serverLists";
-
- private static final String PROPERTY_NAMESPACE = "namespace";
-
@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(OrchestrationRepositoryConfiguration.class);
factory.addConstructorArgValue(element.getAttribute(InstanceBeanDefinitionTag.TYPE_TAG));
+ factory.addConstructorArgValue(element.getAttribute(InstanceBeanDefinitionTag.SERVER_LISTS_TAG));
+ factory.addConstructorArgValue(element.getAttribute(InstanceBeanDefinitionTag.NAMESPACE_TAG));
factory.addConstructorArgValue(parseProperties(element, parserContext));
- addPropertyValueIfNotEmpty(InstanceBeanDefinitionTag.SERVER_LISTS_TAG, PROPERTY_SERVER_LIST, element, factory);
- addPropertyValueIfNotEmpty(InstanceBeanDefinitionTag.NAMESPACE_TAG, PROPERTY_NAMESPACE, element, factory);
return factory.getBeanDefinition();
}
- private void addPropertyValueIfNotEmpty(final String attributeName, final String propertyName, final Element element, final BeanDefinitionBuilder factory) {
- String attributeValue = element.getAttribute(attributeName);
- if (!Strings.isNullOrEmpty(attributeValue)) {
- factory.addPropertyValue(propertyName, attributeValue);
- }
- }
-
private Properties parseProperties(final Element element, final ParserContext parserContext) {
Element propsElement = DomUtils.getChildElementByTagName(element, InstanceBeanDefinitionTag.PROP_TAG);
return null == propsElement ? new Properties() : parserContext.getDelegate().parsePropsElement(propsElement);