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

azexin 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 3cb384c86bc Disable system-schema-metadata-enabled in pipeline (#26890)
3cb384c86bc is described below

commit 3cb384c86bcb7f6849d85969abeed2bff5d2fead
Author: Hongsheng Zhong <[email protected]>
AuthorDate: Mon Jul 10 20:22:35 2023 +0800

    Disable system-schema-metadata-enabled in pipeline (#26890)
    
    * Comment unnecessary sharding strategy in IT
    
    * Disable system-schema-metadata-enabled in 
ShardingSpherePipelineDataSourceCreator
    
    * Disable system-schema-metadata-enabled in yaml config
    
    * Add database id for standalone mode
---
 .../ShardingSpherePipelineDataSourceCreator.java      | 16 +++++++++++++---
 .../resources/config_sharding_sphere_jdbc_source.yaml | 19 +++++++++++--------
 .../resources/config_sharding_sphere_jdbc_target.yaml |  4 ++++
 .../migration_sharding_sphere_jdbc_target.yaml        |  4 ++++
 4 files changed, 32 insertions(+), 11 deletions(-)

diff --git 
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/data/pipeline/datasource/creator/ShardingSpherePipelineDataSourceCreator.java
 
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/data/pipeline/datasource/creator/ShardingSpherePipelineDataSourceCreator.java
index 627d009e55d..b8862ed0df0 100644
--- 
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/data/pipeline/datasource/creator/ShardingSpherePipelineDataSourceCreator.java
+++ 
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/data/pipeline/datasource/creator/ShardingSpherePipelineDataSourceCreator.java
@@ -21,6 +21,7 @@ import 
org.apache.shardingsphere.data.pipeline.api.datasource.config.impl.Shardi
 import 
org.apache.shardingsphere.data.pipeline.spi.datasource.creator.PipelineDataSourceCreator;
 import 
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
 import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
+import 
org.apache.shardingsphere.infra.config.props.temporary.TemporaryConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
 import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmConfiguration;
@@ -37,15 +38,19 @@ import java.sql.SQLException;
 import java.util.Collections;
 import java.util.Optional;
 import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * ShardingSphere pipeline data source creator.
  */
 public final class ShardingSpherePipelineDataSourceCreator implements 
PipelineDataSourceCreator {
     
+    private static final AtomicInteger STANDALONE_DATABASE_ID = new 
AtomicInteger(1);
+    
     @Override
     public DataSource createPipelineDataSource(final Object dataSourceConfig) 
throws SQLException {
         YamlRootConfiguration rootConfig = 
YamlEngine.unmarshal(YamlEngine.marshal(dataSourceConfig), 
YamlRootConfiguration.class);
+        disableSystemSchemaMetadata(rootConfig);
         enableStreamingQuery(rootConfig);
         updateSingleRuleConfiguration(rootConfig);
         Optional<YamlShardingRuleConfiguration> yamlShardingRuleConfig = 
ShardingRuleConfigurationConverter.findYamlShardingRuleConfiguration(rootConfig.getRules());
@@ -55,7 +60,7 @@ public final class ShardingSpherePipelineDataSourceCreator 
implements PipelineDa
         }
         rootConfig.setDatabaseName(rootConfig.getDatabaseName());
         rootConfig.setSchemaName(rootConfig.getSchemaName());
-        
rootConfig.setMode(createStandaloneModeConfiguration(rootConfig.getDatabaseName()));
+        rootConfig.setMode(createStandaloneModeConfiguration());
         return 
YamlShardingSphereDataSourceFactory.createDataSourceWithoutCache(rootConfig);
     }
     
@@ -66,6 +71,10 @@ public final class ShardingSpherePipelineDataSourceCreator 
implements PipelineDa
         rootConfig.getRules().add(singleRuleConfig);
     }
     
+    private void disableSystemSchemaMetadata(final YamlRootConfiguration 
rootConfig) {
+        
rootConfig.getProps().put(TemporaryConfigurationPropertyKey.SYSTEM_SCHEMA_METADATA_ENABLED.getKey(),
 String.valueOf(Boolean.FALSE));
+    }
+    
     // TODO Another way is improving ExecuteQueryCallback.executeSQL to enable 
streaming query, then remove it
     private void enableStreamingQuery(final YamlRootConfiguration rootConfig) {
         // Set a large enough value to enable ConnectionMode.MEMORY_STRICTLY, 
make sure streaming query work.
@@ -91,7 +100,7 @@ public final class ShardingSpherePipelineDataSourceCreator 
implements PipelineDa
         }
     }
     
