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 04:12:18 UTC

[GitHub] [shardingsphere] huanghao495430759 opened a new pull request #10327: subscribe global rule configurations changed event, persist global rule configurations into registry center.

huanghao495430759 opened a new pull request #10327:
URL: https://github.com/apache/shardingsphere/pull/10327


   Fixes #10252 .
   
   - subscribe global rule configurations changed event.
   - persist global rule configurations into registry center.
   


-- 
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



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

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #10327:
URL: https://github.com/apache/shardingsphere/pull/10327#discussion_r631703764



##########
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:
       Hi @huanghao495430759 ,
   Please look at #10310, @zhujunxxxxx is on the way.




-- 
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



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

Posted by GitBox <gi...@apache.org>.
menghaoranss commented on a change in pull request #10327:
URL: https://github.com/apache/shardingsphere/pull/10327#discussion_r631674857



##########
File path: shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java
##########
@@ -90,13 +90,18 @@ private boolean isEmptyLocalConfiguration(final YamlProxyServerConfiguration ser
             entry -> swapperEngine.swapToRuleConfigurations(entry.getValue().getRules()), (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
     }
     
+    private Collection<RuleConfiguration> getGlobalRuleConfigurations(final Collection<YamlRuleConfiguration> globalRuleConfigs) {
+        return new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(globalRuleConfigs);
+    }
+    
     private ProxyConfiguration loadProxyConfiguration() {
         Collection<String> schemaNames = governanceFacade.getRegistryCenter().getAllSchemaNames();
         Map<String, Map<String, DataSourceParameter>> schemaDataSources = loadDataSourceParametersMap(schemaNames);
         Map<String, Collection<RuleConfiguration>> schemaRules = loadSchemaRules(schemaNames);
         Properties props = governanceFacade.getRegistryCenter().loadProperties();
         // TODO load global rules from reg center

Review comment:
       `TODO` should be removed in next PR.




-- 
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



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

Posted by GitBox <gi...@apache.org>.
menghaoranss commented on a change in pull request #10327:
URL: https://github.com/apache/shardingsphere/pull/10327#discussion_r631645797



##########
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:
       Should `metaDataContexts.getUsers()` be retrieved from newGlobalConfigs?




-- 
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



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

Posted by GitBox <gi...@apache.org>.
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



[GitHub] [shardingsphere] menghaoranss merged pull request #10327: subscribe global rule configurations changed event, persist global rule configurations into registry center.

Posted by GitBox <gi...@apache.org>.
menghaoranss merged pull request #10327:
URL: https://github.com/apache/shardingsphere/pull/10327


   


-- 
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



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

Posted by GitBox <gi...@apache.org>.
huanghao495430759 commented on a change in pull request #10327:
URL: https://github.com/apache/shardingsphere/pull/10327#discussion_r631662000



##########
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:
       > Should `metaDataContexts.getUsers()` be retrieved from newGlobalConfigs?
   
   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



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

Posted by GitBox <gi...@apache.org>.
huanghao495430759 commented on a change in pull request #10327:
URL: https://github.com/apache/shardingsphere/pull/10327#discussion_r631706449



##########
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:
       OK, I see.




-- 
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