diff options
Diffstat (limited to 'config-model/src/main/java/com/yahoo/vespa/model/clients/ContainerDocumentApi.java')
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/clients/ContainerDocumentApi.java | 40 |
1 files changed, 22 insertions, 18 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 d5f41353616..33c125dcecf 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 @@ -1,6 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.clients; +import com.yahoo.config.model.producer.AbstractConfigProducer; +import com.yahoo.container.bundle.BundleInstantiationSpecification; import com.yahoo.container.handler.threadpool.ContainerThreadpoolConfig; import com.yahoo.osgi.provider.model.ComponentModel; import com.yahoo.vespa.model.container.ContainerCluster; @@ -39,31 +41,31 @@ public class ContainerDocumentApi { private static void addFeedHandler(ContainerCluster<?> cluster, HandlerOptions handlerOptions) { String bindingSuffix = ContainerCluster.RESERVED_URI_PREFIX + "/feedapi"; - var executor = new Threadpool("feedapi-handler", handlerOptions.feedApiThreadpoolOptions); - var handler = newVespaClientHandler("com.yahoo.vespa.http.server.FeedHandler", - bindingSuffix, handlerOptions, executor); + var handler = newVespaClientHandler("com.yahoo.vespa.http.server.FeedHandler", bindingSuffix, handlerOptions); cluster.addComponent(handler); + var executor = new Threadpool("feedapi-handler", handlerOptions.feedApiThreadpoolOptions); + handler.inject(executor); + handler.addComponent(executor); } private static void addRestApiHandler(ContainerCluster<?> cluster, HandlerOptions handlerOptions) { - var handler = newVespaClientHandler("com.yahoo.document.restapi.resource.DocumentV1ApiHandler", - DOCUMENT_V1_PREFIX + "/*", handlerOptions, null); + var handler = newVespaClientHandler("com.yahoo.document.restapi.resource.DocumentV1ApiHandler", DOCUMENT_V1_PREFIX + "/*", handlerOptions); cluster.addComponent(handler); // We need to include a dummy implementation of the previous restapi handler (using the same class name). // The internal legacy test framework requires that the name of the old handler is listed in /ApplicationStatus. - var oldHandlerDummy = createHandler("com.yahoo.document.restapi.resource.RestApi", null); + var oldHandlerDummy = handlerComponentSpecification("com.yahoo.document.restapi.resource.RestApi"); cluster.addComponent(oldHandlerDummy); } public boolean ignoreUndefinedFields() { return ignoreUndefinedFields; } - private static Handler newVespaClientHandler(String componentId, - String bindingSuffix, - HandlerOptions handlerOptions, - Threadpool executor) { - Handler handler = createHandler(componentId, executor); + private static Handler<AbstractConfigProducer<?>> newVespaClientHandler( + String componentId, + String bindingSuffix, + HandlerOptions handlerOptions) { + Handler<AbstractConfigProducer<?>> handler = handlerComponentSpecification(componentId); if (handlerOptions.bindings.isEmpty()) { handler.addServerBindings( SystemBindingPattern.fromHttpPath(bindingSuffix), @@ -79,9 +81,9 @@ public class ContainerDocumentApi { return handler; } - private static Handler createHandler(String className, Threadpool executor) { - return new Handler(new ComponentModel(className, null, "vespaclient-container-plugin"), - executor); + private static Handler<AbstractConfigProducer<?>> handlerComponentSpecification(String className) { + return new Handler<>(new ComponentModel( + BundleInstantiationSpecification.getFromStrings(className, null, "vespaclient-container-plugin"), "")); } public static final class HandlerOptions { @@ -102,10 +104,12 @@ public class ContainerDocumentApi { } @Override - protected void setDefaultConfigValues(ContainerThreadpoolConfig.Builder builder) { - builder.maxThreads(-4) - .minThreads(-4) - .queueSize(500); + public void getConfig(ContainerThreadpoolConfig.Builder builder) { + super.getConfig(builder); + + // User options overrides below configuration + if (hasUserOptions()) return; + builder.maxThreads(-4).minThreads(-4).queueSize(500); } } |