You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by ca...@apache.org on 2022/10/14 06:22:03 UTC
[doris] branch master updated: [ResourceTag](tag) Unified tag format verification (#13312)
This is an automated email from the ASF dual-hosted git repository.
cambyzju 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 a2a2be22a5 [ResourceTag](tag) Unified tag format verification (#13312)
a2a2be22a5 is described below
commit a2a2be22a502980b3a9bec7860d708989b831800
Author: Zhengguo Yang <ya...@gmail.com>
AuthorDate: Fri Oct 14 14:21:55 2022 +0800
[ResourceTag](tag) Unified tag format verification (#13312)
---
.../org/apache/doris/common/util/PropertyAnalyzer.java | 3 ++-
.../src/main/java/org/apache/doris/resource/Tag.java | 15 ++++++++++-----
.../org/apache/doris/catalog/ReplicaAllocationTest.java | 2 +-
3 files changed, 13 insertions(+), 7 deletions(-)
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 8b72c9cd33..b7e604f5aa 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
@@ -653,7 +653,8 @@ public class PropertyAnalyzer {
continue;
}
String val = entry.getValue().replaceAll(" ", "");
- tagMap.put(keyParts[1], val);
+ Tag tag = Tag.create(keyParts[1], val);
+ tagMap.put(tag.type, tag.value);
iter.remove();
}
if (tagMap.isEmpty() && defaultValue != null) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/resource/Tag.java b/fe/fe-core/src/main/java/org/apache/doris/resource/Tag.java
index d713e2c61e..6b697d15ba 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/resource/Tag.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/resource/Tag.java
@@ -71,7 +71,9 @@ public class Tag implements Writable {
public static final ImmutableSet<String> RESERVED_TAG_VALUES = ImmutableSet.of(
VALUE_FRONTEND, VALUE_BACKEND, VALUE_BROKER, VALUE_REMOTE_STORAGE, VALUE_STORE, VALUE_COMPUTATION,
VALUE_DEFAULT_CLUSTER);
- private static final String TAG_REGEX = "^[a-zA-Z][a-zA-Z0-9_]{0,32}$";
+ private static final String TAG_TYPE_REGEX = "^[a-z][a-z0-9_]{0,32}$";
+ private static final String TAG_VALUE_REGEX = "^[a-zA-Z][a-zA-Z0-9_]{0,32}$";
+
public static final Tag DEFAULT_BACKEND_TAG;
public static final Tag INVALID_TAG;
@@ -87,13 +89,16 @@ public class Tag implements Writable {
public String value;
private Tag(String type, String val) {
- this.type = type.toLowerCase();
- this.value = val.toLowerCase();
+ this.type = type;
+ this.value = val;
}
public static Tag create(String type, String value) throws AnalysisException {
- if (!type.matches(TAG_REGEX) || !value.matches(TAG_REGEX)) {
- throw new AnalysisException("Invalid tag format: " + type + ":" + value);
+ if (!type.matches(TAG_TYPE_REGEX)) {
+ throw new AnalysisException("Invalid tag type format: " + type);
+ }
+ if (!value.matches(TAG_VALUE_REGEX)) {
+ throw new AnalysisException("Invalid tag value format: " + value);
}
return new Tag(type, value);
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/ReplicaAllocationTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/ReplicaAllocationTest.java
index e751a39761..00dbf1443c 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/catalog/ReplicaAllocationTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/ReplicaAllocationTest.java
@@ -123,7 +123,7 @@ public class ReplicaAllocationTest {
properties.clear();
properties.put(PropertyAnalyzer.PROPERTIES_REPLICATION_ALLOCATION, "tag.location.12321:1");
- ExceptionChecker.expectThrowsWithMsg(AnalysisException.class, "Invalid tag format: location:12321",
+ ExceptionChecker.expectThrowsWithMsg(AnalysisException.class, "Invalid tag value format: 12321",
() -> PropertyAnalyzer.analyzeReplicaAllocation(properties, ""));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org