You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2025/09/29 11:30:44 UTC
(shardingsphere) branch master updated: Refactor ShardingSpherePipelineDataSourceCreator createConfigurationProperties (#36755)
This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng 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 de0874c6b2f Refactor ShardingSpherePipelineDataSourceCreator createConfigurationProperties (#36755)
de0874c6b2f is described below
commit de0874c6b2f5374ec06f8bc88ee6d4f65e436b76
Author: Hongsheng Zhong <zh...@apache.org>
AuthorDate: Mon Sep 29 19:30:37 2025 +0800
Refactor ShardingSpherePipelineDataSourceCreator createConfigurationProperties (#36755)
---
.../ShardingSpherePipelineDataSourceCreator.java | 40 ++++++++++++----------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/ShardingSpherePipelineDataSourceCreator.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/ShardingSpherePipelineDataSourceCreator.java
index 47d336c8b11..01e447bd8b9 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/ShardingSpherePipelineDataSourceCreator.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/ShardingSpherePipelineDataSourceCreator.java
@@ -40,10 +40,10 @@ import org.apache.shardingsphere.mode.manager.ContextManager;
import javax.sql.DataSource;
import java.sql.SQLException;
-import java.util.Arrays;
import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
-import java.util.Optional;
import java.util.Properties;
/**
@@ -55,7 +55,7 @@ public final class ShardingSpherePipelineDataSourceCreator implements PipelineDa
public DataSource create(final Object dataSourceConfig) throws SQLException {
YamlRootConfiguration yamlRootConfig = YamlEngine.unmarshal(YamlEngine.marshal(dataSourceConfig), YamlRootConfiguration.class);
removeAuthorityRuleConfiguration(yamlRootConfig);
- updateConfigurationProperties(yamlRootConfig);
+ yamlRootConfig.setProps(createConfigurationProperties());
reviseYamlRuleConfiguration(yamlRootConfig);
yamlRootConfig.setMode(createStandaloneModeConfiguration());
return createShardingSphereDataSource(yamlRootConfig);
@@ -65,30 +65,34 @@ public final class ShardingSpherePipelineDataSourceCreator implements PipelineDa
yamlRootConfig.getRules().removeIf(YamlAuthorityRuleConfiguration.class::isInstance);
}
- private void updateConfigurationProperties(final YamlRootConfiguration yamlRootConfig) {
- Optional<Properties> realtimeProps = getRealtimeProperties();
- if (!realtimeProps.isPresent()) {
- return;
- }
- Properties newProps = new Properties();
- for (String each : Arrays.asList(ConfigurationPropertyKey.KERNEL_EXECUTOR_SIZE.getKey(), ConfigurationPropertyKey.SQL_SHOW.getKey())) {
- Object value = realtimeProps.get().get(each);
+ private Properties createConfigurationProperties() {
+ Properties realtimeProps = getRealtimeProperties();
+ Properties result = new Properties();
+ for (String each : getConfigurationPropertyKeys()) {
+ Object value = realtimeProps.get(each);
if (null != value) {
- newProps.put(each, value);
+ result.put(each, value);
}
}
- newProps.put(TemporaryConfigurationPropertyKey.SYSTEM_SCHEMA_METADATA_ASSEMBLY_ENABLED.getKey(), String.valueOf(Boolean.FALSE));
+ result.put(TemporaryConfigurationPropertyKey.SYSTEM_SCHEMA_METADATA_ASSEMBLY_ENABLED.getKey(), String.valueOf(Boolean.FALSE));
// Set a large enough value to enable ConnectionMode.MEMORY_STRICTLY, make sure streaming query work.
- newProps.put(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY.getKey(), 100000);
- yamlRootConfig.setProps(newProps);
+ result.put(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY.getKey(), 100000);
+ return result;
}
- private Optional<Properties> getRealtimeProperties() {
+ private Properties getRealtimeProperties() {
ContextManager contextManager = PipelineContextManager.getProxyContext();
if (null == contextManager) {
- return Optional.empty();
+ return new Properties();
}
- return Optional.of(contextManager.getMetaDataContexts().getMetaData().getProps().getProps());
+ return contextManager.getMetaDataContexts().getMetaData().getProps().getProps();
+ }
+
+ private List<String> getConfigurationPropertyKeys() {
+ List<String> result = new LinkedList<>();
+ result.add(ConfigurationPropertyKey.KERNEL_EXECUTOR_SIZE.getKey());
+ result.add(ConfigurationPropertyKey.SQL_SHOW.getKey());
+ return result;
}
@SuppressWarnings("unchecked")