diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2020-11-03 11:20:29 +0100 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2020-11-03 11:20:29 +0100 |
commit | 7adc1225e6494e8b5b23dcf8800c4a752ff6a7cc (patch) | |
tree | f05c2d5ca6bcd5a1c32b5fcd628332062dd26e26 /config-model | |
parent | c56b3b30489a279223c9b06760f34da124b7e587 (diff) |
Use new restapi handler implementation by default
Remove feature flag for enabling the new handler.
Cleanup wiring of old and new handler in model.
Diffstat (limited to 'config-model')
3 files changed, 27 insertions, 38 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 6ad81c90107..05502daf10e 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 @@ -30,42 +30,34 @@ public class ContainerDocumentApi { private static void addFeedHandler(ContainerCluster<?> cluster, Options options) { String bindingSuffix = ContainerCluster.RESERVED_URI_PREFIX + "/feedapi"; - var handler = newVespaClientHandler( - "com.yahoo.vespa.http.server.FeedHandler", bindingSuffix, options); + var handler = newVespaClientHandler("com.yahoo.vespa.http.server.FeedHandler", bindingSuffix, options); cluster.addComponent(handler); - var executor = new Threadpool( - "feedapi-handler", cluster, options.feedApiThreadpoolOptions); + var executor = new Threadpool("feedapi-handler", cluster, options.feedApiThreadpoolOptions); handler.inject(executor); handler.addComponent(executor); } private static void addRestApiHandler(ContainerCluster<?> cluster, Options options) { - // TODO(bjorncs,jonmv) Cleanup once old restapi handler is gone - // We need to include the old handler implementation even when the new handler is enabled - // The internal legacy test framework requires that the name of the old handler is listed in /ApplicationStatus - String oldHandlerName = "com.yahoo.document.restapi.resource.RestApi"; - String bindingSuffix = "/document/v1/*"; - var oldHandler = newVespaClientHandler(oldHandlerName, options.useNewRestapiHandler ? null : bindingSuffix, options); - cluster.addComponent(oldHandler); - var executor = new Threadpool("restapi-handler", cluster, /*userOptions*/null); - oldHandler.inject(executor); - oldHandler.addComponent(executor); + var handler = newVespaClientHandler("com.yahoo.document.restapi.resource.DocumentV1ApiHandler", "/document/v1/*", options); + cluster.addComponent(handler); - if (options.useNewRestapiHandler) { - String newHandlerName = "com.yahoo.document.restapi.resource.DocumentV1ApiHandler"; - var newHandler = newVespaClientHandler(newHandlerName, bindingSuffix, options); - cluster.addComponent(newHandler); - } + // 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 = handlerComponentSpecification("com.yahoo.document.restapi.resource.RestApi"); + cluster.addComponent(oldHandlerDummy); + + // TODO(bjorncs,jonmv) Remove threadpool once RestApi handler is reduced to a dummy + var executor = new Threadpool("restapi-handler", cluster, /*userOptions*/null); + oldHandlerDummy.inject(executor); + oldHandlerDummy.addComponent(executor); } private static Handler<AbstractConfigProducer<?>> newVespaClientHandler( String componentId, String bindingSuffix, Options options) { - Handler<AbstractConfigProducer<?>> handler = new Handler<>(new ComponentModel( - BundleInstantiationSpecification.getFromStrings(componentId, null, "vespaclient-container-plugin"), "")); - if (bindingSuffix == null) return handler; // TODO(bjorncs,jonmv) Cleanup once old restapi handler is gone + Handler<AbstractConfigProducer<?>> handler = handlerComponentSpecification(componentId); if (options.bindings.isEmpty()) { handler.addServerBindings( SystemBindingPattern.fromHttpPath(bindingSuffix), @@ -81,17 +73,18 @@ public class ContainerDocumentApi { return handler; } + private static Handler<AbstractConfigProducer<?>> handlerComponentSpecification(String className) { + return new Handler<>(new ComponentModel( + BundleInstantiationSpecification.getFromStrings(className, null, "vespaclient-container-plugin"), "")); + } + public static final class Options { private final Collection<String> bindings; private final ContainerThreadpool.UserOptions feedApiThreadpoolOptions; - private final boolean useNewRestapiHandler; - public Options(Collection<String> bindings, - ContainerThreadpool.UserOptions feedApiThreadpoolOptions, - boolean useNewRestapiHandler) { + public Options(Collection<String> bindings, ContainerThreadpool.UserOptions feedApiThreadpoolOptions) { this.bindings = Collections.unmodifiableCollection(bindings); this.feedApiThreadpoolOptions = feedApiThreadpoolOptions; - this.useNewRestapiHandler = useNewRestapiHandler; } } 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 37dd97a49b1..d76d177fd21 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 @@ -180,7 +180,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()); @@ -401,8 +401,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); @@ -829,11 +829,11 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { return result; } - 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 b5f77157be1..b991608eb48 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 com.yahoo.vespa.model.container.ContainerThreadpool; @@ -20,11 +19,8 @@ public class DocumentApiOptionsBuilder { private static final Logger log = Logger.getLogger(DocumentApiOptionsBuilder.class.getName()); - public static ContainerDocumentApi.Options build(DeployState deployState, Element spec) { - return new ContainerDocumentApi.Options( - getBindings(spec), - threadpoolOptions(spec, "http-client-api"), - deployState.getProperties().useNewRestapiHandler()); + public static ContainerDocumentApi.Options build(Element spec) { + return new ContainerDocumentApi.Options(getBindings(spec), threadpoolOptions(spec, "http-client-api")); } private static ContainerThreadpool.UserOptions threadpoolOptions(Element spec, String elementName) { |