This is an automated email from the ASF dual-hosted git repository.
xuyang pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new af950f7247d [feature](replica) support force set replicate allocation
for olap tables (#32916) (#33340)
af950f7247d is described below
commit af950f7247dccfa72e4958169d062c4facd46d8d
Author: camby <[email protected]>
AuthorDate: Mon Apr 8 14:09:19 2024 +0800
[feature](replica) support force set replicate allocation for olap tables
(#32916) (#33340)
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 e3aa4e368c3..cab7ef9050f 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
@@ -2130,6 +2130,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 long statistics_sql_mem_limit_in_bytes = 2L * 1024 * 1024 *
1024;
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 99e4c09a864..901f554b094 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
@@ -1035,9 +1035,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: [email protected]
For additional commands, e-mail: [email protected]