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 d39fd2c  Add ClusterContextManagerBuilder and use in jdbc (#11850)
d39fd2c is described below

commit d39fd2c4d1f21363c13c791dcb4df48808029da0
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Aug 17 06:56:53 2021 +0800

    Add ClusterContextManagerBuilder and use in jdbc (#11850)
    
    * Add ClusterContextManagerBuilder
    
    * Add ClusterContextManagerBuilder
---
 .../service/impl/SchemaRulePersistService.java     |   1 +
 .../context/manager/ContextManagerBuilder.java     |  48 ++++++
 .../context/ClusterContextManagerBuilder.java      | 165 +++++++++++++++++++++
 .../GovernanceShardingSphereDataSource.java        |  75 +---------
 ...ernanceShardingSphereDataSourceFactoryTest.java |   9 +-
 ...ernanceShardingSphereDataSourceFactoryTest.java |  35 ++---
 .../fixture/TestRegistryCenterRepository.java      |   6 +-
 .../GovernanceShardingSphereDataSourceTest.java    |  12 +-
 .../registry/TestRegistryCenterRepository.java     |  84 -----------
 .../type/GovernanceSpringBootEncryptTest.java      |  16 +-
 .../GovernanceSpringBootRegistryEncryptTest.java   |   7 +-
 ...ceSpringBootRegistryReadwriteSplittingTest.java |   7 +-
 .../GovernanceSpringBootRegistryShardingTest.java  |   7 +-
 ...ernance.repository.spi.RegistryCenterRepository |  18 ---
 .../test/resources/application-encrypt.properties  |   4 +-
 .../application-readwrite-splitting.properties     |   4 +-
 ...ication-registry-readwrite-splitting.properties |   4 +-
 .../test/resources/application-registry.properties |   4 +-
 .../test/resources/application-sharding.properties |   4 +-
 .../registry/TestRegistryCenterRepository.java     |   1 -
 20 files changed, 275 insertions(+), 236 deletions(-)

diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/persist/service/impl/SchemaRulePersistService.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/persist/service/impl/SchemaRulePersistService.java
index f35c434..d9f11b9 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/persist/service/impl/SchemaRulePersistService.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/persist/service/impl/SchemaRulePersistService.java
@@ -65,6 +65,7 @@ public final class SchemaRulePersistService implements 
SchemaBasedPersistService
     @SuppressWarnings("unchecked")
     public Collection<RuleConfiguration> load(final String schemaName) {
         return isExisted(schemaName)
+                // TODO process algorithm provided configuration 
                 ? new 
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(repository.get(SchemaMetadataNode.getRulePath(schemaName)),
 Collection.class))
                 : new LinkedList<>();
     }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/manager/ContextManagerBuilder.java
 
b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/manager/ContextManagerBuilder.java
new file mode 100644
index 0000000..33488f0
--- /dev/null
+++ 
b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/manager/ContextManagerBuilder.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.context.manager;
+
+import org.apache.shardingsphere.infra.config.RuleConfiguration;
+import org.apache.shardingsphere.infra.mode.ShardingSphereMode;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Context manager builder.
+ */
+public interface ContextManagerBuilder {
+    
+    /**
+     * Build context manager.
+     * 
+     * @param mode ShardingSphere mode
+     * @param dataSources data sources
+     * @param schemaRuleConfigs schema rule configurations
+     * @param globalRuleConfigs global rule configurations
+     * @param props properties
+     * @param isOverwrite whether overwrite to persistence
+     * @return context manager
+     * @throws SQLException SQL exception
+     */
+    ContextManager build(ShardingSphereMode mode, Map<String, Map<String, 
DataSource>> dataSources,
+                         Map<String, Collection<RuleConfiguration>> 
schemaRuleConfigs, Collection<RuleConfiguration> globalRuleConfigs, Properties 
props, boolean isOverwrite) throws SQLException;
+}
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/context/ClusterContextManagerBuilder.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/context/ClusterContextManagerBuilder.java
new file mode 100644
index 0000000..99f5cfd
--- /dev/null
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/context/ClusterContextManagerBuilder.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.driver.governance.internal.context;
+
+import com.google.common.base.Preconditions;
+import org.apache.shardingsphere.governance.context.ClusterContextManager;
+import org.apache.shardingsphere.governance.core.registry.RegistryCenter;
+import 
org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
+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.context.manager.ContextManager;
+import org.apache.shardingsphere.infra.context.manager.ContextManagerBuilder;
+import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
+import 
org.apache.shardingsphere.infra.context.metadata.MetaDataContextsBuilder;
+import 
org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.mode.ShardingSphereMode;
+import org.apache.shardingsphere.infra.mode.repository.PersistRepository;
+import org.apache.shardingsphere.infra.persist.DistMetaDataPersistService;
+import org.apache.shardingsphere.transaction.ShardingTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.context.TransactionContexts;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.stream.Collectors;
+
+/**
+ * Cluster context manager builder.
+ */
+public final class ClusterContextManagerBuilder implements 
ContextManagerBuilder {
+    
+    @Override
+    public ContextManager build(final ShardingSphereMode mode, final 
Map<String, Map<String, DataSource>> dataSourcesMap,
+                                final Map<String, 
Collection<RuleConfiguration>> schemaRuleConfigs, final 
Collection<RuleConfiguration> globalRuleConfigs,
+                                final Properties props, final boolean 
isOverwrite) throws SQLException {
+        Optional<PersistRepository> persistRepository = 
mode.getPersistRepository();
+        Preconditions.checkState(persistRepository.isPresent());
+        DistMetaDataPersistService persistService = new 
DistMetaDataPersistService(persistRepository.get());
+        RegistryCenter registryCenter = new 
RegistryCenter((RegistryCenterRepository) persistRepository.get());
+        persistConfigurations(persistService, dataSourcesMap, 
schemaRuleConfigs, globalRuleConfigs, props, isOverwrite);
+        Collection<String> schemaNames = 
persistService.getSchemaMetaDataService().loadAllNames();
+        MetaDataContexts metaDataContexts;
+        // TODO isEmpty for test reg center fixture, will remove after local 
memory reg center fixture finished
+        if (schemaNames.isEmpty()) {
+            metaDataContexts = new MetaDataContextsBuilder(dataSourcesMap, 
schemaRuleConfigs, globalRuleConfigs, props).build(persistService);
+            // TODO finish TODO 
+        } else {
+            metaDataContexts = new 
MetaDataContextsBuilder(loadDataSourcesMap(persistService, dataSourcesMap, 
schemaNames), 
+                    loadSchemaRules(persistService, schemaNames), 
persistService.getGlobalRuleService().load(), 
persistService.getPropsService().load()).build(persistService);
+        }
+        TransactionContexts transactionContexts = 
createTransactionContexts(metaDataContexts);
+        ContextManager result = new ClusterContextManager(persistService, 
registryCenter);
+        result.init(metaDataContexts, transactionContexts);
+        return result;
+    }
+    
+    private void persistConfigurations(final DistMetaDataPersistService 
persistService, final Map<String, Map<String, DataSource>> dataSourcesMap,
+                                       final Map<String, 
Collection<RuleConfiguration>> schemaRuleConfigs, final 
Collection<RuleConfiguration> globalRuleConfigs,
+                                       final Properties props, final boolean 
overwrite) {
+        if (!isEmptyLocalConfiguration(dataSourcesMap, schemaRuleConfigs, 
globalRuleConfigs, props)) {
+            
persistService.persistConfigurations(getDataSourceConfigurations(dataSourcesMap),
 schemaRuleConfigs, globalRuleConfigs, props, overwrite);
+        }
+    }
+    
+    private boolean isEmptyLocalConfiguration(final Map<String, Map<String, 
DataSource>> dataSourcesMap,
+                                              final Map<String, 
Collection<RuleConfiguration>> schemaRuleConfigs, final 
Collection<RuleConfiguration> globalRuleConfigs, final Properties props) {
+        return isEmptyLocalDataSourcesMap(dataSourcesMap) && 
isEmptyLocalSchemaRuleConfigurations(schemaRuleConfigs) && 
globalRuleConfigs.isEmpty() && props.isEmpty();
+    }
+    
+    private boolean isEmptyLocalDataSourcesMap(final Map<String, Map<String, 
DataSource>> dataSourcesMap) {
+        return dataSourcesMap.entrySet().stream().allMatch(entry -> 
entry.getValue().isEmpty());
+    }
+    
+    private boolean isEmptyLocalSchemaRuleConfigurations(final Map<String, 
Collection<RuleConfiguration>> schemaRuleConfigs) {
+        return schemaRuleConfigs.entrySet().stream().allMatch(entry -> 
entry.getValue().isEmpty());
+    }
+    
+    private Map<String, Map<String, DataSourceConfiguration>> 
getDataSourceConfigurations(final Map<String, Map<String, DataSource>> 
dataSourcesMap) {
+        Map<String, Map<String, DataSourceConfiguration>> result = new 
LinkedHashMap<>(dataSourcesMap.size(), 1);
+        for (Entry<String, Map<String, DataSource>> entry : 
dataSourcesMap.entrySet()) {
+            result.put(entry.getKey(), 
DataSourceConverter.getDataSourceConfigurationMap(entry.getValue()));
+        }
+        return result;
+    }
+    
+    private Map<String, Map<String, DataSource>> loadDataSourcesMap(final 
DistMetaDataPersistService persistService, final Map<String, Map<String, 
DataSource>> dataSourcesMap,
+                                                                    final 
Collection<String> schemaNames) {
+        Map<String, Map<String, DataSourceConfiguration>> 
loadedDataSourceConfigs = loadDataSourceConfigurations(persistService, 
schemaNames);
+        Map<String, Map<String, DataSourceConfiguration>> 
changedDataSourceConfigs = getChangedDataSourceConfigurations(dataSourcesMap, 
loadedDataSourceConfigs);
+        Map<String, Map<String, DataSource>> result = new 
LinkedHashMap<>(dataSourcesMap);
+        result.putAll(getChangedDataSources(changedDataSourceConfigs));
+        return result;
+    }
+    
+    private Map<String, Map<String, DataSourceConfiguration>> 
loadDataSourceConfigurations(final DistMetaDataPersistService persistService, 
final Collection<String> schemaNames) {
+        Map<String, Map<String, DataSourceConfiguration>> result = new 
LinkedHashMap<>();
+        for (String each : schemaNames) {
+            result.put(each, persistService.getDataSourceService().load(each));
+        }
+        return result;
+    }
+    
+    // TODO finish this method
+    private Map<String, Map<String, DataSourceConfiguration>> 
getChangedDataSourceConfigurations(final Map<String, Map<String, DataSource>> 
configuredDataSourcesMap, 
+                                                                               
                  final Map<String, Map<String, DataSourceConfiguration>> 
loadedDataSourceConfigs) {
+        return isEmptyLocalDataSourcesMap(configuredDataSourcesMap) ? 
loadedDataSourceConfigs : Collections.emptyMap();
+    }
+    
+    private Map<String, Map<String, DataSource>> getChangedDataSources(final 
Map<String, Map<String, DataSourceConfiguration>> 
changedDataSourceConfigurations) {
+        Map<String, Map<String, DataSource>> result = new 
LinkedHashMap<>(changedDataSourceConfigurations.size(), 1);
+        for (Entry<String, Map<String, DataSourceConfiguration>> entry : 
changedDataSourceConfigurations.entrySet()) {
+            result.put(entry.getKey(), createDataSources(entry.getValue()));
+        }
+        return result;
+    }
+    
+    private Map<String, DataSource> createDataSources(final Map<String, 
DataSourceConfiguration> dataSourceConfigs) {
+        Map<String, DataSource> result = new 
LinkedHashMap<>(dataSourceConfigs.size(), 1);
+        for (Entry<String, DataSourceConfiguration> each : 
dataSourceConfigs.entrySet()) {
+            result.put(each.getKey(), each.getValue().createDataSource());
+        }
+        return result;
+    }
+    
+    private Map<String, Collection<RuleConfiguration>> loadSchemaRules(final 
DistMetaDataPersistService persistService, final Collection<String> 
schemaNames) {
+        return schemaNames.stream().collect(Collectors.toMap(
+            each -> each, each -> 
persistService.getSchemaRuleService().load(each), (oldValue, currentValue) -> 
oldValue, LinkedHashMap::new));
+    }
+    
+    private TransactionContexts createTransactionContexts(final 
MetaDataContexts metaDataContexts) {
+        Map<String, ShardingTransactionManagerEngine> engines = new 
HashMap<>(metaDataContexts.getAllSchemaNames().size(), 1);
+        String xaTransactionMangerType = 
metaDataContexts.getProps().getValue(ConfigurationPropertyKey.XA_TRANSACTION_MANAGER_TYPE);
+        for (String each : metaDataContexts.getAllSchemaNames()) {
+            ShardingTransactionManagerEngine engine = new 
ShardingTransactionManagerEngine();
+            ShardingSphereResource resource = 
metaDataContexts.getMetaData(each).getResource();
+            engine.init(resource.getDatabaseType(), resource.getDataSources(), 
xaTransactionMangerType);
+            engines.put(each, engine);
+        }
+        return new TransactionContexts(engines);
+    }
+}
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 fd50f1d..30b655a 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
@@ -17,30 +17,17 @@
 
 package org.apache.shardingsphere.driver.governance.internal.datasource;
 
-import com.google.common.base.Preconditions;
 import lombok.Getter;
+import 
org.apache.shardingsphere.driver.governance.internal.context.ClusterContextManagerBuilder;
 import 
org.apache.shardingsphere.driver.governance.internal.state.DriverStateContext;
 import 
org.apache.shardingsphere.driver.jdbc.unsupported.AbstractUnsupportedOperationDataSource;
-import org.apache.shardingsphere.governance.context.ClusterContextManager;
-import org.apache.shardingsphere.governance.core.registry.RegistryCenter;
-import 
org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
 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.manager.ContextManager;
-import 
org.apache.shardingsphere.infra.context.metadata.MetaDataContextsBuilder;
-import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.mode.ShardingSphereMode;
 import org.apache.shardingsphere.infra.mode.builder.ModeBuilderEngine;
 import org.apache.shardingsphere.infra.mode.config.ModeConfiguration;
-import org.apache.shardingsphere.infra.mode.repository.PersistRepository;
-import org.apache.shardingsphere.infra.persist.DistMetaDataPersistService;
-import org.apache.shardingsphere.transaction.ShardingTransactionManagerEngine;
-import org.apache.shardingsphere.transaction.context.TransactionContexts;
 import org.apache.shardingsphere.transaction.core.TransactionTypeHolder;
 
 import javax.sql.DataSource;
@@ -49,9 +36,7 @@ import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.Map;
-import java.util.Optional;
 import java.util.Properties;
 import java.util.stream.Collectors;
 
@@ -70,68 +55,18 @@ public final class GovernanceShardingSphereDataSource 
extends AbstractUnsupporte
     public GovernanceShardingSphereDataSource(final String schemaName, final 
ModeConfiguration modeConfig) throws SQLException {
         this.schemaName = schemaName;
         mode = ModeBuilderEngine.build(modeConfig);
-        Optional<PersistRepository> persistRepository = 
mode.getPersistRepository();
-        Preconditions.checkState(persistRepository.isPresent());
-        DistMetaDataPersistService persistService = new 
DistMetaDataPersistService(persistRepository.get());
-        RegistryCenter registryCenter = new 
RegistryCenter((RegistryCenterRepository) persistRepository.get());
-        MetaDataContexts metaDataContexts = 
createMetaDataContexts(persistService);
-        String xaTransactionMangerType = 
metaDataContexts.getProps().getValue(ConfigurationPropertyKey.XA_TRANSACTION_MANAGER_TYPE);
-        TransactionContexts transactionContexts = createTransactionContexts(
-                
metaDataContexts.getMetaData(schemaName).getResource().getDatabaseType(), 
metaDataContexts.getMetaData(schemaName).getResource().getDataSources(), 
xaTransactionMangerType);
-        contextManager = new ClusterContextManager(persistService, 
registryCenter);
-        contextManager.init(metaDataContexts, transactionContexts);
+        contextManager = new ClusterContextManagerBuilder().build(mode, 
+                Collections.singletonMap(schemaName, Collections.emptyMap()), 
Collections.singletonMap(schemaName, Collections.emptyList()), 
Collections.emptyList(), new Properties(), false);
     }
     
     public GovernanceShardingSphereDataSource(final String schemaName, final 
ModeConfiguration modeConfig, final Map<String, DataSource> dataSourceMap, 
                                               final 
Collection<RuleConfiguration> ruleConfigs, final Properties props) throws 
SQLException {
         this.schemaName = schemaName;
         mode = ModeBuilderEngine.build(modeConfig);
-        Optional<PersistRepository> persistRepository = 
mode.getPersistRepository();
-        Preconditions.checkState(persistRepository.isPresent());
-        DistMetaDataPersistService persistService = new 
DistMetaDataPersistService(persistRepository.get());
-        RegistryCenter registryCenter = new 
RegistryCenter((RegistryCenterRepository) persistRepository.get());
-        MetaDataContexts metaDataContexts = 
createMetaDataContexts(persistService, dataSourceMap, ruleConfigs, props);
-        String xaTransactionMangerType = 
metaDataContexts.getProps().getValue(ConfigurationPropertyKey.XA_TRANSACTION_MANAGER_TYPE);
-        TransactionContexts transactionContexts = createTransactionContexts(
-                
metaDataContexts.getMetaData(schemaName).getResource().getDatabaseType(), 
metaDataContexts.getMetaData(schemaName).getResource().getDataSources(), 
xaTransactionMangerType);
-        contextManager = new ClusterContextManager(persistService, 
registryCenter);
-        contextManager.init(metaDataContexts, transactionContexts);
-        uploadLocalConfiguration(persistService, registryCenter, ruleConfigs, 
modeConfig.isOverwrite());
-    }
-    
-    private MetaDataContexts createMetaDataContexts(final 
DistMetaDataPersistService persistService) throws SQLException {
-        Map<String, DataSourceConfiguration> dataSourceConfigs = 
persistService.getDataSourceService().load(schemaName);
-        Collection<RuleConfiguration> ruleConfigs = 
persistService.getSchemaRuleService().load(schemaName);
-        Map<String, DataSource> dataSourceMap = 
DataSourceConverter.getDataSourceMap(dataSourceConfigs);
-        MetaDataContextsBuilder metaDataContextsBuilder = new 
MetaDataContextsBuilder(Collections.singletonMap(schemaName, dataSourceMap),
-                Collections.singletonMap(schemaName, ruleConfigs), 
persistService.getGlobalRuleService().load(), 
persistService.getPropsService().load());
-        return metaDataContextsBuilder.build(persistService);
-    }
-    
-    private MetaDataContexts createMetaDataContexts(final 
DistMetaDataPersistService persistService,
-                                                    final Map<String, 
DataSource> dataSourceMap, final Collection<RuleConfiguration> ruleConfigs, 
final Properties props) throws SQLException {
-        MetaDataContextsBuilder metaDataContextsBuilder = new 
MetaDataContextsBuilder(
-                Collections.singletonMap(schemaName, dataSourceMap), 
Collections.singletonMap(schemaName, ruleConfigs), props);
-        return metaDataContextsBuilder.build(persistService);
-    }
-    
-    private TransactionContexts createTransactionContexts(final DatabaseType 
databaseType, final Map<String, DataSource> dataSourceMap, final String 
xaTransactionMangerType) {
-        ShardingTransactionManagerEngine engine = new 
ShardingTransactionManagerEngine();
-        engine.init(databaseType, dataSourceMap, xaTransactionMangerType);
-        Map<String, ShardingTransactionManagerEngine> engines = new 
HashMap<>(1, 1);
-        engines.put(schemaName, engine);
-        return new TransactionContexts(engines);
-    }
-    
-    private void uploadLocalConfiguration(final DistMetaDataPersistService 
persistService, 
-                                          final RegistryCenter registryCenter, 
final Collection<RuleConfiguration> ruleConfigs, final boolean isOverwrite) {
-        Map<String, DataSourceConfiguration> dataSourceConfigs = 
DataSourceConverter.getDataSourceConfigurationMap(
-                
contextManager.getMetaDataContexts().getMetaData(schemaName).getResource().getDataSources());
         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());
-        
persistService.persistConfigurations(Collections.singletonMap(schemaName, 
dataSourceConfigs),
-                Collections.singletonMap(schemaName, schemaRuleConfigs), 
globalRuleConfigs, contextManager.getMetaDataContexts().getProps().getProps(), 
isOverwrite);
-        registryCenter.onlineInstance(Collections.singletonList(schemaName));
+        contextManager = new ClusterContextManagerBuilder().build(mode, 
+                Collections.singletonMap(schemaName, dataSourceMap), 
Collections.singletonMap(schemaName, schemaRuleConfigs), globalRuleConfigs, 
props, modeConfig.isOverwrite());
     }
     
     @Override
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/test/java/org/apache/shardingsphere/driver/governance/api/GovernanceShardingSphereDataSourceFactoryTest.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/test/java/org/apache/shardingsphere/driver/governance/api/GovernanceShardingSphereDataSourceFactoryTest.java
index dbf0a9b..0e646b6 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/test/java/org/apache/shardingsphere/driver/governance/api/GovernanceShardingSphereDataSourceFactoryTest.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/test/java/org/apache/shardingsphere/driver/governance/api/GovernanceShardingSphereDataSourceFactoryTest.java
@@ -24,7 +24,6 @@ import 
org.apache.shardingsphere.infra.mode.config.ModeConfiguration;
 import org.junit.Test;
 
 import javax.sql.DataSource;
