summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-08-04 13:49:05 +0200
committerGitHub <noreply@github.com>2020-08-04 13:49:05 +0200
commitd0689c6277623a495b915b08f0adb4b13627b7db (patch)
tree937ab9c84acc15a3ba79847e1353f36ce6b74164 /config-model/src/main/java
parent6498cfa2c279ddbec10a6ddcb53ca3e4d9300fdf (diff)
Revert "Bjorncs/container thread pool"
Diffstat (limited to 'config-model/src/main/java')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/clients/ContainerDocumentApi.java84
-rwxr-xr-xconfig-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java3
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/ThreadPoolExecutorComponent.java8
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java18
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/xml/DocumentApiOptionsBuilder.java5
5 files changed, 25 insertions, 93 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/clients/ContainerDocumentApi.java b/config-model/src/main/java/com/yahoo/vespa/model/clients/ContainerDocumentApi.java
index 965ae365597..58f03bffb30 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/clients/ContainerDocumentApi.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/clients/ContainerDocumentApi.java
@@ -5,104 +5,46 @@ import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.container.bundle.BundleInstantiationSpecification;
import com.yahoo.osgi.provider.model.ComponentModel;
import com.yahoo.vespa.model.container.ContainerCluster;
-import com.yahoo.vespa.model.container.ThreadPoolExecutorComponent;
import com.yahoo.vespa.model.container.component.Handler;
import java.util.Collection;
import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
/**
* @author Einar M R Rosenvinge
- * @author bjorncs
*/
public class ContainerDocumentApi {
- private static final int FALLBACK_MAX_POOL_SIZE = 0; // Use fallback based on actual logical core count on host
- private static final int FALLBACK_CORE_POOL_SIZE = 0; // Use fallback based on actual logical core count on host
-
- private final ContainerCluster<?> cluster;
+ private static final String vespaClientBundleSpecification = "vespaclient-container-plugin";
private final Options options;
- private final Handler<AbstractConfigProducer<?>> feedHandler;
- private final Handler<AbstractConfigProducer<?>> restApiHandler;
- public ContainerDocumentApi(ContainerCluster<?> cluster, Options options) {
- this.cluster = cluster;
+ public ContainerDocumentApi(ContainerCluster cluster, Options options) {
this.options = options;
- this.restApiHandler = addRestApiHandler(cluster, options);
- this.feedHandler = addFeedHandler(cluster, options);
- }
-
- public void addNodesDependentThreadpoolConfiguration() {
- if (cluster.getContainers().isEmpty()) throw new IllegalStateException("Cluster is empty");
- ThreadPoolExecutorComponent feedHandlerExecutor = newExecutorComponent("feedapi-handler", cluster, options);
- feedHandler.inject(feedHandlerExecutor);
- feedHandler.addComponent(feedHandlerExecutor);
- ThreadPoolExecutorComponent restApiHandlerExecutor = newExecutorComponent("restapi-handler", cluster, options);
- restApiHandler.inject(restApiHandlerExecutor);
- restApiHandler.addComponent(restApiHandlerExecutor);
- }
-
- private static Handler<AbstractConfigProducer<?>> addFeedHandler(ContainerCluster<?> cluster, Options options) {
- String bindingSuffix = ContainerCluster.RESERVED_URI_PREFIX + "/feedapi";
- var handler = newVespaClientHandler(
- "com.yahoo.vespa.http.server.FeedHandler", bindingSuffix, options);
- cluster.addComponent(handler);
- return handler;
+ setupHandlers(cluster);
}
- private static Handler<AbstractConfigProducer<?>> addRestApiHandler(ContainerCluster<?> cluster, Options options) {
- var handler = newVespaClientHandler(
- "com.yahoo.document.restapi.resource.RestApi", "document/v1/*", options);
- cluster.addComponent(handler);
- return handler;
+ private void setupHandlers(ContainerCluster cluster) {
+ cluster.addComponent(newVespaClientHandler("com.yahoo.document.restapi.resource.RestApi", "document/v1/*"));
+ cluster.addComponent(newVespaClientHandler("com.yahoo.vespa.http.server.FeedHandler", ContainerCluster.RESERVED_URI_PREFIX + "/feedapi"));
}
- private static ThreadPoolExecutorComponent newExecutorComponent(String name, ContainerCluster<?> cluster, Options options) {
- int maxPoolSize = maxPoolSize(cluster);
- return new ThreadPoolExecutorComponent.Builder(name)
- .maxPoolSize(maxPoolSize)
- .corePoolSize(corePoolSize(maxPoolSize, options))
- .queueSize(500)
- .build();
- }
-
- private static Handler<AbstractConfigProducer<?>> newVespaClientHandler(
- String componentId,
- String bindingSuffix,
- Options options) {
+ private Handler<AbstractConfigProducer<?>> newVespaClientHandler(String componentId, String bindingSuffix) {
Handler<AbstractConfigProducer<?>> handler = new Handler<>(new ComponentModel(
- BundleInstantiationSpecification.getFromStrings(componentId, null, "vespaclient-container-plugin"), ""));
+ BundleInstantiationSpecification.getFromStrings(componentId, null, vespaClientBundleSpecification), ""));
+
for (String rootBinding : options.bindings) {
- handler.addServerBindings(rootBinding + bindingSuffix, rootBinding + bindingSuffix + '/');
+ handler.addServerBindings(rootBinding + bindingSuffix,
+ rootBinding + bindingSuffix + '/');
}
return handler;
}
- private static int maxPoolSize(ContainerCluster<?> cluster) {
- List<Double> vcpus = cluster.getContainers().stream()
- .filter(c -> c.getHostResource() != null && c.getHostResource().realResources() != null)
- .map(c -> c.getHostResource().realResources().vcpu())
- .distinct()
- .collect(Collectors.toList());
- // We can only use host resource for calculation if all container nodes in the cluster are homogeneous (in terms of vcpu)
- if (vcpus.size() != 1 || vcpus.get(0) == 0) return FALLBACK_MAX_POOL_SIZE;
- return (int)Math.ceil(vcpus.get(0));
- }
-
- private static int corePoolSize(int maxPoolSize, Options options) {
- if (maxPoolSize == FALLBACK_MAX_POOL_SIZE) return FALLBACK_CORE_POOL_SIZE;
- return (int) Math.ceil(options.feedCoreThreadPoolSizeFactor * maxPoolSize);
- }
-
public static final class Options {
private final Collection<String> bindings;
- private final double feedCoreThreadPoolSizeFactor;
- public Options(Collection<String> bindings, double feedCoreThreadPoolSizeFactor) {
+
+ public Options(Collection<String> bindings) {
this.bindings = Collections.unmodifiableCollection(bindings);
- this.feedCoreThreadPoolSizeFactor = feedCoreThreadPoolSizeFactor;
}
}
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 82b23aa71b5..240157fb7aa 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
@@ -17,7 +17,6 @@ import com.yahoo.container.QrSearchersConfig;
import com.yahoo.container.bundle.BundleInstantiationSpecification;
import com.yahoo.container.core.ApplicationMetadataConfig;
import com.yahoo.container.core.document.ContainerDocumentConfig;
-import com.yahoo.container.handler.ThreadPoolProvider;
import com.yahoo.container.di.config.PlatformBundlesConfig;
import com.yahoo.container.handler.ThreadpoolConfig;
import com.yahoo.container.jdisc.JdiscBindingsConfig;
@@ -174,7 +173,7 @@ public abstract class ContainerCluster<CONTAINER extends Container>
addComponent(new StatisticsComponent());
addSimpleComponent(AccessLog.class);
- addSimpleComponent(ThreadPoolProvider.class);
+ addComponent(new ThreadPoolExecutorComponent.Builder("default-pool").build());
addSimpleComponent(com.yahoo.concurrent.classlock.ClassLocking.class);
addSimpleComponent(SecurityFilterInvoker.class);
addSimpleComponent("com.yahoo.container.jdisc.metric.MetricConsumerProviderProvider");
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ThreadPoolExecutorComponent.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ThreadPoolExecutorComponent.java
index aac73ce7636..2926cb3ee6c 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/ThreadPoolExecutorComponent.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ThreadPoolExecutorComponent.java
@@ -2,15 +2,15 @@
package com.yahoo.vespa.model.container;
import com.yahoo.container.bundle.BundleInstantiationSpecification;
+import com.yahoo.container.handler.ThreadPoolProvider;
import com.yahoo.container.handler.ThreadpoolConfig;
-import com.yahoo.container.handler.threadpool.ContainerThreadPool;
import com.yahoo.osgi.provider.model.ComponentModel;
import com.yahoo.vespa.model.container.component.SimpleComponent;
import java.time.Duration;
/**
- * Component definition for a {@link java.util.concurrent.Executor} using {@link ContainerThreadPool}.
+ * Component definition for a {@link java.util.concurrent.Executor} using {@link ThreadPoolProvider}.
*
* @author bjorncs
*/
@@ -26,8 +26,8 @@ public class ThreadPoolExecutorComponent extends SimpleComponent implements Thre
private ThreadPoolExecutorComponent(Builder builder) {
super(new ComponentModel(
BundleInstantiationSpecification.getFromStrings(
- "threadpool@" + builder.name,
- ContainerThreadPool.class.getName(),
+ "threadpool-provider@" + builder.name,
+ ThreadPoolProvider.class.getName(),
null)));
this.name = builder.name;
this.maxPoolSize = builder.maxPoolSize;
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java
index f24e469ea5c..41e092c7ea5 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java
@@ -183,7 +183,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
addProcessing(deployState, spec, cluster);
addSearch(deployState, spec, cluster);
addDocproc(deployState, spec, cluster);
- addDocumentApi(deployState, spec, cluster); // NOTE: Must be done after addSearch
+ addDocumentApi(spec, cluster); // NOTE: Must be done after addSearch
cluster.addDefaultHandlersExceptStatus();
addStatusHandlers(cluster, context.getDeployState().isHosted());
@@ -198,7 +198,6 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
addClientProviders(deployState, spec, cluster);
addServerProviders(deployState, spec, cluster);
- addHandlerSpecificThreadpools(cluster);
addAthensCopperArgos(cluster, context); // Must be added after nodes.
}
@@ -213,13 +212,6 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
}
}
- private void addHandlerSpecificThreadpools(ContainerCluster<?> cluster) {
- ContainerDocumentApi documentApi = cluster.getDocumentApi();
- if (documentApi != null) {
- documentApi.addNodesDependentThreadpoolConfiguration();
- }
- }
-
private void addAthensCopperArgos(ApplicationContainerCluster cluster, ConfigModelContext context) {
if ( ! context.getDeployState().isHosted()) return;
app.getDeployment().map(DeploymentSpec::fromXml)
@@ -408,8 +400,8 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
cluster.addServlet(new ServletBuilder().build(deployState, cluster, servletElem));
}
- private void addDocumentApi(DeployState deployState, Element spec, ApplicationContainerCluster cluster) {
- ContainerDocumentApi containerDocumentApi = buildDocumentApi(deployState, cluster, spec);
+ private void addDocumentApi(Element spec, ApplicationContainerCluster cluster) {
+ ContainerDocumentApi containerDocumentApi = buildDocumentApi(cluster, spec);
if (containerDocumentApi == null) return;
cluster.setDocumentApi(containerDocumentApi);
@@ -838,11 +830,11 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
return result.toArray(new String[result.size()]);
}
- private ContainerDocumentApi buildDocumentApi(DeployState deployState, ApplicationContainerCluster cluster, Element spec) {
+ private ContainerDocumentApi buildDocumentApi(ApplicationContainerCluster cluster, Element spec) {
Element documentApiElement = XML.getChild(spec, "document-api");
if (documentApiElement == null) return null;
- ContainerDocumentApi.Options documentApiOptions = DocumentApiOptionsBuilder.build(deployState, documentApiElement);
+ ContainerDocumentApi.Options documentApiOptions = DocumentApiOptionsBuilder.build(documentApiElement);
return new ContainerDocumentApi(cluster, documentApiOptions);
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/DocumentApiOptionsBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/DocumentApiOptionsBuilder.java
index bbeeffda612..ae74dbdb4a7 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/DocumentApiOptionsBuilder.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/DocumentApiOptionsBuilder.java
@@ -1,7 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.xml;
-import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.text.XML;
import com.yahoo.vespa.model.clients.ContainerDocumentApi;
import org.w3c.dom.Element;
@@ -21,8 +20,8 @@ public class DocumentApiOptionsBuilder {
private static final Logger log = Logger.getLogger(DocumentApiOptionsBuilder.class.getName());
private static final String[] DEFAULT_BINDINGS = {"http://*/"};
- public static ContainerDocumentApi.Options build(DeployState deployState, Element spec) {
- return new ContainerDocumentApi.Options(getBindings(spec), deployState.getProperties().feedCoreThreadPoolSizeFactor());
+ public static ContainerDocumentApi.Options build(Element spec) {
+ return new ContainerDocumentApi.Options(getBindings(spec));
}
private static List<String> getBindings(Element spec) {