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

chengzhang 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 612cd5d8e80 Rename server.yaml to global.yaml, config- to database- 
and keep compatible with old config (#30163)
612cd5d8e80 is described below

commit 612cd5d8e802d0d712a3a4d89da8fdc048d23879
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Sun Feb 18 13:35:18 2024 +0800

    Rename server.yaml to global.yaml, config- to database- and keep compatible 
with old config (#30163)
    
    * Rename server.yaml to global.yaml, config- to database- and keep 
compatible with old config
    
    * fix unit test
---
 distribution/proxy/src/main/resources/bin/start.sh  |  2 +-
 .../backend/config/ProxyConfigurationLoader.java    | 21 +++++++++++++++++----
 .../{config-encrypt.yaml => database-encrypt.yaml}  |  0
 .../conf/{hbase-db.yaml => database-hbase.yaml}     |  0
 .../conf/{config-mask.yaml => database-mask.yaml}   |  0
 ...tting.yaml => database-readwrite-splitting.yaml} |  0
 .../{config-shadow.yaml => database-shadow.yaml}    |  0
 ...{config-sharding.yaml => database-sharding.yaml} |  0
 .../resources/conf/{server.yaml => global.yaml}     |  0
 9 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/distribution/proxy/src/main/resources/bin/start.sh 
b/distribution/proxy/src/main/resources/bin/start.sh
index b75111486f9..72b64520580 100644
--- a/distribution/proxy/src/main/resources/bin/start.sh
+++ b/distribution/proxy/src/main/resources/bin/start.sh
@@ -116,7 +116,7 @@ print_usage() {
     echo "-a  Bind addresses, can be IPv4, IPv6, hostname. In"
     echo "    case more than one address is specified in a"
     echo "    comma-separated list. The default value is '0.0.0.0'."
-    echo "-p  Bind port, default is '3307', which could be changed in 
server.yaml"
+    echo "-p  Bind port, default is '3307', which could be changed in 
global.yaml"
     echo "-c  Path to config directory of ShardingSphere-Proxy, default is 
'conf'"
     echo "-f  Force start ShardingSphere-Proxy"
     echo "-g  Enable agent if shardingsphere-agent deployed in 'agent' 
directory"
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java
 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java
index e109e69ecaf..e58fa5e7df9 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java
+++ 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java
@@ -51,9 +51,17 @@ import java.util.stream.Collectors;
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
 public final class ProxyConfigurationLoader {
     
-    private static final String SERVER_CONFIG_FILE = "server.yaml";
+    private static final String GLOBAL_CONFIG_FILE = "global.yaml";
     
-    private static final Pattern SCHEMA_CONFIG_FILE_PATTERN = 
Pattern.compile("config-.+\\.yaml");
+    private static final Pattern DATABASE_CONFIG_FILE_PATTERN = 
Pattern.compile("database-.+\\.yaml");
+    
+    // TODO remove COMPATIBLE_GLOBAL_CONFIG_FILE in next major version
+    @Deprecated
+    private static final String COMPATIBLE_GLOBAL_CONFIG_FILE = "server.yaml";
+    
+    // TODO remove COMPATIBLE_DATABASE_CONFIG_FILE_PATTERN in next major 
version
+    @Deprecated
+    private static final Pattern COMPATIBLE_DATABASE_CONFIG_FILE_PATTERN = 
Pattern.compile("config-.+\\.yaml");
     
     /**
      * Load configuration of ShardingSphere-Proxy.
@@ -63,7 +71,7 @@ public final class ProxyConfigurationLoader {
      * @throws IOException IO exception
      */
     public static YamlProxyConfiguration load(final String path) throws 
IOException {
-        YamlProxyServerConfiguration serverConfig = 
loadServerConfiguration(getResourceFile(String.join("/", path, 
SERVER_CONFIG_FILE)));
+        YamlProxyServerConfiguration serverConfig = 
loadServerConfiguration(getGlobalConfigFile(path));
         File configPath = getResourceFile(path);
         Collection<YamlProxyDatabaseConfiguration> databaseConfigs = 
loadDatabaseConfigurations(configPath);
         
YamlProxyConfigurationChecker.checkDataSources(serverConfig.getDataSources(), 
databaseConfigs);
@@ -71,6 +79,11 @@ public final class ProxyConfigurationLoader {
                 YamlProxyDatabaseConfiguration::getDatabaseName, each -> each, 
(oldValue, currentValue) -> oldValue, LinkedHashMap::new)));
     }
     
+    private static File getGlobalConfigFile(final String path) {
+        File result = getResourceFile(String.join("/", path, 
GLOBAL_CONFIG_FILE));
+        return result.exists() ? result : getResourceFile(String.join("/", 
path, COMPATIBLE_GLOBAL_CONFIG_FILE));
+    }
+    
     @SneakyThrows(URISyntaxException.class)
     private static File getResourceFile(final String path) {
         URL url = ProxyConfigurationLoader.class.getResource(path);
@@ -153,6 +166,6 @@ public final class ProxyConfigurationLoader {
     }
     
     private static File[] findRuleConfigurationFiles(final File path) {
-        return path.listFiles(each -> 
SCHEMA_CONFIG_FILE_PATTERN.matcher(each.getName()).matches());
+        return path.listFiles(each -> 
DATABASE_CONFIG_FILE_PATTERN.matcher(each.getName()).matches() || 
COMPATIBLE_DATABASE_CONFIG_FILE_PATTERN.matcher(each.getName()).matches());
     }
 }
diff --git a/proxy/bootstrap/src/main/resources/conf/config-encrypt.yaml 
b/proxy/bootstrap/src/main/resources/conf/database-encrypt.yaml
similarity index 100%
rename from proxy/bootstrap/src/main/resources/conf/config-encrypt.yaml
rename to proxy/bootstrap/src/main/resources/conf/database-encrypt.yaml
diff --git a/proxy/bootstrap/src/main/resources/conf/hbase-db.yaml 
b/proxy/bootstrap/src/main/resources/conf/database-hbase.yaml
similarity index 100%
rename from proxy/bootstrap/src/main/resources/conf/hbase-db.yaml
rename to proxy/bootstrap/src/main/resources/conf/database-hbase.yaml
diff --git a/proxy/bootstrap/src/main/resources/conf/config-mask.yaml 
b/proxy/bootstrap/src/main/resources/conf/database-mask.yaml
similarity index 100%
rename from proxy/bootstrap/src/main/resources/conf/config-mask.yaml
rename to proxy/bootstrap/src/main/resources/conf/database-mask.yaml
diff --git 
a/proxy/bootstrap/src/main/resources/conf/config-readwrite-splitting.yaml 
b/proxy/bootstrap/src/main/resources/conf/database-readwrite-splitting.yaml
similarity index 100%
rename from 
proxy/bootstrap/src/main/resources/conf/config-readwrite-splitting.yaml
rename to 
proxy/bootstrap/src/main/resources/conf/database-readwrite-splitting.yaml
diff --git a/proxy/bootstrap/src/main/resources/conf/config-shadow.yaml 
b/proxy/bootstrap/src/main/resources/conf/database-shadow.yaml
similarity index 100%
rename from proxy/bootstrap/src/main/resources/conf/config-shadow.yaml
rename to proxy/bootstrap/src/main/resources/conf/database-shadow.yaml
diff --git a/proxy/bootstrap/src/main/resources/conf/config-sharding.yaml 
b/proxy/bootstrap/src/main/resources/conf/database-sharding.yaml
similarity index 100%
rename from proxy/bootstrap/src/main/resources/conf/config-sharding.yaml
rename to proxy/bootstrap/src/main/resources/conf/database-sharding.yaml
diff --git a/proxy/bootstrap/src/main/resources/conf/server.yaml 
b/proxy/bootstrap/src/main/resources/conf/global.yaml
similarity index 100%
rename from proxy/bootstrap/src/main/resources/conf/server.yaml
rename to proxy/bootstrap/src/main/resources/conf/global.yaml

Reply via email to