From eaed0dea5ee10e416e859e20f28787868f8a5447 Mon Sep 17 00:00:00 2001 From: wangbo Date: Wed, 1 Nov 2023 10:27:48 +0800 Subject: [PATCH] [refactor](executor)Add % suffix for cpu_hard_limit #26174 --- .../resource/workloadgroup/WorkloadGroup.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/WorkloadGroup.java b/fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/WorkloadGroup.java index b8aebdccab..80b0cab6b3 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/WorkloadGroup.java +++ b/fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/WorkloadGroup.java @@ -103,7 +103,12 @@ public class WorkloadGroup implements Writable, GsonPostProcessable { properties.put(ENABLE_MEMORY_OVERCOMMIT, properties.get(ENABLE_MEMORY_OVERCOMMIT).toLowerCase()); } if (properties.containsKey(CPU_HARD_LIMIT)) { - this.cpuHardLimit = Integer.parseInt(properties.get(CPU_HARD_LIMIT)); + String cpuHardLimitStr = properties.get(CPU_HARD_LIMIT); + if (cpuHardLimitStr.endsWith("%")) { + cpuHardLimitStr = cpuHardLimitStr.substring(0, cpuHardLimitStr.length() - 1); + } + this.cpuHardLimit = Integer.parseInt(cpuHardLimitStr); + this.properties.put(CPU_HARD_LIMIT, cpuHardLimitStr); } } @@ -193,6 +198,9 @@ public class WorkloadGroup implements Writable, GsonPostProcessable { if (properties.containsKey(CPU_HARD_LIMIT)) { String cpuHardLimit = properties.get(CPU_HARD_LIMIT); + if (cpuHardLimit.endsWith("%")) { + cpuHardLimit = cpuHardLimit.substring(0, cpuHardLimit.length() - 1); + } if (!StringUtils.isNumeric(cpuHardLimit) || Long.parseLong(cpuHardLimit) <= 0) { throw new DdlException(CPU_HARD_LIMIT + " " + cpuHardLimit + " requires a positive integer."); } @@ -271,7 +279,11 @@ public class WorkloadGroup implements Writable, GsonPostProcessable { public void getProcNodeData(BaseProcResult result) { for (Map.Entry entry : properties.entrySet()) { - result.addRow(Lists.newArrayList(String.valueOf(id), name, entry.getKey(), entry.getValue())); + if (CPU_HARD_LIMIT.equals(entry.getKey())) { + result.addRow(Lists.newArrayList(String.valueOf(id), name, entry.getKey(), entry.getValue() + "%")); + } else { + result.addRow(Lists.newArrayList(String.valueOf(id), name, entry.getKey(), entry.getValue())); + } } }