This is an automated email from the ASF dual-hosted git repository.
wuweijie 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 ddb6bb9 Remove PersistedYamlDataSourceConfiguration and
PersistedYamlRuleConfiguration (#10379)
ddb6bb9 is described below
commit ddb6bb9f8385260c4863f6e198258ff28eb01fc5
Author: Liang Zhang <[email protected]>
AuthorDate: Tue May 18 22:51:25 2021 +0800
Remove PersistedYamlDataSourceConfiguration and
PersistedYamlRuleConfiguration (#10379)
* Remove PersistedYamlDataSourceConfiguration
* Remove PersistedYamlRuleConfiguration
* Update docs
* Fix testcases
* Merge conflicts
---
.../governance/management/registry-center.cn.md | 62 +++++----
.../governance/management/registry-center.en.md | 62 +++++----
.../resources/conf/config-database-discovery.yaml | 58 ++++-----
.../governance/core/registry/RegistryCenter.java | 55 ++++----
.../core/registry/RegistryCenterNode.java | 10 +-
.../listener/impl/DataSourceChangedListener.java | 16 +--
.../listener/impl/GlobalRuleChangedListener.java | 6 +-
.../listener/impl/RuleChangedListener.java | 6 +-
.../PersistedYamlDataSourceConfiguration.java | 34 -----
.../persisted/PersistedYamlRuleConfiguration.java | 36 -----
.../core/registry/RegistryCenterNodeTest.java | 10 +-
.../core/registry/RegistryCenterTest.java | 145 +++++++++++----------
.../impl/DataSourceChangedListenerTest.java | 6 +-
.../listener/impl/RuleChangedListenerTest.java | 8 +-
.../src/test/resources/yaml/authority-rule.yaml | 13 +-
.../src/test/resources/yaml/data-source.yaml | 11 +-
.../resources/yaml/database-discovery-rule.yaml | 31 +++--
.../src/test/resources/yaml/encrypt-rule.yaml | 1 -
.../resources/yaml/readwrite-splitting-rule.yaml | 1 -
.../data-database-discovery-rule.yaml | 31 +++--
.../yaml/registryCenter/data-encrypt-rule.yaml | 1 -
.../yaml/registryCenter/data-global-rule.yaml | 13 +-
.../data-readwrite-splitting-rule.yaml | 1 -
.../yaml/registryCenter/data-shadow-rule.yaml | 1 -
.../registryCenter/data-sharding-encrypt-rule.yaml | 75 ++++++-----
.../yaml/registryCenter/data-sharding-rule.yaml | 30 ++---
.../yaml/registryCenter/data-source-init-sql.yaml | 34 ++---
.../resources/yaml/registryCenter/data-source.yaml | 25 ++--
.../src/test/resources/yaml/sharding-rule.yaml | 1 -
.../GovernanceSpringBootRegistryEncryptTest.java | 4 +-
...ceSpringBootRegistryReadwriteSplittingTest.java | 4 +-
.../GovernanceSpringBootRegistryShardingTest.java | 4 +-
.../src/test/resources/yaml/data-source.yaml | 13 +-
.../src/test/resources/yaml/encrypt-rule.yaml | 25 ++--
.../yaml/readwrite-splitting-databases.yaml | 37 +++---
.../resources/yaml/readwrite-splitting-rule.yaml | 1 -
.../test/resources/yaml/sharding-databases.yaml | 37 +++---
.../src/test/resources/yaml/sharding-rule.yaml | 95 +++++++-------
.../resources/conf/config-database-discovery.yaml | 58 ++++-----
.../resources/conf/reg_center/data-sources.yaml | 45 ++++---
.../resources/conf/reg_center/sharding-rule.yaml | 1 -
41 files changed, 499 insertions(+), 608 deletions(-)
diff --git
a/docs/document/content/features/governance/management/registry-center.cn.md
b/docs/document/content/features/governance/management/registry-center.cn.md
index 0723d4c..f9bf802 100644
--- a/docs/document/content/features/governance/management/registry-center.cn.md
+++ b/docs/document/content/features/governance/management/registry-center.cn.md
@@ -23,12 +23,12 @@ namespace
├──props # 属性配置
├──metadata # Metadata 配置
├ ├──${schema_1} # Schema 名称1
- ├ ├ ├──datasource # 数据源配置
- ├ ├ ├──rule # 规则配置
+ ├ ├ ├──dataSources # 数据源配置
+ ├ ├ ├──rules # 规则配置
├ ├ ├──schema # 表结构配置
├ ├──${schema_2} # Schema 名称2
- ├ ├ ├──datasource # 数据源配置
- ├ ├ ├──rule # 规则配置
+ ├ ├ ├──dataSources # 数据源配置
+ ├ ├ ├──rules # 规则配置
├ ├ ├──schema # 表结构配置
├──states
├ ├──proxynodes
@@ -63,44 +63,42 @@ executor-size: 20
sql-show: true
```
-### /metadata/${schemeName}/datasource
+### /metadata/${schemeName}/dataSources
多个数据库连接池的集合,不同数据库连接池属性自适配(例如:DBCP,C3P0,Druid, HikariCP)。
```yaml
-dataSources:
- ds_0:
- dataSourceClassName: com.zaxxer.hikari.HikariDataSource
- props:
- url:
jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
- password: null
- maxPoolSize: 50
- maintenanceIntervalMilliseconds: 30000
- connectionTimeoutMilliseconds: 30000
- idleTimeoutMilliseconds: 60000
- minPoolSize: 1
- username: root
- maxLifetimeMilliseconds: 1800000
- ds_1:
- dataSourceClassName: com.zaxxer.hikari.HikariDataSource
- props:
- url:
jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
- password: null
- maxPoolSize: 50
- maintenanceIntervalMilliseconds: 30000
- connectionTimeoutMilliseconds: 30000
- idleTimeoutMilliseconds: 60000
- minPoolSize: 1
- username: root
- maxLifetimeMilliseconds: 1800000
+ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ props:
+ url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
+ password: null
+ maxPoolSize: 50
+ maintenanceIntervalMilliseconds: 30000
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ minPoolSize: 1
+ username: root
+ maxLifetimeMilliseconds: 1800000
+ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ props:
+ url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
+ password: null
+ maxPoolSize: 50
+ maintenanceIntervalMilliseconds: 30000
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ minPoolSize: 1
+ username: root
+ maxLifetimeMilliseconds: 1800000
```
-### /metadata/${schemeName}/rule
+### /metadata/${schemeName}/rules
规则配置,可包括数据分片、读写分离、数据加密、影子库压测等配置。
```yaml
-rules:
- !SHARDING
xxx
diff --git
a/docs/document/content/features/governance/management/registry-center.en.md
b/docs/document/content/features/governance/management/registry-center.en.md
index 169bbd6..3d37d51 100644
--- a/docs/document/content/features/governance/management/registry-center.en.md
+++ b/docs/document/content/features/governance/management/registry-center.en.md
@@ -23,12 +23,12 @@ namespace
├──props # Properties configuration
├──metadata # Metadata configuration
├ ├──${schema_1} # Schema name 1
- ├ ├ ├──datasource # Datasource configuration
- ├ ├ ├──rule # Rule configuration
+ ├ ├ ├──dataSources # Datasource configuration
+ ├ ├ ├──rules # Rule configuration
├ ├ ├──schema # Table configuration
├ ├──${schema_2} # Schema name 2
- ├ ├ ├──datasource # Datasource configuration
- ├ ├ ├──rule # Rule configuration
+ ├ ├ ├──dataSources # Datasource configuration
+ ├ ├ ├──rules # Rule configuration
├ ├ ├──schema # Table configuration
├──states
├ ├──proxynodes
@@ -63,44 +63,42 @@ executor-size: 20
sql-show: true
```
-### /metadata/${schemeName}/datasource
+### /metadata/${schemeName}/dataSources
A collection of multiple database connection pools, whose properties (e.g.
DBCP, C3P0, Druid and HikariCP) are configured by users themselves.
```yaml
-dataSources:
- ds_0:
- dataSourceClassName: com.zaxxer.hikari.HikariDataSource
- props:
- url:
jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
- password: null
- maxPoolSize: 50
- maintenanceIntervalMilliseconds: 30000
- connectionTimeoutMilliseconds: 30000
- idleTimeoutMilliseconds: 60000
- minPoolSize: 1
- username: root
- maxLifetimeMilliseconds: 1800000
- ds_1:
- dataSourceClassName: com.zaxxer.hikari.HikariDataSource
- props:
- url:
jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
- password: null
- maxPoolSize: 50
- maintenanceIntervalMilliseconds: 30000
- connectionTimeoutMilliseconds: 30000
- idleTimeoutMilliseconds: 60000
- minPoolSize: 1
- username: root
- maxLifetimeMilliseconds: 1800000
+ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ props:
+ url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
+ password: null
+ maxPoolSize: 50
+ maintenanceIntervalMilliseconds: 30000
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ minPoolSize: 1
+ username: root
+ maxLifetimeMilliseconds: 1800000
+ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ props:
+ url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
+ password: null
+ maxPoolSize: 50
+ maintenanceIntervalMilliseconds: 30000
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ minPoolSize: 1
+ username: root
+ maxLifetimeMilliseconds: 1800000
```
-### /metadata/${schemeName}/rule
+### /metadata/${schemeName}/rules
Rule configurations, including sharding, readwrite-splitting, data encryption,
shadow DB configurations.
```yaml
-rules:
- !SHARDING
xxx
diff --git
a/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/resources/conf/config-database-discovery.yaml
b/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/resources/conf/config-database-discovery.yaml
index 4dac500..7e0f78e 100644
---
a/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/resources/conf/config-database-discovery.yaml
+++
b/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/resources/conf/config-database-discovery.yaml
@@ -58,20 +58,20 @@
#
#rules:
#- !DB_DISCOVERY
-# dataSources:
-# pr_ds:
-# dataSourceNames:
-# - ds_0
-# - ds_1
-# - ds_2
-# discoveryTypeName: mgr
-# discoveryTypes:
-# mgr:
-# type: MGR
-# props:
-# groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
-# zkServerLists: 'localhost:2181'
-# keepAliveCron: '0/5 * * * * ?'
+# dataSources:
+# pr_ds:
+# dataSourceNames:
+# - ds_0
+# - ds_1
+# - ds_2
+# discoveryTypeName: mgr
+# discoveryTypes:
+# mgr:
+# type: MGR
+# props:
+# groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
+# zkServerLists: 'localhost:2181'
+# keepAliveCron: '0/5 * * * * ?'
######################################################################################################
#
@@ -114,18 +114,18 @@
# maintenanceIntervalMilliseconds: 30000
#
#rules:
-# - !DB_DISCOVERY
-# dataSources:
-# pr_ds:
-# dataSourceNames:
-# - ds_0
-# - ds_1
-# - ds_2
-# discoveryTypeName: mgr
-# discoveryTypes:
-# mgr:
-# type: MGR
-# props:
-# groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
-# zkServerLists: 'localhost:2181'
-# keepAliveCron: '0/5 * * * * ?'
+#- !DB_DISCOVERY
+# dataSources:
+# pr_ds:
+# dataSourceNames:
+# - ds_0
+# - ds_1
+# - ds_2
+# discoveryTypeName: mgr
+# discoveryTypes:
+# mgr:
+# type: MGR
+# props:
+# groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
+# zkServerLists: 'localhost:2181'
+# keepAliveCron: '0/5 * * * * ?'
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenter.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenter.java
index 21b7cca..ce07abe 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenter.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenter.java
@@ -43,8 +43,6 @@ import
org.apache.shardingsphere.governance.core.registry.listener.event.rule.Sw
import
org.apache.shardingsphere.governance.core.registry.listener.event.scaling.StartScalingEvent;
import org.apache.shardingsphere.governance.core.yaml.schema.pojo.YamlSchema;
import
org.apache.shardingsphere.governance.core.yaml.schema.swapper.SchemaYamlSwapper;
-import
org.apache.shardingsphere.governance.core.yaml.persisted.PersistedYamlDataSourceConfiguration;
-import
org.apache.shardingsphere.governance.core.yaml.persisted.PersistedYamlRuleConfiguration;
import
org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import
org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
@@ -63,7 +61,7 @@ import
org.apache.shardingsphere.infra.metadata.user.ShardingSphereUsers;
import
org.apache.shardingsphere.infra.metadata.user.yaml.config.YamlUsersConfigurationConverter;
import org.apache.shardingsphere.infra.rule.event.impl.DataSourceDisabledEvent;
import org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceEvent;
-import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations;
+import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import
org.apache.shardingsphere.infra.yaml.swapper.YamlDataSourceConfigurationSwapper;
import
org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
@@ -76,6 +74,7 @@ import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Optional;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
@@ -144,7 +143,7 @@ public final class RegistryCenter {
* @param dataSourceConfigs data source configurations
*/
public void persistDataSourceConfigurations(final String schemaName, final
Map<String, DataSourceConfiguration> dataSourceConfigs) {
- repository.persist(node.getMetadataDataSourcePath(schemaName),
YamlEngine.marshal(createPersistedYamlDataSourceConfiguration(dataSourceConfigs)));
+ repository.persist(node.getMetadataDataSourcePath(schemaName),
YamlEngine.marshal(createYamlDataSourceConfiguration(dataSourceConfigs)));
}
private void persistRuleConfigurations(final String schemaName, final
Collection<RuleConfiguration> ruleConfigs, final boolean isOverwrite) {
@@ -160,7 +159,7 @@ public final class RegistryCenter {
* @param ruleConfigs rule configurations
*/
public void persistRuleConfigurations(final String schemaName, final
Collection<RuleConfiguration> ruleConfigs) {
- repository.persist(node.getRulePath(schemaName),
YamlEngine.marshal(createYamlRootRuleConfigurations(schemaName, ruleConfigs)));
+ repository.persist(node.getRulePath(schemaName),
YamlEngine.marshal(createYamlRuleConfigurations(schemaName, ruleConfigs)));
}
/**
@@ -177,7 +176,7 @@ public final class RegistryCenter {
private void persistGlobalRuleConfigurations(final
Collection<RuleConfiguration> globalRuleConfigs, final boolean isOverwrite) {
if (!globalRuleConfigs.isEmpty() && (isOverwrite ||
!hasGlobalRuleConfigurations())) {
- repository.persist(node.getGlobalRuleNode(),
YamlEngine.marshal(createGlobalPersistedYamlRuleConfiguration(globalRuleConfigs)));
+ repository.persist(node.getGlobalRuleNode(),
YamlEngine.marshal(new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(globalRuleConfigs)));
}
}
@@ -187,26 +186,24 @@ public final class RegistryCenter {
}
}
+ @SuppressWarnings("unchecked")
private Collection<RuleConfiguration> loadCachedRuleConfigurations(final
String schemaName, final String ruleConfigCacheId) {
return new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(
-
YamlEngine.unmarshal(registryCacheManager.loadCache(node.getRulePath(schemaName),
ruleConfigCacheId), YamlRootRuleConfigurations.class).getRules());
+
YamlEngine.unmarshal(registryCacheManager.loadCache(node.getRulePath(schemaName),
ruleConfigCacheId), Collection.class));
}
private void addDataSourceConfigurations(final String schemaName, final
Map<String, DataSourceConfiguration> dataSourceConfigs) {
Map<String, DataSourceConfiguration> dataSourceConfigMap =
loadDataSourceConfigurations(schemaName);
dataSourceConfigMap.putAll(dataSourceConfigs);
- repository.persist(node.getMetadataDataSourcePath(schemaName),
YamlEngine.marshal(createPersistedYamlDataSourceConfiguration(dataSourceConfigMap)));
+ repository.persist(node.getMetadataDataSourcePath(schemaName),
YamlEngine.marshal(createYamlDataSourceConfiguration(dataSourceConfigMap)));
}
- private PersistedYamlDataSourceConfiguration
createPersistedYamlDataSourceConfiguration(final Map<String,
DataSourceConfiguration> dataSourceConfigs) {
- Map<String, Map<String, Object>> yamlDataSourceConfigs =
dataSourceConfigs.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, entry -> new
YamlDataSourceConfigurationSwapper().swapToMap(entry.getValue()), (oldValue,
currentValue) -> oldValue, LinkedHashMap::new));
- PersistedYamlDataSourceConfiguration result = new
PersistedYamlDataSourceConfiguration();
- result.setDataSources(yamlDataSourceConfigs);
- return result;
+ private Map<String, Map<String, Object>>
createYamlDataSourceConfiguration(final Map<String, DataSourceConfiguration>
dataSourceConfigs) {
+ return dataSourceConfigs.entrySet().stream()
+ .collect(Collectors.toMap(Entry::getKey, entry -> new
YamlDataSourceConfigurationSwapper().swapToMap(entry.getValue()), (oldValue,
currentValue) -> oldValue, LinkedHashMap::new));
}
- private YamlRootRuleConfigurations createYamlRootRuleConfigurations(final
String schemaName, final Collection<RuleConfiguration> ruleConfigs) {
+ private Collection<YamlRuleConfiguration>
createYamlRuleConfigurations(final String schemaName, final
Collection<RuleConfiguration> ruleConfigs) {
Collection<RuleConfiguration> configs = new LinkedList<>();
for (RuleConfiguration each : ruleConfigs) {
Optional<RuleConfigurationChecker> checker =
RuleConfigurationCheckerFactory.newInstance(each);
@@ -215,9 +212,7 @@ public final class RegistryCenter {
configs.add(each);
}
}
- YamlRootRuleConfigurations result = new YamlRootRuleConfigurations();
- result.setRules(new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(configs));
- return result;
+ return new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(configs);
}
private void persistChangedPrivilege(final Collection<ShardingSphereUser>
users) {
@@ -234,12 +229,6 @@ public final class RegistryCenter {
return !Strings.isNullOrEmpty(repository.get(node.getPropsPath()));
}
- private PersistedYamlRuleConfiguration
createGlobalPersistedYamlRuleConfiguration(final Collection<RuleConfiguration>
globalRuleConfigs) {
- PersistedYamlRuleConfiguration result = new
PersistedYamlRuleConfiguration();
- result.setRules(new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(globalRuleConfigs));
- return result;
- }
-
private void persistSchemaName(final String schemaName) {
String schemaNames = repository.get(node.getMetadataNodePath());
if (Strings.isNullOrEmpty(schemaNames)) {
@@ -265,13 +254,14 @@ public final class RegistryCenter {
return hasDataSourceConfiguration(schemaName) ?
getDataSourceConfigurations(repository.get(node.getMetadataDataSourcePath(schemaName)))
: new LinkedHashMap<>();
}
+ @SuppressWarnings("unchecked")
private static Map<String, DataSourceConfiguration>
getDataSourceConfigurations(final String yamlContent) {
- PersistedYamlDataSourceConfiguration persistedConfig =
YamlEngine.unmarshal(yamlContent, PersistedYamlDataSourceConfiguration.class);
- if (null == persistedConfig.getDataSources() ||
persistedConfig.getDataSources().isEmpty()) {
+ Map<String, Map<String, Object>> yamlDataSources =
YamlEngine.unmarshal(yamlContent, Map.class);
+ if (yamlDataSources.isEmpty()) {
return new LinkedHashMap<>();
}
- Map<String, DataSourceConfiguration> result = new
LinkedHashMap<>(persistedConfig.getDataSources().size());
- persistedConfig.getDataSources().forEach((key, value) ->
result.put(key, new
YamlDataSourceConfigurationSwapper().swapToDataSourceConfiguration(value)));
+ Map<String, DataSourceConfiguration> result = new
LinkedHashMap<>(yamlDataSources.size());
+ yamlDataSources.forEach((key, value) -> result.put(key, new
YamlDataSourceConfigurationSwapper().swapToDataSourceConfiguration(value)));
return result;
}
@@ -281,11 +271,10 @@ public final class RegistryCenter {
* @param schemaName schema name
* @return rule configurations
*/
+ @SuppressWarnings("unchecked")
public Collection<RuleConfiguration> loadRuleConfigurations(final String
schemaName) {
return hasRuleConfiguration(schemaName)
- ? new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(
-
YamlEngine.unmarshal(repository.get(node.getRulePath(schemaName)),
PersistedYamlRuleConfiguration.class).getRules())
- : new LinkedList<>();
+ ? new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(repository.get(node.getRulePath(schemaName)),
Collection.class)) : new LinkedList<>();
}
/**
@@ -293,10 +282,10 @@ public final class RegistryCenter {
*
* @return global rule configurations
*/
+ @SuppressWarnings("unchecked")
public Collection<RuleConfiguration> loadGlobalRuleConfigurations() {
return hasGlobalRuleConfigurations()
- ? new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(repository.get(node.getGlobalRuleNode()),
PersistedYamlRuleConfiguration.class).getRules())
- : Collections.emptyList();
+ ? new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(repository.get(node.getGlobalRuleNode()),
Collection.class)) : Collections.emptyList();
}
/**
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterNode.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterNode.java
index 6810a53..3dd24d3 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterNode.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterNode.java
@@ -47,15 +47,15 @@ public final class RegistryCenterNode {
private static final String METADATA_NODE = "metadata";
- private static final String DATA_SOURCE_NODE = "datasource";
+ private static final String DATA_SOURCES_NODE = "dataSources";
- private static final String RULE_NODE = "rule";
+ private static final String RULES_NODE = "rules";
private static final String SCHEMA_NODE = "schema";
private static final String USERS_NODE = "users";
- private static final String GLOBAL_RULE_NODE = "rule";
+ private static final String GLOBAL_RULE_NODE = "rules";
private static final String PRIVILEGE_NODE = "privilegenode";
@@ -133,7 +133,7 @@ public final class RegistryCenterNode {
* @return data source path
*/
public String getMetadataDataSourcePath(final String schemaName) {
- return getFullMetadataPath(schemaName, DATA_SOURCE_NODE);
+ return getFullMetadataPath(schemaName, DATA_SOURCES_NODE);
}
/**
@@ -233,7 +233,7 @@ public final class RegistryCenterNode {
* @return rule path
*/
public String getRulePath(final String schemaName) {
- return getFullMetadataPath(schemaName, RULE_NODE);
+ return getFullMetadataPath(schemaName, RULES_NODE);
}
/**
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/listener/impl/DataSourceChangedListener.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/listener/impl/DataSourceChangedListener.java
index 29ab533..828b784 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/listener/impl/DataSourceChangedListener.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/listener/impl/DataSourceChangedListener.java
@@ -22,17 +22,16 @@ import
org.apache.shardingsphere.governance.core.registry.RegistryCenterNode;
import
org.apache.shardingsphere.governance.core.registry.listener.PostGovernanceRepositoryEventListener;
import
org.apache.shardingsphere.governance.core.registry.listener.event.GovernanceEvent;
import
org.apache.shardingsphere.governance.core.registry.listener.event.datasource.DataSourceChangedEvent;
-import
org.apache.shardingsphere.governance.core.yaml.persisted.PersistedYamlDataSourceConfiguration;
-import
org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
import
org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
+import
org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import
org.apache.shardingsphere.infra.yaml.swapper.YamlDataSourceConfigurationSwapper;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.Map;
import java.util.Map.Entry;
-import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -62,15 +61,12 @@ public final class DataSourceChangedListener extends
PostGovernanceRepositoryEve
return
registryCenterNode.getMetadataDataSourcePath(schemaName).equals(eventPath);
}
+ @SuppressWarnings("unchecked")
private DataSourceChangedEvent createDataSourceChangedEvent(final String
schemaName, final DataChangedEvent event) {
- PersistedYamlDataSourceConfiguration result =
YamlEngine.unmarshal(event.getValue(),
PersistedYamlDataSourceConfiguration.class);
- return checkDataSourceEvent(result) ? new
DataSourceChangedEvent(schemaName, new HashMap<>())
- : new DataSourceChangedEvent(schemaName,
result.getDataSources().entrySet().stream()
+ Map<String, Map<String, Object>> yamlDataSources =
YamlEngine.unmarshal(event.getValue(), Map.class);
+ return yamlDataSources.isEmpty() ? new
DataSourceChangedEvent(schemaName, new HashMap<>())
+ : new DataSourceChangedEvent(schemaName,
yamlDataSources.entrySet().stream()
.collect(Collectors.toMap(Entry::getKey, entry -> new
YamlDataSourceConfigurationSwapper()
.swapToDataSourceConfiguration(entry.getValue()),
(oldValue, currentValue) -> oldValue, LinkedHashMap::new)));
}
-
- private boolean checkDataSourceEvent(final
PersistedYamlDataSourceConfiguration persistedConfig) {
- return Objects.isNull(persistedConfig) ||
Objects.isNull(persistedConfig.getDataSources()) ||
persistedConfig.getDataSources().isEmpty();
- }
}
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/listener/impl/GlobalRuleChangedListener.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/listener/impl/GlobalRuleChangedListener.java
index 2656eef..69176da 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/listener/impl/GlobalRuleChangedListener.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/listener/impl/GlobalRuleChangedListener.java
@@ -22,9 +22,8 @@ import
org.apache.shardingsphere.governance.core.registry.RegistryCenterNode;
import
org.apache.shardingsphere.governance.core.registry.listener.PostGovernanceRepositoryEventListener;
import
org.apache.shardingsphere.governance.core.registry.listener.event.GovernanceEvent;
import
org.apache.shardingsphere.governance.core.registry.listener.event.rule.GlobalRuleConfigurationsChangedEvent;
-import
org.apache.shardingsphere.governance.core.yaml.persisted.PersistedYamlRuleConfiguration;
-import
org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
import
org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
+import
org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
@@ -48,8 +47,9 @@ public final class GlobalRuleChangedListener extends
PostGovernanceRepositoryEve
return Optional.of(new GlobalRuleConfigurationsChangedEvent("",
getGlobalRuleConfigurations(event)));
}
+ @SuppressWarnings("unchecked")
private Collection<RuleConfiguration> getGlobalRuleConfigurations(final
DataChangedEvent event) {
- Collection<YamlRuleConfiguration> globalRuleConfigs =
YamlEngine.unmarshal(event.getValue(),
PersistedYamlRuleConfiguration.class).getRules();
+ Collection<YamlRuleConfiguration> globalRuleConfigs =
YamlEngine.unmarshal(event.getValue(), Collection.class);
Preconditions.checkState(!globalRuleConfigs.isEmpty(), "No available
global rule to load for governance.");
return new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(globalRuleConfigs);
}
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/listener/impl/RuleChangedListener.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/listener/impl/RuleChangedListener.java
index 8ed8d20..6f2e093 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/listener/impl/RuleChangedListener.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/listener/impl/RuleChangedListener.java
@@ -24,9 +24,8 @@ import
org.apache.shardingsphere.governance.core.registry.listener.PostGovernanc
import
org.apache.shardingsphere.governance.core.registry.listener.event.GovernanceEvent;
import
org.apache.shardingsphere.governance.core.registry.listener.event.rule.RuleConfigurationCachedEvent;
import
org.apache.shardingsphere.governance.core.registry.listener.event.rule.RuleConfigurationsChangedEvent;
-import
org.apache.shardingsphere.governance.core.yaml.persisted.PersistedYamlRuleConfiguration;
-import
org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
import
org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
+import
org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
@@ -75,8 +74,9 @@ public final class RuleChangedListener extends
PostGovernanceRepositoryEventList
return new RuleConfigurationsChangedEvent(schemaName,
getRuleConfigurations(event.getValue()));
}
+ @SuppressWarnings("unchecked")
private Collection<RuleConfiguration> getRuleConfigurations(final String
yamlContent) {
- Collection<YamlRuleConfiguration> rules =
YamlEngine.unmarshal(yamlContent,
PersistedYamlRuleConfiguration.class).getRules();
+ Collection<YamlRuleConfiguration> rules =
YamlEngine.unmarshal(yamlContent, Collection.class);
Preconditions.checkState(!rules.isEmpty(), "No available rule to load
for governance.");
return new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(rules);
}
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/persisted/PersistedYamlDataSourceConfiguration.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/persisted/PersistedYamlDataSourceConfiguration.java
deleted file mode 100644
index 031444f..0000000
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/persisted/PersistedYamlDataSourceConfiguration.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.governance.core.yaml.persisted;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.apache.shardingsphere.infra.yaml.config.YamlConfiguration;
-
-import java.util.Map;
-
-/**
- * Persisted data source configuration for YAML.
- */
-@Getter
-@Setter
-public final class PersistedYamlDataSourceConfiguration implements
YamlConfiguration {
-
- private Map<String, Map<String, Object>> dataSources;
-}
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/persisted/PersistedYamlRuleConfiguration.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/persisted/PersistedYamlRuleConfiguration.java
deleted file mode 100644
index fa7a6be..0000000
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/persisted/PersistedYamlRuleConfiguration.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.governance.core.yaml.persisted;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.apache.shardingsphere.infra.yaml.config.YamlConfiguration;
-import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-/**
- * Persisted rule configuration for YAML.
- */
-@Getter
-@Setter
-public final class PersistedYamlRuleConfiguration implements YamlConfiguration
{
-
- private Collection<YamlRuleConfiguration> rules = new LinkedList<>();
-}
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterNodeTest.java
b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterNodeTest.java
index 319fd6c..f3e3326 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterNodeTest.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterNodeTest.java
@@ -84,7 +84,7 @@ public final class RegistryCenterNodeTest {
@Test
public void assertGetRulePath() {
- assertThat(registryCenterNode.getRulePath(DefaultSchema.LOGIC_NAME),
is("/metadata/logic_db/rule"));
+ assertThat(registryCenterNode.getRulePath(DefaultSchema.LOGIC_NAME),
is("/metadata/logic_db/rules"));
}
@Test
@@ -94,7 +94,7 @@ public final class RegistryCenterNodeTest {
@Test
public void assertGetGlobalRuleNodePath() {
- assertThat(registryCenterNode.getGlobalRuleNode(), is("/rule"));
+ assertThat(registryCenterNode.getGlobalRuleNode(), is("/rules"));
}
@Test
@@ -104,7 +104,7 @@ public final class RegistryCenterNodeTest {
@Test
public void assertGetSchemaName() {
-
assertThat(registryCenterNode.getSchemaName("/metadata/logic_db/rule"),
is(DefaultSchema.LOGIC_NAME));
+
assertThat(registryCenterNode.getSchemaName("/metadata/logic_db/rules"),
is(DefaultSchema.LOGIC_NAME));
}
@Test
@@ -112,8 +112,8 @@ public final class RegistryCenterNodeTest {
Collection<String> actual =
registryCenterNode.getAllSchemaConfigPaths(Collections.singletonList(DefaultSchema.LOGIC_NAME));
assertThat(actual.size(), is(4));
assertThat(actual, hasItems("/metadata"));
- assertThat(actual, hasItems("/metadata/logic_db/rule"));
- assertThat(actual, hasItems("/metadata/logic_db/datasource"));
+ assertThat(actual, hasItems("/metadata/logic_db/rules"));
+ assertThat(actual, hasItems("/metadata/logic_db/dataSources"));
assertThat(actual, hasItems("/metadata/logic_db/schema"));
}
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterTest.java
b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterTest.java
index 196d8b6..2bf1896 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterTest.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterTest.java
@@ -28,7 +28,6 @@ import
org.apache.shardingsphere.governance.core.registry.listener.event.metadat
import
org.apache.shardingsphere.governance.core.registry.listener.event.metadata.MetaDataDroppedEvent;
import
org.apache.shardingsphere.governance.core.registry.listener.event.rule.RuleConfigurationsAlteredEvent;
import
org.apache.shardingsphere.governance.core.registry.listener.event.rule.SwitchRuleConfigurationEvent;
-import
org.apache.shardingsphere.governance.core.yaml.persisted.PersistedYamlRuleConfiguration;
import org.apache.shardingsphere.governance.core.yaml.schema.pojo.YamlSchema;
import
org.apache.shardingsphere.governance.core.yaml.schema.swapper.SchemaYamlSwapper;
import
org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
@@ -40,7 +39,6 @@ import
org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
import
org.apache.shardingsphere.infra.metadata.schema.refresher.event.SchemaAlteredEvent;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
-import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import
org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
import
org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
@@ -175,8 +173,8 @@ public final class RegistryCenterTest {
public void
assertPersistConfigurationForShardingRuleWithoutAuthenticationAndIsNotOverwriteAndConfigurationIsExisted()
{
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createRuleConfigurations(), false);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/datasource"),
any());
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rule"),
any());
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"),
any());
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"),
any());
}
@Test
@@ -197,112 +195,112 @@ public final class RegistryCenterTest {
public void
assertPersistConfigurationForShardingRuleWithoutAuthenticationAndIsNotOverwriteAndConfigurationIsNotExisted()
{
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createRuleConfigurations(), false);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/datasource"),
any());
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rule"),
any());
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"),
any());
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"),
any());
}
@Test
public void
assertPersistConfigurationForShardingRuleWithoutAuthenticationAndIsOverwrite() {
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createRuleConfigurations(), true);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/datasource"),
any());
- verify(registryCenterRepository,
times(0)).persist("/metadata/sharding_db/rule", readYAML(SHARDING_RULE_YAML));
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"),
any());
+ verify(registryCenterRepository,
times(0)).persist("/metadata/sharding_db/rules", readYAML(SHARDING_RULE_YAML));
}
@Test
public void
assertPersistConfigurationForReplicaQueryRuleWithoutAuthenticationAndIsNotOverwriteAndConfigurationIsExisted()
{
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createReadwriteSplittingRuleConfiguration(),
false);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/datasource"),
any());
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rule"),
any());
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"),
any());
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"),
any());
}
@Test
public void
assertPersistConfigurationForReplicaQueryRuleWithoutAuthenticationAndIsNotOverwriteAndConfigurationIsNotExisted()
{
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createReadwriteSplittingRuleConfiguration(),
false);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/datasource"),
any());
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rule"),
any());
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"),
any());
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"),
any());
}
@Test
public void
assertPersistConfigurationForReadwriteSplittingWithoutAuthenticationAndIsOverwrite()
{
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createReadwriteSplittingRuleConfiguration(),
true);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/datasource"),
any());
- verify(registryCenterRepository,
times(0)).persist("/metadata/sharding_db/rule",
readYAML(READWRITE_SPLITTING_RULE_YAML));
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"),
any());
+ verify(registryCenterRepository,
times(0)).persist("/metadata/sharding_db/rules",
readYAML(READWRITE_SPLITTING_RULE_YAML));
}
@Test
public void
assertPersistConfigurationForDatabaseDiscoveryRuleWithoutAuthenticationAndIsOverwrite()
{
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createDatabaseDiscoveryRuleConfiguration(),
true);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/datasource"),
any());
- verify(registryCenterRepository,
times(0)).persist("/metadata/sharding_db/rule",
readYAML(DB_DISCOVERY_RULE_YAML));
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"),
any());
+ verify(registryCenterRepository,
times(0)).persist("/metadata/sharding_db/rules",
readYAML(DB_DISCOVERY_RULE_YAML));
}
@Test
public void
assertPersistConfigurationForShardingRuleWithAuthenticationAndIsNotOverwriteAndConfigurationIsExisted()
{
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createRuleConfigurations(), false);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/datasource"),
any());
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rule"),
any());
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"),
any());
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"),
any());
}
@Test
public void
assertPersistConfigurationForShardingRuleWithAuthenticationAndIsNotOverwriteAndConfigurationIsNotExisted()
{
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createRuleConfigurations(), false);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/datasource"),
any());
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rule"),
any());
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"),
any());
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"),
any());
}
@Test
public void
assertPersistConfigurationForShardingRuleWithAuthenticationAndIsOverwrite() {
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createRuleConfigurations(), true);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/datasource"),
any());
- verify(registryCenterRepository,
times(0)).persist("/metadata/sharding_db/rule", readYAML(SHARDING_RULE_YAML));
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"),
any());
+ verify(registryCenterRepository,
times(0)).persist("/metadata/sharding_db/rules", readYAML(SHARDING_RULE_YAML));
}
@Test
public void
assertPersistConfigurationForReplicaQueryRuleWithAuthenticationAndIsNotOverwriteAndConfigurationIsExisted()
{
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createReadwriteSplittingRuleConfiguration(),
false);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/datasource"),
any());
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rule"),
any());
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"),
any());
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"),
any());
}
@Test
public void
assertPersistConfigurationForReadwriteSplittingRuleWithAuthenticationAndIsNotOverwriteAndConfigurationIsNotExisted()
{
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createReadwriteSplittingRuleConfiguration(),
false);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/datasource"),
any());
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rule"),
any());
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"),
any());
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"),
any());
}
@Test
public void
assertPersistConfigurationForReadwriteSplittingRuleWithAuthenticationAndIsOverwrite()
{
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createReadwriteSplittingRuleConfiguration(),
true);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/datasource"),
any());
- verify(registryCenterRepository,
times(0)).persist("/metadata/sharding_db/rule",
readYAML(READWRITE_SPLITTING_RULE_YAML));
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"),
any());
+ verify(registryCenterRepository,
times(0)).persist("/metadata/sharding_db/rules",
readYAML(READWRITE_SPLITTING_RULE_YAML));
}
@Test
public void
assertPersistConfigurationForDatabaseDiscoveryRuleWithAuthenticationAndIsOverwrite()
{
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createDatabaseDiscoveryRuleConfiguration(),
true);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/datasource"),
any());
- verify(registryCenterRepository,
times(0)).persist("/metadata/sharding_db/rule",
readYAML(DB_DISCOVERY_RULE_YAML));
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"),
any());
+ verify(registryCenterRepository,
times(0)).persist("/metadata/sharding_db/rules",
readYAML(DB_DISCOVERY_RULE_YAML));
}
@Test
public void assertPersistConfigurationForEncrypt() {
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createEncryptRuleConfiguration(), true);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/datasource"),
any());
- verify(registryCenterRepository,
times(0)).persist("/metadata/sharding_db/rule", readYAML(ENCRYPT_RULE_YAML));
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"),
any());
+ verify(registryCenterRepository,
times(0)).persist("/metadata/sharding_db/rules", readYAML(ENCRYPT_RULE_YAML));
}
@Test
@@ -315,15 +313,15 @@ public final class RegistryCenterTest {
public void assertPersistConfigurationForShadow() {
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistConfigurations("sharding_db",
createDataSourceConfigurations(), createShadowRuleConfiguration(), true);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/datasource"),
any());
- verify(registryCenterRepository,
times(0)).persist("/metadata/sharding_db/rule", readYAML(SHADOW_RULE_YAML));
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"),
any());
+ verify(registryCenterRepository,
times(0)).persist("/metadata/sharding_db/rules", readYAML(SHADOW_RULE_YAML));
}
@Test
public void assertPersistGlobalConfiguration() {
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.persistGlobalConfiguration(createGlobalRuleConfigurations(),
createProperties(), true);
- verify(registryCenterRepository).persist(eq("/rule"), any());
+ verify(registryCenterRepository).persist(eq("/rules"), any());
verify(registryCenterRepository).persist("/props", PROPS_YAML);
}
@@ -352,28 +350,34 @@ public final class RegistryCenterTest {
return result;
}
+ @SuppressWarnings("unchecked")
private Collection<RuleConfiguration> createRuleConfigurations() {
- return new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(SHARDING_RULE_YAML),
PersistedYamlRuleConfiguration.class).getRules());
+ return new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(SHARDING_RULE_YAML),
Collection.class));
}
+ @SuppressWarnings("unchecked")
private Collection<RuleConfiguration>
createReadwriteSplittingRuleConfiguration() {
- return new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(READWRITE_SPLITTING_RULE_YAML),
YamlRootRuleConfigurations.class).getRules());
+ return new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(READWRITE_SPLITTING_RULE_YAML),
Collection.class));
}
+ @SuppressWarnings("unchecked")
private Collection<RuleConfiguration>
createDatabaseDiscoveryRuleConfiguration() {
- return new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(DB_DISCOVERY_RULE_YAML),
YamlRootRuleConfigurations.class).getRules());
+ return new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(DB_DISCOVERY_RULE_YAML),
Collection.class));
}
+ @SuppressWarnings("unchecked")
private Collection<RuleConfiguration> createEncryptRuleConfiguration() {
- return new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(ENCRYPT_RULE_YAML),
YamlRootRuleConfigurations.class).getRules());
+ return new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(ENCRYPT_RULE_YAML),
Collection.class));
}
+ @SuppressWarnings("unchecked")
private Collection<RuleConfiguration> createShadowRuleConfiguration() {
- return new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(SHADOW_RULE_YAML),
YamlRootRuleConfigurations.class).getRules());
+ return new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(SHADOW_RULE_YAML),
Collection.class));
}
+ @SuppressWarnings("unchecked")
private Collection<RuleConfiguration> createGlobalRuleConfigurations() {
- return new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(GLOBAL_RULE_YAML),
PersistedYamlRuleConfiguration.class).getRules());
+ return new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(GLOBAL_RULE_YAML),
Collection.class));
}
private Properties createProperties() {
@@ -384,7 +388,7 @@ public final class RegistryCenterTest {
@Test
public void assertLoadDataSourceConfigurations() {
-
when(registryCenterRepository.get("/metadata/sharding_db/datasource")).thenReturn(readYAML(DATA_SOURCE_YAM));
+
when(registryCenterRepository.get("/metadata/sharding_db/dataSources")).thenReturn(readYAML(DATA_SOURCE_YAM));
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
Map<String, DataSourceConfiguration> actual =
registryCenter.loadDataSourceConfigurations("sharding_db");
assertThat(actual.size(), is(2));
@@ -401,7 +405,7 @@ public final class RegistryCenterTest {
@Test
public void assertLoadDataSourceConfigurationsNotExistPath() {
-
when(registryCenterRepository.get("/metadata/sharding_db/datasource")).thenReturn("");
+
when(registryCenterRepository.get("/metadata/sharding_db/dataSources")).thenReturn("");
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
Map<String, DataSourceConfiguration> actual =
registryCenter.loadDataSourceConfigurations("sharding_db");
assertThat(actual.size(), is(0));
@@ -409,7 +413,7 @@ public final class RegistryCenterTest {
@Test
public void assertLoadShardingAndEncryptRuleConfiguration() {
-
when(registryCenterRepository.get("/metadata/sharding_db/rule")).thenReturn(readYAML(SHARDING_AND_ENCRYPT_RULE_YAML));
+
when(registryCenterRepository.get("/metadata/sharding_db/rules")).thenReturn(readYAML(SHARDING_AND_ENCRYPT_RULE_YAML));
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
Collection<RuleConfiguration> ruleConfigurations =
registryCenter.loadRuleConfigurations("sharding_db");
assertThat(ruleConfigurations.size(), is(2));
@@ -430,7 +434,7 @@ public final class RegistryCenterTest {
@Test
public void assertLoadShardingRuleConfiguration() {
-
when(registryCenterRepository.get("/metadata/sharding_db/rule")).thenReturn(readYAML(SHARDING_RULE_YAML));
+
when(registryCenterRepository.get("/metadata/sharding_db/rules")).thenReturn(readYAML(SHARDING_RULE_YAML));
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
Collection<RuleConfiguration> actual =
registryCenter.loadRuleConfigurations("sharding_db");
assertThat(actual.size(), is(1));
@@ -441,7 +445,7 @@ public final class RegistryCenterTest {
@Test
public void assertLoadReadwriteSplittingRuleConfiguration() {
-
when(registryCenterRepository.get("/metadata/sharding_db/rule")).thenReturn(readYAML(READWRITE_SPLITTING_RULE_YAML));
+
when(registryCenterRepository.get("/metadata/sharding_db/rules")).thenReturn(readYAML(READWRITE_SPLITTING_RULE_YAML));
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
Collection<RuleConfiguration> actual =
registryCenter.loadRuleConfigurations("sharding_db");
ReadwriteSplittingRuleConfiguration config =
(ReadwriteSplittingRuleConfiguration) actual.iterator().next();
@@ -452,7 +456,7 @@ public final class RegistryCenterTest {
@Test
public void assertLoadDatabaseDiscoveryRuleConfiguration() {
-
when(registryCenterRepository.get("/metadata/sharding_db/rule")).thenReturn(readYAML(DB_DISCOVERY_RULE_YAML));
+
when(registryCenterRepository.get("/metadata/sharding_db/rules")).thenReturn(readYAML(DB_DISCOVERY_RULE_YAML));
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
Collection<RuleConfiguration> actual =
registryCenter.loadRuleConfigurations("sharding_db");
DatabaseDiscoveryRuleConfiguration config =
(DatabaseDiscoveryRuleConfiguration) actual.iterator().next();
@@ -462,7 +466,7 @@ public final class RegistryCenterTest {
@Test
public void assertLoadEncryptRuleConfiguration() {
-
when(registryCenterRepository.get("/metadata/sharding_db/rule")).thenReturn(readYAML(ENCRYPT_RULE_YAML));
+
when(registryCenterRepository.get("/metadata/sharding_db/rules")).thenReturn(readYAML(ENCRYPT_RULE_YAML));
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
EncryptRuleConfiguration actual = (EncryptRuleConfiguration)
registryCenter.loadRuleConfigurations("sharding_db").iterator().next();
assertThat(actual.getEncryptors().size(), is(1));
@@ -473,7 +477,7 @@ public final class RegistryCenterTest {
@Test
public void assertLoadShadowRuleConfiguration() {
-
when(registryCenterRepository.get("/metadata/sharding_db/rule")).thenReturn(readYAML(SHADOW_RULE_YAML));
+
when(registryCenterRepository.get("/metadata/sharding_db/rules")).thenReturn(readYAML(SHADOW_RULE_YAML));
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
ShadowRuleConfiguration actual = (ShadowRuleConfiguration)
registryCenter.loadRuleConfigurations("sharding_db").iterator().next();
assertThat(actual.getSourceDataSourceNames(), is(Arrays.asList("ds",
"ds1")));
@@ -491,7 +495,7 @@ public final class RegistryCenterTest {
@Test
public void assertLoadGlobalRuleConfigurations() {
-
when(registryCenterRepository.get("/rule")).thenReturn(readYAML(GLOBAL_RULE_YAML));
+
when(registryCenterRepository.get("/rules")).thenReturn(readYAML(GLOBAL_RULE_YAML));
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
Collection<RuleConfiguration> globalRuleConfigs =
registryCenter.loadGlobalRuleConfigurations();
assertFalse(globalRuleConfigs.isEmpty());
@@ -519,8 +523,8 @@ public final class RegistryCenterTest {
}
@Test
- public void assertLoadDataSourceConfigurationsWithConnectionInitSqls() {
-
when(registryCenterRepository.get("/metadata/sharding_db/datasource")).thenReturn(readYAML(DATA_SOURCE_YAML_WITH_CONNECTION_INIT_SQL));
+ public void assertLoadDataSourceConfigurationsWithConnectionInitSQLs() {
+
when(registryCenterRepository.get("/metadata/sharding_db/dataSources")).thenReturn(readYAML(DATA_SOURCE_YAML_WITH_CONNECTION_INIT_SQL));
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
Map<String, DataSourceConfiguration> actual =
registryCenter.loadDataSourceConfigurations("sharding_db");
assertThat(actual.size(), is(2));
@@ -573,28 +577,27 @@ public final class RegistryCenterTest {
DataSourceAddedEvent event = new DataSourceAddedEvent("sharding_db",
createDataSourceConfigurations());
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.renew(event);
-
verify(registryCenterRepository).persist(startsWith("/metadata/sharding_db/datasource"),
anyString());
+
verify(registryCenterRepository).persist(startsWith("/metadata/sharding_db/dataSources"),
anyString());
}
@Test
public void assertRenewDataSourceEventHasDataSourceConfig() {
DataSourceAddedEvent event = new DataSourceAddedEvent("sharding_db",
createDataSourceConfigurations());
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
- String dataSourceYaml = "dataSources:\n"
- + " ds_0:\n"
- + " dataSourceClassName: xxx\n"
- + " url:
jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false\n"
- + " username: root\n"
- + " password: root\n"
- + " connectionTimeoutMilliseconds: 30000\n"
- + " idleTimeoutMilliseconds: 60000\n"
- + " maxLifetimeMilliseconds: 1800000\n"
- + " maxPoolSize: 50\n"
- + " minPoolSize: 1\n"
- + " maintenanceIntervalMilliseconds: 30000\n";
-
when(registryCenterRepository.get("/metadata/sharding_db/datasource")).thenReturn(dataSourceYaml);
+ String dataSourceYaml = "ds_0:\n"
+ + " dataSourceClassName: xxx\n"
+ + " url:
jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false\n"
+ + " username: root\n"
+ + " password: root\n"
+ + " connectionTimeoutMilliseconds: 30000\n"
+ + " idleTimeoutMilliseconds: 60000\n"
+ + " maxLifetimeMilliseconds: 1800000\n"
+ + " maxPoolSize: 50\n"
+ + " minPoolSize: 1\n"
+ + " maintenanceIntervalMilliseconds: 30000\n";
+
when(registryCenterRepository.get("/metadata/sharding_db/dataSources")).thenReturn(dataSourceYaml);
registryCenter.renew(event);
-
verify(registryCenterRepository).persist(startsWith("/metadata/sharding_db/datasource"),
anyString());
+
verify(registryCenterRepository).persist(startsWith("/metadata/sharding_db/dataSources"),
anyString());
}
@Test
@@ -602,7 +605,7 @@ public final class RegistryCenterTest {
RuleConfigurationsAlteredEvent event = new
RuleConfigurationsAlteredEvent("sharding_db", createRuleConfigurations());
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.renew(event);
-
verify(registryCenterRepository).persist(startsWith("/metadata/sharding_db/rule"),
anyString());
+
verify(registryCenterRepository).persist(startsWith("/metadata/sharding_db/rules"),
anyString());
}
@Test
@@ -690,8 +693,8 @@ public final class RegistryCenterTest {
when(registryCacheManager.loadCache(anyString(),
eq("testCacheId"))).thenReturn(readYAML(SHARDING_RULE_YAML));
SwitchRuleConfigurationEvent event = new
SwitchRuleConfigurationEvent("sharding_db", "testCacheId");
registryCenter.renew(event);
-
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rule"),
anyString());
-
verify(registryCacheManager).deleteCache(eq("/metadata/sharding_db/rule"),
eq("testCacheId"));
+
verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"),
anyString());
+
verify(registryCacheManager).deleteCache(eq("/metadata/sharding_db/rules"),
eq("testCacheId"));
}
@Test
@@ -699,7 +702,7 @@ public final class RegistryCenterTest {
DataSourceAlteredEvent event = new
DataSourceAlteredEvent("sharding_db", createDataSourceConfigurations());
RegistryCenter registryCenter = new
RegistryCenter(registryCenterRepository);
registryCenter.renew(event);
-
verify(registryCenterRepository).persist(startsWith("/metadata/sharding_db/datasource"),
anyString());
+
verify(registryCenterRepository).persist(startsWith("/metadata/sharding_db/dataSources"),
anyString());
}
@Test
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/listener/impl/DataSourceChangedListenerTest.java
b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/listener/impl/DataSourceChangedListenerTest.java
index c95c6e0..2da7151 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/listener/impl/DataSourceChangedListenerTest.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/listener/impl/DataSourceChangedListenerTest.java
@@ -58,14 +58,14 @@ public final class DataSourceChangedListenerTest extends
GovernanceListenerTest
@Test
public void assertCreateEventWithInvalidPath() {
String dataSource = readYAML(DATA_SOURCE_FILE);
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/metadata/sharding_db/rule", dataSource, Type.UPDATED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/metadata/sharding_db/rules", dataSource, Type.UPDATED);
Optional<GovernanceEvent> actual =
dataSourceChangedListener.createEvent(dataChangedEvent);
assertFalse(actual.isPresent());
}
@Test
public void assertCreateEventWithEmptyValue() {
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/metadata/sharding_db/datasource", "", Type.UPDATED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/metadata/sharding_db/dataSources", "", Type.UPDATED);
Optional<GovernanceEvent> actual =
dataSourceChangedListener.createEvent(dataChangedEvent);
assertFalse(actual.isPresent());
}
@@ -73,7 +73,7 @@ public final class DataSourceChangedListenerTest extends
GovernanceListenerTest
@Test
public void assertCreateEvent() {
String dataSource = readYAML(DATA_SOURCE_FILE);
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/metadata/sharding_db/datasource", dataSource, Type.UPDATED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/metadata/sharding_db/dataSources", dataSource, Type.UPDATED);
Optional<GovernanceEvent> actual =
dataSourceChangedListener.createEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(DataSourceChangedEvent.class));
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/listener/impl/RuleChangedListenerTest.java
b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/listener/impl/RuleChangedListenerTest.java
index 0a6bb54..578a310 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/listener/impl/RuleChangedListenerTest.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/listener/impl/RuleChangedListenerTest.java
@@ -66,14 +66,14 @@ public final class RuleChangedListenerTest extends
GovernanceListenerTest {
@Test
public void assertCreateEventWithEmptyValue() {
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/metadata/sharding_db/rule", "", Type.UPDATED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/metadata/sharding_db/rules", "", Type.UPDATED);
Optional<GovernanceEvent> actual =
ruleChangedListener.createEvent(dataChangedEvent);
assertFalse(actual.isPresent());
}
@Test
public void assertCreateEventWithShardingRule() {
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/metadata/sharding_db/rule", readYAML(SHARDING_RULE_FILE),
Type.UPDATED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/metadata/sharding_db/rules", readYAML(SHARDING_RULE_FILE),
Type.UPDATED);
Optional<GovernanceEvent> actual =
ruleChangedListener.createEvent(dataChangedEvent);
assertTrue(actual.isPresent());
assertThat(((RuleConfigurationsChangedEvent)
actual.get()).getSchemaName(), is("sharding_db"));
@@ -84,7 +84,7 @@ public final class RuleChangedListenerTest extends
GovernanceListenerTest {
@Test
public void assertCreateEventWithEncryptRule() {
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/metadata/encrypt_db/rule", readYAML(ENCRYPT_RULE_FILE),
Type.UPDATED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/metadata/encrypt_db/rules", readYAML(ENCRYPT_RULE_FILE),
Type.UPDATED);
Optional<GovernanceEvent> actual =
ruleChangedListener.createEvent(dataChangedEvent);
assertTrue(actual.isPresent());
RuleConfigurationsChangedEvent event =
(RuleConfigurationsChangedEvent) actual.get();
@@ -99,7 +99,7 @@ public final class RuleChangedListenerTest extends
GovernanceListenerTest {
@Test
public void assertCreateEventWithReadwriteSplittingRule() {
- DataChangedEvent dataChangedEvent = new
DataChangedEvent("/metadata/readwrite_splitting_db/rule",
readYAML(READWRITE_SPLITTING_RULE_FILE), Type.UPDATED);
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/metadata/readwrite_splitting_db/rules",
readYAML(READWRITE_SPLITTING_RULE_FILE), Type.UPDATED);
Optional<GovernanceEvent> actual =
ruleChangedListener.createEvent(dataChangedEvent);
assertTrue(actual.isPresent());
RuleConfigurationsChangedEvent event =
(RuleConfigurationsChangedEvent) actual.get();
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/authority-rule.yaml
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/authority-rule.yaml
index 2f4b8a9..a0ce468 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/authority-rule.yaml
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/authority-rule.yaml
@@ -15,10 +15,9 @@
# limitations under the License.
#
-rules:
- - !AUTHORITY
- users:
- - root@%:root
- - sharding@:sharding
- provider:
- type: NATIVE
+- !AUTHORITY
+ users:
+ - root@%:root
+ - sharding@:sharding
+ provider:
+ type: NATIVE
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/data-source.yaml
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/data-source.yaml
index e5f140c..7fcc99d 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/data-source.yaml
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/data-source.yaml
@@ -14,9 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-dataSources:
- write_ds:
- dataSourceClassName: com.zaxxer.hikari.HikariDataSource
- url: jdbc:mysql://localhost:3306/demo_write_ds
- username: root
- password: null
+write_ds:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ url: jdbc:mysql://localhost:3306/demo_write_ds
+ username: root
+ password: null
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/database-discovery-rule.yaml
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/database-discovery-rule.yaml
index 50ddf3f..5a3d284 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/database-discovery-rule.yaml
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/database-discovery-rule.yaml
@@ -15,19 +15,18 @@
# limitations under the License.
#
-rules:
- - !DB_DISCOVERY
- dataSources:
- pr_ds:
- dataSourceNames:
- - ds_0
- - ds_1
- - ds_2
- discoveryTypeName: mgr
- discoveryTypes:
- mgr:
- type: MGR
- props:
- groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
- zkServerLists: 'localhost:2181'
- keepAliveCron: '0/5 * * * * ?'
+- !DB_DISCOVERY
+ dataSources:
+ pr_ds:
+ dataSourceNames:
+ - ds_0
+ - ds_1
+ - ds_2
+ discoveryTypeName: mgr
+ discoveryTypes:
+ mgr:
+ type: MGR
+ props:
+ groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
+ zkServerLists: 'localhost:2181'
+ keepAliveCron: '0/5 * * * * ?'
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/encrypt-rule.yaml
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/encrypt-rule.yaml
index 4b172e6..10dc2ef 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/encrypt-rule.yaml
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/encrypt-rule.yaml
@@ -15,7 +15,6 @@
# limitations under the License.
#
-rules:
- !ENCRYPT
tables:
t_order:
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/readwrite-splitting-rule.yaml
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/readwrite-splitting-rule.yaml
index 0f40706..e20f352 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/readwrite-splitting-rule.yaml
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/readwrite-splitting-rule.yaml
@@ -15,7 +15,6 @@
# limitations under the License.
#
-rules:
- !READWRITE_SPLITTING
dataSources:
pr_ds:
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-database-discovery-rule.yaml
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-database-discovery-rule.yaml
index 50ddf3f..5a3d284 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-database-discovery-rule.yaml
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-database-discovery-rule.yaml
@@ -15,19 +15,18 @@
# limitations under the License.
#
-rules:
- - !DB_DISCOVERY
- dataSources:
- pr_ds:
- dataSourceNames:
- - ds_0
- - ds_1
- - ds_2
- discoveryTypeName: mgr
- discoveryTypes:
- mgr:
- type: MGR
- props:
- groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
- zkServerLists: 'localhost:2181'
- keepAliveCron: '0/5 * * * * ?'
+- !DB_DISCOVERY
+ dataSources:
+ pr_ds:
+ dataSourceNames:
+ - ds_0
+ - ds_1
+ - ds_2
+ discoveryTypeName: mgr
+ discoveryTypes:
+ mgr:
+ type: MGR
+ props:
+ groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
+ zkServerLists: 'localhost:2181'
+ keepAliveCron: '0/5 * * * * ?'
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-encrypt-rule.yaml
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-encrypt-rule.yaml
index 4b172e6..10dc2ef 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-encrypt-rule.yaml
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-encrypt-rule.yaml
@@ -15,7 +15,6 @@
# limitations under the License.
#
-rules:
- !ENCRYPT
tables:
t_order:
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-global-rule.yaml
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-global-rule.yaml
index 2f4b8a9..a0ce468 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-global-rule.yaml
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-global-rule.yaml
@@ -15,10 +15,9 @@
# limitations under the License.
#
-rules:
- - !AUTHORITY
- users:
- - root@%:root
- - sharding@:sharding
- provider:
- type: NATIVE
+- !AUTHORITY
+ users:
+ - root@%:root
+ - sharding@:sharding
+ provider:
+ type: NATIVE
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-readwrite-splitting-rule.yaml
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-readwrite-splitting-rule.yaml
index 0f40706..e20f352 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-readwrite-splitting-rule.yaml
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-readwrite-splitting-rule.yaml
@@ -15,7 +15,6 @@
# limitations under the License.
#
-rules:
- !READWRITE_SPLITTING
dataSources:
pr_ds:
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-shadow-rule.yaml
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-shadow-rule.yaml
index e2810f4..d5404ba 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-shadow-rule.yaml
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-shadow-rule.yaml
@@ -15,7 +15,6 @@
# limitations under the License.
#
-rules:
- !SHADOW
column: shadow
sourceDataSourceNames:
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-sharding-encrypt-rule.yaml
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-sharding-encrypt-rule.yaml
index 540883b..e5e2f01 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-sharding-encrypt-rule.yaml
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-sharding-encrypt-rule.yaml
@@ -15,42 +15,41 @@
# limitations under the License.
#
-rules:
- - !SHARDING
- tables:
- t_order:
- actualDataNodes: ds_${0..1}.t_order_${0..1}
- tableStrategy:
- standard:
- shardingColumn: order_id
- shardingAlgorithmName: table_inline
- keyGenerateStrategy:
- column: order_id
- keyGeneratorName: snowflake
- shardingAlgorithms:
- table_inline:
- type: INLINE
- props:
- algorithm-expression: t_order_${order_id % 2}
- keyGenerators:
- snowflake:
- type: SNOWFLAKE
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order_${0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: table_inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ shardingAlgorithms:
+ table_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_${order_id % 2}
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
- - !ENCRYPT
- encryptors:
- aes_encryptor:
- type: AES
- props:
- aes-key-value: 123456abcd
- md5_encryptor:
- type: MD5
- tables:
- t_encrypt:
- columns:
- user_id:
- plainColumn: user_plain
- cipherColumn: user_cipher
- encryptorName: aes_encryptor
- order_id:
- cipherColumn: order_cipher
- encryptorName: md5_encryptor
+- !ENCRYPT
+ encryptors:
+ aes_encryptor:
+ type: AES
+ props:
+ aes-key-value: 123456abcd
+ md5_encryptor:
+ type: MD5
+ tables:
+ t_encrypt:
+ columns:
+ user_id:
+ plainColumn: user_plain
+ cipherColumn: user_cipher
+ encryptorName: aes_encryptor
+ order_id:
+ cipherColumn: order_cipher
+ encryptorName: md5_encryptor
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-sharding-rule.yaml
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-sharding-rule.yaml
index e4e94be..92172fb 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-sharding-rule.yaml
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-sharding-rule.yaml
@@ -15,19 +15,17 @@
# limitations under the License.
#
-rules:
- - !SHARDING
- tables:
- t_order:
- logicTable: t_order
- actualDataNodes: ds_${0..1}.t_order_${0..1}
- tableStrategy:
- standard:
- shardingColumn: order_id
- shardingAlgorithmName: table_inline
-
- shardingAlgorithms:
- table_inline:
- type: INLINE
- props:
- algorithm-expression: t_order_${order_id % 2}
+- !SHARDING
+ tables:
+ t_order:
+ logicTable: t_order
+ actualDataNodes: ds_${0..1}.t_order_${0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: table_inline
+ shardingAlgorithms:
+ table_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_${order_id % 2}
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-source-init-sql.yaml
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-source-init-sql.yaml
index 7a6e51e..de41954 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-source-init-sql.yaml
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-source-init-sql.yaml
@@ -14,22 +14,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-dataSources:
- ds_0:
- dataSourceClassName:
org.apache.shardingsphere.governance.core.registry.MockDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds_0
- username: root
- password: root
- connectionInitSqls:
- - set names utf8mb4;
- - set names utf8;
- ds_1:
- dataSourceClassName:
org.apache.shardingsphere.governance.core.registry.MockDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds_1
- username: root
- password: root
- connectionInitSqls:
+
+ds_0:
+ dataSourceClassName:
org.apache.shardingsphere.governance.core.registry.MockDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/ds_0
+ username: root
+ password: root
+ connectionInitSqls:
+ - set names utf8mb4;
+ - set names utf8;
+ds_1:
+ dataSourceClassName:
org.apache.shardingsphere.governance.core.registry.MockDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/ds_1
+ username: root
+ password: root
+ connectionInitSqls:
- set names utf8mb4;
- set names utf8;
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-source.yaml
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-source.yaml
index 12b4c1a..ad00671 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-source.yaml
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-source.yaml
@@ -14,16 +14,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-dataSources:
- ds_0:
- dataSourceClassName:
org.apache.shardingsphere.governance.core.registry.MockDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds_0
- username: root
- password: root
- ds_1:
- dataSourceClassName:
org.apache.shardingsphere.governance.core.registry.MockDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds_1
- username: root
- password: root
+ds_0:
+ dataSourceClassName:
org.apache.shardingsphere.governance.core.registry.MockDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/ds_0
+ username: root
+ password: root
+ds_1:
+ dataSourceClassName:
org.apache.shardingsphere.governance.core.registry.MockDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/ds_1
+ username: root
+ password: root
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/sharding-rule.yaml
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/sharding-rule.yaml
index 8c33631..e64e855 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/sharding-rule.yaml
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/sharding-rule.yaml
@@ -15,7 +15,6 @@
# limitations under the License.
#
-rules:
- !SHARDING
tables:
t_order:
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryEncryptTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegis
[...]
index aae5bb3..bcda82f 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryEncryptTest.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryEncryptTest.java
@@ -67,8 +67,8 @@ public class GovernanceSpringBootRegistryEncryptTest {
String dataSource = readYAML(DATA_SOURCE_FILE);
String encryptRule = readYAML(ENCRYPT_RULE_FILE);
TestRegistryCenterRepository repository = new
TestRegistryCenterRepository();
- repository.persist("/metadata/logic_db/datasource", dataSource);
- repository.persist("/metadata/logic_db/rule", encryptRule);
+ repository.persist("/metadata/logic_db/dataSources", dataSource);
+ repository.persist("/metadata/logic_db/rules", encryptRule);
repository.persist("/props",
ConfigurationPropertyKey.SQL_SHOW.getKey() + ": 'true'\n");
repository.persist("/states/datanodes", "");
}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryReadwriteSplittingTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpri
[...]
index 31fdb97..6b9aba3 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryReadwriteSplittingTest.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryReadwriteSplittingTest.java
@@ -61,8 +61,8 @@ public class
GovernanceSpringBootRegistryReadwriteSplittingTest {
public static void init() {
EmbedTestingServer.start();
TestRegistryCenterRepository repository = new
TestRegistryCenterRepository();
- repository.persist("/metadata/logic_db/datasource",
readYAML(DATA_SOURCE_FILE));
- repository.persist("/metadata/logic_db/rule", readYAML(RULE_FILE));
+ repository.persist("/metadata/logic_db/dataSources",
readYAML(DATA_SOURCE_FILE));
+ repository.persist("/metadata/logic_db/rules", readYAML(RULE_FILE));
repository.persist("/props", "{}\n");
repository.persist("/states/datanodes", "");
}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryShardingTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegi
[...]
index 2400a76..6dee703 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryShardingTest.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryShardingTest.java
@@ -67,8 +67,8 @@ public class GovernanceSpringBootRegistryShardingTest {
String shardingDatabases = readYAML(SHARDING_DATABASES_FILE);
String shardingRule = readYAML(SHARDING_RULE_FILE);
TestRegistryCenterRepository repository = new
TestRegistryCenterRepository();
- repository.persist("/metadata/logic_db/datasource", shardingDatabases);
- repository.persist("/metadata/logic_db/rule", shardingRule);
+ repository.persist("/metadata/logic_db/dataSources",
shardingDatabases);
+ repository.persist("/metadata/logic_db/rules", shardingRule);
repository.persist("/props",
ConfigurationPropertyKey.EXECUTOR_SIZE.getKey() + ": '100'\n" +
ConfigurationPropertyKey.SQL_SHOW.getKey() + ": 'true'\n");
repository.persist("/states/datanodes", "");
}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/data-source.yaml
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/data-source.yaml
index daeaeca..74a3d0d 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/data-source.yaml
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/data-source.yaml
@@ -14,10 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-dataSources:
- dataSource:
- dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
- url: jdbc:h2:mem:ds;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
- maxTotal: 100
- password: ''
- username: sa
+dataSource:
+ dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
+ url: jdbc:h2:mem:ds;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
+ maxTotal: 100
+ password: ''
+ username: sa
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/encrypt-rule.yaml
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/encrypt-rule.yaml
index 7c5edf7..1a7780c 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/encrypt-rule.yaml
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/encrypt-rule.yaml
@@ -15,16 +15,15 @@
# limitations under the License.
#
-rules:
- - !ENCRYPT
- encryptors:
- order_encrypt:
- props:
- aes-key-value: '123456'
- type: AES
- tables:
- t_order:
- columns:
- user_id:
- cipherColumn: user_id
- encryptorName: order_encrypt
+- !ENCRYPT
+ encryptors:
+ order_encrypt:
+ props:
+ aes-key-value: '123456'
+ type: AES
+ tables:
+ t_order:
+ columns:
+ user_id:
+ cipherColumn: user_id
+ encryptorName: order_encrypt
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/readwrite-splitting-databases.yaml
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/readwrite-splitting-databases.yaml
index 7a7bff0..a41d4aa 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/readwrite-splitting-databases.yaml
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/readwrite-splitting-databases.yaml
@@ -14,22 +14,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-dataSources:
- write_ds:
- dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
- url:
jdbc:h2:mem:write_ds;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
- maxTotal: 16
- password:
- username: sa
- read_ds_0:
- dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
- url:
jdbc:h2:mem:demo_read_ds_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
- maxTotal: 16
- password:
- username: sa
- read_ds_1:
- dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
- url:
jdbc:h2:mem:demo_read_ds_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
- maxTotal: 16
- password:
- username: sa
\ No newline at end of file
+write_ds:
+ dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
+ url:
jdbc:h2:mem:write_ds;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
+ maxTotal: 16
+ password:
+ username: sa
+read_ds_0:
+ dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
+ url:
jdbc:h2:mem:demo_read_ds_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
+ maxTotal: 16
+ password:
+ username: sa
+read_ds_1:
+ dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
+ url:
jdbc:h2:mem:demo_read_ds_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
+ maxTotal: 16
+ password:
+ username: sa
\ No newline at end of file
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/readwrite-splitting-rule.yaml
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/readwrite-splitting-rule.yaml
index 46074ad..198bbe1 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/readwrite-splitting-rule.yaml
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/readwrite-splitting-rule.yaml
@@ -15,7 +15,6 @@
# limitations under the License.
#
-rules:
- !READWRITE_SPLITTING
loadBalancers:
roundRobin:
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/sharding-databases.yaml
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/sharding-databases.yaml
index 0dd31b1..c983dc2 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/sharding-databases.yaml
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/sharding-databases.yaml
@@ -14,23 +14,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-dataSources:
- ds:
- dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
- url: jdbc:h2:mem:ds;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
- maxTotal: 16
- password: ''
- username: sa
- ds_0:
- dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
- url: jdbc:h2:mem:ds_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
- maxTotal: 16
- password: ''
- username: sa
- ds_1:
- dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
- url: jdbc:h2:mem:ds_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
- maxTotal: 16
- password: ''
- username: sa
+ds:
+ dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
+ url: jdbc:h2:mem:ds;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
+ maxTotal: 16
+ password: ''
+ username: sa
+ds_0:
+ dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
+ url: jdbc:h2:mem:ds_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
+ maxTotal: 16
+ password: ''
+ username: sa
+ds_1:
+ dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
+ url: jdbc:h2:mem:ds_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
+ maxTotal: 16
+ password: ''
+ username: sa
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/sharding-rule.yaml
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/sharding-rule.yaml
index 3a1d2b7..dd142e2 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/sharding-rule.yaml
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/yaml/sharding-rule.yaml
@@ -15,51 +15,50 @@
# limitations under the License.
#
-rules:
- - !SHARDING
- bindingTables:
- - t_order
- - t_order_item
- broadcastTables:
- - t_config
- defaultDatabaseStrategy:
- standard:
- shardingAlgorithmName: database_inline
- shardingColumn: user_id
- tables:
- t_order:
- actualDataNodes: ds_${0..1}.t_order_${0..1}
- keyGenerateStrategy:
- column: order_id
- keyGeneratorName: snowflake
- logicTable: t_order
- tableStrategy:
- standard:
- shardingAlgorithmName: t_order_inline
- shardingColumn: order_id
- t_order_item:
- actualDataNodes: ds_${0..1}.t_order_item_${0..1}
- keyGenerateStrategy:
- column: order_item_id
- keyGeneratorName: snowflake
- logicTable: t_order_item
- tableStrategy:
- standard:
- shardingAlgorithmName: t_order_item_inline
- shardingColumn: order_id
- shardingAlgorithms:
- database_inline:
- type: INLINE
- props:
- algorithm-expression: ds_${user_id % 2}
- t_order_inline:
- type: INLINE
- props:
- algorithm-expression: t_order_${order_id % 2}
- t_order_item_inline:
- type: INLINE
- props:
- algorithm-expression: t_order_item_${order_id % 2}
- keyGenerators:
- snowflake:
- type: SNOWFLAKE
+- !SHARDING
+ bindingTables:
+ - t_order
+ - t_order_item
+ broadcastTables:
+ - t_config
+ defaultDatabaseStrategy:
+ standard:
+ shardingAlgorithmName: database_inline
+ shardingColumn: user_id
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order_${0..1}
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ logicTable: t_order
+ tableStrategy:
+ standard:
+ shardingAlgorithmName: t_order_inline
+ shardingColumn: order_id
+ t_order_item:
+ actualDataNodes: ds_${0..1}.t_order_item_${0..1}
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ logicTable: t_order_item
+ tableStrategy:
+ standard:
+ shardingAlgorithmName: t_order_item_inline
+ shardingColumn: order_id
+ shardingAlgorithms:
+ database_inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds_${user_id % 2}
+ t_order_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_${order_id % 2}
+ t_order_item_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_item_${order_id % 2}
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-database-discovery.yaml
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-database-discovery.yaml
index 4dac500..7e0f78e 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-database-discovery.yaml
+++
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-database-discovery.yaml
@@ -58,20 +58,20 @@
#
#rules:
#- !DB_DISCOVERY
-# dataSources:
-# pr_ds:
-# dataSourceNames:
-# - ds_0
-# - ds_1
-# - ds_2
-# discoveryTypeName: mgr
-# discoveryTypes:
-# mgr:
-# type: MGR
-# props:
-# groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
-# zkServerLists: 'localhost:2181'
-# keepAliveCron: '0/5 * * * * ?'
+# dataSources:
+# pr_ds:
+# dataSourceNames:
+# - ds_0
+# - ds_1
+# - ds_2
+# discoveryTypeName: mgr
+# discoveryTypes:
+# mgr:
+# type: MGR
+# props:
+# groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
+# zkServerLists: 'localhost:2181'
+# keepAliveCron: '0/5 * * * * ?'
######################################################################################################
#
@@ -114,18 +114,18 @@
# maintenanceIntervalMilliseconds: 30000
#
#rules:
-# - !DB_DISCOVERY
-# dataSources:
-# pr_ds:
-# dataSourceNames:
-# - ds_0
-# - ds_1
-# - ds_2
-# discoveryTypeName: mgr
-# discoveryTypes:
-# mgr:
-# type: MGR
-# props:
-# groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
-# zkServerLists: 'localhost:2181'
-# keepAliveCron: '0/5 * * * * ?'
+#- !DB_DISCOVERY
+# dataSources:
+# pr_ds:
+# dataSourceNames:
+# - ds_0
+# - ds_1
+# - ds_2
+# discoveryTypeName: mgr
+# discoveryTypes:
+# mgr:
+# type: MGR
+# props:
+# groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
+# zkServerLists: 'localhost:2181'
+# keepAliveCron: '0/5 * * * * ?'
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/conf/reg_center/data-sources.yaml
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/conf/reg_center/data-sources.yaml
index 920d4e0..3ed7a49 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/conf/reg_center/data-sources.yaml
+++
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/conf/reg_center/data-sources.yaml
@@ -15,26 +15,25 @@
# limitations under the License.
#
-dataSources:
- ds_0:
- dataSourceClassName: com.zaxxer.hikari.HikariDataSource
- jdbcUrl: jdbc:fixturedb:xxx
- username: root
- password: pwd
- connectionTimeout: 1000
- idleTimeout: 2000
- maxLifetime: 4000
- maxPoolSize: 20
- minPoolSize: 10
- readOnly: true
- ds_1:
- dataSourceClassName: com.zaxxer.hikari.HikariDataSource
- jdbcUrl: jdbc:fixturedb:xxx
- username: root
- password: pwd
- connectionTimeout: 1000
- idleTimeout: 2000
- maxLifetime: 4000
- maxPoolSize: 20
- minPoolSize: 10
- readOnly: true
+ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ jdbcUrl: jdbc:fixturedb:xxx
+ username: root
+ password: pwd
+ connectionTimeout: 1000
+ idleTimeout: 2000
+ maxLifetime: 4000
+ maxPoolSize: 20
+ minPoolSize: 10
+ readOnly: true
+ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ jdbcUrl: jdbc:fixturedb:xxx
+ username: root
+ password: pwd
+ connectionTimeout: 1000
+ idleTimeout: 2000
+ maxLifetime: 4000
+ maxPoolSize: 20
+ minPoolSize: 10
+ readOnly: true
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/conf/reg_center/sharding-rule.yaml
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/conf/reg_center/sharding-rule.yaml
index 8a988d0..43e7618 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/conf/reg_center/sharding-rule.yaml
+++
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/conf/reg_center/sharding-rule.yaml
@@ -15,7 +15,6 @@
# limitations under the License.
#
-rules:
- !SHARDING
tables:
t_order: