diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2020-10-19 13:08:28 +0200 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2020-10-19 13:11:45 +0200 |
commit | 96e57d962282f90b29a01dd188ae9ba1e26746d8 (patch) | |
tree | 7c5e9575ea8b02ef0e97c6ad703b41f20e308f66 /config-model/src/main/java/com/yahoo/vespa/model/container | |
parent | bd1cdc00cdf97a01cdf82e082728f519f3f53572 (diff) |
Move vcpu() method to ContainerCluster
Diffstat (limited to 'config-model/src/main/java/com/yahoo/vespa/model/container')
4 files changed, 11 insertions, 10 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java index 0bafd3cfdcf..4888add3253 100755 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java @@ -69,6 +69,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; +import java.util.OptionalDouble; import java.util.Set; /** @@ -630,4 +631,12 @@ public abstract class ContainerCluster<CONTAINER extends Container> public boolean getDeferChangesUntilRestart() { return deferChangesUntilRestart; } + /** Effective vcpu for the containers in cluster. Use this value as scale factor for performance/resource tuning. **/ + public OptionalDouble vcpu() { + return getContainers().stream() + .filter(c -> c.getHostResource() != null && c.getHostResource().realResources() != null) + .mapToDouble(c -> c.getHostResource().realResources().vcpu()) + .max(); // Use highest vcpu as scale factor + } + } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerThreadpool.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerThreadpool.java index 93a02833d26..5074f1ecbbe 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerThreadpool.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerThreadpool.java @@ -11,7 +11,6 @@ import com.yahoo.vespa.model.container.component.SimpleComponent; import org.w3c.dom.Element; import java.util.Optional; -import java.util.OptionalDouble; /** * Component definition for a {@link java.util.concurrent.Executor} using {@link ContainerThreadPool}. @@ -48,13 +47,6 @@ public class ContainerThreadpool extends SimpleComponent implements ContainerThr protected Optional<UserOptions> userOptions() { return Optional.ofNullable(userOptions); } protected boolean hasUserOptions() { return userOptions().isPresent(); } - protected static OptionalDouble vcpu(ContainerCluster<?> cluster) { - return cluster.getContainers().stream() - .filter(c -> c.getHostResource() != null && c.getHostResource().realResources() != null) - .mapToDouble(c -> c.getHostResource().realResources().vcpu()) - .max(); // Use highest vcpu as scale factor - } - public static class UserOptions { private final int maxThreads; private final int minThreads; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/DefaultThreadpoolProvider.java b/config-model/src/main/java/com/yahoo/vespa/model/container/DefaultThreadpoolProvider.java index 1ebd62d6479..2db567b1460 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/DefaultThreadpoolProvider.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/DefaultThreadpoolProvider.java @@ -40,7 +40,7 @@ class DefaultThreadpoolProvider extends SimpleComponent implements ThreadpoolCon } double threadPoolSizeFactor = deployState.getProperties().threadPoolSizeFactor(); - double vcpu = ContainerThreadpool.vcpu(cluster).orElse(0); + double vcpu = cluster.vcpu().orElse(0); if (threadPoolSizeFactor <= 0 || vcpu == 0) return; // Configuration is currently identical to the search handler's threadpool diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/SearchHandler.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/SearchHandler.java index 473cfa05e64..ff6fd48c06a 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/SearchHandler.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/SearchHandler.java @@ -57,7 +57,7 @@ class SearchHandler extends ProcessingHandler<SearchChains> { if (hasUserOptions()) return; double threadPoolSizeFactor = deployState.getProperties().threadPoolSizeFactor(); - double vcpu = vcpu(cluster).orElse(0); + double vcpu = cluster.vcpu().orElse(0); if (threadPoolSizeFactor <= 0 || vcpu == 0) { builder.maxThreads(500); builder.minThreads(500); |