-import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.Collections;
@@ -68,12 +67,10 @@ public final class 
GovernanceShardingSphereDataSourceFactoryTest {
     }
     
     private DataSource createDataSource() throws SQLException {
-        DataSource result = mock(DataSource.class);
-        Connection connection = mock(Connection.class, RETURNS_DEEP_STUBS);
-        
when(connection.getMetaData().getURL()).thenReturn("jdbc:mysql://localhost:3306/mysql?serverTimezone=GMT%2B8");
+        DataSource result = mock(DataSource.class, RETURNS_DEEP_STUBS);
+        
when(result.getConnection().getMetaData().getURL()).thenReturn("jdbc:mysql://localhost:3306/mysql?serverTimezone=GMT%2B8");
         ResultSet resultSet = mock(ResultSet.class);
-        when(connection.getMetaData().getTables(null, null, null, new 
String[]{TABLE_TYPE, VIEW_TYPE})).thenReturn(resultSet);
-        when(result.getConnection()).thenReturn(connection);
+        when(result.getConnection().getMetaData().getTables(null, null, null, 
new String[]{TABLE_TYPE, VIEW_TYPE})).thenReturn(resultSet);
         return result;
     }
 }
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/test/java/org/apache/shardingsphere/driver/governance/api/yaml/YamlGovernanceShardingSphereDataSourceFactoryTest.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/test/java/org/apache/shardingsphere/driver/governance/api/yaml/YamlGovernanceShardingSphereDataSourceFactoryTest.java
index b4f91fb..6a0152a 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/test/java/org/apache/shardingsphere/driver/governance/api/yaml/YamlGovernanceShardingSphereDataSourceFactoryTest.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/test/java/org/apache/shardingsphere/driver/governance/api/yaml/YamlGovernanceShardingSphereDataSourceFactoryTest.java
@@ -29,40 +29,31 @@ import java.net.URISyntaxException;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
-import java.util.Arrays;
-import java.util.List;
 
 public final class YamlGovernanceShardingSphereDataSourceFactoryTest extends 
