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 574a93e  Remove useless parameters of GlobalRuleBuilder (#10005)
574a93e is described below

commit 574a93e7162c24f622915becaa75c79f5d1d1410
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Apr 9 15:58:32 2021 +0800

    Remove useless parameters of GlobalRuleBuilder (#10005)
---
 .../shardingsphere/authority/spi/PrivilegeLoadAlgorithm.java   |  5 +----
 .../loader/storage/StoragePrivilegeLoadAlgorithm.java          |  4 +---
 .../apache/shardingsphere/authority/rule/AuthorityRule.java    |  5 ++---
 .../authority/rule/builder/AuthorityRuleBuilder.java           |  5 ++---
 .../shardingsphere/infra/rule/builder/GlobalRuleBuilder.java   |  4 +---
 .../infra/rule/builder/ShardingSphereRulesBuilder.java         |  9 ++++-----
 .../infra/context/metadata/MetaDataContextsBuilder.java        | 10 +++-------
 7 files changed, 14 insertions(+), 28 deletions(-)

diff --git 
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/spi/PrivilegeLoadAlgorithm.java
 
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/spi/PrivilegeLoadAlgorithm.java
index 15a4d6e..5839494 100644
--- 
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/spi/PrivilegeLoadAlgorithm.java
+++ 
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/spi/PrivilegeLoadAlgorithm.java
@@ -22,7 +22,6 @@ import 
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm;
 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 java.util.Collection;
 import java.util.Map;
@@ -37,10 +36,8 @@ public interface PrivilegeLoadAlgorithm extends 
ShardingSphereAlgorithm {
      * 
      * @param databaseType database type
      * @param mataDataMap mata data map
-     * @param rules rules
      * @param users users
      * @return user and privileges map
      */
-    Map<ShardingSphereUser, ShardingSpherePrivileges> load(DatabaseType 
databaseType, Map<String, ShardingSphereMetaData> mataDataMap, 
-                                                           
Collection<ShardingSphereRule> rules, Collection<ShardingSphereUser> users);
+    Map<ShardingSphereUser, ShardingSpherePrivileges> load(DatabaseType 
databaseType, Map<String, ShardingSphereMetaData> mataDataMap, 
Collection<ShardingSphereUser> users);
 }
diff --git 
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/loader/storage/StoragePrivilegeLoadAlgorithm.java
 
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/loader/storage/StoragePrivilegeLoadAlgorithm.java
index 267059d..f292626 100644
--- 
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/loader/storage/StoragePrivilegeLoadAlgorithm.java
+++ 
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/loader/storage/StoragePrivilegeLoadAlgorithm.java
@@ -24,7 +24,6 @@ import 
org.apache.shardingsphere.authority.spi.PrivilegeLoadAlgorithm;
 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.spi.ShardingSphereServiceLoader;
 
 import java.util.Collection;
@@ -41,8 +40,7 @@ public final class StoragePrivilegeLoadAlgorithm implements 
PrivilegeLoadAlgorit
     }
     
     @Override
-    public Map<ShardingSphereUser, ShardingSpherePrivileges> load(final 
DatabaseType databaseType, final Map<String, ShardingSphereMetaData> 
mataDataMap,
-                                                                  final 
Collection<ShardingSphereRule> rules, final Collection<ShardingSphereUser> 
users) {
+    public Map<ShardingSphereUser, ShardingSpherePrivileges> load(final 
DatabaseType databaseType, final Map<String, ShardingSphereMetaData> 
mataDataMap, final Collection<ShardingSphereUser> users) {
         return StoragePrivilegeBuilder.build(databaseType, new 
LinkedList<>(mataDataMap.values()), users);
     }
     
diff --git 
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
 
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
index 30f138e..d0b3c8c 100644
--- 
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
+++ 
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
@@ -26,7 +26,6 @@ import 
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmF
 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.scope.GlobalRule;
 import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
 
@@ -43,10 +42,10 @@ public final class AuthorityRule implements GlobalRule {
     }
     
     public AuthorityRule(final AuthorityRuleConfiguration config, final 
Map<String, ShardingSphereMetaData> mataDataMap, final DatabaseType 
databaseType,
-                         final Collection<ShardingSphereUser> users, final 
Collection<ShardingSphereRule> builtRules) {
+                         final Collection<ShardingSphereUser> users) {
         PrivilegeLoadAlgorithm privilegeLoader = 
ShardingSphereAlgorithmFactory.createAlgorithm(config.getPrivilegeLoader(), 
PrivilegeLoadAlgorithm.class);
         ShardingSphereAuthority authority = null == 
AuthorityContext.getInstance().getAuthority() ? new DefaultAuthority() : 
AuthorityContext.getInstance().getAuthority();
-        authority.init(privilegeLoader.load(databaseType, mataDataMap, 
builtRules, users));
+        authority.init(privilegeLoader.load(databaseType, mataDataMap, users));
         AuthorityContext.getInstance().init(authority);
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java
 
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java
index 21dd8aa..c3a6070 100644
--- 
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java
+++ 
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java
@@ -23,7 +23,6 @@ import org.apache.shardingsphere.authority.rule.AuthorityRule;
 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.GlobalRuleBuilder;
 
 import java.util.Collection;
@@ -36,8 +35,8 @@ public final class AuthorityRuleBuilder implements 
GlobalRuleBuilder<AuthorityRu
     
     @Override
     public AuthorityRule build(final Map<String, ShardingSphereMetaData> 
mataDataMap, final DatabaseType databaseType,
-                               final AuthorityRuleConfiguration ruleConfig, 
final Collection<ShardingSphereUser> users, final 
Collection<ShardingSphereRule> builtRules) {
-        return new AuthorityRule(ruleConfig, mataDataMap, databaseType, users, 
builtRules);
+                               final AuthorityRuleConfiguration ruleConfig, 
final Collection<ShardingSphereUser> users) {
+        return new AuthorityRule(ruleConfig, mataDataMap, databaseType, users);
     }
     
     @Override
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/GlobalRuleBuilder.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/GlobalRuleBuilder.java
index 771ede6..9ea02ae 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/GlobalRuleBuilder.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/GlobalRuleBuilder.java
@@ -21,7 +21,6 @@ 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.scope.GlobalRule;
 import org.apache.shardingsphere.infra.spi.ordered.OrderedSPI;
 
@@ -43,8 +42,7 @@ public interface GlobalRuleBuilder<R extends GlobalRule, T 
extends RuleConfigura
      * @param databaseType database type
      * @param ruleConfig rule configuration
      * @param users users
-     * @param builtRules built rules
      * @return global rule
      */
-    R build(Map<String, ShardingSphereMetaData> mataDataMap, DatabaseType 
databaseType, T ruleConfig, Collection<ShardingSphereUser> users, 
Collection<ShardingSphereRule> builtRules);
+    R build(Map<String, ShardingSphereMetaData> mataDataMap, DatabaseType 
databaseType, T ruleConfig, Collection<ShardingSphereUser> users);
 }
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 34f9c7c..a5dfe4a 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
@@ -72,17 +72,16 @@ public final class ShardingSphereRulesBuilder {
      * @param globalRuleConfigurations global rule configurations
      * @param mataDataMap mata data map
      * @param users users
-     * @param schemaRules built schema rules
      * @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 Collection<ShardingSphereRule> 
schemaRules) {
+    public static Collection<ShardingSphereRule> buildGlobalRules(final 
Collection<RuleConfiguration> globalRuleConfigurations, 
+                                                                  final 
Map<String, ShardingSphereMetaData> mataDataMap, final 
Collection<ShardingSphereUser> users) {
         Map<RuleConfiguration, GlobalRuleBuilder> builders = 
OrderedSPIRegistry.getRegisteredServices(globalRuleConfigurations, 
GlobalRuleBuilder.class);
-        Collection<ShardingSphereRule> result = new LinkedList<>(schemaRules);
+        Collection<ShardingSphereRule> result = new LinkedList<>();
         for (Entry<RuleConfiguration, GlobalRuleBuilder> entry : 
builders.entrySet()) {
             DatabaseType databaseType = mataDataMap.isEmpty() ? new 
MySQLDatabaseType() : 
getDatabaseType(mataDataMap.values().iterator().next().getResource().getDataSources());
-            result.add(entry.getValue().build(mataDataMap, databaseType, 
entry.getKey(), users, result));
+            result.add(entry.getValue().build(mataDataMap, databaseType, 
entry.getKey(), users));
         }
         return result;
     }
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 c33a750..b934468 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
@@ -95,11 +95,7 @@ public final class MetaDataContextsBuilder {
         for (String each : schemaRuleConfigs.keySet()) {
             mataDataMap.put(each, buildMetaData(each));
         }
-        Collection<ShardingSphereRule> schemaRules = new LinkedList<>();
-        for (ShardingSphereMetaData each : mataDataMap.values()) {
-            schemaRules.addAll(each.getRuleMetaData().getRules());
-        }
-        return new StandardMetaDataContexts(mataDataMap, 
buildGlobalSchemaMetaData(mataDataMap, schemaRules), executorEngine, new 
ShardingSphereUsers(users), props);
+        return new StandardMetaDataContexts(mataDataMap, 
buildGlobalSchemaMetaData(mataDataMap), executorEngine, new 
ShardingSphereUsers(users), props);
     }
     
     private ShardingSphereMetaData buildMetaData(final String schemaName) 
throws SQLException {
@@ -129,8 +125,8 @@ public final class MetaDataContextsBuilder {
         }
     }
     
-    private ShardingSphereRuleMetaData buildGlobalSchemaMetaData(final 
Map<String, ShardingSphereMetaData> mataDataMap, final 
Collection<ShardingSphereRule> schemaRules) {
-        return new ShardingSphereRuleMetaData(globalRuleConfigs, 
ShardingSphereRulesBuilder.buildGlobalRules(globalRuleConfigs, mataDataMap, 
users, schemaRules));
+    private ShardingSphereRuleMetaData buildGlobalSchemaMetaData(final 
Map<String, ShardingSphereMetaData> mataDataMap) {
+        return new ShardingSphereRuleMetaData(globalRuleConfigs, 
ShardingSphereRulesBuilder.buildGlobalRules(globalRuleConfigs, mataDataMap, 
users));
     }
     
     private ShardingSphereResource buildResource(final DatabaseType 
databaseType, final Map<String, DataSource> dataSourceMap) throws SQLException {

Reply via email to