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 eb77921  Refactor RDLUpdater.updateCurrentRuleConfiguration method's 
return value for clean empty rule (#11035)
eb77921 is described below

commit eb77921ad18468d0e7a99f98d5ae9afaba35c918
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Jun 27 16:03:59 2021 +0800

    Refactor RDLUpdater.updateCurrentRuleConfiguration method's return value 
for clean empty rule (#11035)
---
 .../shardingsphere/infra/distsql/RDLUpdater.java   |  3 ++-
 .../text/distsql/rdl/impl/RDLBackendHandler.java   | 16 +++----------
 ...AlterDatabaseDiscoveryRuleStatementUpdater.java |  3 ++-
 .../updater/AlterEncryptRuleStatementUpdater.java  |  3 ++-
 ...lterReadwriteSplittingRuleStatementUpdater.java |  3 ++-
 ...erShardingBindingTableRuleStatementUpdater.java |  3 ++-
 ...ShardingBroadcastTableRuleStatementUpdater.java |  3 ++-
 .../AlterShardingTableRuleStatementUpdater.java    |  3 ++-
 ...reateDatabaseDiscoveryRuleStatementUpdater.java |  3 ++-
 .../updater/CreateEncryptRuleStatementUpdater.java |  3 ++-
 ...eateReadwriteSplittingRuleStatementUpdater.java |  3 ++-
 ...teShardingBindingTableRuleStatementUpdater.java |  3 ++-
 ...ShardingBroadcastTableRuleStatementUpdater.java |  3 ++-
 .../CreateShardingTableRuleStatementUpdater.java   |  3 ++-
 .../DropDatabaseDiscoveryRuleStatementUpdater.java | 27 +++++++++++-----------
 .../updater/DropEncryptRuleStatementUpdater.java   |  7 ++----
 ...DropReadwriteSplittingRuleStatementUpdater.java |  7 ++----
 ...opShardingBindingTableRuleStatementUpdater.java |  3 ++-
 ...ShardingBroadcastTableRuleStatementUpdater.java |  3 ++-
 .../DropShardingTableRuleStatementUpdater.java     |  3 ++-
 20 files changed, 52 insertions(+), 53 deletions(-)

diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/RDLUpdater.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/RDLUpdater.java
index 08f2360..51a02b2 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/RDLUpdater.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/RDLUpdater.java
@@ -46,6 +46,7 @@ public interface RDLUpdater<T extends SQLStatement, R extends 
RuleConfiguration>
      * @param schemaName schema name
      * @param sqlStatement SQL statement
      * @param currentRuleConfig current rule configuration to be updated
+     * @return current rule configuration is empty or not 
      */
-    void updateCurrentRuleConfiguration(String schemaName, T sqlStatement, R 
currentRuleConfig);
+    boolean updateCurrentRuleConfiguration(String schemaName, T sqlStatement, 
R currentRuleConfig);
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/RDLBackendHandler.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/RDLBackendHandler.java
index c681cbe..49d1e67 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/RDLBackendHandler.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/RDLBackendHandler.java
@@ -22,7 +22,6 @@ import 
org.apache.shardingsphere.infra.config.RuleConfiguration;
 import org.apache.shardingsphere.infra.config.scope.SchemaRuleConfiguration;
 import org.apache.shardingsphere.infra.distsql.RDLUpdater;
 import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
-import 
org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
 import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.infra.spi.typed.TypedSPIRegistry;
 import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
@@ -33,10 +32,8 @@ import 
org.apache.shardingsphere.proxy.backend.text.SchemaRequiredBackendHandler
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 
 import java.lang.reflect.ParameterizedType;
-import java.util.Collection;
 import java.util.Optional;
 import java.util.Properties;
-import java.util.stream.Collectors;
 
 /**
  * RDL backend handler.
@@ -60,7 +57,9 @@ public abstract class RDLBackendHandler<T extends 
SQLStatement, R extends Schema
         R currentRuleConfig = 
findCurrentRuleConfiguration(schemaName).orElse(null);
         RDLUpdater rdlUpdater = 
TypedSPIRegistry.getRegisteredService(RDLUpdater.class, 
sqlStatement.getClass().getCanonicalName(), new Properties());
         rdlUpdater.checkSQLStatement(schemaName, sqlStatement, 
currentRuleConfig, 
ProxyContext.getInstance().getMetaData(schemaName).getResource());
-        rdlUpdater.updateCurrentRuleConfiguration(schemaName, sqlStatement, 
currentRuleConfig);
+        if (rdlUpdater.updateCurrentRuleConfiguration(schemaName, 
sqlStatement, currentRuleConfig)) {
+            
ProxyContext.getInstance().getMetaData(schemaName).getRuleMetaData().getConfigurations().remove(currentRuleConfig);
+        }
         postRuleConfigurationChange(schemaName);
         return new UpdateResponseHeader(sqlStatement);
     }
@@ -84,13 +83,4 @@ public abstract class RDLBackendHandler<T extends 
SQLStatement, R extends Schema
         ShardingSphereEventBus.getInstance().post(
                 new RuleConfigurationsAlteredSQLNotificationEvent(schemaName, 
ProxyContext.getInstance().getMetaData(schemaName).getRuleMetaData().getConfigurations()));
     }
-    
-    protected final Collection<String> getNotExistedResources(final String 
schemaName, final Collection<String> resourceNames) {
-        return resourceNames.stream().filter(each -> 
!isExistedResource(schemaName, each)).collect(Collectors.toSet());
-    }
-    
-    private boolean isExistedResource(final String schemaName, final String 
resourceName) {
-        ShardingSphereResource resource = 
ProxyContext.getInstance().getMetaData(schemaName).getResource();
-        return resource.getDataSources().containsKey(resourceName);
-    }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterDatabaseDiscoveryRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterDatabaseDiscoveryRuleStatementUpdater.java
index 75fb92f..2c97f4f 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterDatabaseDiscoveryRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterDatabaseDiscoveryRuleStatementUpdater.java
@@ -103,9 +103,10 @@ public final class 
AlterDatabaseDiscoveryRuleStatementUpdater implements RDLUpda
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
AlterDatabaseDiscoveryRuleStatement sqlStatement, final 
DatabaseDiscoveryRuleConfiguration currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final AlterDatabaseDiscoveryRuleStatement sqlStatement, final 
DatabaseDiscoveryRuleConfiguration currentRuleConfig) {
         dropRuleConfiguration(sqlStatement, currentRuleConfig);
         addRuleConfiguration(sqlStatement, currentRuleConfig);
+        return false;
     }
     
     private void dropRuleConfiguration(final 
AlterDatabaseDiscoveryRuleStatement sqlStatement, final 
DatabaseDiscoveryRuleConfiguration currentRuleConfig) {
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterEncryptRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterEncryptRuleStatementUpdater.java
index d498638..3325787 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterEncryptRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterEncryptRuleStatementUpdater.java
@@ -87,9 +87,10 @@ public final class AlterEncryptRuleStatementUpdater 
implements RDLUpdater<AlterE
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
AlterEncryptRuleStatement sqlStatement, final EncryptRuleConfiguration 
currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final AlterEncryptRuleStatement sqlStatement, final EncryptRuleConfiguration 
currentRuleConfig) {
         dropRuleConfiguration(sqlStatement, currentRuleConfig);
         addRuleConfiguration(sqlStatement, currentRuleConfig);
+        return false;
     }
     
     private void dropRuleConfiguration(final AlterEncryptRuleStatement 
sqlStatement, final EncryptRuleConfiguration currentRuleConfig) {
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterReadwriteSplittingRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterReadwriteSplittingRuleStatementUpdater.java
index 8621309..a26c66c 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterReadwriteSplittingRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterReadwriteSplittingRuleStatementUpdater.java
@@ -99,9 +99,10 @@ public final class 
AlterReadwriteSplittingRuleStatementUpdater implements RDLUpd
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
AlterReadwriteSplittingRuleStatement sqlStatement, final 
ReadwriteSplittingRuleConfiguration currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final AlterReadwriteSplittingRuleStatement sqlStatement, final 
ReadwriteSplittingRuleConfiguration currentRuleConfig) {
         dropRuleConfiguration(sqlStatement, currentRuleConfig);
         addRuleConfiguration(sqlStatement, currentRuleConfig);
+        return false;
     }
     
     private void dropRuleConfiguration(final 
AlterReadwriteSplittingRuleStatement sqlStatement, final 
ReadwriteSplittingRuleConfiguration currentRuleConfig) {
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterShardingBindingTableRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterShardingBindingTableRuleStatementUpdater.java
index b722ab6..39a0e78 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterShardingBindingTableRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterShardingBindingTableRuleStatementUpdater.java
@@ -75,9 +75,10 @@ public final class 
AlterShardingBindingTableRuleStatementUpdater implements RDLU
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
AlterShardingBindingTableRulesStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final AlterShardingBindingTableRulesStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
         dropRuleConfiguration(currentRuleConfig);
         addRuleConfiguration(sqlStatement, currentRuleConfig);
+        return false;
     }
     
     private void dropRuleConfiguration(final ShardingRuleConfiguration 
currentRuleConfig) {
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterShardingBroadcastTableRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterShardingBroadcastTableRuleStatementUpdater.java
index 8f2f43d..5c8b8b1 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterShardingBroadcastTableRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterShardingBroadcastTableRuleStatementUpdater.java
@@ -41,9 +41,10 @@ public final class 
AlterShardingBroadcastTableRuleStatementUpdater implements RD
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
AlterShardingBroadcastTableRulesStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final AlterShardingBroadcastTableRulesStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
         dropRuleConfiguration(currentRuleConfig);
         addRuleConfiguration(sqlStatement, currentRuleConfig);
+        return false;
     }
     
     private void dropRuleConfiguration(final ShardingRuleConfiguration 
currentRuleConfig) {
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterShardingTableRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterShardingTableRuleStatementUpdater.java
index 7d574b1..94985cc 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterShardingTableRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/AlterShardingTableRuleStatementUpdater.java
@@ -143,9 +143,10 @@ public final class AlterShardingTableRuleStatementUpdater 
implements RDLUpdater<
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
AlterShardingTableRuleStatement sqlStatement, final ShardingRuleConfiguration 
currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final AlterShardingTableRuleStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
         dropRuleConfiguration(sqlStatement, currentRuleConfig);
         addRuleConfiguration(sqlStatement, currentRuleConfig);
+        return false;
     }
     
     private void dropRuleConfiguration(final AlterShardingTableRuleStatement 
sqlStatement, final ShardingRuleConfiguration currentRuleConfig) {
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateDatabaseDiscoveryRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateDatabaseDiscoveryRuleStatementUpdater.java
index 1c54e80..ee7b04b 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateDatabaseDiscoveryRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateDatabaseDiscoveryRuleStatementUpdater.java
@@ -97,7 +97,7 @@ public final class 
CreateDatabaseDiscoveryRuleStatementUpdater implements RDLUpd
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
CreateDatabaseDiscoveryRuleStatement sqlStatement, final 
DatabaseDiscoveryRuleConfiguration currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final CreateDatabaseDiscoveryRuleStatement sqlStatement, final 
DatabaseDiscoveryRuleConfiguration currentRuleConfig) {
         YamlDatabaseDiscoveryRuleConfiguration yamlDatabaseDiscoveryRuleConfig 
= DatabaseDiscoveryRuleStatementConverter.convert(sqlStatement.getRules());
         DatabaseDiscoveryRuleConfiguration createdDatabaseDiscoveryRuleConfig 
= new YamlRuleConfigurationSwapperEngine()
                 
.swapToRuleConfigurations(Collections.singleton(yamlDatabaseDiscoveryRuleConfig))
@@ -108,6 +108,7 @@ public final class 
CreateDatabaseDiscoveryRuleStatementUpdater implements RDLUpd
             
currentRuleConfig.getDataSources().addAll(createdDatabaseDiscoveryRuleConfig.getDataSources());
             
currentRuleConfig.getDiscoveryTypes().putAll(createdDatabaseDiscoveryRuleConfig.getDiscoveryTypes());
         }
+        return false;
     }
     
     private Collection<String> getRuleNames(final 
DatabaseDiscoveryRuleConfiguration databaseDiscoveryRuleConfiguration) {
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateEncryptRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateEncryptRuleStatementUpdater.java
index b02c247..c0a2388 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateEncryptRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateEncryptRuleStatementUpdater.java
@@ -77,7 +77,7 @@ public final class CreateEncryptRuleStatementUpdater 
implements RDLUpdater<Creat
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
CreateEncryptRuleStatement sqlStatement, final EncryptRuleConfiguration 
currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final CreateEncryptRuleStatement sqlStatement, final EncryptRuleConfiguration 
currentRuleConfig) {
         YamlEncryptRuleConfiguration yamlEncryptRuleConfiguration = 
EncryptRuleStatementConverter.convert(sqlStatement.getRules());
         EncryptRuleConfiguration createdEncryptRuleConfiguration = new 
YamlRuleConfigurationSwapperEngine()
                 
.swapToRuleConfigurations(Collections.singleton(yamlEncryptRuleConfiguration))
@@ -88,6 +88,7 @@ public final class CreateEncryptRuleStatementUpdater 
implements RDLUpdater<Creat
             
currentRuleConfig.getTables().addAll(createdEncryptRuleConfiguration.getTables());
             
currentRuleConfig.getEncryptors().putAll(createdEncryptRuleConfiguration.getEncryptors());
         }
+        return false;
     }
     
     private Collection<String> getRuleNames(final EncryptRuleConfiguration 
encryptRuleConfig) {
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateReadwriteSplittingRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateReadwriteSplittingRuleStatementUpdater.java
index fbc8b6f..1d0f68a 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateReadwriteSplittingRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateReadwriteSplittingRuleStatementUpdater.java
@@ -98,7 +98,7 @@ public final class 
CreateReadwriteSplittingRuleStatementUpdater implements RDLUp
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
CreateReadwriteSplittingRuleStatement sqlStatement, final 
ReadwriteSplittingRuleConfiguration currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final CreateReadwriteSplittingRuleStatement sqlStatement, final 
ReadwriteSplittingRuleConfiguration currentRuleConfig) {
         YamlReadwriteSplittingRuleConfiguration 
yamlReadwriteSplittingRuleConfig = 
ReadwriteSplittingRuleStatementConverter.convert(sqlStatement);
         ReadwriteSplittingRuleConfiguration 
createdReadwriteSplittingRuleConfig = new YamlRuleConfigurationSwapperEngine()
                 
.swapToRuleConfigurations(Collections.singleton(yamlReadwriteSplittingRuleConfig))
@@ -109,6 +109,7 @@ public final class 
CreateReadwriteSplittingRuleStatementUpdater implements RDLUp
             
currentRuleConfig.getDataSources().addAll(createdReadwriteSplittingRuleConfig.getDataSources());
             
currentRuleConfig.getLoadBalancers().putAll(createdReadwriteSplittingRuleConfig.getLoadBalancers());
         }
+        return false;
     }
     
     @Override
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateShardingBindingTableRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateShardingBindingTableRuleStatementUpdater.java
index bb4b23d..ed4fa4d 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateShardingBindingTableRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateShardingBindingTableRuleStatementUpdater.java
@@ -80,9 +80,10 @@ public final class 
CreateShardingBindingTableRuleStatementUpdater implements RDL
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
CreateShardingBindingTableRulesStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final CreateShardingBindingTableRulesStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
         YamlShardingRuleConfiguration yamlShardingRuleConfiguration = 
ShardingRuleStatementConverter.convert(sqlStatement);
         
currentRuleConfig.getBindingTableGroups().addAll(yamlShardingRuleConfiguration.getBindingTables());
+        return false;
     }
     
     @Override
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateShardingBroadcastTableRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateShardingBroadcastTableRuleStatementUpdater.java
index 4cf1b06..32be774 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateShardingBroadcastTableRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateShardingBroadcastTableRuleStatementUpdater.java
@@ -35,7 +35,7 @@ public final class 
CreateShardingBroadcastTableRuleStatementUpdater implements R
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
CreateShardingBroadcastTableRulesStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final CreateShardingBroadcastTableRulesStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
         if (null == currentRuleConfig) {
             ShardingRuleConfiguration shardingRuleConfiguration = new 
ShardingRuleConfiguration();
             
shardingRuleConfiguration.setBroadcastTables(sqlStatement.getTables());
@@ -46,6 +46,7 @@ public final class 
CreateShardingBroadcastTableRuleStatementUpdater implements R
             }
             
currentRuleConfig.getBroadcastTables().addAll(sqlStatement.getTables());
         }
+        return false;
     }
     
     @Override
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateShardingTableRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateShardingTableRuleStatementUpdater.java
index 2de0c42..444bbe3 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateShardingTableRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/CreateShardingTableRuleStatementUpdater.java
@@ -87,7 +87,7 @@ public final class CreateShardingTableRuleStatementUpdater 
implements RDLUpdater
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
CreateShardingTableRuleStatement sqlStatement, final ShardingRuleConfiguration 
currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final CreateShardingTableRuleStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
         ShardingRuleConfiguration shardingRuleConfig = 
(ShardingRuleConfiguration) new YamlRuleConfigurationSwapperEngine()
                 
.swapToRuleConfigurations(Collections.singleton(ShardingRuleStatementConverter.convert(sqlStatement))).iterator().next();
         if (null == currentRuleConfig) {
@@ -97,6 +97,7 @@ public final class CreateShardingTableRuleStatementUpdater 
implements RDLUpdater
             
currentRuleConfig.getShardingAlgorithms().putAll(shardingRuleConfig.getShardingAlgorithms());
             
currentRuleConfig.getKeyGenerators().putAll(shardingRuleConfig.getKeyGenerators());
         }
+        return false;
     }
     
     private Collection<String> getAllTables(final String schemaName, final 
ShardingRuleConfiguration currentRuleConfig) {
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropDatabaseDiscoveryRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropDatabaseDiscoveryRuleStatementUpdater.java
index 342749a..c821c13 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropDatabaseDiscoveryRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropDatabaseDiscoveryRuleStatementUpdater.java
@@ -17,15 +17,16 @@
 
 package org.apache.shardingsphere.proxy.backend.text.distsql.rdl.impl.updater;
 
+import com.google.common.base.Preconditions;
 import 
org.apache.shardingsphere.dbdiscovery.api.config.DatabaseDiscoveryRuleConfiguration;
 import 
org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDataSourceRuleConfiguration;
 import 
org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.DropDatabaseDiscoveryRuleStatement;
 import org.apache.shardingsphere.infra.distsql.RDLUpdater;
 import 
org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import 
org.apache.shardingsphere.proxy.backend.exception.DatabaseDiscoveryRuleNotExistedException;
 
 import java.util.Collection;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 /**
@@ -37,7 +38,7 @@ public final class DropDatabaseDiscoveryRuleStatementUpdater 
implements RDLUpdat
     public void checkSQLStatement(final String schemaName, final 
DropDatabaseDiscoveryRuleStatement sqlStatement, 
                                   final DatabaseDiscoveryRuleConfiguration 
currentRuleConfig, final ShardingSphereResource resource) {
         checkCurrentRuleConfiguration(schemaName, sqlStatement, 
currentRuleConfig);
-        checkRuleNames(schemaName, sqlStatement, currentRuleConfig);
+        checkToBeDroppedRuleNames(schemaName, sqlStatement, currentRuleConfig);
     }
     
     private void checkCurrentRuleConfiguration(final String schemaName, final 
DropDatabaseDiscoveryRuleStatement sqlStatement, final 
DatabaseDiscoveryRuleConfiguration currentRuleConfig) {
@@ -46,25 +47,23 @@ public final class 
DropDatabaseDiscoveryRuleStatementUpdater implements RDLUpdat
         }
     }
     
-    private void checkRuleNames(final String schemaName, final 
DropDatabaseDiscoveryRuleStatement sqlStatement, final 
DatabaseDiscoveryRuleConfiguration currentRuleConfig) {
-        Collection<String> existRuleNames = 
currentRuleConfig.getDataSources().stream().map(DatabaseDiscoveryDataSourceRuleConfiguration::getName).collect(Collectors.toList());
-        Collection<String> notExistedRuleNames = 
sqlStatement.getRuleNames().stream().filter(each -> 
!existRuleNames.contains(each)).collect(Collectors.toList());
+    private void checkToBeDroppedRuleNames(final String schemaName, final 
DropDatabaseDiscoveryRuleStatement sqlStatement, final 
DatabaseDiscoveryRuleConfiguration currentRuleConfig) {
+        Collection<String> currentRuleNames = 
currentRuleConfig.getDataSources().stream().map(DatabaseDiscoveryDataSourceRuleConfiguration::getName).collect(Collectors.toList());
+        Collection<String> notExistedRuleNames = 
sqlStatement.getRuleNames().stream().filter(each -> 
!currentRuleNames.contains(each)).collect(Collectors.toList());
         if (!notExistedRuleNames.isEmpty()) {
             throw new DatabaseDiscoveryRuleNotExistedException(schemaName, 
notExistedRuleNames);
         }
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
DropDatabaseDiscoveryRuleStatement sqlStatement, final 
DatabaseDiscoveryRuleConfiguration currentRuleConfig) {
-        sqlStatement.getRuleNames().forEach(each -> {
-            DatabaseDiscoveryDataSourceRuleConfiguration 
databaseDiscoveryDataSourceRuleConfig = currentRuleConfig.getDataSources()
-                    .stream().filter(dataSource -> 
dataSource.getName().equals(each)).findAny().get();
-            
currentRuleConfig.getDataSources().remove(databaseDiscoveryDataSourceRuleConfig);
-            
currentRuleConfig.getDiscoveryTypes().remove(databaseDiscoveryDataSourceRuleConfig.getDiscoveryTypeName());
-        });
-        if (currentRuleConfig.getDataSources().isEmpty()) {
-            
ProxyContext.getInstance().getMetaData(schemaName).getRuleMetaData().getConfigurations().remove(currentRuleConfig);
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final DropDatabaseDiscoveryRuleStatement sqlStatement, final 
DatabaseDiscoveryRuleConfiguration currentRuleConfig) {
+        for (String each : sqlStatement.getRuleNames()) {
+            Optional<DatabaseDiscoveryDataSourceRuleConfiguration> 
dataSourceRuleConfig = 
currentRuleConfig.getDataSources().stream().filter(dataSource -> 
dataSource.getName().equals(each)).findAny();
+            Preconditions.checkState(dataSourceRuleConfig.isPresent());
+            
currentRuleConfig.getDataSources().remove(dataSourceRuleConfig.get());
+            
currentRuleConfig.getDiscoveryTypes().remove(dataSourceRuleConfig.get().getDiscoveryTypeName());
         }
+        return currentRuleConfig.getDataSources().isEmpty();
     }
     
     @Override
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropEncryptRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropEncryptRuleStatementUpdater.java
index 4b9cdab..1a95c70 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropEncryptRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropEncryptRuleStatementUpdater.java
@@ -22,7 +22,6 @@ import 
org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfigu
 import 
org.apache.shardingsphere.encrypt.distsql.parser.statement.DropEncryptRuleStatement;
 import org.apache.shardingsphere.infra.distsql.RDLUpdater;
 import 
org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import 
org.apache.shardingsphere.proxy.backend.exception.EncryptRuleNotExistedException;
 
 import java.util.Collection;
@@ -50,15 +49,13 @@ public final class DropEncryptRuleStatementUpdater 
implements RDLUpdater<DropEnc
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
DropEncryptRuleStatement sqlStatement, final EncryptRuleConfiguration 
currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final DropEncryptRuleStatement sqlStatement, final EncryptRuleConfiguration 
currentRuleConfig) {
         sqlStatement.getTables().forEach(each -> {
             EncryptTableRuleConfiguration encryptTableRuleConfiguration = 
currentRuleConfig.getTables().stream().filter(tableRule -> 
tableRule.getName().equals(each)).findAny().get();
             
currentRuleConfig.getTables().remove(encryptTableRuleConfiguration);
             encryptTableRuleConfiguration.getColumns().forEach(column -> 
currentRuleConfig.getEncryptors().remove(column.getEncryptorName()));
         });
-        if (currentRuleConfig.getTables().isEmpty()) {
-            
ProxyContext.getInstance().getMetaData(schemaName).getRuleMetaData().getConfigurations().remove(currentRuleConfig);
-        }
+        return currentRuleConfig.getTables().isEmpty();
     }
     
     @Override
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropReadwriteSplittingRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropReadwriteSplittingRuleStatementUpdater.java
index 78ed479..661ed03 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropReadwriteSplittingRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropReadwriteSplittingRuleStatementUpdater.java
@@ -19,7 +19,6 @@ package 
org.apache.shardingsphere.proxy.backend.text.distsql.rdl.impl.updater;
 
 import org.apache.shardingsphere.infra.distsql.RDLUpdater;
 import 
org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import 
org.apache.shardingsphere.proxy.backend.exception.ReadwriteSplittingRuleNotExistedException;
 import 
org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
 import 
org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
@@ -47,15 +46,13 @@ public final class 
DropReadwriteSplittingRuleStatementUpdater implements RDLUpda
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
DropReadwriteSplittingRuleStatement sqlStatement, final 
ReadwriteSplittingRuleConfiguration currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final DropReadwriteSplittingRuleStatement sqlStatement, final 
ReadwriteSplittingRuleConfiguration currentRuleConfig) {
         sqlStatement.getRuleNames().forEach(each -> {
             ReadwriteSplittingDataSourceRuleConfiguration dataSourceRuleConfig 
= currentRuleConfig.getDataSources().stream().filter(dataSource -> 
each.equals(dataSource.getName())).findAny().get();
             currentRuleConfig.getDataSources().remove(dataSourceRuleConfig);
             
currentRuleConfig.getLoadBalancers().remove(dataSourceRuleConfig.getLoadBalancerName());
         });
-        if (currentRuleConfig.getDataSources().isEmpty()) {
-            
ProxyContext.getInstance().getMetaData(schemaName).getRuleMetaData().getConfigurations().remove(currentRuleConfig);
-        }
+        return currentRuleConfig.getDataSources().isEmpty();
     }
     
     @Override
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropShardingBindingTableRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropShardingBindingTableRuleStatementUpdater.java
index 453e49f..92bc564 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropShardingBindingTableRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropShardingBindingTableRuleStatementUpdater.java
@@ -37,8 +37,9 @@ public final class 
DropShardingBindingTableRuleStatementUpdater implements RDLUp
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
DropShardingBindingTableRulesStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final DropShardingBindingTableRulesStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
         currentRuleConfig.getBindingTableGroups().clear();
+        return false;
     }
     
     @Override
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropShardingBroadcastTableRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropShardingBroadcastTableRuleStatementUpdater.java
index ae126dd..87c1660 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropShardingBroadcastTableRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropShardingBroadcastTableRuleStatementUpdater.java
@@ -37,8 +37,9 @@ public final class 
DropShardingBroadcastTableRuleStatementUpdater implements RDL
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
DropShardingBroadcastTableRulesStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final DropShardingBroadcastTableRulesStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
         currentRuleConfig.getBroadcastTables().clear();
+        return false;
     }
     
     @Override
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropShardingTableRuleStatementUpdater.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropShardingTableRuleStatementUpdater.java
index 56c2d84..fcc7147 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropShardingTableRuleStatementUpdater.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/updater/DropShardingTableRuleStatementUpdater.java
@@ -57,10 +57,11 @@ public final class DropShardingTableRuleStatementUpdater 
implements RDLUpdater<D
     }
     
     @Override
-    public void updateCurrentRuleConfiguration(final String schemaName, final 
DropShardingTableRuleStatement sqlStatement, final ShardingRuleConfiguration 
currentRuleConfig) {
+    public boolean updateCurrentRuleConfiguration(final String schemaName, 
final DropShardingTableRuleStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
         for (String each : getDroppedTables(sqlStatement)) {
             dropShardingTable(currentRuleConfig, each);
         }
+        return false;
     }
     
     private Collection<String> getDroppedTables(final 
DropShardingTableRuleStatement sqlStatement) {

Reply via email to