diff options
author | Kristian Aune <kraune@verizonmedia.com> | 2023-10-18 10:32:29 +0200 |
---|---|---|
committer | Kristian Aune <kraune@verizonmedia.com> | 2023-10-18 10:32:29 +0200 |
commit | bd84e40fb7b588ca32f1fb0016ba90ff7ee04584 (patch) | |
tree | b561e07ac29bf156ad6b8988dd79febf69e56a9e | |
parent | 771b853b8a0b13a476854eed4e98317d02232ebc (diff) |
Make code locale-independent
2 files changed, 12 insertions, 11 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/JvmHeapSizeValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/JvmHeapSizeValidator.java index 510fff66c10..425a662bb2d 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/JvmHeapSizeValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/JvmHeapSizeValidator.java @@ -3,6 +3,7 @@ package com.yahoo.vespa.model.application.validation; import com.yahoo.config.model.deploy.DeployState; +import com.yahoo.text.Text; import com.yahoo.vespa.model.VespaModel; import java.util.logging.Level; @@ -32,21 +33,20 @@ public class JvmHeapSizeValidator extends Validator { double gbLimit = 0.6; double availableMemoryGb = mp.availableMemoryGb().getAsDouble(); double modelCostGb = jvmModelCost / (1024D * 1024 * 1024); - ds.getDeployLogger().log(Level.FINE, () -> "JVM: %d%% (limit: %d%%), %.2fGB (limit: %.2fGB), ONNX: %.2fGB" - .formatted(mp.percentage(), percentLimit, availableMemoryGb, gbLimit, modelCostGb)); + ds.getDeployLogger().log(Level.FINE, () -> Text.format("JVM: %d%% (limit: %d%%), %.2fGB (limit: %.2fGB), ONNX: %.2fGB", + mp.percentage(), percentLimit, availableMemoryGb, gbLimit, modelCostGb)); if (mp.percentage() < percentLimit) { - throw new IllegalArgumentException( - ("Allocated percentage of memory of JVM in cluster '%s' is too low (%d%% < %d%%). " + + throw new IllegalArgumentException(Text.format("Allocated percentage of memory of JVM in cluster '%s' is too low (%d%% < %d%%). " + "Estimated cost of ONNX models is %.2fGB. Either use a node flavor with more memory or use less expensive models. " + - "You may override this validation by specifying 'allocated-memory' (https://docs.vespa.ai/en/performance/container-tuning.html#jvm-heap-size).") - .formatted(clusterId, mp.percentage(), percentLimit, modelCostGb)); + "You may override this validation by specifying 'allocated-memory' (https://docs.vespa.ai/en/performance/container-tuning.html#jvm-heap-size).", + clusterId, mp.percentage(), percentLimit, modelCostGb)); } if (availableMemoryGb < gbLimit) { throw new IllegalArgumentException( - ("Allocated memory to JVM in cluster '%s' is too low (%.2fGB < %.2fGB). " + + Text.format("Allocated memory to JVM in cluster '%s' is too low (%.2fGB < %.2fGB). " + "Estimated cost of ONNX models is %.2fGB. Either use a node flavor with more memory or use less expensive models. " + - "You may override this validation by specifying 'allocated-memory' (https://docs.vespa.ai/en/performance/container-tuning.html#jvm-heap-size).") - .formatted(clusterId, availableMemoryGb, gbLimit, modelCostGb)); + "You may override this validation by specifying 'allocated-memory' (https://docs.vespa.ai/en/performance/container-tuning.html#jvm-heap-size).", + clusterId, availableMemoryGb, gbLimit, modelCostGb)); } } }); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/JvmHeapSizeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/JvmHeapSizeValidatorTest.java index d6da03f5b94..ebd8b5836da 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/JvmHeapSizeValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/JvmHeapSizeValidatorTest.java @@ -15,6 +15,7 @@ import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.config.model.provision.InMemoryProvisioner; import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.config.provision.NodeResources; +import com.yahoo.text.Text; import com.yahoo.vespa.model.VespaModel; import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; @@ -97,7 +98,7 @@ class JvmHeapSizeValidatorTest { private static DeployState createDeployState(double nodeGb, long modelCostBytes) { String servicesXml = - """ + Text.format(""" <?xml version="1.0" encoding="utf-8" ?> <services version='1.0'> <container version='1.0'> @@ -109,7 +110,7 @@ class JvmHeapSizeValidatorTest { <tokenizer-model path="app/tokenizer.json"/> </component> </container> - </services>""".formatted(nodeGb); + </services>""", nodeGb); return createDeployState(servicesXml, nodeGb, modelCostBytes); } |