summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'config-model/src/main/java')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java79
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java15
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java2
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java32
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java1
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricSet.java2
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV4Builder.java52
-rwxr-xr-xconfig-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java31
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/jersey/JerseyHandler.java28
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApi.java54
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApiContext.java6
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/jersey/xml/RestApiBuilder.java5
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/FederationSearcher.java1
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/routing/Protocol.java16
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/routing/Routing.java5
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/DocumentDatabase.java11
16 files changed, 174 insertions, 166 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java b/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java
index 8c7398b3dde..afd33da369f 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java
@@ -13,12 +13,16 @@ import com.yahoo.searchlib.rankingexpression.rule.ReferenceNode;
import com.yahoo.tensor.TensorType;
import com.yahoo.tensor.evaluation.TypeContext;
+import java.util.ArrayDeque;
import java.util.Collection;
import java.util.Collections;
+import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.Stack;
+import java.util.stream.Collectors;
/**
* A context which only contains type information.
@@ -26,21 +30,29 @@ import java.util.Optional;
* query, attribute or constant features, as we do not have information about which such
* features exist (but we know those that exist are doubles).
*
+ * This is not multithread safe.
+ *
* @author bratseth
*/
public class MapEvaluationTypeContext extends FunctionReferenceContext implements TypeContext<Reference> {
private final Map<Reference, TensorType> featureTypes = new HashMap<>();
- public MapEvaluationTypeContext(Collection<ExpressionFunction> functions) {
+ /** For invocation loop detection */
+ private final Deque<Reference> currentResolutionCallStack;
+
+ MapEvaluationTypeContext(Collection<ExpressionFunction> functions) {
super(functions);
+ this.currentResolutionCallStack = new ArrayDeque<>();
}
- public MapEvaluationTypeContext(Map<String, ExpressionFunction> functions,
- Map<String, String> bindings,
- Map<Reference, TensorType> featureTypes) {
+ private MapEvaluationTypeContext(Map<String, ExpressionFunction> functions,
+ Map<String, String> bindings,
+ Map<Reference, TensorType> featureTypes,
+ Deque<Reference> currentResolutionCallStack) {
super(functions, bindings);
this.featureTypes.putAll(featureTypes);
+ this.currentResolutionCallStack = currentResolutionCallStack;
}
public void setType(Reference reference, TensorType type) {
@@ -54,6 +66,11 @@ public class MapEvaluationTypeContext extends FunctionReferenceContext implement
@Override
public TensorType getType(Reference reference) {
+ if (currentResolutionCallStack.contains(reference))
+ throw new IllegalArgumentException("Invocation loop: " +
+ currentResolutionCallStack.stream().map(Reference::toString).collect(Collectors.joining(" -> ")) +
+ " -> " + reference);
+
// A reference to a macro argument?
Optional<String> binding = boundIdentifier(reference);
if (binding.isPresent()) {
@@ -61,36 +78,42 @@ public class MapEvaluationTypeContext extends FunctionReferenceContext implement
// This is not pretty, but changing to bind expressions rather
// than their string values requires deeper changes
return new RankingExpression(binding.get()).type(this);
- }
- catch (ParseException e) {
+ } catch (ParseException e) {
throw new IllegalArgumentException(e);
}
}
- // A reference to an attribute, query or constant feature?
- if (FeatureNames.isSimpleFeature(reference)) {
- // The argument may be a local identifier bound to the actual value
- String argument = reference.simpleArgument().get();
- reference = Reference.simple(reference.name(), bindings.getOrDefault(argument, argument));
- return featureTypes.getOrDefault(reference, defaultTypeOf(reference));
- }
+ try {
+ currentResolutionCallStack.addLast(reference);
- // A reference to a function?
- Optional<ExpressionFunction> function = functionInvocation(reference);
- if (function.isPresent()) {
- return function.get().getBody().type(this.withBindings(bind(function.get().arguments(), reference.arguments())));
- }
+ // A reference to an attribute, query or constant feature?
+ if (FeatureNames.isSimpleFeature(reference)) {
+ // The argument may be a local identifier bound to the actual value
+ String argument = reference.simpleArgument().get();
+ reference = Reference.simple(reference.name(), bindings.getOrDefault(argument, argument));
+ return featureTypes.getOrDefault(reference, defaultTypeOf(reference));
+ }
- // A reference to a feature which returns a tensor?
- Optional<TensorType> featureTensorType = tensorFeatureType(reference);
- if (featureTensorType.isPresent()) {
- return featureTensorType.get();
- }
+ // A reference to a function?
+ Optional<ExpressionFunction> function = functionInvocation(reference);
+ if (function.isPresent()) {
+ return function.get().getBody().type(this.withBindings(bind(function.get().arguments(), reference.arguments())));
+ }
+
+ // A reference to a feature which returns a tensor?
+ Optional<TensorType> featureTensorType = tensorFeatureType(reference);
+ if (featureTensorType.isPresent()) {
+ return featureTensorType.get();
+ }
- // We do not know what this is - since we do not have complete knowledge abut the match features
- // in Java we must assume this is a match feature and return the double type - which is the type of all
- // all match features
- return TensorType.empty;
+ // We do not know what this is - since we do not have complete knowledge abut the match features
+ // in Java we must assume this is a match feature and return the double type - which is the type of all
+ // all match features
+ return TensorType.empty;
+ }
+ finally {
+ currentResolutionCallStack.removeLast();
+ }
}
/**
@@ -173,7 +196,7 @@ public class MapEvaluationTypeContext extends FunctionReferenceContext implement
@Override
public MapEvaluationTypeContext withBindings(Map<String, String> bindings) {
if (bindings.isEmpty() && this.bindings.isEmpty()) return this;
- return new MapEvaluationTypeContext(functions(), bindings, featureTypes);
+ return new MapEvaluationTypeContext(functions(), bindings, featureTypes, currentResolutionCallStack);
}
}
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java
index 164cb7f808e..5ac1418c0c7 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java
@@ -1,6 +1,11 @@
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition;
+import com.yahoo.config.FileReference;
+import com.yahoo.vespa.model.AbstractService;
+import com.yahoo.vespa.model.utils.FileSender;
+
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -33,4 +38,14 @@ public class RankingConstants {
return Collections.unmodifiableMap(constants);
}
+ /** Initiate sending of these constants to some services over file distribution */
+ public void sendTo(Collection<? extends AbstractService> services) {
+ for (RankingConstant constant : constants.values()) {
+ FileReference reference = (constant.getPathType() == RankingConstant.PathType.FILE)
+ ? FileSender.sendFileToServices(constant.getFileName(), services)
+ : FileSender.sendUriToServices(constant.getUri(), services);
+ constant.setFileReference(reference.value());
+ }
+ }
+
}
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java
index 4af26b72817..9a00ee5bbd0 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java
@@ -94,7 +94,7 @@ public class DerivedConfiguration {
summaries = new Summaries(search, deployLogger);
summaryMap = new SummaryMap(search, summaries);
juniperrc = new Juniperrc(search);
- rankProfileList = new RankProfileList(search, attributeFields, rankProfileRegistry, queryProfiles, importedModels);
+ rankProfileList = new RankProfileList(search, search.rankingConstants(), attributeFields, rankProfileRegistry, queryProfiles, importedModels);
indexingScript = new IndexingScript(search);
indexInfo = new IndexInfo(search);
indexSchema = new IndexSchema(search);
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
index 10881ab9ce0..fcbfb47c597 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
@@ -3,24 +3,35 @@ package com.yahoo.searchdefinition.derived;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.searchdefinition.RankProfileRegistry;
+import com.yahoo.searchdefinition.RankingConstant;
+import com.yahoo.searchdefinition.RankingConstants;
import com.yahoo.searchlib.rankingexpression.integration.ml.ImportedModels;
import com.yahoo.vespa.config.search.RankProfilesConfig;
import com.yahoo.searchdefinition.RankProfile;
import com.yahoo.searchdefinition.Search;
+import com.yahoo.vespa.config.search.core.RankingConstantsConfig;
+import com.yahoo.vespa.model.AbstractService;
+
+import java.util.Collection;
import java.util.Map;
+import java.util.logging.Logger;
/**
* The derived rank profiles of a search definition
*
* @author bratseth
*/
-public class RankProfileList extends Derived implements RankProfilesConfig.Producer {
+public class RankProfileList extends Derived implements RankProfilesConfig.Producer, RankingConstantsConfig.Producer {
+
+ private static final Logger log = Logger.getLogger(RankProfileList.class.getName());
private final Map<String, RawRankProfile> rankProfiles = new java.util.LinkedHashMap<>();
+ private final RankingConstants rankingConstants;
public static RankProfileList empty = new RankProfileList();
private RankProfileList() {
+ this.rankingConstants = new RankingConstants();
}
/**
@@ -30,11 +41,13 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ
* @param attributeFields the attribute fields to create a ranking for
*/
public RankProfileList(Search search,
+ RankingConstants rankingConstants,
AttributeFields attributeFields,
RankProfileRegistry rankProfileRegistry,
QueryProfileRegistry queryProfiles,
ImportedModels importedModels) {
setName(search == null ? "default" : search.getName());
+ this.rankingConstants = rankingConstants;
deriveRankProfiles(rankProfileRegistry, queryProfiles, importedModels, search, attributeFields);
}
@@ -68,6 +81,10 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ
return rankProfiles.get(name);
}
+ public void sendConstantsTo(Collection<? extends AbstractService> services) {
+ rankingConstants.sendTo(services);
+ }
+
@Override
public String getDerivedName() { return "rank-profiles"; }
@@ -78,4 +95,17 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ
}
}
+ @Override
+ public void getConfig(RankingConstantsConfig.Builder builder) {
+ for (RankingConstant constant : rankingConstants.asMap().values()) {
+ if ("".equals(constant.getFileReference()))
+ log.warning("Illegal file reference " + constant); // Let tests pass ... we should find a better way
+ else
+ builder.constant(new RankingConstantsConfig.Constant.Builder()
+ .name(constant.getName())
+ .fileref(constant.getFileReference())
+ .type(constant.getType()));
+ }
+ }
+
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java
index 3e9d188670e..1b15233fead 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java
@@ -169,6 +169,7 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri
deployState.rankProfileRegistry(),
deployState.getQueryProfiles().getRegistry());
this.rankProfileList = new RankProfileList(null, // null search -> global
+ rankingConstants,
AttributeFields.empty,
deployState.rankProfileRegistry(),
deployState.getQueryProfiles().getRegistry(),
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricSet.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricSet.java
index e8985b094ac..73d77406700 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricSet.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricSet.java
@@ -135,6 +135,8 @@ public class VespaMetricSet {
metrics.add(new Metric("http.status.3xx.rate"));
metrics.add(new Metric("http.status.4xx.rate"));
metrics.add(new Metric("http.status.5xx.rate"));
+ metrics.add(new Metric("http.status.401.rate"));
+ metrics.add(new Metric("http.status.403.rate"));
metrics.add(new Metric("jdisc.http.request.uri_length.average"));
metrics.add(new Metric("jdisc.http.request.uri_length.max"));
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV4Builder.java b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV4Builder.java
index e34d490afe1..095b27a0904 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV4Builder.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV4Builder.java
@@ -1,18 +1,22 @@
// 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.builder.xml.dom;
-import com.yahoo.component.Version;
import com.yahoo.config.model.ConfigModelContext;
import com.yahoo.config.model.api.ConfigServerSpec;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ClusterSpec;
+import com.yahoo.config.provision.SystemName;
+import com.yahoo.log.LogLevel;
+import com.yahoo.searchdefinition.derived.RankProfileList;
import com.yahoo.vespa.model.HostResource;
import com.yahoo.vespa.model.HostSystem;
import com.yahoo.vespa.model.admin.Admin;
import com.yahoo.vespa.model.admin.Logserver;
import com.yahoo.vespa.model.admin.Slobrok;
import com.yahoo.vespa.model.container.Container;
+import com.yahoo.vespa.model.container.ContainerCluster;
import com.yahoo.vespa.model.container.ContainerModel;
+import com.yahoo.vespa.model.container.component.Handler;
import org.w3c.dom.Element;
import java.util.ArrayList;
@@ -73,14 +77,46 @@ public class DomAdminV4Builder extends DomAdminBuilderBase {
if (nodesSpecification.count() > 1) throw new IllegalArgumentException("You can only request a single log server");
if (nodesSpecification.isDedicated()) {
- createLogserver(admin, allocateHosts(admin.getHostSystem(), "logserver", nodesSpecification));
- }
- else {
- if (containerModels.iterator().hasNext())
- createLogserver(admin, sortedContainerHostsFrom(containerModels.iterator().next(), nodesSpecification.count(), false));
+ Collection<HostResource> hosts = allocateHosts(admin.getHostSystem(), "logserver", nodesSpecification);
+ if (hosts.isEmpty()) return; // No log server can be created (and none is needed)
+
+ Logserver logserver = createLogserver(admin, hosts);
+ // TODO: Enable for main system as well
+ if (context.getDeployState().isHosted() && context.getDeployState().zone().system() == SystemName.cd)
+ createAdditionalContainerOnLogserverHost(admin, logserver.getHostResource());
+ } else if (containerModels.iterator().hasNext()) {
+ List<HostResource> hosts = sortedContainerHostsFrom(containerModels.iterator().next(), nodesSpecification.count(), false);
+ if (hosts.isEmpty()) return; // No log server can be created (and none is needed)
+
+ createLogserver(admin, hosts);
+ } else {
+ context.getDeployLogger().log(LogLevel.INFO, "No container host available to use for running logserver");
}
}
+ // Creates a container cluster 'logserver-cluster' with 1 container on logserver host
+ // for setting up a handler for getting logs from logserver
+ private void createAdditionalContainerOnLogserverHost(Admin admin, HostResource hostResource) {
+ ContainerCluster logServerCluster = new ContainerCluster(admin, "logserver-cluster", "logserver-cluster", RankProfileList.empty);
+ ContainerModel logserverClusterModel = new ContainerModel(context.withParent(admin).withId(logServerCluster.getSubId()));
+ logserverClusterModel.setCluster(logServerCluster);
+
+ addLogHandler(logServerCluster);
+
+ Container container = new Container(logServerCluster, "logserver-container", 0);
+ container.setHostResource(hostResource);
+ container.initService();
+ logServerCluster.addContainer(container);
+ admin.addAndInitializeService(hostResource, container);
+ }
+
+ // TODO: Wire in handler for getting logs
+ private void addLogHandler(ContainerCluster cluster) {
+ Handler<?> logHandler = Handler.fromClassName("TODO");
+ //logHandler.addServerBindings("http://*/logs/", "https://*/logs/");
+ cluster.addComponent(logHandler);
+ }
+
private Collection<HostResource> allocateHosts(HostSystem hostSystem, String clusterId, NodesSpecification nodesSpecification) {
return nodesSpecification.provision(hostSystem,
ClusterSpec.Type.admin,
@@ -148,12 +184,12 @@ public class DomAdminV4Builder extends DomAdminBuilderBase {
return HostResource.pickHosts(hosts, count, 1);
}
- private void createLogserver(Admin admin, Collection<HostResource> hosts) {
- if (hosts.isEmpty()) return; // No log server can be created (and none is needed)
+ private Logserver createLogserver(Admin admin, Collection<HostResource> hosts) {
Logserver logserver = new Logserver(admin);
logserver.setHostResource(hosts.iterator().next());
admin.setLogserver(logserver);
logserver.initService();
+ return logserver;
}
private void createSlobroks(Admin admin, Collection<HostResource> hosts) {
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 8c6c13d810f..fbe86d26b02 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
@@ -41,10 +41,9 @@ import com.yahoo.search.config.IndexInfoConfig;
import com.yahoo.search.config.QrStartConfig;
import com.yahoo.search.pagetemplates.PageTemplatesConfig;
import com.yahoo.search.query.profile.config.QueryProfilesConfig;
-import com.yahoo.searchdefinition.RankProfileRegistry;
-import com.yahoo.searchdefinition.derived.AttributeFields;
import com.yahoo.searchdefinition.derived.RankProfileList;
import com.yahoo.vespa.config.search.RankProfilesConfig;
+import com.yahoo.vespa.config.search.core.RankingConstantsConfig;
import com.yahoo.vespa.configdefinition.IlscriptsConfig;
import com.yahoo.vespa.model.PortsMeta;
import com.yahoo.vespa.model.Service;
@@ -66,11 +65,9 @@ import com.yahoo.vespa.model.container.docproc.ContainerDocproc;
import com.yahoo.vespa.model.container.docproc.DocprocChains;
import com.yahoo.vespa.model.container.http.Http;
import com.yahoo.vespa.model.container.jersey.Jersey2Servlet;
-import com.yahoo.vespa.model.container.jersey.JerseyHandler;
import com.yahoo.vespa.model.container.jersey.RestApi;
import com.yahoo.vespa.model.container.processing.ProcessingChains;
import com.yahoo.vespa.model.container.search.ContainerSearch;
-import com.yahoo.vespa.model.container.search.QueryProfiles;
import com.yahoo.vespa.model.container.search.searchchain.SearchChains;
import com.yahoo.vespa.model.content.Content;
import com.yahoo.vespa.model.search.AbstractSearchCluster;
@@ -79,7 +76,6 @@ import com.yahoo.vespaclient.config.FeederConfig;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
-
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
@@ -91,7 +87,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
-import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -129,7 +124,8 @@ public final class ContainerCluster
RoutingProviderConfig.Producer,
ConfigserverConfig.Producer,
ThreadpoolConfig.Producer,
- RankProfilesConfig.Producer
+ RankProfilesConfig.Producer,
+ RankingConstantsConfig.Producer
{
@@ -364,6 +360,7 @@ public final class ContainerCluster
public void prepare() {
addAndSendApplicationBundles();
+ rankProfileList.sendConstantsTo(containers);
sendUserConfiguredFiles();
setApplicationMetaData();
for (RestApi restApi : restApiGroup.getComponents())
@@ -562,10 +559,6 @@ public final class ContainerCluster
@Override
public final void getConfig(JdiscBindingsConfig.Builder builder) {
builder.handlers.putAll(DiscBindingsConfigGenerator.generate(getHandlers()));
-
- allJersey1Handlers().forEach(handler ->
- builder.handlers.putAll(DiscBindingsConfigGenerator.generate(handler))
- );
}
@Override
@@ -573,10 +566,6 @@ public final class ContainerCluster
clusterVerifier.getConfig(builder);
}
- private Stream<JerseyHandler> allJersey1Handlers() {
- return restApiGroup.getComponents().stream().flatMap(streamOf(RestApi::getJersey1Handler));
- }
-
@Override
public void getConfig(ServletPathsConfig.Builder builder) {
allServlets().forEach(servlet ->
@@ -591,14 +580,7 @@ public final class ContainerCluster
}
private Stream<Jersey2Servlet> allJersey2Servlets() {
- return restApiGroup.getComponents().stream().flatMap(streamOf(RestApi::getJersey2Servlet));
- }
-
- private <T, R> Function<T, Stream<R>> streamOf(Function<T, Optional<R>> f) {
- return t ->
- f.apply(t).
- <Stream<R>>map(Stream::of).
- orElse(Stream.empty());
+ return restApiGroup.getComponents().stream().map(RestApi::getJersey2Servlet);
}
@Override
@@ -732,6 +714,9 @@ public final class ContainerCluster
rankProfileList.getConfig(builder);
}
+ @Override
+ public void getConfig(RankingConstantsConfig.Builder builder) { rankProfileList.getConfig(builder); }
+
public void setMbusParams(MbusParams mbusParams) {
this.mbusParams = mbusParams;
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/JerseyHandler.java b/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/JerseyHandler.java
deleted file mode 100644
index 737882b703d..00000000000
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/JerseyHandler.java
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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.jersey;
-
-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.component.Handler;
-
-/**
- * @author gjoranv
- * @since 5.6
- */
-public class JerseyHandler extends Handler<AbstractConfigProducer<?>> {
-
- public static final String BUNDLE = "container-jersey";
- public static final String CLASS = "com.yahoo.container.jdisc.jersey.JerseyHandler";
-
- public JerseyHandler(String bindingPath) {
- super(new ComponentModel(bundleSpec(CLASS, BUNDLE, bindingPath)));
- }
-
- public static BundleInstantiationSpecification bundleSpec(String className, String bundle, String bindingPath) {
- return BundleInstantiationSpecification.getFromStrings(
- className + "-" + RestApi.idFromPath(bindingPath),
- className,
- bundle);
- }
-}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApi.java b/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApi.java
index 63825aa2a1b..be8209bcc4e 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApi.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApi.java
@@ -2,32 +2,24 @@
package com.yahoo.vespa.model.container.jersey;
import com.yahoo.config.model.producer.AbstractConfigProducer;
-import com.yahoo.container.config.jersey.JerseyInitConfig;
-import com.yahoo.vespa.model.container.component.Component;
-
-import java.util.Optional;
/**
+ * Represents a rest-api
+ *
* @author gjoranv
- * @since 5.6
*/
-public class RestApi extends AbstractConfigProducer<AbstractConfigProducer<?>> implements
- JerseyInitConfig.Producer
-{
- public final boolean isJersey2;
+public class RestApi extends AbstractConfigProducer<AbstractConfigProducer<?>> {
+
private final String bindingPath;
- private final Component<?, ?> jerseyHandler;
+ private final Jersey2Servlet jerseyServlet;
private RestApiContext restApiContext;
- public RestApi(String bindingPath, boolean isJersey2) {
+ public RestApi(String bindingPath) {
super(idFromPath(bindingPath));
this.bindingPath = bindingPath;
- this.isJersey2 = isJersey2;
- jerseyHandler = isJersey2 ?
- createJersey2Servlet(this.bindingPath):
- createJersey1Handler(this.bindingPath);
- addChild(jerseyHandler);
+ jerseyServlet = createJersey2Servlet(this.bindingPath);
+ addChild(jerseyServlet);
}
public static String idFromPath(String path) {
@@ -38,44 +30,20 @@ public class RestApi extends AbstractConfigProducer<AbstractConfigProducer<?>> i
return new Jersey2Servlet(bindingPath);
}
- private static JerseyHandler createJersey1Handler(String bindingPath) {
- JerseyHandler jerseyHandler = new JerseyHandler(bindingPath);
- jerseyHandler.addServerBindings(getBindings(bindingPath));
- return jerseyHandler;
- }
-
public String getBindingPath() {
return bindingPath;
}
- @Override
- public void getConfig(JerseyInitConfig.Builder builder) {
- builder.jerseyMapping(bindingPath);
- }
-
public void setRestApiContext(RestApiContext restApiContext) {
this.restApiContext = restApiContext;
addChild(restApiContext);
- jerseyHandler.inject(restApiContext);
+ jerseyServlet.inject(restApiContext);
}
public RestApiContext getContext() { return restApiContext; }
- public Optional<JerseyHandler> getJersey1Handler() {
- return isJersey2 ?
- Optional.empty():
- Optional.of((JerseyHandler)jerseyHandler);
- }
-
- public Optional<Jersey2Servlet> getJersey2Servlet() {
- return isJersey2 ?
- Optional.of((Jersey2Servlet)jerseyHandler) :
- Optional.empty();
- }
-
- private static String[] getBindings(String bindingPath) {
- String bindingWithoutScheme = "://*/" + bindingPath + "/*";
- return new String[] {"http" + bindingWithoutScheme, "https" + bindingWithoutScheme};
+ public Jersey2Servlet getJersey2Servlet() {
+ return jerseyServlet;
}
public void prepare() {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApiContext.java b/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApiContext.java
index 5e48a1b1951..7fce9d2b636 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApiContext.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApiContext.java
@@ -22,7 +22,6 @@ import java.util.logging.Logger;
/**
* @author gjoranv
- * @since 5.16
*/
public class RestApiContext extends SimpleComponent implements
JerseyBundlesConfig.Producer,
@@ -87,10 +86,6 @@ public class RestApiContext extends SimpleComponent implements
}
}
- public void addInjections(Map<String, String> injections) {
- injectComponentForClass.putAll(injections);
- }
-
@Override
public void validate() throws Exception {
super.validate();
@@ -117,7 +112,6 @@ public class RestApiContext extends SimpleComponent implements
private Predicate<Component> isCycleGeneratingComponent = component -> {
switch (component.getClassId().getName()) {
case CONTAINER_CLASS:
- case JerseyHandler.CLASS:
case Jersey2Servlet.CLASS:
case "com.yahoo.jdisc.http.server.jetty.JettyHttpServer":
case "com.yahoo.container.handler.observability.ApplicationStatusHandler":
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/xml/RestApiBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/xml/RestApiBuilder.java
index 245db3c014f..6728f0be29f 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/xml/RestApiBuilder.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/xml/RestApiBuilder.java
@@ -13,8 +13,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import static com.yahoo.config.model.builder.xml.XmlHelper.getOptionalAttribute;
-
/**
* @author gjoranv
* @since 5.6
@@ -24,8 +22,7 @@ public class RestApiBuilder extends VespaDomBuilder.DomConfigProducerBuilder<Res
@Override
protected RestApi doBuild(AbstractConfigProducer ancestor, Element spec) {
String bindingPath = spec.getAttribute("path");
- boolean jersey2 = Boolean.parseBoolean(getOptionalAttribute(spec, "jersey2").orElse("false"));
- RestApi restApi = new RestApi(bindingPath, jersey2);
+ RestApi restApi = new RestApi(bindingPath);
restApi.setRestApiContext(
createRestApiContext(ancestor, spec, bindingPath));
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/FederationSearcher.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/FederationSearcher.java
index 19d014e0a1d..ceb48732116 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/FederationSearcher.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/FederationSearcher.java
@@ -15,6 +15,7 @@ import java.util.*;
/**
* Config producer for the FederationSearcher.
+ *
* @author Tony Vaagenes
*/
public class FederationSearcher extends Searcher<FederationSearcherModel> implements FederationConfig.Producer {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/routing/Protocol.java b/config-model/src/main/java/com/yahoo/vespa/model/routing/Protocol.java
index ad684894176..49596aa0ddf 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/routing/Protocol.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/routing/Protocol.java
@@ -12,18 +12,10 @@ import com.yahoo.messagebus.routing.RoutingTableSpec;
*/
public interface Protocol {
- /**
- * Returns the specification for the routing table of this protocol.
- *
- * @return The routing table spec.
- */
- public RoutingTableSpec getRoutingTableSpec();
+ /** Returns the specification for the routing table of this protocol. */
+ RoutingTableSpec getRoutingTableSpec();
- /**
- * Returns the specification of the application as seen by this protocol.
- *
- * @return The application spec.
- */
- public ApplicationSpec getApplicationSpec();
+ /** Returns the specification of the application as seen by this protocol. */
+ ApplicationSpec getApplicationSpec();
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/routing/Routing.java b/config-model/src/main/java/com/yahoo/vespa/model/routing/Routing.java
index 16f51935f2a..2403594d331 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/routing/Routing.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/routing/Routing.java
@@ -21,7 +21,7 @@ public class Routing extends ConfigModel {
private final List<String> errors = new ArrayList<>();
private ApplicationSpec explicitApplication = null;
private RoutingSpec explicitRouting = null;
- private List<Protocol> protocols = new ArrayList<>();
+ private final List<Protocol> protocols = new ArrayList<>();
private RoutingSpec derivedRouting;
public Routing(ConfigModelContext modelContext) {
@@ -91,7 +91,7 @@ public class Routing extends ConfigModel {
}
public void getConfig(MessagebusConfig.Builder builder) {
- if (derivedRouting==null) {
+ if (derivedRouting == null) {
// The error list should be populated then
return;
}
@@ -198,4 +198,5 @@ public class Routing extends ConfigModel {
public List<String> getErrors() {
return Collections.unmodifiableList(errors);
}
+
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/DocumentDatabase.java b/config-model/src/main/java/com/yahoo/vespa/model/search/DocumentDatabase.java
index a6bf51a2503..b29ed0fc25b 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/DocumentDatabase.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/search/DocumentDatabase.java
@@ -75,16 +75,7 @@ public class DocumentDatabase extends AbstractConfigProducer implements
@Override
public void getConfig(RankingConstantsConfig.Builder builder) {
- for (RankingConstant constant : derivedCfg.getSearch().rankingConstants().asMap().values()) {
- if ("".equals(constant.getFileReference())) {
- System.err.println("INVALID rank constant "+constant.getName()+" [missing file reference]"); // TODO: Throw or log warning
- continue;
- }
- builder.constant(new RankingConstantsConfig.Constant.Builder()
- .name(constant.getName())
- .fileref(constant.getFileReference())
- .type(constant.getType()));
- }
+ derivedCfg.getRankProfileList().getConfig(builder);
}
@Override