AbstractYamlDataSourceTest {
     
-    private static final List<String> CONFIG_FILES = Arrays.asList(
-            
"/yaml/integrate/sharding_readwrite_splitting/configWithDataSourceWithProps.yaml",
-            
"/yaml/integrate/sharding_readwrite_splitting/configWithoutDataSourceWithProps.yaml",
-            
"/yaml/integrate/sharding_readwrite_splitting/configWithDataSourceWithoutRules.yaml");
+    private static final String CONFIG_FILE = 
"/yaml/integrate/sharding_readwrite_splitting/configWithDataSourceWithProps.yaml";
     
     private static DataSource dataSource;
     
     @Test
     public void assertCreateDataSource() {
-        CONFIG_FILES.forEach(each -> {
-            try {
-                File yamlFile = new 
File(YamlGovernanceShardingSphereDataSourceFactoryTest.class.getResource(each).toURI());
-                executeSQL(yamlFile);
-            } catch (final URISyntaxException | SQLException | IOException ex) 
{
-                throw new ShardingSphereException(ex);
-            }
-        });
+        try {
+            File yamlFile = new 
File(YamlGovernanceShardingSphereDataSourceFactoryTest.class.getResource(CONFIG_FILE).toURI());
+            executeSQL(yamlFile);
+        } catch (final URISyntaxException | SQLException | IOException ex) {
+            throw new ShardingSphereException(ex);
+        }
     }
     
     @Test
     public void assertCreateDataSourceByYamlBytes() {
-        CONFIG_FILES.forEach(each -> {
-            try {
-                File yamlFile = new 
File(YamlGovernanceShardingSphereDataSourceFactoryTest.class.getResource(each).toURI());
-                executeSQL(getYamlBytes(yamlFile));
-            } catch (final URISyntaxException | SQLException | IOException ex) 
{
-                throw new ShardingSphereException(ex);
-            }
-        });
+        try {
+            File yamlFile = new 
File(YamlGovernanceShardingSphereDataSourceFactoryTest.class.getResource(CONFIG_FILE).toURI());
+            executeSQL(getYamlBytes(yamlFile));
+        } catch (final URISyntaxException | SQLException | IOException ex) {
+            throw new ShardingSphereException(ex);
+        }
     }
     
     private void executeSQL(final File yamlFile) throws SQLException, 
IOException {
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/test/java/org/apache/shardingsphere/driver/governance/fixture/TestRegistryCenterRepository.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/test/java/org/apache/shardingsphere/driver/governance/fixture/TestRegistryCenterRepository.java
index 812901d..c4a68da 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/test/java/org/apache/shardingsphere/driver/governance/fixture/TestRegistryCenterRepository.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/test/java/org/apache/shardingsphere/driver/governance/fixture/TestRegistryCenterRepository.java
@@ -17,9 +17,10 @@
 
 package org.apache.shardingsphere.driver.governance.fixture;
 
-import 
org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
 import 
org.apache.shardingsphere.governance.repository.api.config.RegistryCenterConfiguration;
 import 
org.apache.shardingsphere.governance.repository.api.listener.DataChangedEventListener;
+import 
org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
+import org.apache.shardingsphere.infra.database.DefaultSchema;
 
 import java.util.Collections;
 import java.util.LinkedHashMap;
@@ -33,6 +34,7 @@ public final class TestRegistryCenterRepository implements 
RegistryCenterReposit
     
     @Override
     public void init(final RegistryCenterConfiguration config) {
+        REGISTRY_DATA.put("/metadata", DefaultSchema.LOGIC_NAME);
     }
     
     @Override
@@ -42,7 +44,7 @@ public final class TestRegistryCenterRepository implements 
RegistryCenterReposit
     
     @Override
     public List<String> getChildrenKeys(final String key) {
-        return Collections.emptyList();
+        return REGISTRY_DATA.containsKey(key) ? 
Collections.singletonList(REGISTRY_DATA.get(key)) : Collections.emptyList();
     }
     
     @Override
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/test/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSourceTest.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/test/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSourceTest.java
index 1c86a79..eeed658 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/test/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSourceTest.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/test/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSourceTest.java
@@ -33,16 +33,10 @@ public final class GovernanceShardingSphereDataSourceTest {
     
     @Test
     public void assertInitializeGovernanceShardingSphereDataSource() throws 
SQLException {
-        assertThat(new 
GovernanceShardingSphereDataSource(DefaultSchema.LOGIC_NAME, 
getModeConfiguration()).getConnection(), instanceOf(Connection.class));
+        assertThat(new 
GovernanceShardingSphereDataSource(DefaultSchema.LOGIC_NAME, 
createModeConfiguration()).getConnection(), instanceOf(Connection.class));
     }
     
-    private static ModeConfiguration getModeConfiguration() {
-        return new ModeConfiguration("Cluster", 
getRegistryCenterConfiguration(), true);
-    }
-    
-    private static RegistryCenterConfiguration 
getRegistryCenterConfiguration() {
-        Properties properties = new Properties();
-        properties.setProperty("overwrite", "true");
-        return new RegistryCenterConfiguration("GOV_TEST", "test_name", 
"localhost:3181", properties);
+    private static ModeConfiguration createModeConfiguration() {
+        return new ModeConfiguration("Cluster", new 
RegistryCenterConfiguration("GOV_TEST", "test_name", "localhost:3181", new 
Properties()), true);
     }
 }
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/registry/TestRegistryCenterRepository.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/registry/TestRegistryCenterRepository.java
deleted file mode 100644
index a1a15e2..0000000
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/registry/TestRegistryCenterRepository.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.spring.boot.governance.registry;
-
-import 
org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
-import 
org.apache.shardingsphere.governance.repository.api.config.RegistryCenterConfiguration;
-import 
org.apache.shardingsphere.governance.repository.api.listener.DataChangedEventListener;
-
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-public final class TestRegistryCenterRepository implements 
RegistryCenterRepository {
-    
-    private static final Map<String, String> REGISTRY_DATA = new 
LinkedHashMap<>();
-    
-    @Override
-    public void init(final RegistryCenterConfiguration config) {
-    }
-    
-    @Override
-    public String get(final String key) {
-        return REGISTRY_DATA.get(key);
-    }
-    
-    @Override
-    public List<String> getChildrenKeys(final String key) {
-        return Collections.emptyList();
-    }
-    
-    @Override
-    public void persist(final String key, final String value) {
-        REGISTRY_DATA.put(key, value);
-    }
-    
-    @Override
-    public void persistEphemeral(final String key, final String value) {
-        REGISTRY_DATA.put(key, value);
-    }
-    
-    @Override
-    public boolean tryLock(final String key, final long time, final TimeUnit 
unit) {
-        return false;
-    }
-    
-    @Override
-    public void releaseLock(final String key) {
-    }
-    
-    @Override
-    public void delete(final String key) {
-    }
-    
-    @Override
-    public void watch(final String key, final DataChangedEventListener 
listener) {
-    }
-    
-    @Override
-    public void close() {
-        REGISTRY_DATA.clear();
-    }
-    
-    @Override
-    public String getType() {
-        return "TestRegistry";
-    }
-}
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootEncryptTest.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootEncryptTest.java
index 2b44593..ab55759 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootEncryptTest.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootEncryptTest.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.spring.boot.governance.type;
 
 import org.apache.commons.dbcp2.BasicDataSource;
 import 
org.apache.shardingsphere.driver.governance.internal.datasource.GovernanceShardingSphereDataSource;
-import 
org.apache.shardingsphere.encrypt.algorithm.config.AlgorithmProvidedEncryptRuleConfiguration;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
+import 
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
 import org.apache.shardingsphere.infra.context.manager.ContextManager;
 import org.apache.shardingsphere.infra.database.DefaultSchema;
 import 
org.apache.shardingsphere.spring.boot.governance.util.EmbedTestingServer;
@@ -63,12 +63,12 @@ public class GovernanceSpringBootEncryptTest {
         BasicDataSource embedDataSource = (BasicDataSource) 
contextManager.getMetaDataContexts().getMetaData(DefaultSchema.LOGIC_NAME).getResource().getDataSources().values().iterator().next();
         assertThat(embedDataSource.getMaxTotal(), is(100));
         assertThat(embedDataSource.getUsername(), is("sa"));
-        AlgorithmProvidedEncryptRuleConfiguration configuration =
-                (AlgorithmProvidedEncryptRuleConfiguration) 
contextManager.getMetaDataContexts().getMetaData(DefaultSchema.LOGIC_NAME).getRuleMetaData().getConfigurations().iterator().next();
-        assertThat(configuration.getEncryptors().size(), is(1));
-        EncryptAlgorithm encryptAlgorithm = 
configuration.getEncryptors().get("order_encrypt");
+        EncryptRuleConfiguration config =
+                (EncryptRuleConfiguration) 
contextManager.getMetaDataContexts().getMetaData(DefaultSchema.LOGIC_NAME).getRuleMetaData().getConfigurations().iterator().next();
+        assertThat(config.getEncryptors().size(), is(1));
+        ShardingSphereAlgorithmConfiguration encryptAlgorithm = 
config.getEncryptors().get("order_encrypt");
         assertThat(encryptAlgorithm.getType(), is("AES"));
-        assertThat(configuration.getTables().size(), is(1));
-        
assertThat(configuration.getTables().iterator().next().getColumns().iterator().next().getCipherColumn(),
 is("cipher_order_id"));
+        assertThat(config.getTables().size(), is(1));
+        
assertThat(config.getTables().iterator().next().getColumns().iterator().next().getCipherColumn(),
 is("cipher_order_id"));
     }
 }
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryEncryptTest.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegis
 [...]
index c28d617..1b6fe04 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryEncryptTest.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryEncryptTest.java
@@ -21,11 +21,12 @@ import lombok.SneakyThrows;
 import org.apache.commons.dbcp2.BasicDataSource;
 import 
org.apache.shardingsphere.driver.governance.internal.datasource.GovernanceShardingSphereDataSource;
 import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
+import 
org.apache.shardingsphere.governance.repository.api.config.RegistryCenterConfiguration;
+import 
org.apache.shardingsphere.governance.repository.zookeeper.CuratorZookeeperRepository;
 import 
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.context.manager.ContextManager;
 import org.apache.shardingsphere.infra.database.DefaultSchema;
-import 
org.apache.shardingsphere.spring.boot.governance.registry.TestRegistryCenterRepository;
 import 
org.apache.shardingsphere.spring.boot.governance.util.EmbedTestingServer;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -42,6 +43,7 @@ import java.lang.reflect.Field;
 import java.net.URISyntaxException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.util.Properties;
 import java.util.stream.Collectors;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
@@ -67,7 +69,8 @@ public class GovernanceSpringBootRegistryEncryptTest {
         EmbedTestingServer.start();
         String dataSource = readYAML(DATA_SOURCE_FILE);
         String encryptRule = readYAML(ENCRYPT_RULE_FILE);
-        TestRegistryCenterRepository repository = new 
TestRegistryCenterRepository();
+        CuratorZookeeperRepository repository = new 
CuratorZookeeperRepository();
+        repository.init(new RegistryCenterConfiguration("ZooKeeper", 
"governance-spring-boot-test", "localhost:3183", new Properties()));
         repository.persist("/metadata/logic_db/dataSources", dataSource);
         repository.persist("/metadata/logic_db/rules", encryptRule);
         repository.persist("/props", 
ConfigurationPropertyKey.SQL_SHOW.getKey() + ": 'true'\n");
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryReadwriteSplittingTest.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpri
 [...]
index dd8418f..036d4e2 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryReadwriteSplittingTest.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryReadwriteSplittingTest.java
@@ -20,9 +20,10 @@ package 
org.apache.shardingsphere.spring.boot.governance.type;
 import lombok.SneakyThrows;
 import org.apache.commons.dbcp2.BasicDataSource;
 import 
org.apache.shardingsphere.driver.governance.internal.datasource.GovernanceShardingSphereDataSource;
+import 
org.apache.shardingsphere.governance.repository.api.config.RegistryCenterConfiguration;
+import 
org.apache.shardingsphere.governance.repository.zookeeper.CuratorZookeeperRepository;
 import org.apache.shardingsphere.infra.context.manager.ContextManager;
 import org.apache.shardingsphere.infra.database.DefaultSchema;
-import 
org.apache.shardingsphere.spring.boot.governance.registry.TestRegistryCenterRepository;
 import 
org.apache.shardingsphere.spring.boot.governance.util.EmbedTestingServer;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -39,6 +40,7 @@ import java.lang.reflect.Field;
 import java.net.URISyntaxException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.util.Properties;
 import java.util.stream.Collectors;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -61,7 +63,8 @@ public class 
GovernanceSpringBootRegistryReadwriteSplittingTest {
     @BeforeClass
     public static void init() {
         EmbedTestingServer.start();
-        TestRegistryCenterRepository repository = new 
TestRegistryCenterRepository();
+        CuratorZookeeperRepository repository = new 
CuratorZookeeperRepository();
+        repository.init(new RegistryCenterConfiguration("ZooKeeper", 
"governance-spring-boot-registry-readwrite-splitting-test", "localhost:3183", 
new Properties()));
         repository.persist("/metadata/logic_db/dataSources", 
readYAML(DATA_SOURCE_FILE));
         repository.persist("/metadata/logic_db/rules", readYAML(RULE_FILE));
         repository.persist("/props", "{}\n");
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryShardingTest.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegi
 [...]
index 35bee21..cdcd9e4 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryShardingTest.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryShardingTest.java
@@ -20,6 +20,8 @@ package org.apache.shardingsphere.spring.boot.governance.type;
 import lombok.SneakyThrows;
 import org.apache.commons.dbcp2.BasicDataSource;
 import 
org.apache.shardingsphere.driver.governance.internal.datasource.GovernanceShardingSphereDataSource;
+import 
org.apache.shardingsphere.governance.repository.api.config.RegistryCenterConfiguration;
+import 
org.apache.shardingsphere.governance.repository.zookeeper.CuratorZookeeperRepository;
 import 
org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.context.manager.ContextManager;
 import org.apache.shardingsphere.infra.database.DefaultSchema;
@@ -27,7 +29,6 @@ import org.apache.shardingsphere.infra.datanode.DataNode;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.sharding.rule.TableRule;
-import 
org.apache.shardingsphere.spring.boot.governance.registry.TestRegistryCenterRepository;
 import 
org.apache.shardingsphere.spring.boot.governance.util.EmbedTestingServer;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -45,6 +46,7 @@ import java.net.URISyntaxException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Iterator;
+import java.util.Properties;
 import java.util.stream.Collectors;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -69,7 +71,8 @@ public class GovernanceSpringBootRegistryShardingTest {
         EmbedTestingServer.start();
         String shardingDatabases = readYAML(SHARDING_DATABASES_FILE);
         String shardingRule = readYAML(SHARDING_RULE_FILE);
-        TestRegistryCenterRepository repository = new 
TestRegistryCenterRepository();
+        CuratorZookeeperRepository repository = new 
CuratorZookeeperRepository();
+        repository.init(new RegistryCenterConfiguration("ZooKeeper", 
"governance-spring-boot-test", "localhost:3183", new Properties()));
         repository.persist("/metadata/logic_db/dataSources", 
shardingDatabases);
         repository.persist("/metadata/logic_db/rules", shardingRule);
         repository.persist("/props", 
ConfigurationPropertyKey.EXECUTOR_SIZE.getKey() + ": '100'\n" + 
ConfigurationPropertyKey.SQL_SHOW.getKey() + ": 'true'\n");
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/META-INF/services/org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/META-INF/services/org.apache.shardingsphere.governance.repository.spi.Reg
 [...]
deleted file mode 100644
index c17dacd..0000000
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/META-INF/services/org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.spring.boot.governance.registry.TestRegistryCenterRepository
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-encrypt.properties
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-encrypt.properties
index 1f0dac3..df1c17f 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-encrypt.properties
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-encrypt.properties
@@ -33,7 +33,7 @@ 
spring.shardingsphere.rules.encrypt.tables.t_order.columns.order_id.encryptor-na
 spring.shardingsphere.props.sql-show=true
 
 spring.shardingsphere.mode.type=Cluster
-spring.shardingsphere.mode.repository.type=TestRegistry
+spring.shardingsphere.mode.repository.type=ZooKeeper
 
spring.shardingsphere.mode.repository.props.namespace=governance-spring-boot-encrypt-test
-spring.shardingsphere.mode.repository.props.server-lists=localhost:3183
+spring.shardingsphere.mode.repository.props.serverLists=localhost:3183
 spring.shardingsphere.mode.overwrite=true
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-readwrite-splitting.properties
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-readwrite-splitting.properties
index a48c224..b88b136 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-readwrite-splitting.properties
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-readwrite-splitting.properties
@@ -43,7 +43,7 @@ 
spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.write-data-so
 
spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.read-data-source-names=read_ds_0,read_ds_1
 
 spring.shardingsphere.mode.type=Cluster
-spring.shardingsphere.mode.repository.type=TestRegistry
+spring.shardingsphere.mode.repository.type=ZooKeeper
 
spring.shardingsphere.mode.repository.props.namespace=governance-spring-boot-read-query-test
-spring.shardingsphere.mode.repository.props.server-lists=localhost:3183
+spring.shardingsphere.mode.repository.props.serverLists=localhost:3183
 spring.shardingsphere.mode.overwrite=true
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-registry-readwrite-splitting.properties
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-registry-readwrite-splitting.properties
index 76c250e..d6b3d18 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-registry-readwrite-splitting.properties
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-registry-readwrite-splitting.properties
@@ -16,7 +16,7 @@
 #
 
 spring.shardingsphere.mode.type=Cluster
-spring.shardingsphere.mode.repository.type=TestRegistry
+spring.shardingsphere.mode.repository.type=ZooKeeper
 
spring.shardingsphere.mode.repository.props.namespace=governance-spring-boot-registry-readwrite-splitting-test
-spring.shardingsphere.mode.repository.props.server-lists=localhost:3183
+spring.shardingsphere.mode.repository.props.serverLists=localhost:3183
 spring.shardingsphere.mode.overwrite=true
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-registry.properties
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-registry.properties
index 3d469ae..f80e31f 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-registry.properties
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-registry.properties
@@ -16,7 +16,7 @@
 #
 
 spring.shardingsphere.mode.type=Cluster
-spring.shardingsphere.mode.repository.type=TestRegistry
+spring.shardingsphere.mode.repository.type=ZooKeeper
 
spring.shardingsphere.mode.repository.props.namespace=governance-spring-boot-test
-spring.shardingsphere.mode.repository.props.server-lists=localhost:3183
+spring.shardingsphere.mode.repository.props.serverLists=localhost:3183
 spring.shardingsphere.mode.overwrite=true
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-sharding.properties
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-sharding.properties
index 01d2741..7f962b7 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-sharding.properties
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/resources/application-sharding.properties
@@ -70,7 +70,7 @@ spring.shardingsphere.props.sql-show=true
 spring.shardingsphere.props.executor-size=100
 
 spring.shardingsphere.mode.type=Cluster
-spring.shardingsphere.mode.repository.type=TestRegistry
+spring.shardingsphere.mode.repository.type=ZooKeeper
 
spring.shardingsphere.mode.repository.props.namespace=governance-spring-boot-sharding-test
-spring.shardingsphere.mode.repository.props.server-lists=localhost:3183
+spring.shardingsphere.mode.repository.props.serverLists=localhost:3183
 spring.shardingsphere.mode.overwrite=true
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/governance/registry/TestRegistryCenterRepository.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/governance/registry/TestRegistryCenterReposi
 [...]
index 709da50..2d09139 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/governance/registry/TestRegistryCenterRepository.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/governance/registry/TestRegistryCenterRepository.java
@@ -56,7 +56,6 @@ public final class TestRegistryCenterRepository implements 
RegistryCenterReposit
     
     @Override
     public void releaseLock(final String key) {
-        
     }
     
     @Override

Reply via email to