This is an automated email from the ASF dual-hosted git repository.
menghaoran 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 55a35ff Add GlobalRuleConfiguration and SchemaRuleConfiguration
interfaces (#10763)
55a35ff is described below
commit 55a35ff62a74193e796a4c99703350c2c774b37c
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Jun 11 16:47:51 2021 +0800
Add GlobalRuleConfiguration and SchemaRuleConfiguration interfaces (#10763)
* Refactor GovernanceShardingSphereDataSource
* Add GlobalRuleConfiguration and SchemaRuleConfiguration interfaces
---
.../api/config/DatabaseDiscoveryRuleConfiguration.java | 4 ++--
...ithmProvidedDatabaseDiscoveryRuleConfiguration.java | 4 ++--
.../encrypt/api/config/EncryptRuleConfiguration.java | 4 ++--
.../AlgorithmProvidedEncryptRuleConfiguration.java | 4 ++--
.../api/ReadwriteSplittingRuleConfiguration.java | 4 ++--
...thmProvidedReadwriteSplittingRuleConfiguration.java | 4 ++--
.../shadow/api/config/ShadowRuleConfiguration.java | 4 ++--
.../sharding/api/config/ShardingRuleConfiguration.java | 4 ++--
.../AlgorithmProvidedShardingRuleConfiguration.java | 4 ++--
.../api/config/AuthorityRuleConfiguration.java | 8 ++++----
.../infra/config/scope/GlobalRuleConfiguration.java} | 18 +++---------------
.../infra/config/scope/SchemaRuleConfiguration.java} | 18 +++---------------
.../datasource/GovernanceShardingSphereDataSource.java | 12 ++++++++----
13 files changed, 36 insertions(+), 56 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/DatabaseDiscoveryRuleConfiguration.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/DatabaseDiscoveryRuleConfiguration.java
index a34404c..6d18b9b 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/DatabaseDiscoveryRuleConfiguration.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/DatabaseDiscoveryRuleConfiguration.java
@@ -20,8 +20,8 @@ package org.apache.shardingsphere.dbdiscovery.api.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import
org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDataSourceRuleConfiguration;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
import
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.config.scope.SchemaRuleConfiguration;
import java.util.Collection;
import java.util.Map;
@@ -31,7 +31,7 @@ import java.util.Map;
*/
@RequiredArgsConstructor
@Getter
-public final class DatabaseDiscoveryRuleConfiguration implements
RuleConfiguration {
+public final class DatabaseDiscoveryRuleConfiguration implements
SchemaRuleConfiguration {
private final Collection<DatabaseDiscoveryDataSourceRuleConfiguration>
dataSources;
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/config/AlgorithmProvidedDatabaseDiscoveryRuleConfiguration.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/config/AlgorithmProvidedDatabaseDiscoveryRuleConfiguration.java
index 81c0737..1039ed3 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/config/AlgorithmProvidedDatabaseDiscoveryRuleConfiguration.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/config/AlgorithmProvidedDatabaseDiscoveryRuleConfiguration.java
@@ -23,7 +23,7 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import
org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDataSourceRuleConfiguration;
import org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryType;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
+import org.apache.shardingsphere.infra.config.scope.SchemaRuleConfiguration;
import java.util.Collection;
import java.util.LinkedHashMap;
@@ -37,7 +37,7 @@ import java.util.Map;
@AllArgsConstructor
@Getter
@Setter
-public final class AlgorithmProvidedDatabaseDiscoveryRuleConfiguration
implements RuleConfiguration {
+public final class AlgorithmProvidedDatabaseDiscoveryRuleConfiguration
implements SchemaRuleConfiguration {
private Collection<DatabaseDiscoveryDataSourceRuleConfiguration>
dataSources = new LinkedList<>();
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/api/config/EncryptRuleConfiguration.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/api/config/EncryptRuleConfiguration.java
index a27ea28..0117db7 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/api/config/EncryptRuleConfiguration.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/api/config/EncryptRuleConfiguration.java
@@ -20,8 +20,8 @@ package org.apache.shardingsphere.encrypt.api.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
import
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.config.scope.SchemaRuleConfiguration;
import java.util.Collection;
import java.util.Map;
@@ -31,7 +31,7 @@ import java.util.Map;
*/
@RequiredArgsConstructor
@Getter
-public final class EncryptRuleConfiguration implements RuleConfiguration {
+public final class EncryptRuleConfiguration implements SchemaRuleConfiguration
{
private final Collection<EncryptTableRuleConfiguration> tables;
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/config/AlgorithmProvidedEncryptRuleConfiguration.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/config/AlgorithmProvidedEncryptRuleConfiguration.java
index ec9b5b2..9e1fbeb 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/config/AlgorithmProvidedEncryptRuleConfiguration.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/config/AlgorithmProvidedEncryptRuleConfiguration.java
@@ -23,7 +23,7 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
+import org.apache.shardingsphere.infra.config.scope.SchemaRuleConfiguration;
import java.util.Collection;
import java.util.LinkedHashMap;
@@ -37,7 +37,7 @@ import java.util.Map;
@NoArgsConstructor
@Getter
@Setter
-public final class AlgorithmProvidedEncryptRuleConfiguration implements
RuleConfiguration {
+public final class AlgorithmProvidedEncryptRuleConfiguration implements
SchemaRuleConfiguration {
private Collection<EncryptTableRuleConfiguration> tables = new
LinkedList<>();
diff --git
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/main/java/org/apache/shardingsphere/readwritesplitting/api/ReadwriteSplittingRuleConfiguration.java
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/main/java/org/apache/shardingsphere/readwritesplitting/api/ReadwriteSplittingRuleConfiguration.java
index 8f6627a..d2f97d5 100644
---
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/main/java/org/apache/shardingsphere/readwritesplitting/api/ReadwriteSplittingRuleConfiguration.java
+++
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/main/java/org/apache/shardingsphere/readwritesplitting/api/ReadwriteSplittingRuleConfiguration.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.readwritesplitting.api;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
import
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.config.scope.SchemaRuleConfiguration;
import
org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
import java.util.Collection;
@@ -31,7 +31,7 @@ import java.util.Map;
*/
@RequiredArgsConstructor
@Getter
-public final class ReadwriteSplittingRuleConfiguration implements
RuleConfiguration {
+public final class ReadwriteSplittingRuleConfiguration implements
SchemaRuleConfiguration {
private final Collection<ReadwriteSplittingDataSourceRuleConfiguration>
dataSources;
diff --git
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/config/AlgorithmProvidedReadwriteSplittingRuleConfiguration.java
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/config/AlgorithmProvidedReadwriteSplittingRuleConfiguration.java
index 33f12f4..2cdc260 100644
---
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/config/AlgorithmProvidedReadwriteSplittingRuleConfiguration.java
+++
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/config/AlgorithmProvidedReadwriteSplittingRuleConfiguration.java
@@ -21,7 +21,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
+import org.apache.shardingsphere.infra.config.scope.SchemaRuleConfiguration;
import
org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
import
org.apache.shardingsphere.readwritesplitting.spi.ReplicaLoadBalanceAlgorithm;
@@ -37,7 +37,7 @@ import java.util.Map;
@NoArgsConstructor
@Getter
@Setter
-public final class AlgorithmProvidedReadwriteSplittingRuleConfiguration
implements RuleConfiguration {
+public final class AlgorithmProvidedReadwriteSplittingRuleConfiguration
implements SchemaRuleConfiguration {
private Collection<ReadwriteSplittingDataSourceRuleConfiguration>
dataSources = new LinkedList<>();
diff --git
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-api/src/main/java/org/apache/shardingsphere/shadow/api/config/ShadowRuleConfiguration.java
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-api/src/main/java/org/apache/shardingsphere/shadow/api/config/ShadowRuleConfiguration.java
index 60a16e0..07d0cfe 100644
---
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-api/src/main/java/org/apache/shardingsphere/shadow/api/config/ShadowRuleConfiguration.java
+++
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-api/src/main/java/org/apache/shardingsphere/shadow/api/config/ShadowRuleConfiguration.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.shadow.api.config;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import lombok.Getter;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
+import org.apache.shardingsphere.infra.config.scope.SchemaRuleConfiguration;
import java.util.List;
@@ -28,7 +28,7 @@ import java.util.List;
* Shadow rule configuration.
*/
@Getter
-public final class ShadowRuleConfiguration implements RuleConfiguration {
+public final class ShadowRuleConfiguration implements SchemaRuleConfiguration {
private final String column;
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/api/config/ShardingRuleConfiguration.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/api/config/ShardingRuleConfiguration.java
index a64bdb8..fa7c21f 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/api/config/ShardingRuleConfiguration.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/api/config/ShardingRuleConfiguration.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.sharding.api.config;
import lombok.Getter;
import lombok.Setter;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
import
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.config.scope.SchemaRuleConfiguration;
import
org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
import
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
@@ -36,7 +36,7 @@ import java.util.Map;
*/
@Getter
@Setter
-public final class ShardingRuleConfiguration implements RuleConfiguration {
+public final class ShardingRuleConfiguration implements
SchemaRuleConfiguration {
private Collection<ShardingTableRuleConfiguration> tables = new
LinkedList<>();
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/config/AlgorithmProvidedShardingRuleConfiguration.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/config/AlgorithmProvidedShardingRuleConfiguration.java
index bccfdf4..ee8bee8 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/config/AlgorithmProvidedShardingRuleConfiguration.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/config/AlgorithmProvidedShardingRuleConfiguration.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.sharding.algorithm.config;
import lombok.Getter;
import lombok.Setter;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
+import org.apache.shardingsphere.infra.config.scope.SchemaRuleConfiguration;
import
org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
import
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
@@ -37,7 +37,7 @@ import java.util.Map;
*/
@Getter
@Setter
-public final class AlgorithmProvidedShardingRuleConfiguration implements
RuleConfiguration {
+public final class AlgorithmProvidedShardingRuleConfiguration implements
SchemaRuleConfiguration {
private Collection<ShardingTableRuleConfiguration> tables = new
LinkedList<>();
diff --git
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-api/src/main/java/org/apache/shardingsphere/authority/api/config/AuthorityRuleConfiguration.java
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-api/src/main/java/org/apache/shardingsphere/authority/api/config/AuthorityRuleConfiguration.java
index f6d5d6a..5bb920c 100644
---
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-api/src/main/java/org/apache/shardingsphere/authority/api/config/AuthorityRuleConfiguration.java
+++
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-api/src/main/java/org/apache/shardingsphere/authority/api/config/AuthorityRuleConfiguration.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.authority.api.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
import
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.config.scope.GlobalRuleConfiguration;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import java.util.Collection;
@@ -30,9 +30,9 @@ import java.util.Collection;
*/
@RequiredArgsConstructor
@Getter
-public final class AuthorityRuleConfiguration implements RuleConfiguration {
-
+public final class AuthorityRuleConfiguration implements
GlobalRuleConfiguration {
+
private final Collection<ShardingSphereUser> users;
-
+
private final ShardingSphereAlgorithmConfiguration provider;
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-api/src/main/java/org/apache/shardingsphere/authority/api/config/AuthorityRuleConfiguration.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/scope/GlobalRuleConfiguration.java
similarity index 60%
copy from
shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-api/src/main/java/org/apache/shardingsphere/authority/api/config/AuthorityRuleConfiguration.java
copy to
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/scope/GlobalRuleConfiguration.java
index f6d5d6a..096f60e 100644
---
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-api/src/main/java/org/apache/shardingsphere/authority/api/config/AuthorityRuleConfiguration.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/scope/GlobalRuleConfiguration.java
@@ -15,24 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.api.config;
+package org.apache.shardingsphere.infra.config.scope;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
-
-import java.util.Collection;
/**
- * Authority rule configuration.
+ * Global rule configuration.
*/
-@RequiredArgsConstructor
-@Getter
-public final class AuthorityRuleConfiguration implements RuleConfiguration {
-
- private final Collection<ShardingSphereUser> users;
-
- private final ShardingSphereAlgorithmConfiguration provider;
+public interface GlobalRuleConfiguration extends RuleConfiguration {
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-api/src/main/java/org/apache/shardingsphere/authority/api/config/AuthorityRuleConfiguration.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/scope/SchemaRuleConfiguration.java
similarity index 60%
copy from
shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-api/src/main/java/org/apache/shardingsphere/authority/api/config/AuthorityRuleConfiguration.java
copy to
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/scope/SchemaRuleConfiguration.java
index f6d5d6a..d541b70 100644
---
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-api/src/main/java/org/apache/shardingsphere/authority/api/config/AuthorityRuleConfiguration.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/scope/SchemaRuleConfiguration.java
@@ -15,24 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.api.config;
+package org.apache.shardingsphere.infra.config.scope;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
-
-import java.util.Collection;
/**
- * Authority rule configuration.
+ * Schema rule configuration.
*/
-@RequiredArgsConstructor
-@Getter
-public final class AuthorityRuleConfiguration implements RuleConfiguration {
-
- private final Collection<ShardingSphereUser> users;
-
- private final ShardingSphereAlgorithmConfiguration provider;
+public interface SchemaRuleConfiguration extends RuleConfiguration {
}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSource.java
b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSource.java
index 6385994..1f2678e 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSource.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSource.java
@@ -28,6 +28,8 @@ import
org.apache.shardingsphere.infra.config.RuleConfiguration;
import
org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConverter;
import
org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
+import org.apache.shardingsphere.infra.config.scope.GlobalRuleConfiguration;
+import org.apache.shardingsphere.infra.config.scope.SchemaRuleConfiguration;
import
org.apache.shardingsphere.infra.context.metadata.MetaDataAwareEventSubscriber;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
import
org.apache.shardingsphere.infra.context.metadata.MetaDataContextsBuilder;
@@ -49,6 +51,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Properties;
+import java.util.stream.Collectors;
/**
* Governance ShardingSphere data source.
@@ -81,7 +84,7 @@ public final class GovernanceShardingSphereDataSource extends
AbstractUnsupporte
String xaTransactionMangerType =
metaDataContexts.getProps().getValue(ConfigurationPropertyKey.XA_TRANSACTION_MANAGER_TYPE);
transactionContexts =
createTransactionContexts(metaDataContexts.getDefaultMetaData().getResource().getDatabaseType(),
metaDataContexts.getDefaultMetaData().getResource().getDataSources(),
xaTransactionMangerType);
- uploadLocalConfiguration(governanceFacade);
+ uploadLocalConfiguration(governanceFacade, ruleConfigs);
}
private GovernanceFacade createGovernanceFacade(final
GovernanceConfiguration config) {
@@ -120,11 +123,12 @@ public final class GovernanceShardingSphereDataSource
extends AbstractUnsupporte
return new
StandardTransactionContexts(Collections.singletonMap(DefaultSchema.LOGIC_NAME,
engine));
}
- private void uploadLocalConfiguration(final GovernanceFacade
governanceFacade) {
+ private void uploadLocalConfiguration(final GovernanceFacade
governanceFacade, final Collection<RuleConfiguration> ruleConfigs) {
Map<String, DataSourceConfiguration> dataSourceConfigs =
DataSourceConverter.getDataSourceConfigurationMap(metaDataContexts.getDefaultMetaData().getResource().getDataSources());
- Collection<RuleConfiguration> ruleConfigurations =
metaDataContexts.getDefaultMetaData().getRuleMetaData().getConfigurations();
+ Collection<RuleConfiguration> schemaRuleConfigs =
ruleConfigs.stream().filter(each -> each instanceof
SchemaRuleConfiguration).collect(Collectors.toList());
+ Collection<RuleConfiguration> globalRuleConfigs =
ruleConfigs.stream().filter(each -> each instanceof
GlobalRuleConfiguration).collect(Collectors.toList());
governanceFacade.onlineInstance(Collections.singletonMap(DefaultSchema.LOGIC_NAME,
dataSourceConfigs),
- Collections.singletonMap(DefaultSchema.LOGIC_NAME,
ruleConfigurations),
metaDataContexts.getGlobalRuleMetaData().getConfigurations(),
metaDataContexts.getProps().getProps());
+ Collections.singletonMap(DefaultSchema.LOGIC_NAME,
schemaRuleConfigs), globalRuleConfigs, metaDataContexts.getProps().getProps());
}
@Override