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

duanzhengqiang 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 74eb73f  Revert "Support governance for JDBC scenario (#10082)" 
(#10085)
74eb73f is described below

commit 74eb73f3bb7e9f8a14767c24c5be1366610b755f
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Apr 14 14:49:25 2021 +0800

    Revert "Support governance for JDBC scenario (#10082)" (#10085)
    
    This reverts commit 06dc851f61c0e121479c98badcb09b739deb2698.
---
 ...lGovernanceShardingSphereDataSourceFactory.java | 15 ------
 .../adapter/impl/ShardingSphereJDBCContainer.java  | 57 ++++++----------------
 .../container/governance/ZookeeperContainer.java   | 38 ---------------
 .../src/test/resources/env/engine-env.properties   |  2 +-
 4 files changed, 17 insertions(+), 95 deletions(-)

diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/api/yaml/YamlGovernanceShardingSphereDataSourceFactory.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/api/yaml/YamlGovernanceShardingSphereDataSourceFactory.java
index 000b198..4dd72dd 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/api/yaml/YamlGovernanceShardingSphereDataSourceFactory.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/api/yaml/YamlGovernanceShardingSphereDataSourceFactory.java
@@ -59,21 +59,6 @@ public final class 
YamlGovernanceShardingSphereDataSourceFactory {
     /**
      * Create ShardingSphere data source.
      *
-     * @param dataSourceMap data source
-     * @param governance governance configuration
-     * @param rulesYamlFile YAML file for rule configurations
-     * @return ShardingSphere data source
-     * @throws SQLException  SQL exception
-     * @throws IOException  SQL exception
-     */
-    public static DataSource createDataSource(final Map<String, DataSource> 
dataSourceMap, final YamlGovernanceConfiguration governance, final File 
rulesYamlFile) throws SQLException, IOException {
-        YamlGovernanceRootRuleConfigurations configurations = 
unmarshal(rulesYamlFile);
-        return createDataSource(dataSourceMap, configurations, 
configurations.getProps(), governance);
-    }
-    
-    /**
-     * Create ShardingSphere data source.
-     *
      * @param dataSourceMap data source map
      * @param yamlFile YAML file for rule configurations
      * @return ShardingSphere data source
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/adapter/impl/ShardingSphereJDBCContainer.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/adapter/impl/ShardingSphereJDBCContainer.java
index 1cc9da2..37f13f0 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/adapter/impl/ShardingSphereJDBCContainer.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/adapter/impl/ShardingSphereJDBCContainer.java
@@ -17,24 +17,24 @@
 
 package 
org.apache.shardingsphere.test.integration.junit.container.adapter.impl;
 
-import lombok.SneakyThrows;
 import 
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
 import 
org.apache.shardingsphere.driver.governance.api.yaml.YamlGovernanceShardingSphereDataSourceFactory;
 import org.apache.shardingsphere.test.integration.env.EnvironmentPath;
 import 
org.apache.shardingsphere.test.integration.junit.container.ShardingSphereContainer;
 import 
org.apache.shardingsphere.test.integration.junit.container.adapter.ShardingSphereAdapterContainer;
-import 
org.apache.shardingsphere.test.integration.junit.container.governance.ZookeeperContainer;
 import 
org.apache.shardingsphere.test.integration.junit.container.storage.ShardingSphereStorageContainer;
 import 
org.apache.shardingsphere.test.integration.junit.param.model.ParameterizedArray;
 import org.testcontainers.containers.wait.strategy.WaitStrategy;
+import org.testcontainers.lifecycle.Startable;
 
 import javax.sql.DataSource;
 import java.io.File;
 import java.io.IOException;
 import java.sql.SQLException;
+import java.util.List;
 import java.util.Map;
-import java.util.Optional;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.stream.Collectors;
 
 /**
  * ShardingSphere JDBC container.
@@ -43,61 +43,36 @@ public final class ShardingSphereJDBCContainer extends 
ShardingSphereAdapterCont
     
     private final AtomicBoolean isHealthy = new AtomicBoolean();
     
-    private DataSource dataSource;
+    private Map<String, DataSource> dataSourceMap;
     
     public ShardingSphereJDBCContainer(final ParameterizedArray 
parameterizedArray) {
         super("ShardingSphere-JDBC", "ShardingSphere-JDBC", true, 
parameterizedArray);
     }
     
-    @SneakyThrows
     @Override
     public void start() {
         super.start();
-        Optional<ZookeeperContainer> governance = getDependencies().stream()
-                .filter(x -> x instanceof ZookeeperContainer)
-                .map(x -> (ZookeeperContainer) x)
-                .findFirst();
-        ShardingSphereStorageContainer storageContainer = 
getDependencies().stream()
-                .filter(x -> x instanceof ShardingSphereStorageContainer)
-                .map(x -> (ShardingSphereStorageContainer) x)
-                .findFirst()
-                .orElseThrow(Exception::new);
-        Map<String, DataSource> dataSourceMap = 
storageContainer.getDataSourceMap();
-        try {
-            if 
("sharding_governance".equals(getParameterizedArray().getScenario())) {
-                dataSource = createDataSource(dataSourceMap, governance, 0);
-            } else {
-                dataSource = 
YamlShardingSphereDataSourceFactory.createDataSource(dataSourceMap, new 
File(EnvironmentPath.getRulesConfigurationFile(getParameterizedArray().getScenario())));
-            }
-        } catch (SQLException | IOException ex) {
-            throw new RuntimeException(ex);
-        }
+        List<Startable> startables = getDependencies().stream()
+                .filter(e -> e instanceof ShardingSphereStorageContainer)
+                .collect(Collectors.toList());
+        dataSourceMap = ((ShardingSphereStorageContainer) 
startables.get(0)).getDataSourceMap();
         isHealthy.set(true);
     }
     
-    @SneakyThrows
-    private DataSource createDataSource(final Map<String, DataSource> 
dataSourceMap, final Optional<ZookeeperContainer> governance, final int retry) {
-        try {
-            return 
YamlGovernanceShardingSphereDataSourceFactory.createDataSource(
-                    dataSourceMap,
-                    governance.orElseThrow(() -> new 
NullPointerException("Governance Container cannot be 
null.")).getGovernanceConfiguration(),
-                    new 
File(EnvironmentPath.getRulesConfigurationFile(getParameterizedArray().getScenario()))
-            );
-        } catch (NullPointerException ex) {
-            if (retry == 0) {
-                return createDataSource(dataSourceMap, governance, 1);
-            }
-            throw ex;
-        }
-    }
-    
     /**
      * Get data source.
      *
      * @return data source
      */
     public DataSource getDataSource() {
-        return dataSource;
+        try {
+            if 
("sharding_governance".equals(getParameterizedArray().getScenario())) {
+                return 
YamlGovernanceShardingSphereDataSourceFactory.createDataSource(new 
File(EnvironmentPath.getRulesConfigurationFile(getParameterizedArray().getScenario())));
+            }
+            return 
YamlShardingSphereDataSourceFactory.createDataSource(dataSourceMap, new 
File(EnvironmentPath.getRulesConfigurationFile(getParameterizedArray().getScenario())));
+        } catch (SQLException | IOException ex) {
+            throw new RuntimeException(ex);
+        }
     }
     
     @Override
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/governance/ZookeeperContainer.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/governance/ZookeeperContainer.java
index 25f3525..caacd07 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/governance/ZookeeperContainer.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/governance/ZookeeperContainer.java
@@ -17,14 +17,10 @@
 
 package org.apache.shardingsphere.test.integration.junit.container.governance;
 
-import 
org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceCenterConfiguration;
-import 
org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceConfiguration;
 import 
org.apache.shardingsphere.test.integration.junit.container.ShardingSphereContainer;
 import 
org.apache.shardingsphere.test.integration.junit.param.model.ParameterizedArray;
 import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
 
-import java.util.Properties;
-
 public class ZookeeperContainer extends ShardingSphereContainer {
     
     public ZookeeperContainer(final ParameterizedArray parameterizedArray) {
@@ -32,38 +28,4 @@ public class ZookeeperContainer extends 
ShardingSphereContainer {
         setWaitStrategy(new 
LogMessageWaitStrategy().withRegEx(".*PrepRequestProcessor \\(sid:[0-9]+\\) 
started.*"));
     }
     
-    /**
-     * Get server lists.
-     *
-     * @return server lists
-     */
-    public String getServerLists() {
-        return getHost() + ":" + getMappedPort(2181);
-    }
-    
-    /**
-     * Get governance configuration.
-     *
-     * @return governance configuration
-     */
-    public YamlGovernanceConfiguration getGovernanceConfiguration() {
-        YamlGovernanceConfiguration result = new YamlGovernanceConfiguration();
-        result.setName("governance_ds");
-        result.setOverwrite(true);
-        result.setRegistryCenter(createGovernanceCenterConfiguration());
-        return result;
-    }
-    
-    private YamlGovernanceCenterConfiguration 
createGovernanceCenterConfiguration() {
-        YamlGovernanceCenterConfiguration configuration = new 
YamlGovernanceCenterConfiguration();
-        configuration.setServerLists(getServerLists());
-        configuration.setType("zookeeper");
-        Properties props = new Properties();
-        props.setProperty("retryIntervalMilliseconds", "500");
-        props.setProperty("timeToLiveSeconds", "60");
-        props.setProperty("maxRetries", "3");
-        props.setProperty("operationTimeoutMilliseconds", "500");
-        configuration.setProps(props);
-        return configuration;
-    }
 }
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/engine-env.properties
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/engine-env.properties
index 5b8ea79..116a239 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/engine-env.properties
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/engine-env.properties
@@ -21,7 +21,7 @@ it.env.type=${it.env}
 it.adapters=jdbc
 
 
#it.scenarios=db,tbl,dbtbl_with_read_write_splitting,read_write_splitting,encrypt,dbtbl_with_read_write_splitting_and_encrypt,sharding_governance,shadow
-it.scenarios=db,tbl,dbtbl_with_read_write_splitting,read_write_splitting,encrypt,dbtbl_with_read_write_splitting_and_encrypt,sharding_governance
+it.scenarios=db,tbl,dbtbl_with_read_write_splitting,read_write_splitting,encrypt,dbtbl_with_read_write_splitting_and_encrypt
 
 #it.databases=H2,MySQL,Oracle,SQLServer,PostgreSQL
 it.databases=H2

Reply via email to