This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch 2.1-tmp in repository https://gitbox.apache.org/repos/asf/doris.git
commit 14c5247fb7d951791899ee057c1f6f41ef1532ac 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 a727c23bb74..0d4ddb947a7 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 @@ -2239,6 +2239,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 9737d95e2e6..0a943441b68 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 @@ -1129,9 +1129,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