Skip to content

Commit

Permalink
Operator factor settings should have the OperatorDynamic setting prop…
Browse files Browse the repository at this point in the history
…erty (elastic#83359)

Relates elastic#82819
  • Loading branch information
tlrx authored Feb 1, 2022
1 parent 3d4c3d2 commit 4f1e779
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,12 @@ public class RecoverySettings {
DEFAULT_FACTOR_VALUE
);

public static final Setting<Double> NODE_BANDWIDTH_RECOVERY_OPERATOR_FACTOR_WRITE_SETTING = factorSetting(
"node.bandwidth.recovery.operator.factor.write",
NODE_BANDWIDTH_RECOVERY_OPERATOR_FACTOR_SETTING
public static final Setting<Double> NODE_BANDWIDTH_RECOVERY_OPERATOR_FACTOR_WRITE_SETTING = operatorFactorSetting(
"node.bandwidth.recovery.operator.factor.write"
);

public static final Setting<Double> NODE_BANDWIDTH_RECOVERY_OPERATOR_FACTOR_READ_SETTING = factorSetting(
"node.bandwidth.recovery.operator.factor.read",
NODE_BANDWIDTH_RECOVERY_OPERATOR_FACTOR_SETTING
public static final Setting<Double> NODE_BANDWIDTH_RECOVERY_OPERATOR_FACTOR_READ_SETTING = operatorFactorSetting(
"node.bandwidth.recovery.operator.factor.read"
);

public static final Setting<Double> NODE_BANDWIDTH_RECOVERY_OPERATOR_FACTOR_MAX_OVERCOMMIT_SETTING = Setting.doubleSetting(
Expand Down Expand Up @@ -184,6 +182,14 @@ private static Setting<Double> operatorFactorSetting(String key, double defaultV
}, Property.NodeScope, Property.OperatorDynamic);
}

private static Setting<Double> 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.
*/
Expand Down

0 comments on commit 4f1e779

Please sign in to comment.