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

xuyang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 0de7d9f4093 [feature](replica) support force set replicate allocation 
for olap tables (#32916)
0de7d9f4093 is described below

commit 0de7d9f40934de9397d1a34159f9a14697e8cdea
Author: camby <camby...@tencent.com>
AuthorDate: Sun Apr 7 15:09:47 2024 +0800

    [feature](replica) support force set replicate allocation for olap tables 
(#32916)
    
    Add a config to force set replication allocation for all OLAP tables and 
partitions.
---
 .../main/java/org/apache/doris/common/Config.java  | 10 ++++++++++
 .../apache/doris/common/util/PropertyAnalyzer.java | 22 ++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java 
b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
index b2467f95b65..bd59bde2374 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
@@ -2242,6 +2242,16 @@ public class Config extends ConfigBase {
                     + "This config is recommended to be used only in the test 
environment"})
     public static int force_olap_table_replication_num = 0;
 
+    @ConfField(mutable = true, masterOnly = true, description = {
+            "用于强制设定内表的副本分布,如果该参数不为空,则用户在建表或者创建分区时指定的副本数及副本标签将被忽略,而使用本参数设置的值。"
+                    + "该参数影响包括创建分区、修改表属性、动态分区等操作。该参数建议仅用于测试环境",
+            "Used to force set the replica allocation of the internal table. 
If the config is not empty, "
+                    + "the replication_num and replication_allocation 
specified by the user when creating the table "
+                    + "or partitions will be ignored, and the value set by 
this parameter will be used."
+                    + "This config effect the operations including create 
tables, create partitions and create "
+                    + "dynamic partitions. This config is recommended to be 
used only in the test environment"})
+    public static String force_olap_table_replication_allocation = "";
+
     @ConfField
     public static int auto_analyze_simultaneously_running_task_num = 1;
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java 
b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
index 3b4a8472fc1..7f05ea40e19 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
@@ -1233,9 +1233,31 @@ public class PropertyAnalyzer {
 
     public static ReplicaAllocation analyzeReplicaAllocation(Map<String, 
String> properties, String prefix)
             throws AnalysisException {
+        if (!Config.force_olap_table_replication_allocation.isEmpty()) {
+            properties = forceRewriteReplicaAllocation(properties, prefix);
+        }
         return analyzeReplicaAllocationImpl(properties, prefix, true);
     }
 
+    public static Map<String, String> 
forceRewriteReplicaAllocation(Map<String, String> properties,
+            String prefix) {
+        if (properties == null) {
+            properties = Maps.newHashMap();
+        }
+        String propNumKey = Strings.isNullOrEmpty(prefix) ? 
PROPERTIES_REPLICATION_NUM
+                : prefix + "." + PROPERTIES_REPLICATION_NUM;
+        if (properties.containsKey(propNumKey)) {
+            properties.remove(propNumKey);
+        }
+        String propTagKey = Strings.isNullOrEmpty(prefix) ? 
PROPERTIES_REPLICATION_ALLOCATION
+                : prefix + "." + PROPERTIES_REPLICATION_ALLOCATION;
+        if (properties.containsKey(propTagKey)) {
+            properties.remove(propTagKey);
+        }
+        properties.put(propTagKey,  
Config.force_olap_table_replication_allocation);
+        return properties;
+    }
+
     // There are 2 kinds of replication property:
     // 1. "replication_num" = "3"
     // 2. "replication_allocation" = "tag.location.zone1: 2, 
tag.location.zone2: 1"


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to