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 c8c16f9 Remove name of ConfigCenterNode
new 9061a1d Merge pull request #7069 from menghaoranss/dev0825
c8c16f9 is described below
commit c8c16f91ca2fc66f2c3b4a733440ae1e820cac53
Author: menghaoranss <[email protected]>
AuthorDate: Wed Aug 26 00:19:21 2020 +0800
Remove name of ConfigCenterNode
---
.../orchestration/core/config/ConfigCenter.java | 4 +-
.../core/config/ConfigCenterNode.java | 10 +-
.../listener/AuthenticationChangedListener.java | 4 +-
.../ClusterConfigurationChangedListener.java | 4 +-
.../listener/ConfigurationListenerManager.java | 12 +-
.../MetricsConfigurationChangedListener.java | 4 +-
.../config/listener/PropertiesChangedListener.java | 4 +-
.../config/listener/SchemaChangedListener.java | 8 +-
.../core/config/ConfigCenterNodeTest.java | 28 ++--
.../core/config/ConfigCenterTest.java | 172 ++++++++++-----------
.../AuthenticationChangedListenerTest.java | 2 +-
.../ClusterConfigurationChangedListenerTest.java | 2 +-
.../listener/ConfigurationListenerManagerTest.java | 2 +-
.../MetricsConfigurationChangedListenerTest.java | 2 +-
.../listener/PropertiesChangedListenerTest.java | 2 +-
.../config/listener/SchemaChangedListenerTest.java | 80 +++++-----
.../core/facade/OrchestrationFacade.java | 10 +-
.../listener/OrchestrationListenerManager.java | 8 +-
.../listener/OrchestrationListenerManagerTest.java | 2 +-
.../core/metadata/MetaDataCenter.java | 4 +-
.../core/metadata/MetaDataCenterNode.java | 4 +-
.../metadata/listener/MetaDataChangedListener.java | 4 +-
.../metadata/listener/MetaDataListenerManager.java | 4 +-
.../core/metadata/MetaDataCenterNodeTest.java | 4 +-
.../core/metadata/MetaDataCenterTest.java | 8 +-
.../listener/MetaDataChangedListenerTest.java | 4 +-
.../listener/MetaDataListenerManagerTest.java | 2 +-
.../core/registry/RegistryCenter.java | 4 +-
.../core/registry/RegistryCenterNode.java | 8 +-
.../listener/DataSourceStateChangedListener.java | 6 +-
.../listener/InstanceStateChangedListener.java | 4 +-
.../registry/listener/RegistryListenerManager.java | 6 +-
.../core/registry/RegistryCenterNodeTest.java | 10 +-
.../core/registry/RegistryCenterTest.java | 4 +-
.../DataSourceStateChangedListenerTest.java | 4 +-
.../listener/InstanceStateChangedListenerTest.java | 6 +-
.../listener/RegistryListenerManagerTest.java | 2 +-
.../repository/etcd/EtcdRepository.java | 2 +-
.../zookeeper/CuratorZookeeperRepository.java | 7 +-
.../OrchestrationSpringBootMasterSlaveTest.java | 2 +-
...OrchestrationSpringBootRegistryEncryptTest.java | 8 +-
...estrationSpringBootRegistryMasterSlaveTest.java | 24 +--
...rchestrationSpringBootRegistryShardingTest.java | 9 +-
.../test/resources/application-encrypt.properties | 2 +-
.../resources/application-masterslave.properties | 6 +-
...=> application-registry-masterslave.properties} | 19 +--
46 files changed, 252 insertions(+), 275 deletions(-)
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenter.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenter.java
index 56babde..3b0fcfd 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenter.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenter.java
@@ -68,8 +68,8 @@ public final class ConfigCenter {
private final ConfigurationRepository repository;
- public ConfigCenter(final String name, final ConfigurationRepository
repository) {
- node = new ConfigCenterNode(name);
+ public ConfigCenter(final ConfigurationRepository repository) {
+ node = new ConfigCenterNode();
this.repository = repository;
DataSourceCallback.getInstance().register(this::persistDataSourceConfiguration);
RuleCallback.getInstance().register(this::persistRuleConfigurations);
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNode.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNode.java
index b615765..527ff51 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNode.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNode.java
@@ -54,15 +54,13 @@ public final class ConfigCenterNode {
private static final String PATH_SEPARATOR = "/";
- private final String name;
-
/**
* Get schema path.
*
* @return schema path
*/
public String getSchemaPath() {
- return Joiner.on(PATH_SEPARATOR).join("", name, ROOT, SCHEMA_NODE);
+ return Joiner.on(PATH_SEPARATOR).join("", ROOT, SCHEMA_NODE);
}
/**
@@ -72,7 +70,7 @@ public final class ConfigCenterNode {
* @return schema name path
*/
public String getSchemaNamePath(final String schemaName) {
- return Joiner.on(PATH_SEPARATOR).join("", name, ROOT, SCHEMA_NODE,
schemaName);
+ return Joiner.on(PATH_SEPARATOR).join("", ROOT, SCHEMA_NODE,
schemaName);
}
/**
@@ -114,11 +112,11 @@ public final class ConfigCenterNode {
}
private String getFullPath(final String schemaName, final String node) {
- return Joiner.on(PATH_SEPARATOR).join("", name, ROOT, SCHEMA_NODE,
schemaName, node);
+ return Joiner.on(PATH_SEPARATOR).join("", ROOT, SCHEMA_NODE,
schemaName, node);
}
private String getFullPath(final String node) {
- return Joiner.on(PATH_SEPARATOR).join("", name, ROOT, node);
+ return Joiner.on(PATH_SEPARATOR).join("", ROOT, node);
}
/**
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/AuthenticationChangedListener.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/AuthenticationChangedListener.java
index 4e0fc97..7f164c5 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/AuthenticationChangedListener.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/AuthenticationChangedListener.java
@@ -33,8 +33,8 @@ import java.util.Collections;
*/
public final class AuthenticationChangedListener extends
PostOrchestrationRepositoryEventListener {
- public AuthenticationChangedListener(final String name, final
ConfigurationRepository configurationRepository) {
- super(configurationRepository, Collections.singletonList(new
ConfigCenterNode(name).getAuthenticationPath()));
+ public AuthenticationChangedListener(final ConfigurationRepository
configurationRepository) {
+ super(configurationRepository, Collections.singletonList(new
ConfigCenterNode().getAuthenticationPath()));
}
@Override
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/ClusterConfigurationChangedListener.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/ClusterConfigurationC
[...]
index 0027966..1f5e35b 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/ClusterConfigurationChangedListener.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/ClusterConfigurationChangedListener.java
@@ -33,8 +33,8 @@ import java.util.Collections;
*/
public final class ClusterConfigurationChangedListener extends
PostOrchestrationRepositoryEventListener {
- public ClusterConfigurationChangedListener(final String name, final
ConfigurationRepository configurationRepository) {
- super(configurationRepository, Collections.singletonList(new
ConfigCenterNode(name).getClusterPath()));
+ public ClusterConfigurationChangedListener(final ConfigurationRepository
configurationRepository) {
+ super(configurationRepository, Collections.singletonList(new
ConfigCenterNode().getClusterPath()));
}
@Override
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/ConfigurationListenerManager.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/ConfigurationListenerManager.java
index 5a16956..d9c693b 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/ConfigurationListenerManager.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/ConfigurationListenerManager.java
@@ -37,12 +37,12 @@ public final class ConfigurationListenerManager {
private final ClusterConfigurationChangedListener
clusterConfigurationChangedListener;
- public ConfigurationListenerManager(final String name, final
ConfigurationRepository configurationRepository, final Collection<String>
schemaNames) {
- schemaChangedListener = new SchemaChangedListener(name,
configurationRepository, schemaNames);
- propertiesChangedListener = new PropertiesChangedListener(name,
configurationRepository);
- authenticationChangedListener = new
AuthenticationChangedListener(name, configurationRepository);
- metricsConfigurationChangedListener = new
MetricsConfigurationChangedListener(name, configurationRepository);
- clusterConfigurationChangedListener = new
ClusterConfigurationChangedListener(name, configurationRepository);
+ public ConfigurationListenerManager(final ConfigurationRepository
configurationRepository, final Collection<String> schemaNames) {
+ schemaChangedListener = new
SchemaChangedListener(configurationRepository, schemaNames);
+ propertiesChangedListener = new
PropertiesChangedListener(configurationRepository);
+ authenticationChangedListener = new
AuthenticationChangedListener(configurationRepository);
+ metricsConfigurationChangedListener = new
MetricsConfigurationChangedListener(configurationRepository);
+ clusterConfigurationChangedListener = new
ClusterConfigurationChangedListener(configurationRepository);
}
/**
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/MetricsConfigurationChangedListener.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/MetricsConfigurationC
[...]
index 7a3799b..8a9fa82 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/MetricsConfigurationChangedListener.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/MetricsConfigurationChangedListener.java
@@ -33,8 +33,8 @@ import java.util.Collections;
*/
public final class MetricsConfigurationChangedListener extends
PostOrchestrationRepositoryEventListener {
- public MetricsConfigurationChangedListener(final String name, final
ConfigurationRepository configurationRepository) {
- super(configurationRepository, Collections.singletonList(new
ConfigCenterNode(name).getMetricsPath()));
+ public MetricsConfigurationChangedListener(final ConfigurationRepository
configurationRepository) {
+ super(configurationRepository, Collections.singletonList(new
ConfigCenterNode().getMetricsPath()));
}
@Override
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/PropertiesChangedListener.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/PropertiesChangedListener.java
index b267183..ebe5d79 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/PropertiesChangedListener.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/PropertiesChangedListener.java
@@ -31,8 +31,8 @@ import java.util.Collections;
*/
public final class PropertiesChangedListener extends
PostOrchestrationRepositoryEventListener {
- public PropertiesChangedListener(final String name, final
ConfigurationRepository configurationRepository) {
- super(configurationRepository, Collections.singletonList(new
ConfigCenterNode(name).getPropsPath()));
+ public PropertiesChangedListener(final ConfigurationRepository
configurationRepository) {
+ super(configurationRepository, Collections.singletonList(new
ConfigCenterNode().getPropsPath()));
}
@Override
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/SchemaChangedListener.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/SchemaChangedListener.java
index 2dd93d2..240171e 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/SchemaChangedListener.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/listener/SchemaChangedListener.java
@@ -59,10 +59,10 @@ public final class SchemaChangedListener extends
PostOrchestrationRepositoryEven
private final Collection<String> existedSchemaNames = new
LinkedHashSet<>();
- public SchemaChangedListener(final String name, final
ConfigurationRepository configurationRepository, final Collection<String>
schemaNames) {
- super(configurationRepository, new
ConfigCenterNode(name).getAllSchemaConfigPaths(schemaNames));
- configurationService = new ConfigCenter(name, configurationRepository);
- configurationNode = new ConfigCenterNode(name);
+ public SchemaChangedListener(final ConfigurationRepository
configurationRepository, final Collection<String> schemaNames) {
+ super(configurationRepository, new
ConfigCenterNode().getAllSchemaConfigPaths(schemaNames));
+ configurationService = new ConfigCenter(configurationRepository);
+ configurationNode = new ConfigCenterNode();
existedSchemaNames.addAll(schemaNames);
}
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNodeTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNodeTest.java
index d9cf7f6..8d12715 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNodeTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterNodeTest.java
@@ -30,60 +30,60 @@ import static org.junit.Assert.assertTrue;
public final class ConfigCenterNodeTest {
- private final ConfigCenterNode configurationNode = new
ConfigCenterNode("test");
+ private final ConfigCenterNode configurationNode = new ConfigCenterNode();
@Test
public void assertGetSchemaPath() {
- assertThat(configurationNode.getRulePath(DefaultSchema.LOGIC_NAME),
is("/test/config/schema/logic_db/rule"));
+ assertThat(configurationNode.getRulePath(DefaultSchema.LOGIC_NAME),
is("/config/schema/logic_db/rule"));
}
@Test
public void assertGetDataSourcePath() {
-
assertThat(configurationNode.getDataSourcePath(DefaultSchema.LOGIC_NAME),
is("/test/config/schema/logic_db/datasource"));
+
assertThat(configurationNode.getDataSourcePath(DefaultSchema.LOGIC_NAME),
is("/config/schema/logic_db/datasource"));
}
@Test
public void assertGetRulePath() {
- assertThat(configurationNode.getRulePath(DefaultSchema.LOGIC_NAME),
is("/test/config/schema/logic_db/rule"));
+ assertThat(configurationNode.getRulePath(DefaultSchema.LOGIC_NAME),
is("/config/schema/logic_db/rule"));
}
@Test
public void assertGetAuthenticationPath() {
- assertThat(configurationNode.getAuthenticationPath(),
is("/test/config/authentication"));
+ assertThat(configurationNode.getAuthenticationPath(),
is("/config/authentication"));
}
@Test
public void assertGetPropsPath() {
- assertThat(configurationNode.getPropsPath(), is("/test/config/props"));
+ assertThat(configurationNode.getPropsPath(), is("/config/props"));
}
@Test
public void assertGetSchemaName() {
-
assertThat(configurationNode.getSchemaName("/test/config/schema/logic_db/rule"),
is(DefaultSchema.LOGIC_NAME));
+
assertThat(configurationNode.getSchemaName("/config/schema/logic_db/rule"),
is(DefaultSchema.LOGIC_NAME));
}
@Test
public void assertGetAllSchemaConfigPaths() {
Collection<String> actual =
configurationNode.getAllSchemaConfigPaths(Collections.singletonList(DefaultSchema.LOGIC_NAME));
assertThat(actual.size(), is(4));
- assertThat(actual, hasItems("/test/config/schema"));
- assertThat(actual, hasItems("/test/config/schema/logic_db"));
- assertThat(actual, hasItems("/test/config/schema/logic_db/rule"));
- assertThat(actual,
hasItems("/test/config/schema/logic_db/datasource"));
+ assertThat(actual, hasItems("/config/schema"));
+ assertThat(actual, hasItems("/config/schema/logic_db"));
+ assertThat(actual, hasItems("/config/schema/logic_db/rule"));
+ assertThat(actual, hasItems("/config/schema/logic_db/datasource"));
}
@Test
public void assertGetClusterPath() {
- assertThat(configurationNode.getClusterPath(),
is("/test/config/cluster"));
+ assertThat(configurationNode.getClusterPath(), is("/config/cluster"));
}
@Test
public void assertGetMetricsPath() {
-
assertTrue(configurationNode.getMetricsPath().contains("/test/config/metrics"));
+
assertTrue(configurationNode.getMetricsPath().contains("/config/metrics"));
}
@Test
public void assertGetSchemaNamePath() {
- assertThat(configurationNode.getSchemaNamePath("sharding_db"),
is("/test/config/schema/sharding_db"));
+ assertThat(configurationNode.getSchemaNamePath("sharding_db"),
is("/config/schema/sharding_db"));
}
}
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterTest.java
index c700ec0..b696b99 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenterTest.java
@@ -99,144 +99,144 @@ public final class ConfigCenterTest {
@Test
public void
assertPersistConfigurationForShardingRuleWithoutAuthenticationAndIsNotOverwriteAndConfigurationIsExisted()
{
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createRuleConfigurations(), false);
- verify(configurationRepository,
times(0)).persist(eq("/test/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
- verify(configurationRepository,
times(0)).persist("/test/config/schema/sharding_db/rule",
readYAML(SHARDING_RULE_YAML));
+ verify(configurationRepository,
times(0)).persist(eq("/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
+ verify(configurationRepository,
times(0)).persist("/config/schema/sharding_db/rule",
readYAML(SHARDING_RULE_YAML));
}
@Test
public void assertMoreShardingSchema() {
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createRuleConfigurations(), false);
- verify(configurationRepository,
times(0)).persist("/test/config/schema", "myTest1,myTest2,sharding_db");
+ verify(configurationRepository, times(0)).persist("/config/schema",
"myTest1,myTest2,sharding_db");
}
@Test
public void assertMoreAndContainsShardingSchema() {
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createRuleConfigurations(), false);
- verify(configurationRepository,
times(0)).persist("/test/config/schema", "myTest1,sharding_db");
+ verify(configurationRepository, times(0)).persist("/config/schema",
"myTest1,sharding_db");
}
@Test
public void
assertPersistConfigurationForShardingRuleWithoutAuthenticationAndIsNotOverwriteAndConfigurationIsNotExisted()
{
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createRuleConfigurations(), false);
- verify(configurationRepository,
times(0)).persist(eq("/test/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
- verify(configurationRepository,
times(0)).persist("/test/config/schema/sharding_db/rule",
readYAML(SHARDING_RULE_YAML));
+ verify(configurationRepository,
times(0)).persist(eq("/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
+ verify(configurationRepository,
times(0)).persist("/config/schema/sharding_db/rule",
readYAML(SHARDING_RULE_YAML));
}
@Test
public void
assertPersistConfigurationForShardingRuleWithoutAuthenticationAndIsOverwrite() {
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createRuleConfigurations(), true);
-
verify(configurationRepository).persist(eq("/test/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
- verify(configurationRepository,
times(0)).persist("/test/config/schema/sharding_db/rule",
readYAML(SHARDING_RULE_YAML));
+
verify(configurationRepository).persist(eq("/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
+ verify(configurationRepository,
times(0)).persist("/config/schema/sharding_db/rule",
readYAML(SHARDING_RULE_YAML));
}
@Test
public void
assertPersistConfigurationForMasterSlaveRuleWithoutAuthenticationAndIsNotOverwriteAndConfigurationIsExisted()
{
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createMasterSlaveRuleConfiguration(), false);
- verify(configurationRepository,
times(0)).persist(eq("/test/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
- verify(configurationRepository,
times(0)).persist("/test/config/schema/sharding_db/rule",
readYAML(MASTER_SLAVE_RULE_YAML));
+ verify(configurationRepository,
times(0)).persist(eq("/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
+ verify(configurationRepository,
times(0)).persist("/config/schema/sharding_db/rule",
readYAML(MASTER_SLAVE_RULE_YAML));
}
@Test
public void
assertPersistConfigurationForMasterSlaveRuleWithoutAuthenticationAndIsNotOverwriteAndConfigurationIsNotExisted()
{
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createMasterSlaveRuleConfiguration(), false);
- verify(configurationRepository,
times(0)).persist(eq("/test/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
- verify(configurationRepository,
times(0)).persist("/test/config/schema/sharding_db/rule",
readYAML(MASTER_SLAVE_RULE_YAML));
+ verify(configurationRepository,
times(0)).persist(eq("/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
+ verify(configurationRepository,
times(0)).persist("/config/schema/sharding_db/rule",
readYAML(MASTER_SLAVE_RULE_YAML));
}
@Test
public void
assertPersistConfigurationForMasterSlaveRuleWithoutAuthenticationAndIsOverwrite()
{
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createMasterSlaveRuleConfiguration(), true);
-
verify(configurationRepository).persist(eq("/test/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
- verify(configurationRepository,
times(0)).persist("/test/config/schema/sharding_db/rule",
readYAML(MASTER_SLAVE_RULE_YAML));
+
verify(configurationRepository).persist(eq("/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
+ verify(configurationRepository,
times(0)).persist("/config/schema/sharding_db/rule",
readYAML(MASTER_SLAVE_RULE_YAML));
}
@Test
public void
assertPersistConfigurationForShardingRuleWithAuthenticationAndIsNotOverwriteAndConfigurationIsExisted()
{
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createRuleConfigurations(), false);
- verify(configurationRepository,
times(0)).persist(eq("/test/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
- verify(configurationRepository,
times(0)).persist("/test/config/schema/sharding_db/rule",
readYAML(SHARDING_RULE_YAML));
+ verify(configurationRepository,
times(0)).persist(eq("/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
+ verify(configurationRepository,
times(0)).persist("/config/schema/sharding_db/rule",
readYAML(SHARDING_RULE_YAML));
}
@Test
public void
assertPersistConfigurationForShardingRuleWithAuthenticationAndIsNotOverwriteAndConfigurationIsNotExisted()
{
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createRuleConfigurations(), false);
- verify(configurationRepository,
times(0)).persist(eq("/test/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
- verify(configurationRepository,
times(0)).persist("/test/config/schema/sharding_db/rule",
readYAML(SHARDING_RULE_YAML));
+ verify(configurationRepository,
times(0)).persist(eq("/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
+ verify(configurationRepository,
times(0)).persist("/config/schema/sharding_db/rule",
readYAML(SHARDING_RULE_YAML));
}
@Test
public void
assertPersistConfigurationForShardingRuleWithAuthenticationAndIsOverwrite() {
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createRuleConfigurations(), true);
-
verify(configurationRepository).persist(eq("/test/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
- verify(configurationRepository,
times(0)).persist("/test/config/schema/sharding_db/rule",
readYAML(SHARDING_RULE_YAML));
+
verify(configurationRepository).persist(eq("/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
+ verify(configurationRepository,
times(0)).persist("/config/schema/sharding_db/rule",
readYAML(SHARDING_RULE_YAML));
}
@Test
public void
assertPersistConfigurationForMasterSlaveRuleWithAuthenticationAndIsNotOverwriteAndConfigurationIsExisted()
{
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createMasterSlaveRuleConfiguration(), false);
- verify(configurationRepository,
times(0)).persist(eq("/test/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
- verify(configurationRepository,
times(0)).persist("/test/config/schema/sharding_db/rule",
readYAML(MASTER_SLAVE_RULE_YAML));
+ verify(configurationRepository,
times(0)).persist(eq("/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
+ verify(configurationRepository,
times(0)).persist("/config/schema/sharding_db/rule",
readYAML(MASTER_SLAVE_RULE_YAML));
}
@Test
public void
assertPersistConfigurationForMasterSlaveRuleWithAuthenticationAndIsNotOverwriteAndConfigurationIsNotExisted()
{
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(),
createMasterSlaveRuleConfiguration(), false);
- verify(configurationRepository,
times(0)).persist(eq("/test/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
- verify(configurationRepository,
times(0)).persist("/test/config/schema/sharding_db/rule",
readYAML(MASTER_SLAVE_RULE_YAML));
+ verify(configurationRepository,
times(0)).persist(eq("/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
+ verify(configurationRepository,
times(0)).persist("/config/schema/sharding_db/rule",
readYAML(MASTER_SLAVE_RULE_YAML));
}
@Test
public void
assertPersistConfigurationForMasterSlaveRuleWithAuthenticationAndIsOverwrite() {
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createMasterSlaveRuleConfiguration(), true);
-
verify(configurationRepository).persist(eq("/test/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
- verify(configurationRepository,
times(0)).persist("/test/config/schema/sharding_db/rule",
readYAML(MASTER_SLAVE_RULE_YAML));
+
verify(configurationRepository).persist(eq("/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
+ verify(configurationRepository,
times(0)).persist("/config/schema/sharding_db/rule",
readYAML(MASTER_SLAVE_RULE_YAML));
}
@Test
public void assertPersistConfigurationForEncrypt() {
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createEncryptRuleConfiguration(), true);
-
verify(configurationRepository).persist(eq("/test/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
- verify(configurationRepository,
times(0)).persist("/test/config/schema/sharding_db/rule",
readYAML(ENCRYPT_RULE_YAML));
+
verify(configurationRepository).persist(eq("/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
+ verify(configurationRepository,
times(0)).persist("/config/schema/sharding_db/rule",
readYAML(ENCRYPT_RULE_YAML));
}
@Test
public void assertNullRuleConfiguration() {
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), Collections.emptyList(), true);
}
@Test
public void assertPersistConfigurationForShadow() {
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createShadowRuleConfiguration(), true);
-
verify(configurationRepository).persist(eq("/test/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
- verify(configurationRepository,
times(0)).persist("/test/config/schema/sharding_db/rule",
readYAML(SHADOW_RULE_YAML));
+
verify(configurationRepository).persist(eq("/config/schema/sharding_db/datasource"),
ArgumentMatchers.any());
+ verify(configurationRepository,
times(0)).persist("/config/schema/sharding_db/rule",
readYAML(SHADOW_RULE_YAML));
}
@Test
public void assertPersistGlobalConfiguration() {
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistGlobalConfiguration(createAuthentication(),
createProperties(), true);
- verify(configurationRepository,
times(0)).persist("/test/config/authentication", readYAML(AUTHENTICATION_YAML));
- verify(configurationRepository).persist("/test/config/props",
PROPS_YAML);
+ verify(configurationRepository,
times(0)).persist("/config/authentication", readYAML(AUTHENTICATION_YAML));
+ verify(configurationRepository).persist("/config/props", PROPS_YAML);
}
private Map<String, DataSourceConfiguration>
createDataSourceConfigurations() {
@@ -291,8 +291,8 @@ public final class ConfigCenterTest {
@Test
public void assertLoadDataSourceConfigurations() {
-
when(configurationRepository.get("/test/config/schema/sharding_db/datasource")).thenReturn(readYAML(DATA_SOURCE_YAM));
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+
when(configurationRepository.get("/config/schema/sharding_db/datasource")).thenReturn(readYAML(DATA_SOURCE_YAM));
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
Map<String, DataSourceConfiguration> actual =
configurationService.loadDataSourceConfigurations("sharding_db");
assertThat(actual.size(), is(2));
assertDataSourceConfiguration(actual.get("ds_0"),
createDataSourceConfiguration(createDataSource("ds_0")));
@@ -308,16 +308,16 @@ public final class ConfigCenterTest {
@Test
public void assertLoadDataSourceConfigurationsNotExistPath() {
-
when(configurationRepository.get("/test/config/schema/sharding_db/datasource")).thenReturn("");
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+
when(configurationRepository.get("/config/schema/sharding_db/datasource")).thenReturn("");
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
Map<String, DataSourceConfiguration> actual =
configurationService.loadDataSourceConfigurations("sharding_db");
assertThat(actual.size(), is(0));
}
@Test
public void assertLoadShardingAndEncryptRuleConfiguration() {
-
when(configurationRepository.get("/test/config/schema/sharding_db/rule")).thenReturn(readYAML(SHARDING_AND_ENCRYPT_RULE_YAML));
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+
when(configurationRepository.get("/config/schema/sharding_db/rule")).thenReturn(readYAML(SHARDING_AND_ENCRYPT_RULE_YAML));
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
Collection<RuleConfiguration> ruleConfigurations =
configurationService.loadRuleConfigurations("sharding_db");
assertThat(ruleConfigurations.size(), is(2));
for (RuleConfiguration each : ruleConfigurations) {
@@ -337,8 +337,8 @@ public final class ConfigCenterTest {
@Test
public void assertLoadShardingRuleConfiguration() {
-
when(configurationRepository.get("/test/config/schema/sharding_db/rule")).thenReturn(readYAML(SHARDING_RULE_YAML));
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+
when(configurationRepository.get("/config/schema/sharding_db/rule")).thenReturn(readYAML(SHARDING_RULE_YAML));
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
Collection<RuleConfiguration> actual =
configurationService.loadRuleConfigurations("sharding_db");
assertThat(actual.size(), is(1));
ShardingRuleConfiguration actualShardingRuleConfiguration =
(ShardingRuleConfiguration) actual.iterator().next();
@@ -348,8 +348,8 @@ public final class ConfigCenterTest {
@Test
public void assertLoadMasterSlaveRuleConfiguration() {
-
when(configurationRepository.get("/test/config/schema/sharding_db/rule")).thenReturn(readYAML(MASTER_SLAVE_RULE_YAML));
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+
when(configurationRepository.get("/config/schema/sharding_db/rule")).thenReturn(readYAML(MASTER_SLAVE_RULE_YAML));
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
Collection<RuleConfiguration> actual =
configurationService.loadRuleConfigurations("sharding_db");
MasterSlaveRuleConfiguration masterSlaveRuleConfiguration =
(MasterSlaveRuleConfiguration) actual.iterator().next();
assertThat(masterSlaveRuleConfiguration.getDataSources().size(),
is(1));
@@ -359,8 +359,8 @@ public final class ConfigCenterTest {
@Test
public void assertLoadEncryptRuleConfiguration() {
-
when(configurationRepository.get("/test/config/schema/sharding_db/rule")).thenReturn(readYAML(ENCRYPT_RULE_YAML));
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+
when(configurationRepository.get("/config/schema/sharding_db/rule")).thenReturn(readYAML(ENCRYPT_RULE_YAML));
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
EncryptRuleConfiguration actual = (EncryptRuleConfiguration)
configurationService.loadRuleConfigurations("sharding_db").iterator().next();
assertThat(actual.getEncryptors().size(), is(1));
ShardingSphereAlgorithmConfiguration encryptAlgorithmConfiguration =
actual.getEncryptors().get("order_encryptor");
@@ -370,8 +370,8 @@ public final class ConfigCenterTest {
@Test
public void assertLoadShadowRuleConfiguration() {
-
when(configurationRepository.get("/test/config/schema/sharding_db/rule")).thenReturn(readYAML(SHADOW_RULE_YAML));
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+
when(configurationRepository.get("/config/schema/sharding_db/rule")).thenReturn(readYAML(SHADOW_RULE_YAML));
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
ShadowRuleConfiguration actual = (ShadowRuleConfiguration)
configurationService.loadRuleConfigurations("sharding_db").iterator().next();
assertThat(actual.getShadowMappings().get("ds"), is("shadow_ds"));
assertThat(actual.getColumn(), is("shadow"));
@@ -379,8 +379,8 @@ public final class ConfigCenterTest {
@Test
public void assertLoadAuthentication() {
-
when(configurationRepository.get("/test/config/authentication")).thenReturn(readYAML(AUTHENTICATION_YAML));
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+
when(configurationRepository.get("/config/authentication")).thenReturn(readYAML(AUTHENTICATION_YAML));
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
Authentication actual = configurationService.loadAuthentication();
assertThat(actual.getUsers().size(), is(2));
assertThat(actual.getUsers().get("root1").getPassword(), is("root1"));
@@ -388,8 +388,8 @@ public final class ConfigCenterTest {
@Test
public void assertLoadMetricsConfiguration() {
-
when(configurationRepository.get("/test/config/metrics")).thenReturn(readYAML(DATA_METRICS_YAML));
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+
when(configurationRepository.get("/config/metrics")).thenReturn(readYAML(DATA_METRICS_YAML));
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
MetricsConfiguration actual =
configurationService.loadMetricsConfiguration();
assertNotNull(actual);
assertThat(actual.getMetricsName(), is("prometheus"));
@@ -401,16 +401,16 @@ public final class ConfigCenterTest {
@Test
public void assertLoadProperties() {
-
when(configurationRepository.get("/test/config/props")).thenReturn(PROPS_YAML);
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+
when(configurationRepository.get("/config/props")).thenReturn(PROPS_YAML);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
Properties actual = configurationService.loadProperties();
assertThat(actual.get(ConfigurationPropertyKey.SQL_SHOW.getKey()),
is(Boolean.FALSE));
}
@Test
public void assertGetAllSchemaNames() {
-
when(configurationRepository.get("/test/config/schema")).thenReturn("sharding_db,masterslave_db");
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+
when(configurationRepository.get("/config/schema")).thenReturn("sharding_db,masterslave_db");
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
Collection<String> actual = configurationService.getAllSchemaNames();
assertThat(actual.size(), is(2));
assertThat(actual, hasItems("sharding_db"));
@@ -419,8 +419,8 @@ public final class ConfigCenterTest {
@Test
public void assertLoadDataSourceConfigurationsWithConnectionInitSqls() {
-
when(configurationRepository.get("/test/config/schema/sharding_db/datasource")).thenReturn(readYAML(DATA_SOURCE_YAML_WITH_CONNECTION_INIT_SQL));
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+
when(configurationRepository.get("/config/schema/sharding_db/datasource")).thenReturn(readYAML(DATA_SOURCE_YAML_WITH_CONNECTION_INIT_SQL));
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
Map<String, DataSourceConfiguration> actual =
configurationService.loadDataSourceConfigurations("sharding_db");
assertThat(actual.size(), is(2));
assertDataSourceConfigurationWithConnectionInitSqls(actual.get("ds_0"),
createDataSourceConfiguration(createDataSourceWithConnectionInitSqls("ds_0")));
@@ -431,15 +431,15 @@ public final class ConfigCenterTest {
public void assertPersistClusterConfiguration() {
ClusterConfiguration clusterConfiguration = new
ClusterConfigurationYamlSwapper()
.swapToObject(YamlEngine.unmarshal(readYAML(DATA_CLUSTER_YAML),
YamlClusterConfiguration.class));
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistClusterConfiguration(clusterConfiguration,
true);
- verify(configurationRepository,
times(0)).persist(eq("/test/config/cluster"), eq(readYAML(DATA_CLUSTER_YAML)));
+ verify(configurationRepository,
times(0)).persist(eq("/config/cluster"), eq(readYAML(DATA_CLUSTER_YAML)));
}
@Test
public void loadClusterConfiguration() {
-
when(configurationRepository.get("/test/config/cluster")).thenReturn(readYAML(DATA_CLUSTER_YAML));
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+
when(configurationRepository.get("/config/cluster")).thenReturn(readYAML(DATA_CLUSTER_YAML));
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
ClusterConfiguration clusterConfiguration =
configurationService.loadClusterConfiguration();
assertNotNull(clusterConfiguration);
assertNotNull(clusterConfiguration.getHeartbeat());
@@ -479,24 +479,24 @@ public final class ConfigCenterTest {
public void assertPersistMetricsConfiguration() {
MetricsConfiguration metricsConfiguration = new
MetricsConfigurationYamlSwapper()
.swapToObject(YamlEngine.unmarshal(readYAML(DATA_METRICS_YAML),
YamlMetricsConfiguration.class));
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
configurationService.persistMetricsConfiguration(metricsConfiguration,
true);
- verify(configurationRepository,
times(0)).persist(eq("/test/config/metrics"), eq(readYAML(DATA_METRICS_YAML)));
+ verify(configurationRepository,
times(0)).persist(eq("/config/metrics"), eq(readYAML(DATA_METRICS_YAML)));
}
@Test
public void assertPersistSchemaNameWithExistSchema() {
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
-
when(configurationRepository.get("/test/config/schema")).thenReturn("sharding_db");
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
+
when(configurationRepository.get("/config/schema")).thenReturn("sharding_db");
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createRuleConfigurations(), true);
- verify(configurationRepository,
times(0)).persist(eq("/test/config/schema"), eq("sharding_db"));
+ verify(configurationRepository,
times(0)).persist(eq("/config/schema"), eq("sharding_db"));
}
@Test
public void assertPersistSchemaNameWithExistAndNewSchema() {
- ConfigCenter configurationService = new ConfigCenter("test",
configurationRepository);
-
when(configurationRepository.get("/test/config/schema")).thenReturn("master_slave_db");
+ ConfigCenter configurationService = new
ConfigCenter(configurationRepository);
+
when(configurationRepository.get("/config/schema")).thenReturn("master_slave_db");
configurationService.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createRuleConfigurations(), true);
- verify(configurationRepository).persist(eq("/test/config/schema"),
eq("master_slave_db,sharding_db"));
+ verify(configurationRepository).persist(eq("/config/schema"),
eq("master_slave_db,sharding_db"));
}
}
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/AuthenticationChangedListenerTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/AuthenticationChangedLi
[...]
index 29bbcc7..e3e45e1 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/AuthenticationChangedListenerTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/AuthenticationChangedListenerTest.java
@@ -42,7 +42,7 @@ public final class AuthenticationChangedListenerTest {
@Before
public void setUp() {
- authenticationChangedListener = new
AuthenticationChangedListener("test", configurationRepository);
+ authenticationChangedListener = new
AuthenticationChangedListener(configurationRepository);
}
@Test
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/ClusterConfigurationChangedListenerTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/ClusterConfigurat
[...]
index a126bb1..bf205cb 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/ClusterConfigurationChangedListenerTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/ClusterConfigurationChangedListenerTest.java
@@ -46,7 +46,7 @@ public final class ClusterConfigurationChangedListenerTest {
@Before
public void setUp() {
- clusterConfigurationChangedListener = new
ClusterConfigurationChangedListener("test", configurationRepository);
+ clusterConfigurationChangedListener = new
ClusterConfigurationChangedListener(configurationRepository);
}
@Test
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/ConfigurationListenerManagerTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/ConfigurationListenerMan
[...]
index 2328772..df885e4 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/ConfigurationListenerManagerTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/ConfigurationListenerManagerTest.java
@@ -47,7 +47,7 @@ public final class ConfigurationListenerManagerTest {
@Test
public void assertInitListeners() {
- ConfigurationListenerManager actual = new
ConfigurationListenerManager("test", configurationRepository,
Arrays.asList("sharding_db", "masterslave_db"));
+ ConfigurationListenerManager actual = new
ConfigurationListenerManager(configurationRepository,
Arrays.asList("sharding_db", "masterslave_db"));
setField(actual, "schemaChangedListener", schemaChangedListener);
setField(actual, "propertiesChangedListener",
propertiesChangedListener);
setField(actual, "authenticationChangedListener",
authenticationChangedListener);
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/MetricsConfigurationChangedListenerTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/MetricsConfigurat
[...]
index e7cdf3a..f87311d 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/MetricsConfigurationChangedListenerTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/MetricsConfigurationChangedListenerTest.java
@@ -48,7 +48,7 @@ public final class MetricsConfigurationChangedListenerTest {
@Before
public void setUp() {
- metricsConfigurationChangedListener = new
MetricsConfigurationChangedListener("test", configurationRepository);
+ metricsConfigurationChangedListener = new
MetricsConfigurationChangedListener(configurationRepository);
}
@Test
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/PropertiesChangedListenerTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/PropertiesChangedListenerTest.java
index 8d7fa2d..b53662f 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/PropertiesChangedListenerTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/PropertiesChangedListenerTest.java
@@ -41,7 +41,7 @@ public final class PropertiesChangedListenerTest {
@Before
public void setUp() {
- propertiesChangedListener = new PropertiesChangedListener("test",
configurationRepository);
+ propertiesChangedListener = new
PropertiesChangedListener(configurationRepository);
}
@Test
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/SchemaChangedListenerTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/SchemaChangedListenerTest.java
index 81953d0..b3c56ad 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/SchemaChangedListenerTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/test/java/org/apache/shardingsphere/orchestration/core/config/listener/SchemaChangedListenerTest.java
@@ -67,21 +67,21 @@ public final class SchemaChangedListenerTest {
@Before
public void setUp() {
- schemaChangedListener = new SchemaChangedListener("test",
configurationRepository, Arrays.asList("sharding_db", "masterslave_db",
"encrypt_db"));
+ schemaChangedListener = new
SchemaChangedListener(configurationRepository, Arrays.asList("sharding_db",
"masterslave_db", "encrypt_db"));
}
@Test
public void assertCreateIgnoredEvent() {
- assertThat(schemaChangedListener.createOrchestrationEvent(new
DataChangedEvent("/test/config/schema/encrypt_db", "test",
ChangedType.UPDATED)),
+ assertThat(schemaChangedListener.createOrchestrationEvent(new
DataChangedEvent("/config/schema/encrypt_db", "test", ChangedType.UPDATED)),
instanceOf(IgnoredOrchestrationEvent.class));
- assertThat(schemaChangedListener.createOrchestrationEvent(new
DataChangedEvent("/test/config/schema/encrypt_db/rule", "test",
ChangedType.IGNORED)),
+ assertThat(schemaChangedListener.createOrchestrationEvent(new
DataChangedEvent("/config/schema/encrypt_db/rule", "test",
ChangedType.IGNORED)),
instanceOf(IgnoredOrchestrationEvent.class));
}
@Test
public void assertCreateDataSourceChangedEventForExistedSchema() {
String dataSource = readYAML(DATA_SOURCE_FILE);
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema/sharding_db/datasource", dataSource,
ChangedType.UPDATED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema/sharding_db/datasource", dataSource,
ChangedType.UPDATED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(DataSourceChangedEvent.class));
assertThat(((DataSourceChangedEvent) actual).getShardingSchemaName(),
is("sharding_db"));
@@ -90,7 +90,7 @@ public final class SchemaChangedListenerTest {
@Test
public void assertCreateRuleConfigurationsChangedEventForExistedSchema() {
String shardingRule = readYAML(SHARDING_RULE_FILE);
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema/sharding_db/rule", shardingRule,
ChangedType.UPDATED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema/sharding_db/rule", shardingRule,
ChangedType.UPDATED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(RuleConfigurationsChangedEvent.class));
assertThat(((RuleConfigurationsChangedEvent)
actual).getShardingSchemaName(), is("sharding_db"));
@@ -102,7 +102,7 @@ public final class SchemaChangedListenerTest {
@Test
public void assertCreateMasterSlaveRuleChangedEventForExistedSchema() {
String masterSlaveRule = readYAML(MASTER_SLAVE_RULE_FILE);
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema/masterslave_db/rule", masterSlaveRule,
ChangedType.UPDATED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema/masterslave_db/rule", masterSlaveRule,
ChangedType.UPDATED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(RuleConfigurationsChangedEvent.class));
RuleConfigurationsChangedEvent event =
(RuleConfigurationsChangedEvent) actual;
@@ -115,7 +115,7 @@ public final class SchemaChangedListenerTest {
@Test
public void assertCreateEncryptRuleChangedEventForExistedSchema() {
String encryptRule = readYAML(ENCRYPT_RULE_FILE);
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema/encrypt_db/rule", encryptRule,
ChangedType.UPDATED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema/encrypt_db/rule", encryptRule,
ChangedType.UPDATED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(RuleConfigurationsChangedEvent.class));
RuleConfigurationsChangedEvent event =
(RuleConfigurationsChangedEvent) actual;
@@ -130,8 +130,8 @@ public final class SchemaChangedListenerTest {
@Test
public void assertCreateIgnoredOrchestrationEventForNewSchema() {
-
when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn("");
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema/logic_db/rule", "rule",
ChangedType.UPDATED);
+
when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn("");
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema/logic_db/rule", "rule", ChangedType.UPDATED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(SchemaAddedEvent.class));
}
@@ -140,11 +140,11 @@ public final class SchemaChangedListenerTest {
public void assertCreateShardingSchemaAddedEventForNewSchema() {
String shardingRule = readYAML(SHARDING_RULE_FILE);
String dataSource = readYAML(DATA_SOURCE_FILE);
-
when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(shardingRule);
-
when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource);
-
when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(shardingRule);
-
when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource);
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema/logic_db/datasource", dataSource,
ChangedType.UPDATED);
+
when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(shardingRule);
+
when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource);
+
when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(shardingRule);
+
when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema/logic_db/datasource", dataSource,
ChangedType.UPDATED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(SchemaAddedEvent.class));
assertThat(((SchemaAddedEvent)
actual).getRuleConfigurations().iterator().next(),
instanceOf(ShardingRuleConfiguration.class));
@@ -154,11 +154,11 @@ public final class SchemaChangedListenerTest {
public void assertCreateMasterSlaveSchemaAddedEventForNewSchema() {
String dataSource = readYAML(DATA_SOURCE_FILE);
String masterSlaveRule = readYAML(MASTER_SLAVE_RULE_FILE);
-
when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(masterSlaveRule);
-
when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource);
-
when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(masterSlaveRule);
-
when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource);
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema/logic_db/datasource", dataSource,
ChangedType.UPDATED);
+
when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(masterSlaveRule);
+
when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource);
+
when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(masterSlaveRule);
+
when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema/logic_db/datasource", dataSource,
ChangedType.UPDATED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(SchemaAddedEvent.class));
assertThat(((SchemaAddedEvent)
actual).getRuleConfigurations().iterator().next(),
instanceOf(MasterSlaveRuleConfiguration.class));
@@ -168,11 +168,11 @@ public final class SchemaChangedListenerTest {
public void assertCreateEncryptSchemaAddedEventForNewSchema() {
String dataSource = readYAML(DATA_SOURCE_FILE);
String encryptRule = readYAML(ENCRYPT_RULE_FILE);
-
when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(encryptRule);
-
when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource);
-
when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(encryptRule);
-
when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource);
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema/logic_db/datasource", dataSource,
ChangedType.UPDATED);
+
when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(encryptRule);
+
when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource);
+
when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(encryptRule);
+
when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema/logic_db/datasource", dataSource,
ChangedType.UPDATED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(SchemaAddedEvent.class));
assertThat(((SchemaAddedEvent)
actual).getRuleConfigurations().iterator().next(),
instanceOf(EncryptRuleConfiguration.class));
@@ -181,7 +181,7 @@ public final class SchemaChangedListenerTest {
@Test
public void assertCreateSchemaDeletedEventForNewSchema() {
String dataSource = readYAML(DATA_SOURCE_FILE);
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema/logic_db/datasource", dataSource,
ChangedType.DELETED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema/logic_db/datasource", dataSource,
ChangedType.DELETED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(SchemaDeletedEvent.class));
assertThat(((SchemaDeletedEvent) actual).getShardingSchemaName(),
is("logic_db"));
@@ -190,7 +190,7 @@ public final class SchemaChangedListenerTest {
@Test
public void assertCreateWithSchemaDeletedEvent() {
String dataSource = readYAML(DATA_SOURCE_FILE);
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema/logic_db", dataSource,
ChangedType.DELETED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema/logic_db", dataSource, ChangedType.DELETED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(SchemaDeletedEvent.class));
}
@@ -198,7 +198,7 @@ public final class SchemaChangedListenerTest {
@Test
public void assertCreateWithSchemaDeletedEventWithDataSourceNode() {
String dataSource = readYAML(DATA_SOURCE_FILE);
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema/datasource", dataSource,
ChangedType.DELETED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema/datasource", dataSource, ChangedType.DELETED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(SchemaDeletedEvent.class));
}
@@ -207,9 +207,9 @@ public final class SchemaChangedListenerTest {
public void
assertCreateAddedEventWithEncryptRuleConfigurationForNewSchema() {
String dataSource = readYAML(DATA_SOURCE_FILE);
String encryptRule = readYAML(ENCRYPT_RULE_FILE);
-
when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(encryptRule);
-
when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource);
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema/logic_db/rule", encryptRule,
ChangedType.UPDATED);
+
when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(encryptRule);
+
when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema/logic_db/rule", encryptRule,
ChangedType.UPDATED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(SchemaAddedEvent.class));
assertThat(((SchemaAddedEvent)
actual).getRuleConfigurations().iterator().next(),
instanceOf(EncryptRuleConfiguration.class));
@@ -219,9 +219,9 @@ public final class SchemaChangedListenerTest {
public void
assertCreateAddedEventWithShardingRuleConfigurationForNewSchema() {
String dataSource = readYAML(DATA_SOURCE_FILE);
String shardingRule = readYAML(SHARDING_RULE_FILE);
-
when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(shardingRule);
-
when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource);
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema/logic_db/rule", shardingRule,
ChangedType.UPDATED);
+
when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(shardingRule);
+
when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema/logic_db/rule", shardingRule,
ChangedType.UPDATED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(SchemaAddedEvent.class));
assertThat(((SchemaAddedEvent)
actual).getRuleConfigurations().iterator().next(),
instanceOf(ShardingRuleConfiguration.class));
@@ -231,9 +231,9 @@ public final class SchemaChangedListenerTest {
public void
assertCreateAddedEventWithMasterSlaveRuleConfigurationForNewSchema() {
String dataSource = readYAML(DATA_SOURCE_FILE);
String masterSlaveRule = readYAML(MASTER_SLAVE_RULE_FILE);
-
when(configurationRepository.get("/test/config/schema/logic_db/rule")).thenReturn(masterSlaveRule);
-
when(configurationRepository.get("/test/config/schema/logic_db/datasource")).thenReturn(dataSource);
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema/logic_db/rule", masterSlaveRule,
ChangedType.UPDATED);
+
when(configurationRepository.get("/config/schema/logic_db/rule")).thenReturn(masterSlaveRule);
+
when(configurationRepository.get("/config/schema/logic_db/datasource")).thenReturn(dataSource);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema/logic_db/rule", masterSlaveRule,
ChangedType.UPDATED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(SchemaAddedEvent.class));
assertThat(((SchemaAddedEvent)
actual).getRuleConfigurations().iterator().next(),
instanceOf(MasterSlaveRuleConfiguration.class));
@@ -241,7 +241,7 @@ public final class SchemaChangedListenerTest {
@Test
public void assertCreateSchemaNamesUpdatedEventForAdd() {
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema",
"sharding_db,masterslave_db,encrypt_db,shadow_db", ChangedType.UPDATED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema",
"sharding_db,masterslave_db,encrypt_db,shadow_db", ChangedType.UPDATED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(SchemaAddedEvent.class));
assertThat(((SchemaAddedEvent) actual).getShardingSchemaName(),
is("shadow_db"));
@@ -249,7 +249,7 @@ public final class SchemaChangedListenerTest {
@Test
public void assertCreateSchemaNamesUpdatedEventForDelete() {
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema", "sharding_db,masterslave_db",
ChangedType.UPDATED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema", "sharding_db,masterslave_db",
ChangedType.UPDATED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(SchemaDeletedEvent.class));
assertThat(((SchemaDeletedEvent) actual).getShardingSchemaName(),
is("encrypt_db"));
@@ -257,14 +257,14 @@ public final class SchemaChangedListenerTest {
@Test
public void assertCreateSchemaNamesUpdatedEventForIgnore() {
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema",
"sharding_db,masterslave_db,encrypt_db", ChangedType.UPDATED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema", "sharding_db,masterslave_db,encrypt_db",
ChangedType.UPDATED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(IgnoredOrchestrationEvent.class));
}
@Test
public void assertCreateSchemaNameAddEvent() {
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/config/schema/shadow_db", "", ChangedType.ADDED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/config/schema/shadow_db", "", ChangedType.ADDED);
OrchestrationEvent actual =
schemaChangedListener.createOrchestrationEvent(dataChangedEvent);
assertThat(actual, instanceOf(SchemaAddedEvent.class));
assertThat(((SchemaAddedEvent) actual).getShardingSchemaName(),
is("shadow_db"));
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/main/java/org/apache/shardingsphere/orchestration/core/facade/OrchestrationFacade.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/main/java/org/apache/shardingsphere/orchestration/core/facade/OrchestrationFacade.java
index 426dc69..342cd42 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/main/java/org/apache/shardingsphere/orchestration/core/facade/OrchestrationFacade.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/main/java/org/apache/shardingsphere/orchestration/core/facade/OrchestrationFacade.java
@@ -66,11 +66,11 @@ public final class OrchestrationFacade implements
AutoCloseable {
public void init(final OrchestrationConfiguration config, final
Collection<String> schemaNames) {
isOverwrite = config.isOverwrite();
repositoryFacade = new OrchestrationRepositoryFacade(config);
- registryCenter = new RegistryCenter(config.getName(),
repositoryFacade.getRegistryRepository());
- configCenter = new ConfigCenter(config.getName(),
repositoryFacade.getConfigurationRepository());
- metaDataCenter = new MetaDataCenter(config.getName(),
repositoryFacade.getConfigurationRepository());
- listenerManager = new OrchestrationListenerManager(config.getName(),
- repositoryFacade.getRegistryRepository(),
repositoryFacade.getConfigurationRepository(), schemaNames.isEmpty() ?
configCenter.getAllSchemaNames() : schemaNames);
+ registryCenter = new
RegistryCenter(repositoryFacade.getRegistryRepository());
+ configCenter = new
ConfigCenter(repositoryFacade.getConfigurationRepository());
+ metaDataCenter = new
MetaDataCenter(repositoryFacade.getConfigurationRepository());
+ listenerManager = new
OrchestrationListenerManager(repositoryFacade.getRegistryRepository(),
+ repositoryFacade.getConfigurationRepository(),
schemaNames.isEmpty() ? configCenter.getAllSchemaNames() : schemaNames);
}
/**
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/main/java/org/apache/shardingsphere/orchestration/core/facade/listener/OrchestrationListenerManager.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/main/java/org/apache/shardingsphere/orchestration/core/facade/listener/OrchestrationListenerManager.java
index 8b2a992..8fa2dd6 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/main/java/org/apache/shardingsphere/orchestration/core/facade/listener/OrchestrationListenerManager.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/main/java/org/apache/shardingsphere/orchestration/core/facade/listener/OrchestrationListenerManager.java
@@ -36,10 +36,10 @@ public final class OrchestrationListenerManager {
private final MetaDataListenerManager metaDataListenerManager;
- public OrchestrationListenerManager(final String name, final
RegistryRepository registryRepository, final ConfigurationRepository
configurationRepository, final Collection<String> schemaNames) {
- configurationListenerManager = new ConfigurationListenerManager(name,
configurationRepository, schemaNames);
- registryListenerManager = new RegistryListenerManager(name,
registryRepository);
- metaDataListenerManager = new MetaDataListenerManager(name,
configurationRepository, schemaNames);
+ public OrchestrationListenerManager(final RegistryRepository
registryRepository, final ConfigurationRepository configurationRepository,
final Collection<String> schemaNames) {
+ configurationListenerManager = new
ConfigurationListenerManager(configurationRepository, schemaNames);
+ registryListenerManager = new
RegistryListenerManager(registryRepository);
+ metaDataListenerManager = new
MetaDataListenerManager(configurationRepository, schemaNames);
}
/**
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/test/java/org/apache/shardingsphere/orchestration/core/facade/listener/OrchestrationListenerManagerTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/test/java/org/apache/shardingsphere/orchestration/core/facade/listener/OrchestrationListenerMan
[...]
index 35cccc8..d03609d 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/test/java/org/apache/shardingsphere/orchestration/core/facade/listener/OrchestrationListenerManagerTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-facade/src/test/java/org/apache/shardingsphere/orchestration/core/facade/listener/OrchestrationListenerManagerTest.java
@@ -52,7 +52,7 @@ public final class OrchestrationListenerManagerTest {
@Test
public void assertInit() {
- OrchestrationListenerManager actual = new
OrchestrationListenerManager("test_name", registryRepository,
configurationRepository, Collections.emptyList());
+ OrchestrationListenerManager actual = new
OrchestrationListenerManager(registryRepository, configurationRepository,
Collections.emptyList());
FieldUtil.setField(actual, "configurationListenerManager",
configurationListenerManager);
FieldUtil.setField(actual, "registryListenerManager",
registryListenerManager);
FieldUtil.setField(actual, "metaDataListenerManager",
metaDataListenerManager);
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenter.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenter.java
index ea65a6d..47e5709 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenter.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenter.java
@@ -36,8 +36,8 @@ public final class MetaDataCenter {
private final OrchestrationRepository repository;
- public MetaDataCenter(final String name, final OrchestrationRepository
orchestrationRepository) {
- node = new MetaDataCenterNode(name);
+ public MetaDataCenter(final OrchestrationRepository
orchestrationRepository) {
+ node = new MetaDataCenterNode();
repository = orchestrationRepository;
MetaDataCallback.getInstance().register(this::persistMetaDataCenterNode);
}
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterNode.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterNode.java
index b7df713..8c0f732 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterNode.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterNode.java
@@ -31,8 +31,6 @@ public final class MetaDataCenterNode {
private static final String ROOT = "metadata";
- private final String name;
-
/**
* Get meta data node full path.
*
@@ -40,7 +38,7 @@ public final class MetaDataCenterNode {
* @return meta data node full path
*/
public String getMetaDataCenterNodeFullPath(final String schemaName) {
- return Joiner.on("/").join("", name, ROOT, schemaName);
+ return Joiner.on("/").join("", ROOT, schemaName);
}
/**
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataChangedListener.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataChangedListener.java
index 1e4a4a9..e881282 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataChangedListener.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataChangedListener.java
@@ -37,8 +37,8 @@ public final class MetaDataChangedListener extends
PostOrchestrationRepositoryEv
private final Collection<String> schemaNames;
- public MetaDataChangedListener(final String name, final
OrchestrationRepository orchestrationRepository, final Collection<String>
schemaNames) {
- super(orchestrationRepository, new
MetaDataCenterNode(name).getAllSchemaMetadataPaths(schemaNames));
+ public MetaDataChangedListener(final OrchestrationRepository
orchestrationRepository, final Collection<String> schemaNames) {
+ super(orchestrationRepository, new
MetaDataCenterNode().getAllSchemaMetadataPaths(schemaNames));
this.schemaNames = schemaNames;
}
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataListenerManager.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataListenerManager.java
index e1e905b..b32fc05 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataListenerManager.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/main/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataListenerManager.java
@@ -29,8 +29,8 @@ public final class MetaDataListenerManager {
private final MetaDataChangedListener metaDataChangedListener;
- public MetaDataListenerManager(final String name, final
OrchestrationRepository orchestrationRepository, final Collection<String>
schemaNames) {
- metaDataChangedListener = new MetaDataChangedListener(name,
orchestrationRepository, schemaNames);
+ public MetaDataListenerManager(final OrchestrationRepository
orchestrationRepository, final Collection<String> schemaNames) {
+ metaDataChangedListener = new
MetaDataChangedListener(orchestrationRepository, schemaNames);
}
/**
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterNodeTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterNodeTest.java
index 554e889..dfb714e 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterNodeTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterNodeTest.java
@@ -24,11 +24,11 @@ import static org.junit.Assert.assertThat;
public final class MetaDataCenterNodeTest {
- private final MetaDataCenterNode metaDataCenterNode = new
MetaDataCenterNode("test");
+ private final MetaDataCenterNode metaDataCenterNode = new
MetaDataCenterNode();
@Test
public void assertGetMetaDataCenterNodeFullPath() {
assertThat(metaDataCenterNode.getMetaDataCenterNodeFullPath("schema"),
- is("/test/metadata/schema"));
+ is("/metadata/schema"));
}
}
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterTest.java
index 4202515..4c91cf5 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/MetaDataCenterTest.java
@@ -50,25 +50,25 @@ public final class MetaDataCenterTest {
@Before
public void setUp() {
- metaDataCenter = new MetaDataCenter("test", repository);
+ metaDataCenter = new MetaDataCenter(repository);
}
@Test
public void assertPersistMetaDataCenterNode() {
RuleSchemaMetaData ruleSchemaMetaData = new
RuleSchemaMetaDataYamlSwapper().swapToObject(YamlEngine.unmarshal(MetaDataJson.META_DATA,
YamlRuleSchemaMetaData.class));
metaDataCenter.persistMetaDataCenterNode("schema", ruleSchemaMetaData);
- verify(repository).persist(eq("/test/metadata/schema"), anyString());
+ verify(repository).persist(eq("/metadata/schema"), anyString());
}
@Test
public void assertLoadRuleSchemaMetaData() {
-
when(repository.get("/test/metadata/schema")).thenReturn(MetaDataJson.META_DATA);
+
when(repository.get("/metadata/schema")).thenReturn(MetaDataJson.META_DATA);
Optional<RuleSchemaMetaData> optionalRuleSchemaMetaData =
metaDataCenter.loadRuleSchemaMetaData("schema");
assertTrue(optionalRuleSchemaMetaData.isPresent());
Optional<RuleSchemaMetaData> empty =
metaDataCenter.loadRuleSchemaMetaData("test");
assertThat(empty, is(Optional.empty()));
RuleSchemaMetaData ruleSchemaMetaData =
optionalRuleSchemaMetaData.get();
- verify(repository).get(eq("/test/metadata/schema"));
+ verify(repository).get(eq("/metadata/schema"));
assertNotNull(ruleSchemaMetaData);
assertNotNull(ruleSchemaMetaData.getConfiguredSchemaMetaData());
assertNotNull(ruleSchemaMetaData.getUnconfiguredSchemaMetaDataMap());
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataChangedListenerTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataChangedListen
[...]
index 94eb44a..fe8f453 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataChangedListenerTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataChangedListenerTest.java
@@ -41,12 +41,12 @@ public final class MetaDataChangedListenerTest {
@Before
public void setUp() {
- metaDataChangedListener = new MetaDataChangedListener("test",
orchestrationRepository, Collections.singleton("schema"));
+ metaDataChangedListener = new
MetaDataChangedListener(orchestrationRepository,
Collections.singleton("schema"));
}
@Test
public void createOrchestrationEvent() {
- DataChangedEvent event = new DataChangedEvent("/test/metadata/schema",
MetaDataJson.META_DATA, ChangedType.UPDATED);
+ DataChangedEvent event = new DataChangedEvent("/metadata/schema",
MetaDataJson.META_DATA, ChangedType.UPDATED);
MetaDataChangedEvent metaDataChangedEvent = (MetaDataChangedEvent)
metaDataChangedListener.createOrchestrationEvent(event);
assertNotNull(metaDataChangedEvent);
assertThat(metaDataChangedEvent.getSchemaNames(),
is(Collections.singleton("schema")));
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataListenerManagerTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataListenerManag
[...]
index f74870b..23aa471 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataListenerManagerTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-metadata/src/test/java/org/apache/shardingsphere/orchestration/core/metadata/listener/MetaDataListenerManagerTest.java
@@ -40,7 +40,7 @@ public final class MetaDataListenerManagerTest {
@Test
public void assertInitListeners() {
- MetaDataListenerManager actual = new MetaDataListenerManager("test",
orchestrationRepository, Collections.singleton("sharding_db"));
+ MetaDataListenerManager actual = new
MetaDataListenerManager(orchestrationRepository,
Collections.singleton("sharding_db"));
FieldUtil.setField(actual, "metaDataChangedListener",
metaDataChangedListener);
actual.initListeners();
verify(metaDataChangedListener).watch(ChangedType.UPDATED);
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenter.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenter.java
index b875ecc..ba4bdf4 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenter.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenter.java
@@ -35,8 +35,8 @@ public final class RegistryCenter {
private final OrchestrationInstance instance;
- public RegistryCenter(final String name, final RegistryRepository
registryRepository) {
- node = new RegistryCenterNode(name);
+ public RegistryCenter(final RegistryRepository registryRepository) {
+ node = new RegistryCenterNode();
repository = registryRepository;
instance = OrchestrationInstance.getInstance();
}
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNode.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNode.java
index 7fc2f75..6c2b6c6 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNode.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNode.java
@@ -33,8 +33,6 @@ public final class RegistryCenterNode {
private static final String DATA_SOURCES_NODE_PATH = "datasources";
- private final String name;
-
/**
* Get instance node full path.
*
@@ -42,7 +40,7 @@ public final class RegistryCenterNode {
* @return instance node full path
*/
public String getInstancesNodeFullPath(final String instanceId) {
- return Joiner.on("/").join("", name, ROOT, INSTANCES_NODE_PATH,
instanceId);
+ return Joiner.on("/").join("", ROOT, INSTANCES_NODE_PATH, instanceId);
}
/**
@@ -51,7 +49,7 @@ public final class RegistryCenterNode {
* @return data source node full root path
*/
public String getDataSourcesNodeFullRootPath() {
- return Joiner.on("/").join("", name, ROOT, DATA_SOURCES_NODE_PATH);
+ return Joiner.on("/").join("", ROOT, DATA_SOURCES_NODE_PATH);
}
/**
@@ -61,7 +59,7 @@ public final class RegistryCenterNode {
* @return data source node full path
*/
public String getDataSourcesNodeFullPath(final String
schemaDataSourceName) {
- return Joiner.on("/").join("", name, ROOT, DATA_SOURCES_NODE_PATH,
schemaDataSourceName);
+ return Joiner.on("/").join("", ROOT, DATA_SOURCES_NODE_PATH,
schemaDataSourceName);
}
/**
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/DataSourceStateChangedListener.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/DataSourceStateCha
[...]
index 7338b99..b19f8f9 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/DataSourceStateChangedListener.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/DataSourceStateChangedListener.java
@@ -35,9 +35,9 @@ public final class DataSourceStateChangedListener extends
PostOrchestrationRepos
private final RegistryCenterNode registryCenterNode;
- public DataSourceStateChangedListener(final String name, final
RegistryRepository registryRepository) {
- super(registryRepository, Collections.singleton(new
RegistryCenterNode(name).getDataSourcesNodeFullRootPath()));
- registryCenterNode = new RegistryCenterNode(name);
+ public DataSourceStateChangedListener(final RegistryRepository
registryRepository) {
+ super(registryRepository, Collections.singleton(new
RegistryCenterNode().getDataSourcesNodeFullRootPath()));
+ registryCenterNode = new RegistryCenterNode();
}
@Override
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListener.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChanged
[...]
index 2263567..21a9383 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListener.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListener.java
@@ -35,8 +35,8 @@ import java.util.Collections;
*/
public final class InstanceStateChangedListener extends
PostOrchestrationRepositoryEventListener {
- public InstanceStateChangedListener(final String name, final
RegistryRepository registryRepository) {
- super(registryRepository, Collections.singleton(new
RegistryCenterNode(name).getInstancesNodeFullPath(OrchestrationInstance.getInstance().getInstanceId())));
+ public InstanceStateChangedListener(final RegistryRepository
registryRepository) {
+ super(registryRepository, Collections.singleton(new
RegistryCenterNode().getInstancesNodeFullPath(OrchestrationInstance.getInstance().getInstanceId())));
}
@Override
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/RegistryListenerManager.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/RegistryListenerManager.java
index f2d9dd6..aa6497f 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/RegistryListenerManager.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/main/java/org/apache/shardingsphere/orchestration/core/registry/listener/RegistryListenerManager.java
@@ -29,9 +29,9 @@ public final class RegistryListenerManager {
private final DataSourceStateChangedListener
dataSourceStateChangedListener;
- public RegistryListenerManager(final String name, final RegistryRepository
registryRepository) {
- instanceStateChangedListener = new InstanceStateChangedListener(name,
registryRepository);
- dataSourceStateChangedListener = new
DataSourceStateChangedListener(name, registryRepository);
+ public RegistryListenerManager(final RegistryRepository
registryRepository) {
+ instanceStateChangedListener = new
InstanceStateChangedListener(registryRepository);
+ dataSourceStateChangedListener = new
DataSourceStateChangedListener(registryRepository);
}
/**
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNodeTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNodeTest.java
index 5c97860..dbb7603 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNodeTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterNodeTest.java
@@ -24,25 +24,25 @@ import static org.junit.Assert.assertThat;
public final class RegistryCenterNodeTest {
- private final RegistryCenterNode registryCenterNode = new
RegistryCenterNode("test");
+ private final RegistryCenterNode registryCenterNode = new
RegistryCenterNode();
@Test
public void assertGetInstancesNodeFullPath() {
- assertThat(registryCenterNode.getInstancesNodeFullPath("testId"),
is("/test/registry/instances/testId"));
+ assertThat(registryCenterNode.getInstancesNodeFullPath("testId"),
is("/registry/instances/testId"));
}
@Test
public void assertGetDataSourcesNodeFullRootPath() {
- assertThat(registryCenterNode.getDataSourcesNodeFullRootPath(),
is("/test/registry/datasources"));
+ assertThat(registryCenterNode.getDataSourcesNodeFullRootPath(),
is("/registry/datasources"));
}
@Test
public void assertGetDataSourcesNodeFullPath() {
-
assertThat(registryCenterNode.getDataSourcesNodeFullPath("sharding_db"),
is("/test/registry/datasources/sharding_db"));
+
assertThat(registryCenterNode.getDataSourcesNodeFullPath("sharding_db"),
is("/registry/datasources/sharding_db"));
}
@Test
public void assertGetOrchestrationShardingSchema() {
-
assertThat(registryCenterNode.getOrchestrationShardingSchema("/test/registry/datasources/master_slave_db.slave_ds_0").getSchemaName(),
is("master_slave_db"));
+
assertThat(registryCenterNode.getOrchestrationShardingSchema("/registry/datasources/master_slave_db.slave_ds_0").getSchemaName(),
is("master_slave_db"));
}
}
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterTest.java
index e8c5d39..0f4ea76 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/RegistryCenterTest.java
@@ -42,7 +42,7 @@ public final class RegistryCenterTest {
@Before
public void setUp() throws ReflectiveOperationException {
- registryCenter = new RegistryCenter("test", registryRepository);
+ registryCenter = new RegistryCenter(registryRepository);
Field field = registryCenter.getClass().getDeclaredField("repository");
field.setAccessible(true);
field.set(registryCenter, registryRepository);
@@ -57,7 +57,7 @@ public final class RegistryCenterTest {
@Test
public void assertPersistDataSourcesNode() {
registryCenter.persistDataSourcesNode();
- verify(registryRepository).persist("/test/registry/datasources", "");
+ verify(registryRepository).persist("/registry/datasources", "");
}
@Test
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/DataSourceStateChangedListenerTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/DataSourceStat
[...]
index 79011ff..eda95cb 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/DataSourceStateChangedListenerTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/DataSourceStateChangedListenerTest.java
@@ -40,13 +40,13 @@ public final class DataSourceStateChangedListenerTest {
@Before
public void setUp() {
- dataSourceStateChangedListener = new
DataSourceStateChangedListener("test", registryRepository);
+ dataSourceStateChangedListener = new
DataSourceStateChangedListener(registryRepository);
}
@Test
public void assertCreateOrchestrationEvent() {
OrchestrationSchema expected = new
OrchestrationSchema("master_slave_db", "slave_ds_0");
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/test/registry/datasources/master_slave_db.slave_ds_0",
"disabled", ChangedType.UPDATED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/registry/datasources/master_slave_db.slave_ds_0",
"disabled", ChangedType.UPDATED);
assertThat(dataSourceStateChangedListener.createOrchestrationEvent(dataChangedEvent).getOrchestrationSchema().getSchemaName(),
is(expected.getSchemaName()));
}
}
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListenerTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateCha
[...]
index 4335c4c..e78ccb1 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListenerTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/InstanceStateChangedListenerTest.java
@@ -40,17 +40,17 @@ public final class InstanceStateChangedListenerTest {
@Before
public void setUp() {
- instanceStateChangedListener = new
InstanceStateChangedListener("test", registryRepository);
+ instanceStateChangedListener = new
InstanceStateChangedListener(registryRepository);
}
@Test
public void assertCreateOrchestrationEventWhenEnabled() {
- assertFalse(instanceStateChangedListener.createOrchestrationEvent(new
DataChangedEvent("test/test_ds", "", ChangedType.UPDATED)).isCircuitBreak());
+ assertFalse(instanceStateChangedListener.createOrchestrationEvent(new
DataChangedEvent("/test_ds", "", ChangedType.UPDATED)).isCircuitBreak());
}
@Test
public void assertCreateOrchestrationEventWhenDisabled() {
- assertTrue(instanceStateChangedListener.createOrchestrationEvent(new
DataChangedEvent("test/test_ds",
+ assertTrue(instanceStateChangedListener.createOrchestrationEvent(new
DataChangedEvent("/test_ds",
"state: " + RegistryCenterNodeStatus.DISABLED.name(),
ChangedType.UPDATED)).isCircuitBreak());
}
}
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/RegistryListenerManagerTest.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/RegistryListenerManag
[...]
index 69e0dcf..18f33c0 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/RegistryListenerManagerTest.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-registry/src/test/java/org/apache/shardingsphere/orchestration/core/registry/listener/RegistryListenerManagerTest.java
@@ -41,7 +41,7 @@ public final class RegistryListenerManagerTest {
@Test
public void assertInitListeners() {
- RegistryListenerManager actual = new RegistryListenerManager("test",
registryRepository);
+ RegistryListenerManager actual = new
RegistryListenerManager(registryRepository);
FieldUtil.setField(actual, "instanceStateChangedListener",
instanceStateChangedListener);
FieldUtil.setField(actual, "dataSourceStateChangedListener",
dataSourceStateChangedListener);
actual.initListeners();
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-etcd/src/main/java/org/apache/shardingsphere/orchestration/repository/etcd/EtcdRepository.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-etcd/src/
[...]
index 9e9852f..1d1a707 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-etcd/src/main/java/org/apache/shardingsphere/orchestration/repository/etcd/EtcdRepository.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-etcd/src/main/java/org/apache/shardingsphere/orchestration/repository/etcd/EtcdRepository.java
@@ -59,7 +59,7 @@ public final class EtcdRepository implements
ConfigurationRepository, RegistryRe
@Override
public void init(final String name, final OrchestrationCenterConfiguration
config) {
etcdProperties = new EtcdProperties(props);
- client =
Client.builder().endpoints(Util.toURIs(Splitter.on(",").trimResults().splitToList(config.getServerLists()))).build();
+ client =
Client.builder().endpoints(Util.toURIs(Splitter.on(",").trimResults().splitToList(config.getServerLists()))).namespace(ByteSequence.from(name,
Charsets.UTF_8)).build();
}
@SneakyThrows({InterruptedException.class, ExecutionException.class})
diff --git
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-zookeeper-curator/src/main/java/org/apache/shardingsphere/orchestration/repository/zookeeper/CuratorZookeeperRepository.java
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orch
[...]
index 1720a4c..8bebc06 100644
---
a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-zookeeper-curator/src/main/java/org/apache/shardingsphere/orchestration/repository/zookeeper/CuratorZookeeperRepository.java
+++
b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-repository/shardingsphere-orchestration-repository-provider/shardingsphere-orchestration-repository-zookeeper-curator/src/main/java/org/apache/shardingsphere/orchestration/repository/zookeeper/CuratorZookeeperRepository.java
@@ -69,11 +69,11 @@ public final class CuratorZookeeperRepository implements
ConfigurationRepository
@Override
public void init(final String name, final OrchestrationCenterConfiguration
config) {
ZookeeperProperties zookeeperProperties = new
ZookeeperProperties(props);
- client = buildCuratorClient(config, zookeeperProperties);
+ client = buildCuratorClient(name, config, zookeeperProperties);
initCuratorClient(zookeeperProperties);
}
- private CuratorFramework buildCuratorClient(final
OrchestrationCenterConfiguration config, final ZookeeperProperties
zookeeperProperties) {
+ private CuratorFramework buildCuratorClient(final String namespace, final
OrchestrationCenterConfiguration config, final ZookeeperProperties
zookeeperProperties) {
int retryIntervalMilliseconds =
zookeeperProperties.getValue(ZookeeperPropertyKey.RETRY_INTERVAL_MILLISECONDS);
int maxRetries =
zookeeperProperties.getValue(ZookeeperPropertyKey.MAX_RETRIES);
int timeToLiveSeconds =
zookeeperProperties.getValue(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS);
@@ -81,7 +81,8 @@ public final class CuratorZookeeperRepository implements
ConfigurationRepository
String digest =
zookeeperProperties.getValue(ZookeeperPropertyKey.DIGEST);
CuratorFrameworkFactory.Builder builder =
CuratorFrameworkFactory.builder()
.connectString(config.getServerLists())
- .retryPolicy(new
ExponentialBackoffRetry(retryIntervalMilliseconds, maxRetries,
retryIntervalMilliseconds * maxRetries));
+ .retryPolicy(new
ExponentialBackoffRetry(retryIntervalMilliseconds, maxRetries,
retryIntervalMilliseconds * maxRetries))
+ .namespace(namespace);
if (0 != timeToLiveSeconds) {
builder.sessionTimeoutMs(timeToLiveSeconds * 1000);
}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootMasterSlaveTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/Orchestr
[...]
index 57c5fe5..1b0d5a8 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootMasterSlaveTest.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootMasterSlaveTest.java
@@ -65,7 +65,7 @@ public class OrchestrationSpringBootMasterSlaveTest {
ShardingSphereDataSource shardingSphereDataSource =
(ShardingSphereDataSource) field.get(dataSource);
for (DataSource each :
shardingSphereDataSource.getDataSourceMap().values()) {
assertThat(((BasicDataSource) each).getMaxTotal(), is(16));
- assertThat(((BasicDataSource) each).getUsername(), is("root"));
+ assertThat(((BasicDataSource) each).getUsername(), is("sa"));
}
Collection<ShardingSphereRule> rules =
shardingSphereDataSource.getSchemaContexts().getDefaultSchemaContext().getSchema().getRules();
assertThat(rules.size(), is(1));
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryEncryptTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/Orch
[...]
index ab6c938..4243e30 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryEncryptTest.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryEncryptTest.java
@@ -64,10 +64,10 @@ public class OrchestrationSpringBootRegistryEncryptTest {
String dataSource = readYAML(DATA_SOURCE_FILE);
String encryptRule = readYAML(ENCRYPT_RULE_FILE);
TestOrchestrationRepository repository = new
TestOrchestrationRepository();
-
repository.persist("/orchestration-spring-boot-test/config/schema/logic_db/datasource",
dataSource);
-
repository.persist("/orchestration-spring-boot-test/config/schema/logic_db/rule",
encryptRule);
- repository.persist("/orchestration-spring-boot-test/config/props",
"sql.show: 'true'\n");
-
repository.persist("/orchestration-spring-boot-test/registry/datasources", "");
+ repository.persist("/config/schema/logic_db/datasource", dataSource);
+ repository.persist("/config/schema/logic_db/rule", encryptRule);
+ repository.persist("/config/props", "sql.show: 'true'\n");
+ repository.persist("/registry/datasources", "");
}
@Test
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryMasterSlaveTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/
[...]
index 9020ba7..3366ea7 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryMasterSlaveTest.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryMasterSlaveTest.java
@@ -43,7 +43,7 @@ import static org.junit.Assert.assertTrue;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = OrchestrationSpringBootRegistryMasterSlaveTest.class)
@SpringBootApplication
-@ActiveProfiles("registry")
+@ActiveProfiles("registry-masterslave")
public class OrchestrationSpringBootRegistryMasterSlaveTest {
@Resource
@@ -53,29 +53,29 @@ public class OrchestrationSpringBootRegistryMasterSlaveTest
{
public static void init() {
EmbedTestingServer.start();
TestOrchestrationRepository repository = new
TestOrchestrationRepository();
-
repository.persist("/orchestration-spring-boot-test/config/schema/logic_db/datasource",
""
+ repository.persist("/config/schema/logic_db/datasource", ""
+ "ds_master: !!" +
YamlDataSourceConfiguration.class.getName() + "\n"
+ " dataSourceClassName:
org.apache.commons.dbcp2.BasicDataSource\n"
+ " props:\n"
+ " url:
jdbc:h2:mem:ds_master;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+ " maxTotal: 16\n"
- + " password: ''\n"
- + " username: root\n"
+ + " password: \n"
+ + " username: sa\n"
+ "ds_slave_0: !!" +
YamlDataSourceConfiguration.class.getName() + "\n"
+ " dataSourceClassName:
org.apache.commons.dbcp2.BasicDataSource\n"
+ " props:\n"
+ " url:
jdbc:h2:mem:demo_ds_slave_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+ " maxTotal: 16\n"
- + " password: ''\n"
- + " username: root\n"
+ + " password: \n"
+ + " username: sa\n"
+ "ds_slave_1: !!" +
YamlDataSourceConfiguration.class.getName() + "\n"
+ " dataSourceClassName:
org.apache.commons.dbcp2.BasicDataSource\n"
+ " props:\n"
+ " url:
jdbc:h2:mem:demo_ds_slave_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+ " maxTotal: 16\n"
- + " password: ''\n"
- + " username: root\n");
-
repository.persist("/orchestration-spring-boot-test/config/schema/logic_db/rule",
""
+ + " password: \n"
+ + " username: sa\n");
+ repository.persist("/config/schema/logic_db/rule", ""
+ "rules:\n"
+ "- !MASTER_SLAVE\n"
+ " loadBalancers:\n"
@@ -89,8 +89,8 @@ public class OrchestrationSpringBootRegistryMasterSlaveTest {
+ " slaveDataSourceNames: \n"
+ " - ds_slave_0\n"
+ " - ds_slave_1\n");
- repository.persist("/orchestration-spring-boot-test/config/props",
"{}\n");
-
repository.persist("/orchestration-spring-boot-test/registry/datasources", "");
+ repository.persist("/config/props", "{}\n");
+ repository.persist("/registry/datasources", "");
}
@Test
@@ -102,7 +102,7 @@ public class OrchestrationSpringBootRegistryMasterSlaveTest
{
ShardingSphereDataSource shardingSphereDataSource =
(ShardingSphereDataSource) field.get(dataSource);
for (DataSource each :
shardingSphereDataSource.getDataSourceMap().values()) {
assertThat(((BasicDataSource) each).getMaxTotal(), is(16));
- assertThat(((BasicDataSource) each).getUsername(), is("root"));
+ assertThat(((BasicDataSource) each).getUsername(), is("sa"));
}
}
}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryShardingTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/Orc
[...]
index d787071..7afcc11 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryShardingTest.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/orchestration/type/OrchestrationSpringBootRegistryShardingTest.java
@@ -68,12 +68,12 @@ public class OrchestrationSpringBootRegistryShardingTest {
String shardingDatabases = readYAML(SHARDING_DATABASES_FILE);
String shardingRule = readYAML(SHARDING_RULE_FILE);
TestOrchestrationRepository repository = new
TestOrchestrationRepository();
-
repository.persist("/orchestration-spring-boot-test/config/schema/logic_db/datasource",
shardingDatabases);
-
repository.persist("/orchestration-spring-boot-test/config/schema/logic_db/rule",
shardingRule);
- repository.persist("/orchestration-spring-boot-test/config/props", ""
+ repository.persist("/config/schema/logic_db/datasource",
shardingDatabases);
+ repository.persist("/config/schema/logic_db/rule", shardingRule);
+ repository.persist("/config/props", ""
+ "executor.size: '100'\n"
+ "sql.show: 'true'\n");
-
repository.persist("/orchestration-spring-boot-test/registry/datasources", "");
+ repository.persist("/registry/datasources", "");
}
@Test
@@ -86,7 +86,6 @@ public class OrchestrationSpringBootRegistryShardingTest {
}
assertTrue(schemaContexts.getProps().<Boolean>getValue(ConfigurationPropertyKey.SQL_SHOW));
assertTrue(schemaContexts.getProps().getValue(ConfigurationPropertyKey.SQL_SHOW));
-
assertThat(schemaContexts.getProps().getValue(ConfigurationPropertyKey.EXECUTOR_SIZE),
is(100));
}
@Test
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-encrypt.properties
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-encrypt.properties
index 537cb83..a07d414 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-encrypt.properties
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-encrypt.properties
@@ -32,7 +32,7 @@
spring.shardingsphere.rules.encrypt.tables.t_order.columns.order_id.encryptor-na
spring.shardingsphere.props.sql.show=true
-spring.shardingsphere.orchestration.name=orchestration-spring-boot-master-slave-test
+spring.shardingsphere.orchestration.name=orchestration-spring-boot-encrypt-test
spring.shardingsphere.orchestration.overwrite=true
spring.shardingsphere.orchestration.registry-center.type=TestRegistry
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-masterslave.properties
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-masterslave.properties
index 95cee52..aaecf9d 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-masterslave.properties
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-masterslave.properties
@@ -21,21 +21,21 @@
spring.shardingsphere.datasource.names=${spring.example.datasource.name},ds_slav
spring.shardingsphere.datasource.ds_master.type=org.apache.commons.dbcp2.BasicDataSource
spring.shardingsphere.datasource.ds_master.driver-class-name=org.h2.Driver
spring.shardingsphere.datasource.ds_master.url=jdbc:h2:mem:ds_master;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
-spring.shardingsphere.datasource.ds_master.username=root
+spring.shardingsphere.datasource.ds_master.username=sa
spring.shardingsphere.datasource.ds_master.password=
spring.shardingsphere.datasource.ds_master.max-total=16
spring.shardingsphere.datasource.ds_slave_0.type=org.apache.commons.dbcp2.BasicDataSource
spring.shardingsphere.datasource.ds_slave_0.driver-class-name=org.h2.Driver
spring.shardingsphere.datasource.ds_slave_0.url=jdbc:h2:mem:demo_ds_slave_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
-spring.shardingsphere.datasource.ds_slave_0.username=root
+spring.shardingsphere.datasource.ds_slave_0.username=sa
spring.shardingsphere.datasource.ds_slave_0.password=
spring.shardingsphere.datasource.ds_slave_0.max-total=16
spring.shardingsphere.datasource.ds_slave_1.type=org.apache.commons.dbcp2.BasicDataSource
spring.shardingsphere.datasource.ds_slave_1.driver-class-name=org.h2.Driver
spring.shardingsphere.datasource.ds_slave_1.url=jdbc:h2:mem:demo_ds_slave_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
-spring.shardingsphere.datasource.ds_slave_1.username=root
+spring.shardingsphere.datasource.ds_slave_1.username=sa
spring.shardingsphere.datasource.ds_slave_1.password=
spring.shardingsphere.datasource.ds_slave_1.max-total=16
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-encrypt.properties
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-registry-masterslave.properties
similarity index 52%
copy from
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-encrypt.properties
copy to
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-registry-masterslave.properties
index 537cb83..d140ba0 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-encrypt.properties
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/test/resources/application-registry-masterslave.properties
@@ -15,24 +15,7 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.name=ds
-
-spring.shardingsphere.datasource.ds.type=org.apache.commons.dbcp2.BasicDataSource
-spring.shardingsphere.datasource.ds.driver-class-name=org.h2.Driver
-spring.shardingsphere.datasource.ds.url=jdbc:h2:mem:ds;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
-spring.shardingsphere.datasource.ds.username=sa
-spring.shardingsphere.datasource.ds.password=
-spring.shardingsphere.datasource.ds.max-total=100
-
-spring.shardingsphere.rules.encrypt.encryptors.order_encrypt.type=AES
-spring.shardingsphere.rules.encrypt.encryptors.order_encrypt.props.aes.key.value=123456
-spring.shardingsphere.rules.encrypt.tables.t_order.columns.order_id.cipher-column=cipher_order_id
-spring.shardingsphere.rules.encrypt.tables.t_order.columns.order_id.plain-column=plain_order_id
-spring.shardingsphere.rules.encrypt.tables.t_order.columns.order_id.encryptor-name=order_encrypt
-
-spring.shardingsphere.props.sql.show=true
-
-spring.shardingsphere.orchestration.name=orchestration-spring-boot-master-slave-test
+spring.shardingsphere.orchestration.name=orchestration-spring-boot-registry-master-slave-test
spring.shardingsphere.orchestration.overwrite=true
spring.shardingsphere.orchestration.registry-center.type=TestRegistry