-    private YamlModeConfiguration createStandaloneModeConfiguration(final 
String databaseName) {
+    private YamlModeConfiguration createStandaloneModeConfiguration() {
         YamlModeConfiguration result = new YamlModeConfiguration();
         result.setType("Standalone");
         YamlPersistRepositoryConfiguration repository = new 
YamlPersistRepositoryConfiguration();
@@ -99,7 +108,8 @@ public final class ShardingSpherePipelineDataSourceCreator 
implements PipelineDa
         repository.setType("JDBC");
         Properties props = new Properties();
         repository.setProps(props);
-        props.setProperty(JDBCRepositoryPropertyKey.JDBC_URL.getKey(), 
String.format("jdbc:h2:mem:config_%s;DB_CLOSE_DELAY=0;DATABASE_TO_UPPER=false;MODE=MYSQL",
 databaseName));
+        props.setProperty(JDBCRepositoryPropertyKey.JDBC_URL.getKey(),
+                
String.format("jdbc:h2:mem:pipeline_db_%d;DB_CLOSE_DELAY=0;DATABASE_TO_UPPER=false;MODE=MYSQL",
 STANDALONE_DATABASE_ID.getAndIncrement()));
         return result;
     }
     
diff --git 
a/test/it/pipeline/src/test/resources/config_sharding_sphere_jdbc_source.yaml 
b/test/it/pipeline/src/test/resources/config_sharding_sphere_jdbc_source.yaml
index a79c3061d98..ac7775e1204 100644
--- 
a/test/it/pipeline/src/test/resources/config_sharding_sphere_jdbc_source.yaml
+++ 
b/test/it/pipeline/src/test/resources/config_sharding_sphere_jdbc_source.yaml
@@ -29,6 +29,9 @@ mode:
       maxRetries: 3
       operationTimeoutMilliseconds: 500
 
+props:
+  system-schema-metadata-enabled: false
+
 dataSources:
   ds_0:
     dataSourceClassName: com.zaxxer.hikari.HikariDataSource
@@ -38,20 +41,20 @@ dataSources:
 
 rules:
 - !SHARDING
-  defaultDatabaseStrategy:
-    standard:
-      shardingAlgorithmName: default_db_inline
-      shardingColumn: user_id
+#  defaultDatabaseStrategy:
+#    standard:
+#      shardingAlgorithmName: default_db_inline
+#      shardingColumn: user_id
   tables:
     t_order:
       actualDataNodes: ds_0.t_order
       keyGenerateStrategy:
         column: order_id
         keyGeneratorName: snowflake
-      tableStrategy:
-        standard:
-          shardingAlgorithmName: t_order_tbl_inline
-          shardingColumn: order_id
+#      tableStrategy:
+#        standard:
+#          shardingAlgorithmName: t_order_tbl_inline
+#          shardingColumn: order_id
   shardingAlgorithms:
     default_db_inline:
       type: INLINE
diff --git 
a/test/it/pipeline/src/test/resources/config_sharding_sphere_jdbc_target.yaml 
b/test/it/pipeline/src/test/resources/config_sharding_sphere_jdbc_target.yaml
index fc0f958c2ff..92ee83b8211 100644
--- 
a/test/it/pipeline/src/test/resources/config_sharding_sphere_jdbc_target.yaml
+++ 
b/test/it/pipeline/src/test/resources/config_sharding_sphere_jdbc_target.yaml
@@ -15,6 +15,9 @@
 # limitations under the License.
 #
 
+props:
+  system-schema-metadata-enabled: false
+
 dataSources:
   ds_1:
     dataSourceClassName: com.zaxxer.hikari.HikariDataSource
@@ -26,6 +29,7 @@ dataSources:
     url: 
jdbc:h2:mem:test_ds_2;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL
     username: root
     password: root
+
 rules:
 - !SHARDING
   defaultDatabaseStrategy:
diff --git 
a/test/it/pipeline/src/test/resources/migration_sharding_sphere_jdbc_target.yaml
 
b/test/it/pipeline/src/test/resources/migration_sharding_sphere_jdbc_target.yaml
index 7e105fe60cc..47ecc64f6c0 100644
--- 
a/test/it/pipeline/src/test/resources/migration_sharding_sphere_jdbc_target.yaml
+++ 
b/test/it/pipeline/src/test/resources/migration_sharding_sphere_jdbc_target.yaml
@@ -15,6 +15,9 @@
 # limitations under the License.
 #
 
+props:
+  system-schema-metadata-enabled: false
+
 dataSources:
   ds_1:
     dataSourceClassName: com.zaxxer.hikari.HikariDataSource
@@ -26,6 +29,7 @@ dataSources:
     url: 
jdbc:h2:mem:test_ds_2_${databaseNameSuffix};DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL
     username: root
     password: root
+
 rules:
   - !SHARDING
     defaultDatabaseStrategy:

Reply via email to