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 2021/05/10 07:09:27 UTC
[shardingsphere] branch master updated: Move the user configuration
to authority rule (#10287)
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 55b219a Move the user configuration to authority rule (#10287)
55b219a is described below
commit 55b219a9a2d337be454f71f45951b6a87974c727
Author: Zhu jun <zh...@163.com>
AuthorDate: Mon May 10 15:08:46 2021 +0800
Move the user configuration to authority rule (#10287)
* move the user configuration to authority rule
* adapter config
* adapter config
* fix test
* fix test
* fix yaml
---
.../sharding-proxy/sharding/conf/server.yaml | 8 +++++--
.../src/main/resources/conf/server.yaml | 10 ++++++---
.../src/main/resources/conf/server.yaml | 8 +++++--
.../metadata/GovernanceMetaDataContexts.java | 6 ++---
.../governance/core/facade/GovernanceFacade.java | 6 ++---
.../governance/core/registry/RegistryCenter.java | 10 +--------
.../core/facade/GovernanceFacadeTest.java | 6 ++---
.../core/registry/RegistryCenterTest.java | 3 +--
.../api/config/AuthorityRuleConfiguration.java | 7 +++++-
.../rule/builder/AuthorityRuleBuilder.java | 6 ++---
.../DefaultAuthorityRuleConfigurationBuilder.java | 3 ++-
.../config/YamlAuthorityRuleConfiguration.java | 7 +++++-
.../AuthorityRuleConfigurationYamlSwapper.java | 8 ++++++-
.../rule/builder/ShardingSphereRulesBuilder.java | 6 ++---
.../rule/builder/scope/GlobalRuleBuilder.java | 5 +----
.../shardingsphere-infra-context/pom.xml | 5 +++++
.../context/metadata/MetaDataContextsBuilder.java | 25 ++++++++++++++-------
.../metadata/MetaDataContextsBuilderTest.java | 20 +++++++++++++++++
.../GovernanceShardingSphereDataSource.java | 2 +-
.../impl/AbstractBootstrapInitializer.java | 2 +-
.../impl/GovernanceBootstrapInitializer.java | 7 +++---
.../impl/GovernanceBootstrapInitializerTest.java | 1 -
.../impl/StandardBootstrapInitializerTest.java | 26 ++++++++++++++++++----
.../src/test/resources/conf/local/server.yaml | 10 ++++++---
.../src/test/resources/conf/reg_center/server.yaml | 8 +++++++
.../proxy/config/ProxyConfiguration.java | 3 ---
.../proxy/config/ProxyConfigurationLoader.java | 5 ++++-
.../config/yaml/YamlProxyServerConfiguration.java | 2 --
.../swapper/YamlProxyConfigurationSwapper.java | 6 ++---
.../swapper/YamlProxyConfigurationSwapperTest.java | 23 +++++++++++++++++--
.../src/test/resources/conf/server.yaml | 8 +++++--
.../test/resources/docker/proxy/conf/server.yaml | 8 +++++--
.../adapter/ShardingSphereAdapterContainer.java | 16 ++++++++++++-
.../integration/engine/it/dql/GeneralDQLIT.java | 4 ++--
.../resources/docker/db/proxy/conf/server.yaml | 8 +++++--
.../proxy/conf/server.yaml | 8 +++++--
.../proxy/conf/server.yaml | 8 +++++--
.../docker/encrypt/proxy/conf/server.yaml | 8 +++++--
.../readwrite_splitting/proxy/conf/server.yaml | 8 +++++--
.../sharding_governance/proxy/conf/server.yaml | 8 +++++--
.../resources/docker/tbl/proxy/conf/server.yaml | 8 +++++--
41 files changed, 236 insertions(+), 100 deletions(-)
diff --git a/examples/docker/sharding-proxy/sharding/conf/server.yaml b/examples/docker/sharding-proxy/sharding/conf/server.yaml
index 8544fab..43afc71 100644
--- a/examples/docker/sharding-proxy/sharding/conf/server.yaml
+++ b/examples/docker/sharding-proxy/sharding/conf/server.yaml
@@ -28,8 +28,12 @@
# serverLists: localhost:2181
# overwrite: false
-users:
- - root@%:root
+rules:
+ - !AUTHORITY
+ users:
+ - root@%:root
+ provider:
+ type: NATIVE
props:
max-connections-size-per-query: 1
diff --git a/examples/shardingsphere-proxy-example/shardingsphere-proxy-boot-mybatis-example/src/main/resources/conf/server.yaml b/examples/shardingsphere-proxy-example/shardingsphere-proxy-boot-mybatis-example/src/main/resources/conf/server.yaml
index f07d391..7d9185c 100644
--- a/examples/shardingsphere-proxy-example/shardingsphere-proxy-boot-mybatis-example/src/main/resources/conf/server.yaml
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-boot-mybatis-example/src/main/resources/conf/server.yaml
@@ -33,9 +33,13 @@
# operationTimeoutMilliseconds: 500
# overwrite: false
-users:
- - root@:root
- - sharding@%:sharding
+rules:
+ - !AUTHORITY
+ users:
+ - root@:root
+ - sharding@:sharding
+ provider:
+ type: NATIVE
props:
max-connections-size-per-query: 1
diff --git a/examples/shardingsphere-proxy-example/shardingsphere-proxy-hint-example/src/main/resources/conf/server.yaml b/examples/shardingsphere-proxy-example/shardingsphere-proxy-hint-example/src/main/resources/conf/server.yaml
index b03947f..5fc4da6 100644
--- a/examples/shardingsphere-proxy-example/shardingsphere-proxy-hint-example/src/main/resources/conf/server.yaml
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-hint-example/src/main/resources/conf/server.yaml
@@ -33,8 +33,12 @@
# operationTimeoutMilliseconds: 500
# overwrite: false
-users:
- - root@:root
+rules:
+ - !AUTHORITY
+ users:
+ - root@:root
+ provider:
+ type: NATIVE
props:
max-connections-size-per-query: 1
diff --git a/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContexts.java b/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContexts.java
index 111686b..859a3c3 100644
--- a/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContexts.java
+++ b/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContexts.java
@@ -334,7 +334,7 @@ public final class GovernanceMetaDataContexts implements MetaDataContexts {
Collections.singletonMap(schemaName, governanceFacade.getRegistryCenter().loadRuleConfigurations(schemaName)),
// TODO load global schema from reg center
new LinkedList<>(),
- metaDataContexts.getUsers().getUsers(), metaDataContexts.getProps().getProps());
+ metaDataContexts.getProps().getProps());
return metaDataContextsBuilder.build().getMetaDataMap().get(schemaName);
}
@@ -366,7 +366,7 @@ public final class GovernanceMetaDataContexts implements MetaDataContexts {
private ShardingSphereMetaData getChangedMetaData(final ShardingSphereMetaData oldMetaData, final Collection<RuleConfiguration> ruleConfigs) throws SQLException {
// TODO load global schema from reg center
MetaDataContextsBuilder builder = new MetaDataContextsBuilder(Collections.singletonMap(oldMetaData.getName(), oldMetaData.getResource().getDataSources()),
- Collections.singletonMap(oldMetaData.getName(), ruleConfigs), new LinkedList<>(), metaDataContexts.getUsers().getUsers(), metaDataContexts.getProps().getProps());
+ Collections.singletonMap(oldMetaData.getName(), ruleConfigs), new LinkedList<>(), metaDataContexts.getProps().getProps());
return builder.build().getMetaDataMap().values().iterator().next();
}
@@ -379,7 +379,7 @@ public final class GovernanceMetaDataContexts implements MetaDataContexts {
getNewDataSources(oldMetaData.getResource().getDataSources(), getAddedDataSources(oldMetaData, newDataSourceConfigs), modifiedDataSources, deletedDataSources));
// TODO load global schema from reg center
return new MetaDataContextsBuilder(dataSourcesMap, Collections.singletonMap(oldMetaData.getName(), oldMetaData.getRuleMetaData().getConfigurations()), new LinkedList<>(),
- metaDataContexts.getUsers().getUsers(), metaDataContexts.getProps().getProps()).build().getMetaDataMap().get(oldMetaData.getName());
+ metaDataContexts.getProps().getProps()).build().getMetaDataMap().get(oldMetaData.getName());
}
private Map<String, DataSource> getNewDataSources(final Map<String, DataSource> oldDataSources,
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/facade/GovernanceFacade.java b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/facade/GovernanceFacade.java
index 3869e2e..9c3b5b0 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/facade/GovernanceFacade.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/facade/GovernanceFacade.java
@@ -24,7 +24,6 @@ import org.apache.shardingsphere.governance.core.registry.listener.GovernanceLis
import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
-import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import java.util.Collection;
import java.util.Map;
@@ -66,12 +65,11 @@ public final class GovernanceFacade implements AutoCloseable {
*
* @param dataSourceConfigMap schema data source configuration map
* @param schemaRuleMap schema rule map
- * @param users users
* @param props properties
*/
public void onlineInstance(final Map<String, Map<String, DataSourceConfiguration>> dataSourceConfigMap,
- final Map<String, Collection<RuleConfiguration>> schemaRuleMap, final Collection<ShardingSphereUser> users, final Properties props) {
- registryCenter.persistGlobalConfiguration(users, props, isOverwrite);
+ final Map<String, Collection<RuleConfiguration>> schemaRuleMap, final Properties props) {
+ registryCenter.persistGlobalConfiguration(props, isOverwrite);
for (Entry<String, Map<String, DataSourceConfiguration>> entry : dataSourceConfigMap.entrySet()) {
registryCenter.persistConfigurations(entry.getKey(), dataSourceConfigMap.get(entry.getKey()), schemaRuleMap.get(entry.getKey()), isOverwrite);
}
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 6345f04..243c9ea 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
@@ -124,12 +124,10 @@ public final class RegistryCenter {
/**
* Persist global configuration.
*
- * @param users user
* @param props properties
* @param isOverwrite is overwrite config center's configuration
*/
- public void persistGlobalConfiguration(final Collection<ShardingSphereUser> users, final Properties props, final boolean isOverwrite) {
- persistUsers(users, isOverwrite);
+ public void persistGlobalConfiguration(final Properties props, final boolean isOverwrite) {
persistProperties(props, isOverwrite);
}
@@ -198,12 +196,6 @@ public final class RegistryCenter {
return result;
}
- private void persistUsers(final Collection<ShardingSphereUser> users, final boolean isOverwrite) {
- if (!users.isEmpty() && (isOverwrite || !hasUsers())) {
- repository.persist(node.getUsersNode(), YamlEngine.marshal(YamlUsersConfigurationConverter.convertYamlUserConfigurations(users)));
- }
- }
-
private void persistNewUsers(final Collection<ShardingSphereUser> users) {
if (!users.isEmpty()) {
Collection<String> yamlUsers = YamlEngine.unmarshal(repository.get(node.getUsersNode()), Collection.class);
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/facade/GovernanceFacadeTest.java b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/facade/GovernanceFacadeTest.java
index 095b5ad..4c2a4f1 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/facade/GovernanceFacadeTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/facade/GovernanceFacadeTest.java
@@ -25,7 +25,6 @@ import org.apache.shardingsphere.governance.repository.api.config.GovernanceCent
import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
-import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -68,11 +67,10 @@ public final class GovernanceFacadeTest {
public void assertOnlineInstanceWithParameters() {
Map<String, DataSourceConfiguration> dataSourceConfigMap = Collections.singletonMap("test_ds", mock(DataSourceConfiguration.class));
Map<String, Collection<RuleConfiguration>> ruleConfigurationMap = Collections.singletonMap("sharding_db", Collections.singletonList(mock(RuleConfiguration.class)));
- ShardingSphereUser user = new ShardingSphereUser("root", "root", "");
Properties props = new Properties();
- governanceFacade.onlineInstance(Collections.singletonMap("sharding_db", dataSourceConfigMap), ruleConfigurationMap, Collections.singleton(user), props);
+ governanceFacade.onlineInstance(Collections.singletonMap("sharding_db", dataSourceConfigMap), ruleConfigurationMap, props);
verify(registryCenter).persistConfigurations("sharding_db", dataSourceConfigMap, ruleConfigurationMap.get("sharding_db"), false);
- verify(registryCenter).persistGlobalConfiguration(Collections.singleton(user), props, false);
+ verify(registryCenter).persistGlobalConfiguration(props, false);
verify(registryCenter).persistInstanceOnline();
verify(registryCenter).persistDataNodes();
verify(listenerManager).initListeners();
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 e0b2b43..ecfe006 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
@@ -39,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.metadata.user.yaml.config.YamlUsersConfigurationConverter;
import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
@@ -318,7 +317,7 @@ public final class RegistryCenterTest {
@Test
public void assertPersistGlobalConfiguration() {
RegistryCenter registryCenter = new RegistryCenter(registryRepository);
- registryCenter.persistGlobalConfiguration(YamlUsersConfigurationConverter.convertShardingSphereUser(YamlEngine.unmarshal(readYAML(USERS_YAML), Collection.class)), createProperties(), true);
+ registryCenter.persistGlobalConfiguration(createProperties(), true);
verify(registryRepository, times(0)).persist("/users", readYAML(USERS_YAML));
verify(registryRepository).persist("/props", PROPS_YAML);
}
diff --git a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-api/src/main/java/org/apache/shardingsphere/authority/api/config/AuthorityRuleConfiguration.java b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-api/src/main/java/org/apache/shardingsphere/authority/api/config/AuthorityRuleConfiguration.java
index 3297762..f6d5d6a 100644
--- a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-api/src/main/java/org/apache/shardingsphere/authority/api/config/AuthorityRuleConfiguration.java
+++ b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-api/src/main/java/org/apache/shardingsphere/authority/api/config/AuthorityRuleConfiguration.java
@@ -21,6 +21,9 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
+
+import java.util.Collection;
/**
* Authority rule configuration.
@@ -28,6 +31,8 @@ import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmC
@RequiredArgsConstructor
@Getter
public final class AuthorityRuleConfiguration implements RuleConfiguration {
-
+
+ private final Collection<ShardingSphereUser> users;
+
private final ShardingSphereAlgorithmConfiguration provider;
}
diff --git a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java
index 2c19a8f..8225db3 100644
--- a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java
@@ -21,11 +21,9 @@ import org.apache.shardingsphere.authority.api.config.AuthorityRuleConfiguration
import org.apache.shardingsphere.authority.constant.AuthorityOrder;
import org.apache.shardingsphere.authority.rule.AuthorityRule;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.rule.builder.level.KernelRuleBuilder;
import org.apache.shardingsphere.infra.rule.builder.scope.GlobalRuleBuilder;
-import java.util.Collection;
import java.util.Map;
/**
@@ -34,8 +32,8 @@ import java.util.Map;
public final class AuthorityRuleBuilder implements KernelRuleBuilder, GlobalRuleBuilder<AuthorityRule, AuthorityRuleConfiguration> {
@Override
- public AuthorityRule build(final AuthorityRuleConfiguration ruleConfig, final Map<String, ShardingSphereMetaData> mataDataMap, final Collection<ShardingSphereUser> users) {
- return new AuthorityRule(ruleConfig, mataDataMap, users);
+ public AuthorityRule build(final AuthorityRuleConfiguration ruleConfig, final Map<String, ShardingSphereMetaData> mataDataMap) {
+ return new AuthorityRule(ruleConfig, mataDataMap, ruleConfig.getUsers());
}
@Override
diff --git a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/DefaultAuthorityRuleConfigurationBuilder.java b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/DefaultAuthorityRuleConfigurationBuilder.java
index 3e4d1d5..eec4b1c 100644
--- a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/DefaultAuthorityRuleConfigurationBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/DefaultAuthorityRuleConfigurationBuilder.java
@@ -22,6 +22,7 @@ import org.apache.shardingsphere.authority.constant.AuthorityOrder;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.rule.builder.level.DefaultKernelRuleConfigurationBuilder;
+import java.util.Collections;
import java.util.Properties;
/**
@@ -31,7 +32,7 @@ public final class DefaultAuthorityRuleConfigurationBuilder implements DefaultKe
@Override
public AuthorityRuleConfiguration build() {
- return new AuthorityRuleConfiguration(new ShardingSphereAlgorithmConfiguration("NATIVE", new Properties()));
+ return new AuthorityRuleConfiguration(Collections.emptyList(), new ShardingSphereAlgorithmConfiguration("NATIVE", new Properties()));
}
@Override
diff --git a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/yaml/config/YamlAuthorityRuleConfiguration.java b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/yaml/config/YamlAuthorityRuleConfiguration.java
index 7c1c623..6d9ba6c 100644
--- a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/yaml/config/YamlAuthorityRuleConfiguration.java
+++ b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/yaml/config/YamlAuthorityRuleConfiguration.java
@@ -23,13 +23,18 @@ import org.apache.shardingsphere.authority.api.config.AuthorityRuleConfiguration
import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.algorithm.YamlShardingSphereAlgorithmConfiguration;
+import java.util.Collection;
+import java.util.LinkedList;
+
/**
* Authority rule configuration for YAML.
*/
@Getter
@Setter
public final class YamlAuthorityRuleConfiguration implements YamlRuleConfiguration {
-
+
+ private Collection<String> users = new LinkedList<>();
+
private YamlShardingSphereAlgorithmConfiguration provider;
@Override
diff --git a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/AuthorityRuleConfigurationYamlSwapper.java b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/AuthorityRuleConfigurationYamlSwapper.java
index 9bded9a..d718a25 100644
--- a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/AuthorityRuleConfigurationYamlSwapper.java
+++ b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/AuthorityRuleConfigurationYamlSwapper.java
@@ -20,9 +20,13 @@ package org.apache.shardingsphere.authority.yaml.swapper;
import org.apache.shardingsphere.authority.api.config.AuthorityRuleConfiguration;
import org.apache.shardingsphere.authority.constant.AuthorityOrder;
import org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
+import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
+import org.apache.shardingsphere.infra.metadata.user.yaml.config.YamlUsersConfigurationConverter;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapper;
import org.apache.shardingsphere.infra.yaml.swapper.algorithm.ShardingSphereAlgorithmConfigurationYamlSwapper;
+import java.util.Collection;
+
/**
* Authority rule configuration YAML swapper.
*/
@@ -34,12 +38,14 @@ public final class AuthorityRuleConfigurationYamlSwapper implements YamlRuleConf
public YamlAuthorityRuleConfiguration swapToYamlConfiguration(final AuthorityRuleConfiguration data) {
YamlAuthorityRuleConfiguration result = new YamlAuthorityRuleConfiguration();
result.setProvider(algorithmSwapper.swapToYamlConfiguration(data.getProvider()));
+ result.setUsers(YamlUsersConfigurationConverter.convertYamlUserConfigurations(data.getUsers()));
return result;
}
@Override
public AuthorityRuleConfiguration swapToObject(final YamlAuthorityRuleConfiguration yamlConfig) {
- return new AuthorityRuleConfiguration(algorithmSwapper.swapToObject(yamlConfig.getProvider()));
+ Collection<ShardingSphereUser> users = YamlUsersConfigurationConverter.convertShardingSphereUser(yamlConfig.getUsers());
+ return new AuthorityRuleConfiguration(users, algorithmSwapper.swapToObject(yamlConfig.getProvider()));
}
@Override
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/ShardingSphereRulesBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/ShardingSphereRulesBuilder.java
index d6052dd..fa5af12 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/ShardingSphereRulesBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/ShardingSphereRulesBuilder.java
@@ -22,7 +22,6 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.builder.level.DefaultKernelRuleConfigurationBuilder;
import org.apache.shardingsphere.infra.rule.builder.level.KernelRuleBuilder;
@@ -89,17 +88,16 @@ public final class ShardingSphereRulesBuilder {
*
* @param globalRuleConfigurations global rule configurations
* @param mataDataMap mata data map
- * @param users users
* @return built global rules
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public static Collection<ShardingSphereRule> buildGlobalRules(final Collection<RuleConfiguration> globalRuleConfigurations,
- final Map<String, ShardingSphereMetaData> mataDataMap, final Collection<ShardingSphereUser> users) {
+ final Map<String, ShardingSphereMetaData> mataDataMap) {
Map<RuleConfiguration, GlobalRuleBuilder> builders = OrderedSPIRegistry.getRegisteredServices(globalRuleConfigurations, GlobalRuleBuilder.class);
appendDefaultKernelGlobalRuleConfigurationBuilder(builders);
Collection<ShardingSphereRule> result = new LinkedList<>();
for (Entry<RuleConfiguration, GlobalRuleBuilder> entry : builders.entrySet()) {
- result.add(entry.getValue().build(entry.getKey(), mataDataMap, users));
+ result.add(entry.getValue().build(entry.getKey(), mataDataMap));
}
return result;
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/scope/GlobalRuleBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/scope/GlobalRuleBuilder.java
index 2c94f92..e8ea38e 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/scope/GlobalRuleBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/scope/GlobalRuleBuilder.java
@@ -19,10 +19,8 @@ package org.apache.shardingsphere.infra.rule.builder.scope;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.rule.scope.GlobalRule;
-import java.util.Collection;
import java.util.Map;
/**
@@ -38,8 +36,7 @@ public interface GlobalRuleBuilder<R extends GlobalRule, T extends RuleConfigura
*
* @param ruleConfig rule configuration
* @param mataDataMap mata data map
- * @param users users
* @return global rule
*/
- R build(T ruleConfig, Map<String, ShardingSphereMetaData> mataDataMap, Collection<ShardingSphereUser> users);
+ R build(T ruleConfig, Map<String, ShardingSphereMetaData> mataDataMap);
}
diff --git a/shardingsphere-infra/shardingsphere-infra-context/pom.xml b/shardingsphere-infra/shardingsphere-infra-context/pom.xml
index d286666..6da6ce71 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/pom.xml
+++ b/shardingsphere-infra/shardingsphere-infra-context/pom.xml
@@ -49,6 +49,11 @@
<artifactId>shardingsphere-infra-optimize</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-infra-authority-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilder.java b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilder.java
index 8c98c53..13ec156 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilder.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.infra.context.metadata;
+import org.apache.shardingsphere.authority.api.config.AuthorityRuleConfiguration;
import org.apache.shardingsphere.infra.config.DatabaseAccessConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
@@ -43,6 +44,7 @@ import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
@@ -62,23 +64,20 @@ public final class MetaDataContextsBuilder {
private final Collection<RuleConfiguration> globalRuleConfigs;
- private final Collection<ShardingSphereUser> users;
-
private final ConfigurationProperties props;
private final ExecutorEngine executorEngine;
public MetaDataContextsBuilder(final Map<String, Map<String, DataSource>> dataSources, final Map<String, Collection<RuleConfiguration>> schemaRuleConfigs, final Properties props) {
- this(dataSources, schemaRuleConfigs, new LinkedList<>(), new LinkedList<>(), props);
+ this(dataSources, schemaRuleConfigs, new LinkedList<>(), props);
}
public MetaDataContextsBuilder(final Map<String, Map<String, DataSource>> dataSources,
final Map<String, Collection<RuleConfiguration>> schemaRuleConfigs, final Collection<RuleConfiguration> globalRuleConfigs,
- final Collection<ShardingSphereUser> users, final Properties props) {
+ final Properties props) {
this.dataSources = dataSources;
this.schemaRuleConfigs = schemaRuleConfigs;
this.globalRuleConfigs = globalRuleConfigs;
- this.users = users;
this.props = new ConfigurationProperties(null == props ? new Properties() : props);
executorEngine = new ExecutorEngine(this.props.<Integer>getValue(ConfigurationPropertyKey.EXECUTOR_SIZE));
}
@@ -94,7 +93,7 @@ public final class MetaDataContextsBuilder {
for (String each : schemaRuleConfigs.keySet()) {
mataDataMap.put(each, buildMetaData(each));
}
- return new StandardMetaDataContexts(mataDataMap, buildGlobalSchemaMetaData(mataDataMap), executorEngine, new ShardingSphereUsers(users), props);
+ return new StandardMetaDataContexts(mataDataMap, buildGlobalSchemaMetaData(mataDataMap), executorEngine, new ShardingSphereUsers(getUsersFromAuthorityRule()), props);
}
private ShardingSphereMetaData buildMetaData(final String schemaName) throws SQLException {
@@ -105,9 +104,9 @@ public final class MetaDataContextsBuilder {
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(ruleConfigs, rules);
return new ShardingSphereMetaData(schemaName, buildResource(databaseType, dataSourceMap), ruleMetaData, buildSchema(databaseType, dataSourceMap, rules));
}
-
+
private ShardingSphereRuleMetaData buildGlobalSchemaMetaData(final Map<String, ShardingSphereMetaData> mataDataMap) {
- return new ShardingSphereRuleMetaData(globalRuleConfigs, ShardingSphereRulesBuilder.buildGlobalRules(globalRuleConfigs, mataDataMap, users));
+ return new ShardingSphereRuleMetaData(globalRuleConfigs, ShardingSphereRulesBuilder.buildGlobalRules(globalRuleConfigs, mataDataMap));
}
private ShardingSphereResource buildResource(final DatabaseType databaseType, final Map<String, DataSource> dataSourceMap) throws SQLException {
@@ -140,4 +139,14 @@ public final class MetaDataContextsBuilder {
private ShardingSphereSchema buildSchema(final DatabaseType databaseType, final Map<String, DataSource> dataSourceMap, final Collection<ShardingSphereRule> rules) throws SQLException {
return SchemaBuilder.build(new SchemaBuilderMaterials(databaseType, dataSourceMap, rules, props));
}
+
+ private Collection<ShardingSphereUser> getUsersFromAuthorityRule() {
+ for (RuleConfiguration ruleConfig : globalRuleConfigs) {
+ if (ruleConfig instanceof AuthorityRuleConfiguration) {
+ AuthorityRuleConfiguration authorityRuleConfiguration = (AuthorityRuleConfiguration) ruleConfig;
+ return authorityRuleConfiguration.getUsers();
+ }
+ }
+ return Collections.emptyList();
+ }
}
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilderTest.java b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilderTest.java
index 64543f9..041ca21 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilderTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilderTest.java
@@ -17,9 +17,11 @@
package org.apache.shardingsphere.infra.context.metadata;
+import org.apache.shardingsphere.authority.api.config.AuthorityRuleConfiguration;
import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.context.fixture.FixtureRule;
import org.apache.shardingsphere.infra.context.fixture.FixtureRuleConfiguration;
+import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.test.mock.MockedDataSource;
import org.hamcrest.CoreMatchers;
import org.junit.Test;
@@ -42,6 +44,7 @@ public final class MetaDataContextsBuilderTest {
MetaDataContexts actual = new MetaDataContextsBuilder(Collections.emptyMap(), Collections.emptyMap(), null).build();
assertTrue(actual.getAllSchemaNames().isEmpty());
assertTrue(actual.getProps().getProps().isEmpty());
+ assertTrue(actual.getUsers().getUsers().isEmpty());
}
@Test
@@ -67,6 +70,23 @@ public final class MetaDataContextsBuilderTest {
assertThat(actual.getProps().getProps().size(), is(1));
assertThat(actual.getProps().getValue(ConfigurationPropertyKey.EXECUTOR_SIZE), is(1));
}
+
+ @Test
+ public void assertBuildWithAuthorityRuleConfigurations() throws SQLException {
+ Properties props = new Properties();
+ props.setProperty(ConfigurationPropertyKey.EXECUTOR_SIZE.getKey(), "1");
+ ShardingSphereUser user = new ShardingSphereUser("root", "root", "");
+ AuthorityRuleConfiguration authorityRuleConfig = new AuthorityRuleConfiguration(Collections.singleton(user), null);
+
+ MetaDataContexts actual = new MetaDataContextsBuilder(
+ Collections.singletonMap("logic_db", Collections.emptyMap()), Collections.singletonMap("logic_db",
+ Collections.singleton(new FixtureRuleConfiguration())), Collections.singleton(authorityRuleConfig), props).build();
+ assertRules(actual);
+ assertTrue(actual.getMetaData("logic_db").getResource().getDataSources().isEmpty());
+ assertThat(actual.getProps().getProps().size(), is(1));
+ assertThat(actual.getProps().getValue(ConfigurationPropertyKey.EXECUTOR_SIZE), is(1));
+ assertThat(actual.getUsers().getUsers().size(), is(1));
+ }
private void assertRules(final MetaDataContexts actual) {
assertThat(actual.getMetaData("logic_db").getRuleMetaData().getRules().size(), is(1));
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSource.java b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSource.java
index c4e2f00..3317aaa 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSource.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSource.java
@@ -124,7 +124,7 @@ public final class GovernanceShardingSphereDataSource extends AbstractUnsupporte
Map<String, DataSourceConfiguration> dataSourceConfigs = DataSourceConverter.getDataSourceConfigurationMap(metaDataContexts.getDefaultMetaData().getResource().getDataSources());
Collection<RuleConfiguration> ruleConfigurations = metaDataContexts.getDefaultMetaData().getRuleMetaData().getConfigurations();
governanceFacade.onlineInstance(Collections.singletonMap(DefaultSchema.LOGIC_NAME, dataSourceConfigs),
- Collections.singletonMap(DefaultSchema.LOGIC_NAME, ruleConfigurations), Collections.emptyList(), metaDataContexts.getProps().getProps());
+ Collections.singletonMap(DefaultSchema.LOGIC_NAME, ruleConfigurations), metaDataContexts.getProps().getProps());
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/AbstractBootstrapInitializer.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/AbstractBootstrapInitializer.java
index 3cf080f..851ca93 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/AbstractBootstrapInitializer.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/AbstractBootstrapInitializer.java
@@ -80,7 +80,7 @@ public abstract class AbstractBootstrapInitializer implements BootstrapInitializ
private MetaDataContexts createMetaDataContexts(final ProxyConfiguration proxyConfig) throws SQLException {
Map<String, Map<String, DataSource>> dataSourcesMap = createDataSourcesMap(proxyConfig.getSchemaDataSources());
MetaDataContextsBuilder metaDataContextsBuilder = new MetaDataContextsBuilder(
- dataSourcesMap, proxyConfig.getSchemaRules(), proxyConfig.getGlobalRules(), proxyConfig.getUsers(), proxyConfig.getProps());
+ dataSourcesMap, proxyConfig.getSchemaRules(), proxyConfig.getGlobalRules(), proxyConfig.getProps());
return metaDataContextsBuilder.build();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java
index 5feab64..30da5db 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java
@@ -26,7 +26,6 @@ import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration
import org.apache.shardingsphere.infra.config.datasource.DataSourceParameter;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
-import org.apache.shardingsphere.infra.metadata.user.yaml.config.YamlUsersConfigurationConverter;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.proxy.config.ProxyConfiguration;
import org.apache.shardingsphere.proxy.config.YamlProxyConfiguration;
@@ -68,12 +67,12 @@ public final class GovernanceBootstrapInitializer extends AbstractBootstrapIniti
governanceFacade.onlineInstance();
} else {
governanceFacade.onlineInstance(getDataSourceConfigurationMap(ruleConfigs),
- getRuleConfigurations(ruleConfigs), YamlUsersConfigurationConverter.convertShardingSphereUser(serverConfig.getUsers()), serverConfig.getProps());
+ getRuleConfigurations(ruleConfigs), serverConfig.getProps());
}
}
private boolean isEmptyLocalConfiguration(final YamlProxyServerConfiguration serverConfig, final Map<String, YamlProxyRuleConfiguration> ruleConfigs) {
- return ruleConfigs.isEmpty() && null == serverConfig.getUsers() && serverConfig.getProps().isEmpty();
+ return ruleConfigs.isEmpty() && serverConfig.getProps().isEmpty();
}
private Map<String, Map<String, DataSourceConfiguration>> getDataSourceConfigurationMap(final Map<String, YamlProxyRuleConfiguration> ruleConfigs) {
@@ -97,7 +96,7 @@ public final class GovernanceBootstrapInitializer extends AbstractBootstrapIniti
Map<String, Collection<RuleConfiguration>> schemaRules = loadSchemaRules(schemaNames);
Properties props = governanceFacade.getRegistryCenter().loadProperties();
// TODO load global rules from reg center
- return new ProxyConfiguration(schemaDataSources, schemaRules, Collections.emptyList(), governanceFacade.getRegistryCenter().loadUsers(), props);
+ return new ProxyConfiguration(schemaDataSources, schemaRules, Collections.emptyList(), props);
}
private Map<String, Map<String, DataSourceParameter>> loadDataSourceParametersMap(final Collection<String> schemaNames) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializerTest.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializerTest.java
index 8003ead..bc16b67 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializerTest.java
@@ -112,7 +112,6 @@ public final class GovernanceBootstrapInitializerTest extends AbstractBootstrapI
assertNotNull(actual);
assertSchemaDataSources(actual.getSchemaDataSources());
assertSchemaRules(actual.getSchemaRules());
- assertUsers(new ShardingSphereUsers(actual.getUsers()));
assertProps(actual.getProps());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/StandardBootstrapInitializerTest.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/StandardBootstrapInitializerTest.java
index 71a9ff5..3f84346 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/StandardBootstrapInitializerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/StandardBootstrapInitializerTest.java
@@ -17,6 +17,8 @@
package org.apache.shardingsphere.proxy.initializer.impl;
+import org.apache.shardingsphere.authority.api.config.AuthorityRuleConfiguration;
+import org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceParameter;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
@@ -25,6 +27,7 @@ import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUsers;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
+import org.apache.shardingsphere.infra.yaml.config.algorithm.YamlShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapper;
import org.apache.shardingsphere.proxy.config.ProxyConfiguration;
import org.apache.shardingsphere.proxy.config.YamlProxyConfiguration;
@@ -108,10 +111,20 @@ public final class StandardBootstrapInitializerTest extends AbstractBootstrapIni
private void assertProxyConfiguration(final ProxyConfiguration actual) {
assertSchemaDataSources(actual.getSchemaDataSources());
assertSchemaRules(actual.getSchemaRules());
- assertUsers(new ShardingSphereUsers(actual.getUsers()));
+ assertUsers(new ShardingSphereUsers(getUsersFromAuthorityRule(actual.getGlobalRules())));
assertProps(actual.getProps());
}
-
+
+ private Collection<ShardingSphereUser> getUsersFromAuthorityRule(final Collection<RuleConfiguration> globalRuleConfigs) {
+ for (RuleConfiguration ruleConfig : globalRuleConfigs) {
+ if (ruleConfig instanceof AuthorityRuleConfiguration) {
+ AuthorityRuleConfiguration authorityRuleConfiguration = (AuthorityRuleConfiguration) ruleConfig;
+ return authorityRuleConfiguration.getUsers();
+ }
+ }
+ return Collections.emptyList();
+ }
+
private void assertSchemaDataSources(final Map<String, Map<String, DataSourceParameter>> actual) {
assertThat(actual.size(), is(1));
assertTrue(actual.containsKey("logic-db"));
@@ -153,8 +166,13 @@ public final class StandardBootstrapInitializerTest extends AbstractBootstrapIni
}
private YamlProxyServerConfiguration createYamlProxyServerConfiguration() {
- YamlProxyServerConfiguration result = new YamlProxyServerConfiguration();
- result.getUsers().add("root@:root");
+ final YamlProxyServerConfiguration result = new YamlProxyServerConfiguration();
+ YamlAuthorityRuleConfiguration yamlRule = new YamlAuthorityRuleConfiguration();
+ yamlRule.setUsers(Collections.singletonList("root@%:root"));
+ YamlShardingSphereAlgorithmConfiguration provider = new YamlShardingSphereAlgorithmConfiguration();
+ provider.setType("test");
+ yamlRule.setProvider(provider);
+ result.getRules().add(yamlRule);
result.setProps(createProperties());
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/conf/local/server.yaml b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/conf/local/server.yaml
index e229a8a..6bef22f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/conf/local/server.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/conf/local/server.yaml
@@ -27,9 +27,13 @@ governance:
operationTimeoutMilliseconds: 500
overwrite: false
-users:
- - root@:root
- - sharding@:sharding
+rules:
+ - !AUTHORITY
+ users:
+ - root@:root
+ - sharding@:sharding
+ provider:
+ type: NATIVE
props:
alpha-1: alpha-A
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/conf/reg_center/server.yaml b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/conf/reg_center/server.yaml
index e8bbed9..eae6868 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/conf/reg_center/server.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/conf/reg_center/server.yaml
@@ -26,3 +26,11 @@ governance:
maxRetries: 3
operationTimeoutMilliseconds: 500
overwrite: false
+
+rules:
+ - !AUTHORITY
+ users:
+ - root@:root
+ - sharding@:sharding
+ provider:
+ type: NATIVE
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfiguration.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfiguration.java
index 732018c..2b32054 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfiguration.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfiguration.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.proxy.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceParameter;
@@ -40,7 +39,5 @@ public final class ProxyConfiguration {
private final Collection<RuleConfiguration> globalRules;
- private final Collection<ShardingSphereUser> users;
-
private final Properties props;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfigurationLoader.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfigurationLoader.java
index d4669c4..49116cd 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfigurationLoader.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfigurationLoader.java
@@ -20,6 +20,8 @@ package org.apache.shardingsphere.proxy.config;
import com.google.common.base.Preconditions;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
+import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.proxy.config.yaml.YamlProxyRuleConfiguration;
import org.apache.shardingsphere.proxy.config.yaml.YamlProxyServerConfiguration;
@@ -71,7 +73,8 @@ public final class ProxyConfigurationLoader {
private static YamlProxyServerConfiguration loadServerConfiguration(final File yamlFile) throws IOException {
YamlProxyServerConfiguration result = YamlEngine.unmarshal(yamlFile, YamlProxyServerConfiguration.class);
Preconditions.checkNotNull(result, "Server configuration file `%s` is invalid.", yamlFile.getName());
- Preconditions.checkState(!result.getUsers().isEmpty() || null != result.getGovernance(), "Authority configuration is invalid.");
+ YamlRuleConfiguration authorityRuleConfig = result.getRules().stream().filter(ruleConfig -> ruleConfig instanceof YamlAuthorityRuleConfiguration).findAny().orElse(null);
+ Preconditions.checkState(null != result.getGovernance() || null != authorityRuleConfig, "Authority configuration is invalid.");
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlProxyServerConfiguration.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlProxyServerConfiguration.java
index 8d27f82..52fef6d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlProxyServerConfiguration.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlProxyServerConfiguration.java
@@ -35,8 +35,6 @@ import java.util.Properties;
@Setter
public final class YamlProxyServerConfiguration implements YamlConfiguration {
- private Collection<String> users = new LinkedList<>();
-
private YamlGovernanceConfiguration governance;
private YamlScalingConfiguration scaling;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapper.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapper.java
index 935551f..53d7823 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapper.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapper.java
@@ -19,8 +19,6 @@ package org.apache.shardingsphere.proxy.config.yaml.swapper;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceParameter;
-import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
-import org.apache.shardingsphere.infra.metadata.user.yaml.config.YamlUsersConfigurationConverter;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.proxy.config.ProxyConfiguration;
import org.apache.shardingsphere.proxy.config.YamlProxyConfiguration;
@@ -49,9 +47,9 @@ public final class YamlProxyConfigurationSwapper {
Map<String, Map<String, DataSourceParameter>> schemaDataSources = getDataSourceParametersMap(yamlConfig.getRuleConfigurations());
Map<String, Collection<RuleConfiguration>> schemaRules = getRuleConfigurations(yamlConfig.getRuleConfigurations());
Collection<RuleConfiguration> globalRules = new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(yamlConfig.getServerConfiguration().getRules());
- Collection<ShardingSphereUser> users = YamlUsersConfigurationConverter.convertShardingSphereUser(yamlConfig.getServerConfiguration().getUsers());
+
Properties props = yamlConfig.getServerConfiguration().getProps();
- return new ProxyConfiguration(schemaDataSources, schemaRules, globalRules, users, props);
+ return new ProxyConfiguration(schemaDataSources, schemaRules, globalRules, props);
}
private Map<String, Collection<RuleConfiguration>> getRuleConfigurations(final Map<String, YamlProxyRuleConfiguration> yamlRuleConfigurations) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/test/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/test/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java
index 9eb8b91..134bc20 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/test/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/test/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java
@@ -18,6 +18,8 @@
package org.apache.shardingsphere.proxy.config.yaml.swapper;
import com.google.common.collect.Lists;
+import org.apache.shardingsphere.authority.api.config.AuthorityRuleConfiguration;
+import org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceCenterConfiguration;
import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
@@ -26,6 +28,7 @@ import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUsers;
import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
+import org.apache.shardingsphere.infra.yaml.config.algorithm.YamlShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.proxy.config.ProxyConfiguration;
import org.apache.shardingsphere.proxy.config.YamlProxyConfiguration;
import org.apache.shardingsphere.proxy.config.yaml.YamlDataSourceParameter;
@@ -36,6 +39,7 @@ import org.apache.shardingsphere.readwritesplitting.common.yaml.config.YamlReadw
import org.junit.Test;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
@@ -102,10 +106,20 @@ public final class YamlProxyConfigurationSwapperTest {
}
private void assertAuthority(final ProxyConfiguration proxyConfig) {
- Optional<ShardingSphereUser> user = new ShardingSphereUsers(proxyConfig.getUsers()).findUser(new Grantee("user1", ""));
+ Optional<ShardingSphereUser> user = new ShardingSphereUsers(getUsersFromAuthorityRule(proxyConfig.getGlobalRules())).findUser(new Grantee("user1", ""));
assertTrue(user.isPresent());
assertThat(user.get().getPassword(), is("pass"));
}
+
+ private Collection<ShardingSphereUser> getUsersFromAuthorityRule(final Collection<RuleConfiguration> globalRuleConfigs) {
+ for (RuleConfiguration ruleConfig : globalRuleConfigs) {
+ if (ruleConfig instanceof AuthorityRuleConfiguration) {
+ AuthorityRuleConfiguration authorityRuleConfiguration = (AuthorityRuleConfiguration) ruleConfig;
+ return authorityRuleConfiguration.getUsers();
+ }
+ }
+ return Collections.emptyList();
+ }
private YamlProxyConfiguration getYamlProxyConfiguration() {
YamlProxyConfiguration result = mock(YamlProxyConfiguration.class);
@@ -195,7 +209,12 @@ public final class YamlProxyConfigurationSwapperTest {
}
private void prepareAuthentication(final YamlProxyServerConfiguration yamlProxyServerConfig) {
- when(yamlProxyServerConfig.getUsers()).thenReturn(getUsers());
+ YamlAuthorityRuleConfiguration yamlAuthorityRuleConfig = new YamlAuthorityRuleConfiguration();
+ yamlAuthorityRuleConfig.setUsers(getUsers());
+ YamlShardingSphereAlgorithmConfiguration provider = new YamlShardingSphereAlgorithmConfiguration();
+ provider.setType("test");
+ yamlAuthorityRuleConfig.setProvider(provider);
+ when(yamlProxyServerConfig.getRules()).thenReturn(Collections.singletonList(yamlAuthorityRuleConfig));
}
private Collection<String> getUsers() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/test/resources/conf/server.yaml b/shardingsphere-proxy/shardingsphere-proxy-common/src/test/resources/conf/server.yaml
index 3796403..5052389 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/test/resources/conf/server.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/test/resources/conf/server.yaml
@@ -22,8 +22,12 @@ governance:
serverLists: localhost:2181
overwrite: false
-users:
- - root@:root
+rules:
+ - !AUTHORITY
+ users:
+ - root@:root
+ provider:
+ type: NATIVE
props:
max-connections-size-per-query: 1
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/server.yaml
index 1fabd14..2a8743c 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/server.yaml
@@ -15,8 +15,12 @@
# limitations under the License.
#
-users:
- - root@:root
+rules:
+ - !AUTHORITY
+ users:
+ - root@:root
+ provider:
+ type: NATIVE
props:
max-connections-size-per-query: 1
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/adapter/ShardingSphereAdapterContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/adapter/ShardingSphereAdapterContainer.java
index 08c8ec7..1754fb6 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/adapter/ShardingSphereAdapterContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/adapter/ShardingSphereAdapterContainer.java
@@ -20,8 +20,10 @@ package org.apache.shardingsphere.test.integration.junit.container.adapter;
import com.google.common.io.ByteStreams;
import lombok.Getter;
import lombok.SneakyThrows;
+import org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
import org.apache.shardingsphere.infra.metadata.user.yaml.config.YamlUserConfiguration;
import org.apache.shardingsphere.infra.metadata.user.yaml.config.YamlUsersConfigurationConverter;
+import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.proxy.config.yaml.YamlProxyServerConfiguration;
import org.apache.shardingsphere.test.integration.junit.container.ShardingSphereContainer;
@@ -29,6 +31,8 @@ import org.apache.shardingsphere.test.integration.junit.param.model.Parameterize
import javax.sql.DataSource;
import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
/**
* ShardingSphere adapter container.
@@ -53,7 +57,7 @@ public abstract class ShardingSphereAdapterContainer extends ShardingSphereConta
ByteStreams.toByteArray(this.getClass().getResourceAsStream("/docker/" + parameterizedArray.getScenario() + "/proxy/conf/server.yaml")),
YamlProxyServerConfiguration.class
);
- return YamlUsersConfigurationConverter.convertYamlUserConfiguration(configuration.getUsers())
+ return YamlUsersConfigurationConverter.convertYamlUserConfiguration(getUsersFromConfiguration(configuration))
.stream()
.filter(each -> "root".equals(each.getUsername()))
.findFirst()
@@ -66,5 +70,15 @@ public abstract class ShardingSphereAdapterContainer extends ShardingSphereConta
* @return DataSource
*/
public abstract DataSource getDataSource();
+
+ private Collection<String> getUsersFromConfiguration(final YamlProxyServerConfiguration serverConfig) {
+ for (YamlRuleConfiguration config : serverConfig.getRules()) {
+ if (config instanceof YamlAuthorityRuleConfiguration) {
+ YamlAuthorityRuleConfiguration authorityRuleConfig = (YamlAuthorityRuleConfiguration) config;
+ return authorityRuleConfig.getUsers();
+ }
+ }
+ return Collections.emptyList();
+ }
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/GeneralDQLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/GeneralDQLIT.java
index 24fd1ee..8443347 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/GeneralDQLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/GeneralDQLIT.java
@@ -45,7 +45,7 @@ import static org.junit.Assert.assertTrue;
public final class GeneralDQLIT extends BaseDQLIT {
@ClassRule
- public static ComposeManager composeManager = new ComposeManager("GeneralDQLIT");
+ public static ComposeManager composeMaYamlProxyServerConfigurationnager = new ComposeManager("GeneralDQLIT");
public GeneralDQLIT(final AssertionParameterizedArray parameter) {
super(parameter);
@@ -55,7 +55,7 @@ public final class GeneralDQLIT extends BaseDQLIT {
public static Collection<ParameterizedArray> getParameters() {
return ParameterizedArrayFactory.getAssertionParameterized(SQLCommandType.DQL)
.stream()
- .peek(each -> each.setCompose(composeManager.getOrCreateCompose(each)))
+ .peek(each -> each.setCompose(composeMaYamlProxyServerConfigurationnager.getOrCreateCompose(each)))
.collect(Collectors.toList());
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/db/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/db/proxy/conf/server.yaml
index 071d334..6bf0ab3 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/db/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/db/proxy/conf/server.yaml
@@ -27,8 +27,12 @@
# operationTimeoutMilliseconds: 500
# overwrite: true
-users:
- - root@:root
+rules:
+ - !AUTHORITY
+ users:
+ - root@:root
+ provider:
+ type: NATIVE
props:
max-connections-size-per-query: 1
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting/proxy/conf/server.yaml
index 071d334..6bf0ab3 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting/proxy/conf/server.yaml
@@ -27,8 +27,12 @@
# operationTimeoutMilliseconds: 500
# overwrite: true
-users:
- - root@:root
+rules:
+ - !AUTHORITY
+ users:
+ - root@:root
+ provider:
+ type: NATIVE
props:
max-connections-size-per-query: 1
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting_and_encrypt/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting_and_encrypt/proxy/conf/server.yaml
index 071d334..6bf0ab3 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting_and_encrypt/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting_and_encrypt/proxy/conf/server.yaml
@@ -27,8 +27,12 @@
# operationTimeoutMilliseconds: 500
# overwrite: true
-users:
- - root@:root
+rules:
+ - !AUTHORITY
+ users:
+ - root@:root
+ provider:
+ type: NATIVE
props:
max-connections-size-per-query: 1
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/proxy/conf/server.yaml
index 071d334..6bf0ab3 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/proxy/conf/server.yaml
@@ -27,8 +27,12 @@
# operationTimeoutMilliseconds: 500
# overwrite: true
-users:
- - root@:root
+rules:
+ - !AUTHORITY
+ users:
+ - root@:root
+ provider:
+ type: NATIVE
props:
max-connections-size-per-query: 1
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/readwrite_splitting/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/readwrite_splitting/proxy/conf/server.yaml
index 071d334..6bf0ab3 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/readwrite_splitting/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/readwrite_splitting/proxy/conf/server.yaml
@@ -27,8 +27,12 @@
# operationTimeoutMilliseconds: 500
# overwrite: true
-users:
- - root@:root
+rules:
+ - !AUTHORITY
+ users:
+ - root@:root
+ provider:
+ type: NATIVE
props:
max-connections-size-per-query: 1
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/sharding_governance/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/sharding_governance/proxy/conf/server.yaml
index 79827b6..f4af299 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/sharding_governance/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/sharding_governance/proxy/conf/server.yaml
@@ -27,8 +27,12 @@ governance:
operationTimeoutMilliseconds: 500
overwrite: true
-users:
- - root@:root
+rules:
+ - !AUTHORITY
+ users:
+ - root@:root
+ provider:
+ type: NATIVE
props:
max-connections-size-per-query: 1
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/proxy/conf/server.yaml
index 071d334..6bf0ab3 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/proxy/conf/server.yaml
@@ -27,8 +27,12 @@
# operationTimeoutMilliseconds: 500
# overwrite: true
-users:
- - root@:root
+rules:
+ - !AUTHORITY
+ users:
+ - root@:root
+ provider:
+ type: NATIVE
props:
max-connections-size-per-query: 1