From 4f1e77991ceea7f9c7d3ba54811bbc528f2e3075 Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Tue, 1 Feb 2022 14:30:10 +0100 Subject: [PATCH] Operator factor settings should have the OperatorDynamic setting property (#83359) Relates #82819 --- .../indices/recovery/RecoverySettings.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java b/server/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java index 5398fcf1c0f3..9f5fc77aa9cc 100644 --- a/server/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java +++ b/server/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java @@ -103,14 +103,12 @@ public class RecoverySettings { DEFAULT_FACTOR_VALUE ); - public static final Setting NODE_BANDWIDTH_RECOVERY_OPERATOR_FACTOR_WRITE_SETTING = factorSetting( - "node.bandwidth.recovery.operator.factor.write", - NODE_BANDWIDTH_RECOVERY_OPERATOR_FACTOR_SETTING + public static final Setting NODE_BANDWIDTH_RECOVERY_OPERATOR_FACTOR_WRITE_SETTING = operatorFactorSetting( + "node.bandwidth.recovery.operator.factor.write" ); - public static final Setting NODE_BANDWIDTH_RECOVERY_OPERATOR_FACTOR_READ_SETTING = factorSetting( - "node.bandwidth.recovery.operator.factor.read", - NODE_BANDWIDTH_RECOVERY_OPERATOR_FACTOR_SETTING + public static final Setting NODE_BANDWIDTH_RECOVERY_OPERATOR_FACTOR_READ_SETTING = operatorFactorSetting( + "node.bandwidth.recovery.operator.factor.read" ); public static final Setting NODE_BANDWIDTH_RECOVERY_OPERATOR_FACTOR_MAX_OVERCOMMIT_SETTING = Setting.doubleSetting( @@ -184,6 +182,14 @@ private static Setting operatorFactorSetting(String key, double defaultV }, Property.NodeScope, Property.OperatorDynamic); } + private static Setting operatorFactorSetting(String key) { + return new Setting<>(key, NODE_BANDWIDTH_RECOVERY_OPERATOR_FACTOR_SETTING, s -> Setting.parseDouble(s, 0d, 1d, key), v -> { + if (v == 0d) { + throw new IllegalArgumentException("Failed to validate value [" + v + "] for factor setting [" + key + "] must be > [0]"); + } + }, Property.NodeScope, Property.OperatorDynamic); + } + /** * User-defined factors have a value in (0.0, 1.0] and fall back to a corresponding operator factor setting. */