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

yx9o 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 bffc2b95856  Extract DatabaseRuleConfigurationManager from 
ConfigurationManager (#32070)
bffc2b95856 is described below

commit bffc2b9585657b07117158b570bfcb5afd4064b2
Author: Haoran Meng <menghaora...@gmail.com>
AuthorDate: Fri Jul 12 11:55:09 2024 +0800

     Extract DatabaseRuleConfigurationManager from ConfigurationManager (#32070)
    
    * Extract DatabaseRuleConfigurationManager from ConfigurationManager
    
    * fix checkstyle
---
 .../mode/metadata/MetaDataContextManager.java      |   6 +-
 .../metadata/manager/ConfigurationManager.java     |  75 -------------
 ....java => DatabaseRuleConfigurationManager.java} | 123 ++-------------------
 .../mode/metadata/manager/RuleItemManager.java     |  10 +-
 .../StandaloneMetaDataManagerPersistService.java   |   2 +-
 5 files changed, 18 insertions(+), 198 deletions(-)

diff --git 
a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextManager.java
 
b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextManager.java
index 9744129b548..c75242e1c9a 100644
--- 
a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextManager.java
+++ 
b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextManager.java
@@ -23,6 +23,7 @@ import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.manager.GenericSchemaManager;
 import org.apache.shardingsphere.metadata.persist.MetaDataPersistService;
 import org.apache.shardingsphere.mode.metadata.manager.ConfigurationManager;
+import 
org.apache.shardingsphere.mode.metadata.manager.DatabaseRuleConfigurationManager;
 import org.apache.shardingsphere.mode.metadata.manager.SchemaMetaDataManager;
 import org.apache.shardingsphere.mode.metadata.manager.ResourceSwitchManager;
 import org.apache.shardingsphere.mode.metadata.manager.RuleItemManager;
@@ -54,15 +55,18 @@ public class MetaDataContextManager {
     
     private final StorageUnitManager storageUnitManager;
     
+    private final DatabaseRuleConfigurationManager 
databaseRuleConfigurationManager;
+    
     public MetaDataContextManager(final AtomicReference<MetaDataContexts> 
metaDataContexts, final ComputeNodeInstanceContext computeNodeInstanceContext,
                                   final PersistRepository repository) {
         this.metaDataContexts = metaDataContexts;
         resourceSwitchManager = new ResourceSwitchManager();
         databaseManager = new 
ShardingSphereDatabaseDataManager(metaDataContexts);
         storageUnitManager = new StorageUnitManager(metaDataContexts, 
computeNodeInstanceContext, repository, resourceSwitchManager);
+        databaseRuleConfigurationManager = new 
DatabaseRuleConfigurationManager(metaDataContexts, computeNodeInstanceContext, 
repository);
         configurationManager = new ConfigurationManager(metaDataContexts, 
computeNodeInstanceContext, repository);
         schemaMetaDataManager = new SchemaMetaDataManager(metaDataContexts, 
repository);
-        ruleItemManager = new RuleItemManager(metaDataContexts, repository, 
configurationManager);
+        ruleItemManager = new RuleItemManager(metaDataContexts, repository, 
databaseRuleConfigurationManager);
         metaDataPersistService = new MetaDataPersistService(repository);
     }
     
diff --git 
a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/ConfigurationManager.java
 
b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/ConfigurationManager.java
index 527a11b52a0..78d100e9f91 100644
--- 
a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/ConfigurationManager.java
+++ 
b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/ConfigurationManager.java
@@ -23,7 +23,6 @@ import 
org.apache.shardingsphere.infra.config.database.DatabaseConfiguration;
 import 
org.apache.shardingsphere.infra.config.database.impl.DataSourceProvidedDatabaseConfiguration;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import 
org.apache.shardingsphere.infra.config.rule.scope.DatabaseRuleConfiguration;
 import 
org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties;
 import org.apache.shardingsphere.infra.instance.ComputeNodeInstanceContext;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
@@ -34,9 +33,7 @@ import 
org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUn
 import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.manager.GenericSchemaManager;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
-import org.apache.shardingsphere.infra.rule.PartialRuleUpdateSupported;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import 
org.apache.shardingsphere.infra.rule.builder.database.DatabaseRulesBuilder;
 import org.apache.shardingsphere.infra.rule.builder.global.GlobalRulesBuilder;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import 
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine;
@@ -81,72 +78,6 @@ public final class ConfigurationManager {
         metaDataPersistService = new MetaDataPersistService(repository);
     }
     
-    /**
-     * Alter rule configuration.
-     *
-     * @param databaseName database name
-     * @param ruleConfig rule configurations
-     */
-    @SuppressWarnings({"unchecked", "rawtypes"})
-    public synchronized void alterRuleConfiguration(final String databaseName, 
final RuleConfiguration ruleConfig) {
-        ShardingSphereDatabase database = 
metaDataContexts.get().getMetaData().getDatabase(databaseName);
-        Collection<ShardingSphereRule> rules = new 
LinkedList<>(database.getRuleMetaData().getRules());
-        Optional<ShardingSphereRule> toBeChangedRule = 
rules.stream().filter(each -> 
each.getConfiguration().getClass().equals(ruleConfig.getClass())).findFirst();
-        if (toBeChangedRule.isPresent() && toBeChangedRule.get() instanceof 
PartialRuleUpdateSupported && ((PartialRuleUpdateSupported) 
toBeChangedRule.get()).partialUpdate(ruleConfig)) {
-            ((PartialRuleUpdateSupported) 
toBeChangedRule.get()).updateConfiguration(ruleConfig);
-            return;
-        }
-        try {
-            rules.removeIf(each -> 
each.getConfiguration().getClass().isAssignableFrom(ruleConfig.getClass()));
-            rules.addAll(DatabaseRulesBuilder.build(databaseName, 
database.getProtocolType(), database.getRuleMetaData().getRules(),
-                    ruleConfig, computeNodeInstanceContext, 
database.getResourceMetaData()));
-            refreshMetadata(databaseName, database, rules);
-        } catch (final SQLException ex) {
-            log.error("Alter database: {} rule configurations failed", 
databaseName, ex);
-        }
-    }
-    
-    /**
-     * Drop rule configuration.
-     *
-     * @param databaseName database name
-     * @param ruleConfig rule configurations
-     */
-    @SuppressWarnings({"unchecked", "rawtypes"})
-    public synchronized void dropRuleConfiguration(final String databaseName, 
final RuleConfiguration ruleConfig) {
-        ShardingSphereDatabase database = 
metaDataContexts.get().getMetaData().getDatabase(databaseName);
-        Collection<ShardingSphereRule> rules = new 
LinkedList<>(database.getRuleMetaData().getRules());
-        Optional<ShardingSphereRule> toBeChangedRule = 
rules.stream().filter(each -> 
each.getConfiguration().getClass().equals(ruleConfig.getClass())).findFirst();
-        if (toBeChangedRule.isPresent() && toBeChangedRule.get() instanceof 
PartialRuleUpdateSupported && ((PartialRuleUpdateSupported) 
toBeChangedRule.get()).partialUpdate(ruleConfig)) {
-            ((PartialRuleUpdateSupported) 
toBeChangedRule.get()).updateConfiguration(ruleConfig);
-            return;
-        }
-        try {
-            rules.removeIf(each -> 
each.getConfiguration().getClass().isAssignableFrom(ruleConfig.getClass()));
-            if (!((DatabaseRuleConfiguration) ruleConfig).isEmpty()) {
-                rules.addAll(DatabaseRulesBuilder.build(databaseName, 
database.getProtocolType(), database.getRuleMetaData().getRules(),
-                        ruleConfig, computeNodeInstanceContext, 
database.getResourceMetaData()));
-            }
-            refreshMetadata(databaseName, database, rules);
-        } catch (final SQLException ex) {
-            log.error("Drop database: {} rule configurations failed", 
databaseName, ex);
-        }
-    }
-    
-    private void refreshMetadata(final String databaseName, final 
ShardingSphereDatabase database, final Collection<ShardingSphereRule> rules) 
throws SQLException {
-        database.getRuleMetaData().getRules().clear();
-        database.getRuleMetaData().getRules().addAll(rules);
-        MetaDataContexts reloadMetaDataContexts = 
createMetaDataContextsByAlterRule(databaseName, 
database.getRuleMetaData().getConfigurations());
-        metaDataContexts.set(reloadMetaDataContexts);
-        
metaDataContexts.get().getMetaData().getDatabase(databaseName).getSchemas().putAll(buildShardingSphereSchemas(metaDataContexts.get().getMetaData().getDatabase(databaseName)));
-    }
-    
-    private MetaDataContexts createMetaDataContextsByAlterRule(final String 
databaseName, final Collection<RuleConfiguration> ruleConfigs) throws 
SQLException {
-        Map<String, ShardingSphereDatabase> changedDatabases = 
createChangedDatabases(databaseName, false, null, ruleConfigs);
-        return newMetaDataContexts(new 
ShardingSphereMetaData(changedDatabases, 
metaDataContexts.get().getMetaData().getGlobalResourceMetaData(),
-                metaDataContexts.get().getMetaData().getGlobalRuleMetaData(), 
metaDataContexts.get().getMetaData().getProps()));
-    }
-    
     /**
      * Alter schema meta data.
      *
@@ -267,12 +198,6 @@ public final class ConfigurationManager {
                 : ExternalMetaDataFactory.create(databaseName, databaseConfig, 
props, computeNodeInstanceContext);
     }
     
-    private Map<String, ShardingSphereSchema> buildShardingSphereSchemas(final 
ShardingSphereDatabase database) {
-        Map<String, ShardingSphereSchema> result = new 
LinkedHashMap<>(database.getSchemas().size(), 1F);
-        database.getSchemas().forEach((key, value) -> result.put(key, new 
ShardingSphereSchema(value.getTables(), value.getViews())));
-        return result;
-    }
-    
     /**
      * Alter global rule configuration.
      *
diff --git 
a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/ConfigurationManager.java
 
b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/DatabaseRuleConfigurationManager.java
similarity index 64%
copy from 
mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/ConfigurationManager.java
copy to 
mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/DatabaseRuleConfigurationManager.java
index 527a11b52a0..e19f5f7bc04 100644
--- 
a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/ConfigurationManager.java
+++ 
b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/DatabaseRuleConfigurationManager.java
@@ -17,7 +17,6 @@
 
 package org.apache.shardingsphere.mode.metadata.manager;
 
-import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.infra.config.database.DatabaseConfiguration;
 import 
org.apache.shardingsphere.infra.config.database.impl.DataSourceProvidedDatabaseConfiguration;
@@ -31,23 +30,16 @@ import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
 import 
org.apache.shardingsphere.infra.metadata.database.resource.node.StorageNode;
 import 
org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
-import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
-import 
org.apache.shardingsphere.infra.metadata.database.schema.manager.GenericSchemaManager;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.rule.PartialRuleUpdateSupported;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import 
org.apache.shardingsphere.infra.rule.builder.database.DatabaseRulesBuilder;
-import org.apache.shardingsphere.infra.rule.builder.global.GlobalRulesBuilder;
-import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
-import 
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine;
 import org.apache.shardingsphere.metadata.factory.ExternalMetaDataFactory;
 import org.apache.shardingsphere.metadata.factory.InternalMetaDataFactory;
 import org.apache.shardingsphere.metadata.persist.MetaDataPersistService;
 import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
 import org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory;
 import org.apache.shardingsphere.mode.spi.PersistRepository;
-import org.apache.shardingsphere.mode.tuple.annotation.RepositoryTupleEntity;
-import org.apache.shardingsphere.transaction.rule.TransactionRule;
 
 import javax.sql.DataSource;
 import java.sql.SQLException;
@@ -56,17 +48,15 @@ import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Objects;
 import java.util.Optional;
-import java.util.Properties;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
 /**
- * Configuration context manager.
+ * Database rule configuration manager.
  */
 @Slf4j
-public final class ConfigurationManager {
+public final class DatabaseRuleConfigurationManager {
     
     private final AtomicReference<MetaDataContexts> metaDataContexts;
     
@@ -74,8 +64,8 @@ public final class ConfigurationManager {
     
     private final MetaDataPersistService metaDataPersistService;
     
-    public ConfigurationManager(final AtomicReference<MetaDataContexts> 
metaDataContexts, final ComputeNodeInstanceContext computeNodeInstanceContext,
-                                final PersistRepository repository) {
+    public DatabaseRuleConfigurationManager(final 
AtomicReference<MetaDataContexts> metaDataContexts, final 
ComputeNodeInstanceContext computeNodeInstanceContext,
+                                            final PersistRepository 
repository) {
         this.metaDataContexts = metaDataContexts;
         this.computeNodeInstanceContext = computeNodeInstanceContext;
         metaDataPersistService = new MetaDataPersistService(repository);
@@ -147,33 +137,7 @@ public final class ConfigurationManager {
                 metaDataContexts.get().getMetaData().getGlobalRuleMetaData(), 
metaDataContexts.get().getMetaData().getProps()));
     }
     
-    /**
-     * Alter schema meta data.
-     *
-     * @param databaseName database name
-     * @param reloadDatabase reload database
-     * @param currentDatabase current database
-     * @param isDropConfig is drop configuration
-     */
-    public void alterSchemaMetaData(final String databaseName, final 
ShardingSphereDatabase reloadDatabase, final ShardingSphereDatabase 
currentDatabase, final boolean isDropConfig) {
-        Map<String, ShardingSphereSchema> toBeAlterSchemas = 
GenericSchemaManager.getToBeDeletedTablesBySchemas(reloadDatabase.getSchemas(), 
currentDatabase.getSchemas());
-        Map<String, ShardingSphereSchema> toBeAddedSchemas = 
GenericSchemaManager.getToBeAddedTablesBySchemas(reloadDatabase.getSchemas(), 
currentDatabase.getSchemas());
-        if (isDropConfig) {
-            toBeAddedSchemas.forEach((key, value) -> 
metaDataPersistService.getDatabaseMetaDataService().persistByDropConfiguration(databaseName,
 key, value));
-        } else {
-            toBeAddedSchemas.forEach((key, value) -> 
metaDataPersistService.getDatabaseMetaDataService().persistByAlterConfiguration(databaseName,
 key, value));
-        }
-        toBeAlterSchemas.forEach((key, value) -> 
metaDataPersistService.getDatabaseMetaDataService().delete(databaseName, key, 
value));
-    }
-    
-    /**
-     * Get effective resource meta data.
-     *
-     * @param database database
-     * @param resource resource
-     * @return effective resource meta data
-     */
-    public ResourceMetaData getEffectiveResourceMetaData(final 
ShardingSphereDatabase database, final SwitchingResource resource) {
+    private ResourceMetaData getEffectiveResourceMetaData(final 
ShardingSphereDatabase database, final SwitchingResource resource) {
         Map<StorageNode, DataSource> storageNodes = 
getStorageNodes(database.getResourceMetaData().getDataSources(), resource);
         Map<String, StorageUnit> storageUnits = 
getStorageUnits(database.getResourceMetaData().getStorageUnits(), resource);
         return new ResourceMetaData(storageNodes, storageUnits);
@@ -199,37 +163,8 @@ public final class ConfigurationManager {
         return result;
     }
     
-    /**
-     * Create meta data contexts.
-     *
-     * @param databaseName database name
-     * @param internalLoadMetaData internal load meta data
-     * @param switchingResource switching resource
-     * @param ruleConfigs rule configs
-     * @return MetaDataContexts meta data contexts
-     * @throws SQLException SQL exception
-     */
-    public MetaDataContexts createMetaDataContexts(final String databaseName, 
final boolean internalLoadMetaData,
-                                                   final SwitchingResource 
switchingResource, final Collection<RuleConfiguration> ruleConfigs) throws 
SQLException {
-        Map<String, ShardingSphereDatabase> changedDatabases = 
createChangedDatabases(databaseName, internalLoadMetaData, switchingResource, 
ruleConfigs);
-        ConfigurationProperties props = 
metaDataContexts.get().getMetaData().getProps();
-        RuleMetaData changedGlobalMetaData = new RuleMetaData(
-                
GlobalRulesBuilder.buildRules(metaDataContexts.get().getMetaData().getGlobalRuleMetaData().getConfigurations(),
 changedDatabases, props));
-        return newMetaDataContexts(new 
ShardingSphereMetaData(changedDatabases, 
metaDataContexts.get().getMetaData().getGlobalResourceMetaData(), 
changedGlobalMetaData, props));
-    }
-    
-    /**
-     * Create changed databases.
-     *
-     * @param databaseName database name
-     * @param internalLoadMetaData internal load meta data
-     * @param switchingResource switching resource
-     * @param ruleConfigs rule configs
-     * @return ShardingSphere databases
-     * @throws SQLException SQL exception
-     */
-    public synchronized Map<String, ShardingSphereDatabase> 
createChangedDatabases(final String databaseName, final boolean 
internalLoadMetaData,
-                                                                               
    final SwitchingResource switchingResource, final 
Collection<RuleConfiguration> ruleConfigs) throws SQLException {
+    private synchronized Map<String, ShardingSphereDatabase> 
createChangedDatabases(final String databaseName, final boolean 
internalLoadMetaData,
+                                                                               
     final SwitchingResource switchingResource, final 
Collection<RuleConfiguration> ruleConfigs) throws SQLException {
         ResourceMetaData effectiveResourceMetaData = 
getEffectiveResourceMetaData(metaDataContexts.get().getMetaData().getDatabase(databaseName),
 switchingResource);
         Collection<RuleConfiguration> toBeCreatedRuleConfigs = null == 
ruleConfigs
                 ? 
metaDataContexts.get().getMetaData().getDatabase(databaseName).getRuleMetaData().getConfigurations()
@@ -273,50 +208,6 @@ public final class ConfigurationManager {
         return result;
     }
     
-    /**
-     * Alter global rule configuration.
-     *
-     * @param ruleConfig global rule configuration
-     */
-    public synchronized void alterGlobalRuleConfiguration(final 
RuleConfiguration ruleConfig) {
-        if (null == ruleConfig) {
-            return;
-        }
-        closeStaleTransactionRule(ruleConfig);
-        Collection<ShardingSphereRule> rules = new 
LinkedList<>(metaDataContexts.get().getMetaData().getGlobalRuleMetaData().getRules());
-        rules.removeIf(each -> 
each.getConfiguration().getClass().isAssignableFrom(ruleConfig.getClass()));
-        rules.addAll(GlobalRulesBuilder.buildSingleRules(ruleConfig, 
metaDataContexts.get().getMetaData().getDatabases(), 
metaDataContexts.get().getMetaData().getProps()));
-        
metaDataContexts.get().getMetaData().getGlobalRuleMetaData().getRules().clear();
-        
metaDataContexts.get().getMetaData().getGlobalRuleMetaData().getRules().addAll(rules);
-        ShardingSphereMetaData toBeChangedMetaData = new 
ShardingSphereMetaData(metaDataContexts.get().getMetaData().getDatabases(), 
metaDataContexts.get().getMetaData().getGlobalResourceMetaData(),
-                metaDataContexts.get().getMetaData().getGlobalRuleMetaData(), 
metaDataContexts.get().getMetaData().getProps());
-        metaDataContexts.set(newMetaDataContexts(toBeChangedMetaData));
-    }
-    
-    // Optimize string comparison rule type.
-    @SneakyThrows(Exception.class)
-    private void closeStaleTransactionRule(final RuleConfiguration ruleConfig) 
{
-        YamlRuleConfiguration yamlRuleConfig = new 
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfiguration(ruleConfig);
-        if 
(!"transaction".equals(Objects.requireNonNull(yamlRuleConfig.getClass().getAnnotation(RepositoryTupleEntity.class)).value()))
 {
-            return;
-        }
-        Optional<TransactionRule> transactionRule = 
metaDataContexts.get().getMetaData().getGlobalRuleMetaData().findSingleRule(TransactionRule.class);
-        if (transactionRule.isPresent()) {
-            ((AutoCloseable) transactionRule.get()).close();
-        }
-    }
-    
-    /**
-     * Alter properties.
-     *
-     * @param props properties to be altered
-     */
-    public synchronized void alterProperties(final Properties props) {
-        ShardingSphereMetaData toBeChangedMetaData = new 
ShardingSphereMetaData(metaDataContexts.get().getMetaData().getDatabases(), 
metaDataContexts.get().getMetaData().getGlobalResourceMetaData(),
-                metaDataContexts.get().getMetaData().getGlobalRuleMetaData(), 
new ConfigurationProperties(props));
-        metaDataContexts.set(newMetaDataContexts(toBeChangedMetaData));
-    }
-    
     private MetaDataContexts newMetaDataContexts(final ShardingSphereMetaData 
metaData) {
         return MetaDataContextsFactory.create(metaDataPersistService, 
metaData);
     }
diff --git 
a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/RuleItemManager.java
 
b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/RuleItemManager.java
index 9d6aac35ab9..6e189a811ee 100644
--- 
a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/RuleItemManager.java
+++ 
b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/RuleItemManager.java
@@ -35,13 +35,13 @@ public class RuleItemManager {
     
     private final AtomicReference<MetaDataContexts> metaDataContexts;
     
-    private final ConfigurationManager configurationManager;
+    private final DatabaseRuleConfigurationManager ruleConfigurationManager;
     
     private final MetaDataPersistService metaDataPersistService;
     
-    public RuleItemManager(final AtomicReference<MetaDataContexts> 
metaDataContexts, final PersistRepository repository, final 
ConfigurationManager configurationManager) {
+    public RuleItemManager(final AtomicReference<MetaDataContexts> 
metaDataContexts, final PersistRepository repository, final 
DatabaseRuleConfigurationManager ruleConfigurationManager) {
         this.metaDataContexts = metaDataContexts;
-        this.configurationManager = configurationManager;
+        this.ruleConfigurationManager = ruleConfigurationManager;
         metaDataPersistService = new MetaDataPersistService(repository);
     }
     
@@ -63,7 +63,7 @@ public class RuleItemManager {
         RuleConfiguration currentRuleConfig = 
processor.findRuleConfiguration(metaDataContexts.get().getMetaData().getDatabase(databaseName));
         synchronized (this) {
             processor.changeRuleItemConfiguration(event, currentRuleConfig, 
processor.swapRuleItemConfiguration(event, yamlContent));
-            configurationManager.alterRuleConfiguration(databaseName, 
currentRuleConfig);
+            ruleConfigurationManager.alterRuleConfiguration(databaseName, 
currentRuleConfig);
         }
     }
     
@@ -82,7 +82,7 @@ public class RuleItemManager {
         RuleConfiguration currentRuleConfig = 
processor.findRuleConfiguration(metaDataContexts.get().getMetaData().getDatabase(databaseName));
         synchronized (this) {
             processor.dropRuleItemConfiguration(event, currentRuleConfig);
-            configurationManager.dropRuleConfiguration(databaseName, 
currentRuleConfig);
+            ruleConfigurationManager.dropRuleConfiguration(databaseName, 
currentRuleConfig);
         }
     }
 }
diff --git 
a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/persist/StandaloneMetaDataManagerPersistService.java
 
b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/persist/StandaloneMetaDataManagerPersistService.java
index 2f8216509fa..b9b6dd3b81b 100644
--- 
a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/persist/StandaloneMetaDataManagerPersistService.java
+++ 
b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/persist/StandaloneMetaDataManagerPersistService.java
@@ -273,7 +273,7 @@ public final class StandaloneMetaDataManagerPersistService 
implements MetaDataMa
         Collection<MetaDataVersion> metaDataVersions = 
metaDataPersistService.getDatabaseRulePersistService()
                 
.persistConfigurations(metaDataContextManager.getMetaDataContexts().get().getMetaData().getDatabase(databaseName).getName(),
 ruleConfigs);
         
metaDataPersistService.getMetaDataVersionPersistService().switchActiveVersion(metaDataVersions);
-        
metaDataContextManager.getConfigurationManager().alterRuleConfiguration(databaseName,
 ruleConfigs.iterator().next());
+        
metaDataContextManager.getDatabaseRuleConfigurationManager().alterRuleConfiguration(databaseName,
 ruleConfigs.iterator().next());
         clearServiceCache();
     }
     

Reply via email to