You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2021/07/04 10:32:06 UTC

[shardingsphere] branch master updated: Remove RuleDefinitionViolationException declaration of RDLCreateUpdater.updateCurrentRuleConfiguration() (#11146)

This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang 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 73ab059  Remove RuleDefinitionViolationException declaration of RDLCreateUpdater.updateCurrentRuleConfiguration() (#11146)
73ab059 is described below

commit 73ab059cc46f46ecd5afd19fb051bf7040909923
Author: Liang Zhang <te...@163.com>
AuthorDate: Sun Jul 4 18:31:39 2021 +0800

    Remove RuleDefinitionViolationException declaration of RDLCreateUpdater.updateCurrentRuleConfiguration() (#11146)
    
    * Remove RuleDefinitionViolationException declare of RDLCreateUpdater.updateCurrentRuleConfiguration()
    
    * Refactor RDLBackendHandler
---
 .../CreateShardingBroadcastTableRuleStatementUpdater.java  | 14 +++++++++-----
 .../infra/distsql/update/RDLCreateUpdater.java             |  4 +---
 .../proxy/backend/text/distsql/rdl/RDLBackendHandler.java  |  2 +-
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingBroadcastTableRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingBroadcastTableRuleStatemen [...]
index f825809..247077f 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingBroadcastTableRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingBroadcastTableRuleStatementUpdater.java
@@ -17,9 +17,9 @@
 
 package org.apache.shardingsphere.sharding.distsql.handler.update;
 
-import org.apache.shardingsphere.infra.distsql.update.RDLCreateUpdater;
 import org.apache.shardingsphere.infra.distsql.exception.rule.RuleDefinitionViolationException;
 import org.apache.shardingsphere.infra.distsql.exception.rule.RuleInUsedException;
+import org.apache.shardingsphere.infra.distsql.update.RDLCreateUpdater;
 import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import org.apache.shardingsphere.sharding.distsql.parser.statement.CreateShardingBroadcastTableRulesStatement;
@@ -32,6 +32,13 @@ public final class CreateShardingBroadcastTableRuleStatementUpdater implements R
     @Override
     public void checkSQLStatement(final String schemaName, final CreateShardingBroadcastTableRulesStatement sqlStatement, 
                                   final ShardingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+        checkCurrentRuleConfiguration(schemaName, currentRuleConfig);
+    }
+    
+    private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws RuleInUsedException {
+        if (null != currentRuleConfig && !currentRuleConfig.getBroadcastTables().isEmpty()) {
+            throw new RuleInUsedException("Broadcast", schemaName);
+        }
     }
     
     @Override
@@ -41,13 +48,10 @@ public final class CreateShardingBroadcastTableRuleStatementUpdater implements R
     
     @Override
     public void updateCurrentRuleConfiguration(final String schemaName, final CreateShardingBroadcastTableRulesStatement sqlStatement, 
-                                               final ShardingRuleConfiguration currentRuleConfig, final ShardingRuleConfiguration toBeCreatedRuleConfig) throws RuleDefinitionViolationException {
+                                               final ShardingRuleConfiguration currentRuleConfig, final ShardingRuleConfiguration toBeCreatedRuleConfig) {
         if (null == currentRuleConfig) {
             toBeCreatedRuleConfig.setBroadcastTables(sqlStatement.getTables());
         } else {
-            if (!currentRuleConfig.getBroadcastTables().isEmpty()) {
-                throw new RuleInUsedException("Broadcast", schemaName);
-            }
             currentRuleConfig.getBroadcastTables().addAll(sqlStatement.getTables());
         }
     }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RDLCreateUpdater.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RDLCreateUpdater.java
index 1f7dce9..272cfc2 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RDLCreateUpdater.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RDLCreateUpdater.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.infra.distsql.update;
 
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RuleDefinitionViolationException;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 
 /**
@@ -45,7 +44,6 @@ public interface RDLCreateUpdater<T extends SQLStatement, R extends RuleConfigur
      * @param sqlStatement SQL statement
      * @param currentRuleConfig current rule configuration to be updated
      * @param toBeCreatedRuleConfig to be created rule configuration
-     * @throws RuleDefinitionViolationException rule definition violation exception
      */
-    void updateCurrentRuleConfiguration(String schemaName, T sqlStatement, R currentRuleConfig, R toBeCreatedRuleConfig) throws RuleDefinitionViolationException;
+    void updateCurrentRuleConfiguration(String schemaName, T sqlStatement, R currentRuleConfig, R toBeCreatedRuleConfig);
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/RDLBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/RDLBackendHandler.java
index fe3ec46..60b1ad5 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/RDLBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/RDLBackendHandler.java
@@ -88,7 +88,7 @@ public final class RDLBackendHandler<T extends SQLStatement> extends SchemaRequi
     }
     
     @SuppressWarnings({"rawtypes", "unchecked"})
-    private void processCreate(final String schemaName, final T sqlStatement, final RDLCreateUpdater updater, final RuleConfiguration currentRuleConfig) throws RuleDefinitionViolationException {
+    private void processCreate(final String schemaName, final T sqlStatement, final RDLCreateUpdater updater, final RuleConfiguration currentRuleConfig) {
         RuleConfiguration toBeCreatedRuleConfig = updater.buildToBeCreatedRuleConfiguration(schemaName, sqlStatement);
         updater.updateCurrentRuleConfiguration(schemaName, sqlStatement, currentRuleConfig, toBeCreatedRuleConfig);
         if (null == currentRuleConfig && null != toBeCreatedRuleConfig) {