You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/04/13 07:52:06 UTC
[shardingsphere] branch master updated: Proxy supports databaseName configuration and keep compatible with schemaName (#16788)
This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 337326b1373 Proxy supports databaseName configuration and keep compatible with schemaName (#16788)
337326b1373 is described below
commit 337326b1373603e0cc2ef0e4aac6af23f9b51187
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Wed Apr 13 15:51:51 2022 +0800
Proxy supports databaseName configuration and keep compatible with schemaName (#16788)
---
.../core/datasource/ShardingSphereDataSource.java | 2 +-
.../manager/ContextManagerBuilderParameter.java | 4 ++--
.../ContextManagerBuilderParameterTest.java | 22 +++++++++---------
.../cluster/ClusterContextManagerBuilder.java | 8 +++----
.../ClusterContextManagerCoordinatorTest.java | 2 +-
.../memory/MemoryContextManagerBuilder.java | 4 ++--
.../StandaloneContextManagerBuilder.java | 8 +++----
.../StandaloneContextManagerBuilderTextTest.java | 2 +-
.../proxy/backend/config/ProxyConfiguration.java | 2 +-
.../backend/config/ProxyConfigurationLoader.java | 27 ++++++++++++----------
.../backend/config/YamlProxyConfiguration.java | 4 ++--
...on.java => YamlProxyDatabaseConfiguration.java} | 6 +++--
.../swapper/YamlProxyConfigurationSwapper.java | 23 +++++++++---------
.../YamlProxyDataSourceConfigurationSwapper.java | 12 +++++-----
.../ImportSchemaConfigurationHandler.java | 22 +++++++++---------
.../config/ProxyConfigurationLoaderTest.java | 22 +++++++++---------
.../swapper/YamlProxyConfigurationSwapperTest.java | 4 ++--
...amlProxyDataSourceConfigurationSwapperTest.java | 2 +-
.../conf/config_loader/config-encrypt.yaml | 2 +-
.../config_loader/config-readwrite-splitting.yaml | 2 +-
.../conf/config_loader/config-sharding.yaml | 2 +-
.../conf/import/config-database-discovery.yaml | 2 +-
.../conf/import/config-readwrite-splitting.yaml | 2 +-
.../resources/conf/import/config-sharding.yaml | 2 +-
.../conf/swap/config-readwrite-splitting.yaml | 2 +-
.../proxy/initializer/BootstrapInitializer.java | 2 +-
.../resources/conf/config-database-discovery.yaml | 4 ++--
.../src/main/resources/conf/config-encrypt.yaml | 4 ++--
.../resources/conf/config-readwrite-splitting.yaml | 4 ++--
.../src/main/resources/conf/config-shadow.yaml | 4 ++--
.../src/main/resources/conf/config-sharding.yaml | 4 ++--
31 files changed, 109 insertions(+), 103 deletions(-)
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
index 53ebec10d24..0d0b8080854 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
@@ -74,7 +74,7 @@ public final class ShardingSphereDataSource extends AbstractDataSourceAdapter im
Collection<RuleConfiguration> globalRuleConfigs = ruleConfigs.stream().filter(each -> each instanceof GlobalRuleConfiguration).collect(Collectors.toList());
ContextManagerBuilderParameter parameter = ContextManagerBuilderParameter.builder()
.modeConfig(modeConfig)
- .schemaConfigs(Collections.singletonMap(schemaName, new DataSourceProvidedSchemaConfiguration(dataSourceMap, ruleConfigs)))
+ .databaseConfigs(Collections.singletonMap(schemaName, new DataSourceProvidedSchemaConfiguration(dataSourceMap, ruleConfigs)))
.globalRuleConfigs(globalRuleConfigs)
.props(props)
.instanceDefinition(new InstanceDefinition(InstanceType.JDBC)).build();
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameter.java b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameter.java
index b28e5e9677e..ff31b42aa00 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameter.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameter.java
@@ -37,7 +37,7 @@ public final class ContextManagerBuilderParameter {
private final ModeConfiguration modeConfig;
- private final Map<String, ? extends SchemaConfiguration> schemaConfigs;
+ private final Map<String, ? extends SchemaConfiguration> databaseConfigs;
private final Collection<RuleConfiguration> globalRuleConfigs;
@@ -54,6 +54,6 @@ public final class ContextManagerBuilderParameter {
*/
public boolean isEmpty() {
return props.isEmpty() && globalRuleConfigs.isEmpty()
- && schemaConfigs.entrySet().stream().allMatch(entry -> entry.getValue().getDataSources().isEmpty() && entry.getValue().getRuleConfigurations().isEmpty());
+ && databaseConfigs.entrySet().stream().allMatch(entry -> entry.getValue().getDataSources().isEmpty() && entry.getValue().getRuleConfigurations().isEmpty());
}
}
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameterTest.java b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameterTest.java
index 264e56d238d..0bb3fb5838b 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameterTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameterTest.java
@@ -43,7 +43,7 @@ public final class ContextManagerBuilderParameterTest {
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
.globalRuleConfigs(Collections.emptyList())
.props(new Properties())
- .schemaConfigs(mockSchemaConfigs)
+ .databaseConfigs(mockSchemaConfigs)
.build();
assertTrue(contextManagerBuilderParameter.isEmpty());
}
@@ -53,7 +53,7 @@ public final class ContextManagerBuilderParameterTest {
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
.globalRuleConfigs(Collections.emptyList())
.props(new Properties())
- .schemaConfigs(Collections.emptyMap())
+ .databaseConfigs(Collections.emptyMap())
.build();
assertTrue(contextManagerBuilderParameter.isEmpty());
}
@@ -69,7 +69,7 @@ public final class ContextManagerBuilderParameterTest {
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
.globalRuleConfigs(mockGlobalRuleConfigs)
.props(mockProperties)
- .schemaConfigs(mockSchemaConfigs)
+ .databaseConfigs(mockSchemaConfigs)
.build();
assertFalse(contextManagerBuilderParameter.isEmpty());
}
@@ -81,7 +81,7 @@ public final class ContextManagerBuilderParameterTest {
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
.globalRuleConfigs(Collections.emptyList())
.props(mockProperties)
- .schemaConfigs(Collections.emptyMap())
+ .databaseConfigs(Collections.emptyMap())
.build();
assertFalse(contextManagerBuilderParameter.isEmpty());
}
@@ -94,7 +94,7 @@ public final class ContextManagerBuilderParameterTest {
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
.globalRuleConfigs(mockGlobalRuleConfigs)
.props(new Properties())
- .schemaConfigs(Collections.emptyMap())
+ .databaseConfigs(Collections.emptyMap())
.build();
assertFalse(contextManagerBuilderParameter.isEmpty());
}
@@ -105,7 +105,7 @@ public final class ContextManagerBuilderParameterTest {
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
.globalRuleConfigs(Collections.emptyList())
.props(new Properties())
- .schemaConfigs(mockSchemaConfigs)
+ .databaseConfigs(mockSchemaConfigs)
.build();
assertFalse(contextManagerBuilderParameter.isEmpty());
}
@@ -116,7 +116,7 @@ public final class ContextManagerBuilderParameterTest {
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
.globalRuleConfigs(Collections.emptyList())
.props(new Properties())
- .schemaConfigs(mockSchemaConfigs)
+ .databaseConfigs(mockSchemaConfigs)
.build();
assertFalse(contextManagerBuilderParameter.isEmpty());
}
@@ -127,7 +127,7 @@ public final class ContextManagerBuilderParameterTest {
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
.globalRuleConfigs(Collections.emptyList())
.props(new Properties())
- .schemaConfigs(mockSchemaConfigs)
+ .databaseConfigs(mockSchemaConfigs)
.build();
assertFalse(contextManagerBuilderParameter.isEmpty());
}
@@ -141,7 +141,7 @@ public final class ContextManagerBuilderParameterTest {
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
.globalRuleConfigs(mockGlobalRuleConfigs)
.props(new Properties())
- .schemaConfigs(mockSchemaConfigs)
+ .databaseConfigs(mockSchemaConfigs)
.build();
assertFalse(contextManagerBuilderParameter.isEmpty());
}
@@ -154,7 +154,7 @@ public final class ContextManagerBuilderParameterTest {
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
.globalRuleConfigs(Collections.emptyList())
.props(mockProperties)
- .schemaConfigs(mockSchemaConfigs)
+ .databaseConfigs(mockSchemaConfigs)
.build();
assertFalse(contextManagerBuilderParameter.isEmpty());
}
@@ -169,7 +169,7 @@ public final class ContextManagerBuilderParameterTest {
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
.globalRuleConfigs(mockGlobalRuleConfigs)
.props(mockProperties)
- .schemaConfigs(Collections.emptyMap())
+ .databaseConfigs(Collections.emptyMap())
.build();
assertFalse(contextManagerBuilderParameter.isEmpty());
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
index 6da5f3e49c4..ada4213f4e1 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
@@ -87,7 +87,7 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
private void persistConfigurations(final MetaDataPersistService metaDataPersistService, final ContextManagerBuilderParameter parameter) {
boolean isOverwrite = parameter.getModeConfig().isOverwrite();
if (!parameter.isEmpty()) {
- metaDataPersistService.persistConfigurations(parameter.getSchemaConfigs(), parameter.getGlobalRuleConfigs(), parameter.getProps(), isOverwrite);
+ metaDataPersistService.persistConfigurations(parameter.getDatabaseConfigs(), parameter.getGlobalRuleConfigs(), parameter.getProps(), isOverwrite);
}
metaDataPersistService.persistInstanceLabels(parameter.getInstanceDefinition().getInstanceId().getId(), parameter.getLabels(), isOverwrite);
}
@@ -125,11 +125,11 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
private MetaDataContextsBuilder createMetaDataContextsBuilder(final MetaDataPersistService metaDataPersistService, final ContextManagerBuilderParameter parameter) throws SQLException {
Collection<String> schemaNames = InstanceType.JDBC == parameter.getInstanceDefinition().getInstanceType()
- ? parameter.getSchemaConfigs().keySet() : metaDataPersistService.getSchemaMetaDataService().loadAllNames();
+ ? parameter.getDatabaseConfigs().keySet() : metaDataPersistService.getSchemaMetaDataService().loadAllNames();
Collection<RuleConfiguration> globalRuleConfigs = metaDataPersistService.getGlobalRuleService().load();
Properties props = metaDataPersistService.getPropsService().load();
MetaDataContextsBuilder result = new MetaDataContextsBuilder(globalRuleConfigs, props);
- DatabaseType databaseType = DatabaseTypeFactory.getDatabaseType(parameter.getSchemaConfigs(), new ConfigurationProperties(parameter.getProps()));
+ DatabaseType databaseType = DatabaseTypeFactory.getDatabaseType(parameter.getDatabaseConfigs(), new ConfigurationProperties(parameter.getProps()));
for (String each : schemaNames) {
if (databaseType.getSystemSchemas().contains(each)) {
continue;
@@ -142,7 +142,7 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
private SchemaConfiguration createSchemaConfiguration(final String schemaName, final MetaDataPersistService metaDataPersistService,
final ContextManagerBuilderParameter parameter) {
- Map<String, DataSource> dataSources = metaDataPersistService.getEffectiveDataSources(schemaName, parameter.getSchemaConfigs());
+ Map<String, DataSource> dataSources = metaDataPersistService.getEffectiveDataSources(schemaName, parameter.getDatabaseConfigs());
Collection<RuleConfiguration> schemaRuleConfigs = metaDataPersistService.getSchemaRuleService().load(schemaName);
return new DataSourceProvidedSchemaConfiguration(dataSources, schemaRuleConfigs);
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
index 95854f2bf75..081a043e6fa 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
@@ -130,7 +130,7 @@ public final class ClusterContextManagerCoordinatorTest {
PersistRepositoryConfiguration persistRepositoryConfig = new ClusterPersistRepositoryConfiguration("TEST", "", "", new Properties());
ModeConfiguration modeConfig = new ModeConfiguration("Cluster", persistRepositoryConfig, false);
ClusterContextManagerBuilder builder = new ClusterContextManagerBuilder();
- contextManager = builder.build(ContextManagerBuilderParameter.builder().modeConfig(modeConfig).schemaConfigs(new HashMap<>())
+ contextManager = builder.build(ContextManagerBuilderParameter.builder().modeConfig(modeConfig).databaseConfigs(new HashMap<>())
.globalRuleConfigs(new LinkedList<>()).props(new Properties()).instanceDefinition(new InstanceDefinition(InstanceType.PROXY, 3307)).build());
assertTrue(contextManager.getMetaDataContexts().getMetaDataPersistService().isPresent());
contextManager.renewMetaDataContexts(new MetaDataContexts(contextManager.getMetaDataContexts().getMetaDataPersistService().get(), createMetaDataMap(), globalRuleMetaData,
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManagerBuilder.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManagerBuilder.java
index ad7d43ef303..105dc1478f2 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManagerBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManagerBuilder.java
@@ -50,8 +50,8 @@ public final class MemoryContextManagerBuilder implements ContextManagerBuilder
@Override
public ContextManager build(final ContextManagerBuilderParameter parameter) throws SQLException {
MetaDataContextsBuilder metaDataContextsBuilder = new MetaDataContextsBuilder(parameter.getGlobalRuleConfigs(), parameter.getProps());
- DatabaseType databaseType = DatabaseTypeFactory.getDatabaseType(parameter.getSchemaConfigs(), new ConfigurationProperties(parameter.getProps()));
- for (Entry<String, ? extends SchemaConfiguration> entry : parameter.getSchemaConfigs().entrySet()) {
+ DatabaseType databaseType = DatabaseTypeFactory.getDatabaseType(parameter.getDatabaseConfigs(), new ConfigurationProperties(parameter.getProps()));
+ for (Entry<String, ? extends SchemaConfiguration> entry : parameter.getDatabaseConfigs().entrySet()) {
metaDataContextsBuilder.addSchema(entry.getKey(), databaseType, entry.getValue(), parameter.getProps());
}
metaDataContextsBuilder.addSystemSchemas(databaseType);
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
index b533490d5af..caf9541501e 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
@@ -63,7 +63,7 @@ public final class StandaloneContextManagerBuilder implements ContextManagerBuil
private void persistConfigurations(final MetaDataPersistService metaDataPersistService, final ContextManagerBuilderParameter parameter) {
if (!parameter.isEmpty()) {
- metaDataPersistService.persistConfigurations(parameter.getSchemaConfigs(), parameter.getGlobalRuleConfigs(), parameter.getProps(), parameter.getModeConfig().isOverwrite());
+ metaDataPersistService.persistConfigurations(parameter.getDatabaseConfigs(), parameter.getGlobalRuleConfigs(), parameter.getProps(), parameter.getModeConfig().isOverwrite());
}
}
@@ -72,8 +72,8 @@ public final class StandaloneContextManagerBuilder implements ContextManagerBuil
Properties props = metaDataPersistService.getPropsService().load();
MetaDataContextsBuilder builder = new MetaDataContextsBuilder(globalRuleConfigs, props);
Collection<String> schemaNames = InstanceType.JDBC == parameter.getInstanceDefinition().getInstanceType()
- ? parameter.getSchemaConfigs().keySet() : metaDataPersistService.getSchemaMetaDataService().loadAllNames();
- DatabaseType databaseType = DatabaseTypeFactory.getDatabaseType(parameter.getSchemaConfigs(), new ConfigurationProperties(parameter.getProps()));
+ ? parameter.getDatabaseConfigs().keySet() : metaDataPersistService.getSchemaMetaDataService().loadAllNames();
+ DatabaseType databaseType = DatabaseTypeFactory.getDatabaseType(parameter.getDatabaseConfigs(), new ConfigurationProperties(parameter.getProps()));
for (String each : schemaNames) {
if (databaseType.getSystemSchemas().contains(each)) {
continue;
@@ -86,7 +86,7 @@ public final class StandaloneContextManagerBuilder implements ContextManagerBuil
private SchemaConfiguration createSchemaConfiguration(final String schemaName, final MetaDataPersistService metaDataPersistService,
final ContextManagerBuilderParameter parameter) {
- Map<String, DataSource> dataSources = metaDataPersistService.getEffectiveDataSources(schemaName, parameter.getSchemaConfigs());
+ Map<String, DataSource> dataSources = metaDataPersistService.getEffectiveDataSources(schemaName, parameter.getDatabaseConfigs());
Collection<RuleConfiguration> schemaRuleConfigs = metaDataPersistService.getSchemaRuleService().load(schemaName);
return new DataSourceProvidedSchemaConfiguration(dataSources, schemaRuleConfigs);
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilderTextTest.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilderTextTest.java
index f3e5139bd2e..1ad28f2788d 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilderTextTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilderTextTest.java
@@ -43,7 +43,7 @@ public final class StandaloneContextManagerBuilderTextTest {
@Test
public void assertBuild() throws SQLException {
ContextManager actual = new StandaloneContextManagerBuilder().build(ContextManagerBuilderParameter.builder().modeConfig(new ModeConfiguration("Standalone", null, false))
- .schemaConfigs(Collections.singletonMap("foo_schema",
+ .databaseConfigs(Collections.singletonMap("foo_schema",
new DataSourceProvidedSchemaConfiguration(Collections.singletonMap("foo_ds", new MockedDataSource()), Collections.singleton(mock(RuleConfiguration.class)))))
.globalRuleConfigs(Collections.singleton(mock(RuleConfiguration.class))).props(new Properties())
.instanceDefinition(new InstanceDefinition(InstanceType.PROXY, 3307)).build());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfiguration.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfiguration.java
index 4d26fbc1c96..fff29fdda99 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfiguration.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfiguration.java
@@ -30,7 +30,7 @@ import java.util.Map;
@Getter
public final class ProxyConfiguration {
- private final Map<String, DataSourceGeneratedSchemaConfiguration> schemaConfigurations;
+ private final Map<String, DataSourceGeneratedSchemaConfiguration> databaseConfigurations;
private final ProxyGlobalConfiguration globalConfiguration;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java
index a812d10fe16..8dcebc3637a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java
@@ -24,7 +24,7 @@ import lombok.SneakyThrows;
import org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRuleConfiguration;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxySchemaConfiguration;
+import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyServerConfiguration;
import java.io.File;
@@ -59,9 +59,9 @@ public final class ProxyConfigurationLoader {
public static YamlProxyConfiguration load(final String path) throws IOException {
YamlProxyServerConfiguration serverConfig = loadServerConfiguration(getResourceFile(String.join("/", path, SERVER_CONFIG_FILE)));
File configPath = getResourceFile(path);
- Collection<YamlProxySchemaConfiguration> schemaConfigs = loadSchemaConfigurations(configPath);
- return new YamlProxyConfiguration(serverConfig, schemaConfigs.stream().collect(Collectors.toMap(
- YamlProxySchemaConfiguration::getSchemaName, each -> each, (oldValue, currentValue) -> oldValue, LinkedHashMap::new)));
+ Collection<YamlProxyDatabaseConfiguration> databaseConfigs = loadDatabaseConfigurations(configPath);
+ return new YamlProxyConfiguration(serverConfig, databaseConfigs.stream().collect(Collectors.toMap(
+ YamlProxyDatabaseConfiguration::getDatabaseName, each -> each, (oldValue, currentValue) -> oldValue, LinkedHashMap::new)));
}
@SneakyThrows(URISyntaxException.class)
@@ -80,25 +80,28 @@ public final class ProxyConfigurationLoader {
return result;
}
- private static Collection<YamlProxySchemaConfiguration> loadSchemaConfigurations(final File configPath) throws IOException {
- Collection<String> loadedSchemaNames = new HashSet<>();
- Collection<YamlProxySchemaConfiguration> result = new LinkedList<>();
+ private static Collection<YamlProxyDatabaseConfiguration> loadDatabaseConfigurations(final File configPath) throws IOException {
+ Collection<String> loadedDatabaseNames = new HashSet<>();
+ Collection<YamlProxyDatabaseConfiguration> result = new LinkedList<>();
for (File each : findRuleConfigurationFiles(configPath)) {
- loadSchemaConfiguration(each).ifPresent(yamlProxyRuleConfig -> {
+ loadDatabaseConfiguration(each).ifPresent(yamlProxyRuleConfig -> {
Preconditions.checkState(
- loadedSchemaNames.add(yamlProxyRuleConfig.getSchemaName()), "Schema name `%s` must unique at all schema configurations.", yamlProxyRuleConfig.getSchemaName());
+ loadedDatabaseNames.add(yamlProxyRuleConfig.getDatabaseName()), "Database name `%s` must unique at all database configurations.", yamlProxyRuleConfig.getDatabaseName());
result.add(yamlProxyRuleConfig);
});
}
return result;
}
- private static Optional<YamlProxySchemaConfiguration> loadSchemaConfiguration(final File yamlFile) throws IOException {
- YamlProxySchemaConfiguration result = YamlEngine.unmarshal(yamlFile, YamlProxySchemaConfiguration.class);
+ private static Optional<YamlProxyDatabaseConfiguration> loadDatabaseConfiguration(final File yamlFile) throws IOException {
+ YamlProxyDatabaseConfiguration result = YamlEngine.unmarshal(yamlFile, YamlProxyDatabaseConfiguration.class);
if (null == result) {
return Optional.empty();
}
- Preconditions.checkNotNull(result.getSchemaName(), "Property `schemaName` in file `%s` is required.", yamlFile.getName());
+ if (null == result.getDatabaseName()) {
+ result.setDatabaseName(result.getSchemaName());
+ }
+ Preconditions.checkNotNull(result.getDatabaseName(), "Property `databaseName` in file `%s` is required.", yamlFile.getName());
Preconditions.checkState(!result.getDataSources().isEmpty(), "Data sources configuration in file `%s` is required.", yamlFile.getName());
return Optional.of(result);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/YamlProxyConfiguration.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/YamlProxyConfiguration.java
index d2ec1cfa058..8ab671b2b76 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/YamlProxyConfiguration.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/YamlProxyConfiguration.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxySchemaConfiguration;
+import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyServerConfiguration;
import java.util.Map;
@@ -33,5 +33,5 @@ public final class YamlProxyConfiguration {
private final YamlProxyServerConfiguration serverConfiguration;
- private final Map<String, YamlProxySchemaConfiguration> schemaConfigurations;
+ private final Map<String, YamlProxyDatabaseConfiguration> databaseConfigurations;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxySchemaConfiguration.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfiguration.java
similarity index 88%
rename from shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxySchemaConfiguration.java
rename to shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfiguration.java
index 1835cdef67d..00db2eb9fed 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxySchemaConfiguration.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfiguration.java
@@ -28,11 +28,13 @@ import java.util.LinkedList;
import java.util.Map;
/**
- * YAML schema configuration for ShardingSphere-Proxy.
+ * YAML database configuration for ShardingSphere-Proxy.
*/
@Getter
@Setter
-public final class YamlProxySchemaConfiguration implements YamlConfiguration {
+public final class YamlProxyDatabaseConfiguration implements YamlConfiguration {
+
+ private String databaseName;
private String schemaName;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyConfigurationSwapper.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyConfigurationSwapper.java
index af9036b83da..7fcbf212447 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyConfigurationSwapper.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyConfigurationSwapper.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.proxy.backend.config.ProxyConfiguration;
import org.apache.shardingsphere.proxy.backend.config.ProxyGlobalConfiguration;
import org.apache.shardingsphere.proxy.backend.config.YamlProxyConfiguration;
import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDataSourceConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxySchemaConfiguration;
+import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
import java.util.Collection;
import java.util.LinkedHashMap;
@@ -48,29 +48,30 @@ public final class YamlProxyConfigurationSwapper {
* @return proxy configuration
*/
public ProxyConfiguration swap(final YamlProxyConfiguration yamlConfig) {
- Map<String, DataSourceGeneratedSchemaConfiguration> schemaConfigs = swapSchemaConfigurations(yamlConfig);
+ Map<String, DataSourceGeneratedSchemaConfiguration> databaseConfigs = swapDatabaseConfigurations(yamlConfig);
ProxyGlobalConfiguration globalConfig = new ProxyGlobalConfiguration(ruleConfigSwapperEngine.swapToRuleConfigurations(yamlConfig.getServerConfiguration().getRules()),
yamlConfig.getServerConfiguration().getProps(), yamlConfig.getServerConfiguration().getLabels());
- return new ProxyConfiguration(schemaConfigs, globalConfig);
+ return new ProxyConfiguration(databaseConfigs, globalConfig);
}
- private Map<String, DataSourceGeneratedSchemaConfiguration> swapSchemaConfigurations(final YamlProxyConfiguration yamlConfig) {
- Map<String, DataSourceGeneratedSchemaConfiguration> result = new LinkedHashMap<>(yamlConfig.getSchemaConfigurations().size(), 1);
+ private Map<String, DataSourceGeneratedSchemaConfiguration> swapDatabaseConfigurations(final YamlProxyConfiguration yamlConfig) {
+ Map<String, DataSourceGeneratedSchemaConfiguration> result = new LinkedHashMap<>(yamlConfig.getDatabaseConfigurations().size(), 1);
boolean isDataSourceAggregation = yamlConfig.getServerConfiguration().getProps().containsKey("data-source-aggregation-enabled")
&& (boolean) yamlConfig.getServerConfiguration().getProps().get("data-source-aggregation-enabled");
- for (Entry<String, YamlProxySchemaConfiguration> entry : yamlConfig.getSchemaConfigurations().entrySet()) {
- Map<String, DataSourceConfiguration> schemaDataSourceConfigs = swapDataSourceConfigurations(entry.getValue().getDataSources(), entry.getValue().getSchemaName(), isDataSourceAggregation);
- Collection<RuleConfiguration> schemaRuleConfigs = ruleConfigSwapperEngine.swapToRuleConfigurations(entry.getValue().getRules());
- result.put(entry.getKey(), new DataSourceGeneratedSchemaConfiguration(schemaDataSourceConfigs, schemaRuleConfigs));
+ for (Entry<String, YamlProxyDatabaseConfiguration> entry : yamlConfig.getDatabaseConfigurations().entrySet()) {
+ Map<String, DataSourceConfiguration> databaseDataSourceConfigs
+ = swapDataSourceConfigurations(entry.getValue().getDataSources(), entry.getValue().getDatabaseName(), isDataSourceAggregation);
+ Collection<RuleConfiguration> databaseRuleConfigs = ruleConfigSwapperEngine.swapToRuleConfigurations(entry.getValue().getRules());
+ result.put(entry.getKey(), new DataSourceGeneratedSchemaConfiguration(databaseDataSourceConfigs, databaseRuleConfigs));
}
return result;
}
- private Map<String, DataSourceConfiguration> swapDataSourceConfigurations(final Map<String, YamlProxyDataSourceConfiguration> yamlConfigs, final String schemaName,
+ private Map<String, DataSourceConfiguration> swapDataSourceConfigurations(final Map<String, YamlProxyDataSourceConfiguration> yamlConfigs, final String databaseName,
final boolean isDataSourceAggregation) {
Map<String, DataSourceConfiguration> result = new LinkedHashMap<>(yamlConfigs.size(), 1);
for (Entry<String, YamlProxyDataSourceConfiguration> entry : yamlConfigs.entrySet()) {
- result.put(entry.getKey(), dataSourceConfigSwapper.swap(entry.getValue(), schemaName, entry.getKey(), isDataSourceAggregation));
+ result.put(entry.getKey(), dataSourceConfigSwapper.swap(entry.getValue(), databaseName, entry.getKey(), isDataSourceAggregation));
}
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapper.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapper.java
index aa95e212b59..39ef7efd334 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapper.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapper.java
@@ -33,14 +33,14 @@ public final class YamlProxyDataSourceConfigurationSwapper {
* Swap YAML proxy data source configuration to data source configuration.
*
* @param yamlConfig YAML proxy data source configuration
- * @param schemaName Schema name
- * @param dataSourceName Data source name
+ * @param databaseName database name
+ * @param dataSourceName data source name
* @param isDataSourceAggregation is data source aggregation
* @return data source configuration
*/
- public DataSourceConfiguration swap(final YamlProxyDataSourceConfiguration yamlConfig, final String schemaName, final String dataSourceName, final boolean isDataSourceAggregation) {
+ public DataSourceConfiguration swap(final YamlProxyDataSourceConfiguration yamlConfig, final String databaseName, final String dataSourceName, final boolean isDataSourceAggregation) {
if (isDataSourceAggregation) {
- setGlobalDataSourceSchema(schemaName, dataSourceName, yamlConfig.getUrl());
+ setGlobalDataSourceSchema(databaseName, dataSourceName, yamlConfig.getUrl());
}
return new DataSourceConfiguration(swapConnectionConfiguration(yamlConfig), swapPoolConfiguration(yamlConfig));
}
@@ -54,8 +54,8 @@ public final class YamlProxyDataSourceConfigurationSwapper {
yamlConfig.getMaxLifetimeMilliseconds(), yamlConfig.getMaxPoolSize(), yamlConfig.getMinPoolSize(), yamlConfig.getReadOnly(), yamlConfig.getCustomPoolProps());
}
- private void setGlobalDataSourceSchema(final String schemaName, final String dataSourceName, final String jdbcUrl) {
- String key = schemaName + "." + dataSourceName;
+ private void setGlobalDataSourceSchema(final String databaseName, final String dataSourceName, final String jdbcUrl) {
+ String key = databaseName + "." + dataSourceName;
StandardJdbcUrlParser jdbcUrlParser = new StandardJdbcUrlParser();
String value = jdbcUrlParser.parse(jdbcUrl).getDatabase();
GlobalDataSourceRegistry.getInstance().getDataSourceSchema().put(key, value);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportSchemaConfigurationHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportSchemaConfigurationHandler.java
index 3a2a541f1b7..7c77b69f5e9 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportSchemaConfigurationHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportSchemaConfigurationHandler.java
@@ -43,7 +43,7 @@ import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDataSourceConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxySchemaConfiguration;
+import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
import org.apache.shardingsphere.proxy.backend.config.yaml.swapper.YamlProxyDataSourceConfigurationSwapper;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.UpdatableRALBackendHandler;
@@ -144,9 +144,9 @@ public final class ImportSchemaConfigurationHandler extends UpdatableRALBackendH
metaDataPersistService.ifPresent(op -> op.getSchemaRuleService().persist(schemaName, toBeUpdatedRuleConfigs));
}
- private void checkSchemaName(final String schemaName) {
- if (!ProxyContext.getInstance().getAllSchemaNames().contains(schemaName)) {
- throw new SchemaNotExistedException(schemaName);
+ private void checkDatabaseName(final String databaseName) {
+ if (!ProxyContext.getInstance().getAllSchemaNames().contains(databaseName)) {
+ throw new SchemaNotExistedException(databaseName);
}
}
@@ -156,20 +156,20 @@ public final class ImportSchemaConfigurationHandler extends UpdatableRALBackendH
return;
}
File yamlFile = new File(sqlStatement.getFilePath().get());
- YamlProxySchemaConfiguration yamlConfig;
+ YamlProxyDatabaseConfiguration yamlConfig;
try {
- yamlConfig = YamlEngine.unmarshal(yamlFile, YamlProxySchemaConfiguration.class);
+ yamlConfig = YamlEngine.unmarshal(yamlFile, YamlProxyDatabaseConfiguration.class);
if (null == yamlConfig) {
return;
}
} catch (final IOException ex) {
throw new ShardingSphereException(ex);
}
- String schemaName = yamlConfig.getSchemaName();
- DistSQLException.predictionThrow(!Strings.isNullOrEmpty(schemaName), () -> new ImportSchemaNotExistedException(yamlFile.getName()));
- checkSchemaName(schemaName);
+ String databaseName = yamlConfig.getDatabaseName();
+ DistSQLException.predictionThrow(!Strings.isNullOrEmpty(databaseName), () -> new ImportSchemaNotExistedException(yamlFile.getName()));
+ checkDatabaseName(databaseName);
DistSQLException.predictionThrow(null != yamlConfig.getDataSources() && !yamlConfig.getDataSources().isEmpty(), () -> new ImportResourceNotExistedException(yamlFile.getName()));
- alterResourcesConfig(schemaName, yamlConfig.getDataSources());
- alterRulesConfig(schemaName, yamlConfig.getRules());
+ alterResourcesConfig(databaseName, yamlConfig.getDataSources());
+ alterRulesConfig(databaseName, yamlConfig.getRules());
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoaderTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoaderTest.java
index c2a2109198d..072fc4ef76b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoaderTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoaderTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptRuleConfiguratio
import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDataSourceConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxySchemaConfiguration;
+import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
import org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceRuleConfiguration;
import org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
@@ -47,14 +47,14 @@ public final class ProxyConfigurationLoaderTest {
// TODO assert mode
// TODO assert authority rule
actualGlobalRules.next();
- assertThat(actual.getSchemaConfigurations().size(), is(3));
- assertShardingRuleConfiguration(actual.getSchemaConfigurations().get("sharding_db"));
- assertReadwriteSplittingRuleConfiguration(actual.getSchemaConfigurations().get("readwrite_splitting_db"));
- assertEncryptRuleConfiguration(actual.getSchemaConfigurations().get("encrypt_db"));
+ assertThat(actual.getDatabaseConfigurations().size(), is(3));
+ assertShardingRuleConfiguration(actual.getDatabaseConfigurations().get("sharding_db"));
+ assertReadwriteSplittingRuleConfiguration(actual.getDatabaseConfigurations().get("readwrite_splitting_db"));
+ assertEncryptRuleConfiguration(actual.getDatabaseConfigurations().get("encrypt_db"));
}
- private void assertShardingRuleConfiguration(final YamlProxySchemaConfiguration actual) {
- assertThat(actual.getSchemaName(), is("sharding_db"));
+ private void assertShardingRuleConfiguration(final YamlProxyDatabaseConfiguration actual) {
+ assertThat(actual.getDatabaseName(), is("sharding_db"));
assertThat(actual.getDataSources().size(), is(2));
assertDataSourceConfiguration(actual.getDataSources().get("ds_0"), "jdbc:mysql://127.0.0.1:3306/ds_0");
assertDataSourceConfiguration(actual.getDataSources().get("ds_1"), "jdbc:mysql://127.0.0.1:3306/ds_1");
@@ -76,8 +76,8 @@ public final class ProxyConfigurationLoaderTest {
assertNotNull(actual.getDefaultDatabaseStrategy().getNone());
}
- private void assertReadwriteSplittingRuleConfiguration(final YamlProxySchemaConfiguration actual) {
- assertThat(actual.getSchemaName(), is("readwrite_splitting_db"));
+ private void assertReadwriteSplittingRuleConfiguration(final YamlProxyDatabaseConfiguration actual) {
+ assertThat(actual.getDatabaseName(), is("readwrite_splitting_db"));
assertThat(actual.getDataSources().size(), is(3));
assertDataSourceConfiguration(actual.getDataSources().get("write_ds"), "jdbc:mysql://127.0.0.1:3306/write_ds");
assertDataSourceConfiguration(actual.getDataSources().get("read_ds_0"), "jdbc:mysql://127.0.0.1:3306/read_ds_0");
@@ -100,8 +100,8 @@ public final class ProxyConfigurationLoaderTest {
assertThat(actual.getProps().get("read-data-source-names"), is("read_ds_0,read_ds_1"));
}
- private void assertEncryptRuleConfiguration(final YamlProxySchemaConfiguration actual) {
- assertThat(actual.getSchemaName(), is("encrypt_db"));
+ private void assertEncryptRuleConfiguration(final YamlProxyDatabaseConfiguration actual) {
+ assertThat(actual.getDatabaseName(), is("encrypt_db"));
assertThat(actual.getDataSources().size(), is(1));
assertDataSourceConfiguration(actual.getDataSources().get("ds_0"), "jdbc:mysql://127.0.0.1:3306/encrypt_ds");
assertFalse(actual.getRules().stream().filter(
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java
index eddeac0fa62..a1d42aefa98 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java
@@ -56,7 +56,7 @@ public final class YamlProxyConfigurationSwapperTest {
}
private void assertSchemaDataSources(final ProxyConfiguration proxyConfig) {
- Map<String, DataSourceGeneratedSchemaConfiguration> actual = proxyConfig.getSchemaConfigurations();
+ Map<String, DataSourceGeneratedSchemaConfiguration> actual = proxyConfig.getDatabaseConfigurations();
assertThat(actual.size(), is(1));
HikariDataSource dataSource = (HikariDataSource) actual.get("swapper_test").getDataSources().get("foo_db");
assertThat(dataSource.getJdbcUrl(), is("jdbc:h2:mem:foo_db;DB_CLOSE_DELAY=-1"));
@@ -71,7 +71,7 @@ public final class YamlProxyConfigurationSwapperTest {
}
private void assertSchemaRules(final ProxyConfiguration proxyConfig) {
- Map<String, DataSourceGeneratedSchemaConfiguration> actual = proxyConfig.getSchemaConfigurations();
+ Map<String, DataSourceGeneratedSchemaConfiguration> actual = proxyConfig.getDatabaseConfigurations();
assertThat(actual.size(), is(1));
Collection<RuleConfiguration> ruleConfigs = actual.get("swapper_test").getRuleConfigurations();
assertThat(ruleConfigs.size(), is(1));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapperTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapperTest.java
index ebef95b6d29..b54fd2a6db1 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapperTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapperTest.java
@@ -37,7 +37,7 @@ public final class YamlProxyDataSourceConfigurationSwapperTest {
@Test
public void assertSwap() throws IOException {
YamlProxyConfiguration yamlProxyConfig = ProxyConfigurationLoader.load("/conf/swap");
- YamlProxyDataSourceConfiguration yamlProxyDataSourceConfig = yamlProxyConfig.getSchemaConfigurations().get("swapper_test").getDataSources().get("foo_db");
+ YamlProxyDataSourceConfiguration yamlProxyDataSourceConfig = yamlProxyConfig.getDatabaseConfigurations().get("swapper_test").getDataSources().get("foo_db");
DataSourceConfiguration actualDataSourceConfig = new YamlProxyDataSourceConfigurationSwapper().swap(yamlProxyDataSourceConfig, "swapper_test", "foo_db", false);
assertConnectionConfig(actualDataSourceConfig);
assertPoolConfig(actualDataSourceConfig);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/config_loader/config-encrypt.yaml b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/config_loader/config-encrypt.yaml
index 4e63a0348ca..5308fa766ca 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/config_loader/config-encrypt.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/config_loader/config-encrypt.yaml
@@ -15,7 +15,7 @@
# limitations under the License.
#
-schemaName: encrypt_db
+databaseName: encrypt_db
dataSources:
ds_0:
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/config_loader/config-readwrite-splitting.yaml b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/config_loader/config-readwrite-splitting.yaml
index 20f93618552..0f69e48f079 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/config_loader/config-readwrite-splitting.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/config_loader/config-readwrite-splitting.yaml
@@ -15,7 +15,7 @@
# limitations under the License.
#
-schemaName: readwrite_splitting_db
+databaseName: readwrite_splitting_db
dataSources:
write_ds:
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/config_loader/config-sharding.yaml b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/config_loader/config-sharding.yaml
index 3c190391cde..af3d6200e2c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/config_loader/config-sharding.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/config_loader/config-sharding.yaml
@@ -15,7 +15,7 @@
# limitations under the License.
#
-schemaName: sharding_db
+databaseName: sharding_db
dataSources:
ds_0:
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/import/config-database-discovery.yaml b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/import/config-database-discovery.yaml
index 5ccdaeb60a9..befecf2a4c3 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/import/config-database-discovery.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/import/config-database-discovery.yaml
@@ -15,7 +15,7 @@
# limitations under the License.
#
-schemaName: database_discovery_db
+databaseName: database_discovery_db
dataSources:
ds_0:
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/import/config-readwrite-splitting.yaml b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/import/config-readwrite-splitting.yaml
index 297c5e295f4..1066ac7555b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/import/config-readwrite-splitting.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/import/config-readwrite-splitting.yaml
@@ -15,7 +15,7 @@
# limitations under the License.
#
-schemaName: readwrite_splitting_db
+databaseName: readwrite_splitting_db
dataSources:
write_ds:
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/import/config-sharding.yaml b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/import/config-sharding.yaml
index 95940028cf6..a3c786f5dee 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/import/config-sharding.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/import/config-sharding.yaml
@@ -15,7 +15,7 @@
# limitations under the License.
#
-schemaName: sharding_db
+databaseName: sharding_db
dataSources:
ds_1:
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/swap/config-readwrite-splitting.yaml b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/swap/config-readwrite-splitting.yaml
index 4cf089050d1..5fbf8949e33 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/swap/config-readwrite-splitting.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/swap/config-readwrite-splitting.yaml
@@ -15,7 +15,7 @@
# limitations under the License.
#
-schemaName: swapper_test
+databaseName: swapper_test
dataSources:
foo_db:
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
index 28233691ff5..6d87e2176af 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
@@ -67,7 +67,7 @@ public final class BootstrapInitializer {
ProxyConfiguration proxyConfig = new YamlProxyConfigurationSwapper().swap(yamlConfig);
ContextManagerBuilderParameter parameter = ContextManagerBuilderParameter.builder()
.modeConfig(modeConfig)
- .schemaConfigs(proxyConfig.getSchemaConfigurations())
+ .databaseConfigs(proxyConfig.getDatabaseConfigurations())
.globalRuleConfigs(proxyConfig.getGlobalConfiguration().getRules())
.props(proxyConfig.getGlobalConfiguration().getProperties())
.labels(proxyConfig.getGlobalConfiguration().getLabels())
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 0bfd37437e2..bd72b6b884a 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
@@ -22,7 +22,7 @@
#
######################################################################################################
#
-#schemaName: database_discovery_db
+#databaseName: database_discovery_db
#
#dataSources:
# ds_0:
@@ -79,7 +79,7 @@
#
######################################################################################################
-#schemaName: database_discovery_db
+#databaseName: database_discovery_db
#
#dataSources:
# ds_0:
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-encrypt.yaml b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-encrypt.yaml
index 6c27d75fd29..9a01035355e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-encrypt.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-encrypt.yaml
@@ -22,7 +22,7 @@
#
######################################################################################################
#
-#schemaName: encrypt_db
+#databaseName: encrypt_db
#
#dataSources:
# ds_0:
@@ -70,7 +70,7 @@
#
######################################################################################################
#
-#schemaName: encrypt_db
+#databaseName: encrypt_db
#
#dataSources:
# ds_0:
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-readwrite-splitting.yaml b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-readwrite-splitting.yaml
index c6903db7e9a..5aaaae5f2f5 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-readwrite-splitting.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-readwrite-splitting.yaml
@@ -22,7 +22,7 @@
#
######################################################################################################
#
-#schemaName: readwrite_splitting_db
+#databaseName: readwrite_splitting_db
#
#dataSources:
# primary_ds:
@@ -68,7 +68,7 @@
#
######################################################################################################
-#schemaName: readwrite_splitting_db
+#databaseName: readwrite_splitting_db
#
#dataSources:
# write_ds:
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-shadow.yaml b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-shadow.yaml
index 9e8bf9a1fc0..aa8941d8d9c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-shadow.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-shadow.yaml
@@ -22,7 +22,7 @@
#
######################################################################################################
#
-#schemaName: shadow_db
+#databaseName: shadow_db
#
#dataSources:
# ds:
@@ -101,7 +101,7 @@
#
######################################################################################################
#
-#schemaName: shadow_db
+#databaseName: shadow_db
#
#dataSources:
# ds:
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-sharding.yaml b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-sharding.yaml
index d77bc17a35e..1c0abc52e87 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-sharding.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-sharding.yaml
@@ -22,7 +22,7 @@
#
######################################################################################################
#
-#schemaName: sharding_db
+#databaseName: sharding_db
#
#dataSources:
# ds_0:
@@ -120,7 +120,7 @@
#
######################################################################################################
-#schemaName: sharding_db
+#databaseName: sharding_db
#
#dataSources:
# ds_0: