You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/05/13 08:46:30 UTC

[GitHub] [shardingsphere] huanghao495430759 commented on a change in pull request #10327: subscribe global rule configurations changed event, persist global rule configurations into registry center.

huanghao495430759 commented on a change in pull request #10327:
URL: https://github.com/apache/shardingsphere/pull/10327#discussion_r631661528



##########
File path: shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContexts.java
##########
@@ -320,6 +322,22 @@ public synchronized void renew(final PrimaryStateChangedEvent event) {
         }
     }
     
+    /**
+     * Renew global rule configurations.
+     *
+     * @param event global rule configurations changed event
+     */
+    @Subscribe
+    public synchronized void renew(final GlobalRuleConfigurationsChangedEvent event) {
+        Collection<RuleConfiguration> newGlobalConfigs = event.getRuleConfigurations();
+        if (!newGlobalConfigs.isEmpty()) {
+            ShardingSphereRuleMetaData newGlobalRuleMetaData = new ShardingSphereRuleMetaData(newGlobalConfigs,
+                    ShardingSphereRulesBuilder.buildGlobalRules(newGlobalConfigs, metaDataContexts.getMetaDataMap()));
+            metaDataContexts = new StandardMetaDataContexts(
+                    metaDataContexts.getMetaDataMap(), newGlobalRuleMetaData, metaDataContexts.getExecutorEngine(), metaDataContexts.getUsers(), metaDataContexts.getProps());

Review comment:
       because `user `  had save into global authority rule ,so field `ShardingSphereUsers ` in  `StandardMetaDataContexts` will be remove at the next step




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org