diff options
author | Bjørn Christian Seime <bjorn.christian@seime.no> | 2022-12-02 14:52:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-02 14:52:26 +0100 |
commit | 81b884ac555806ae2f0a75773accfd8fe27ecbe1 (patch) | |
tree | 0f92b9ef73a90854cacc96796562d3f21ff1cff6 /config-model/src | |
parent | c956ac4cb73b329243072aabe35f0da508c02d0f (diff) |
Revert "Let list handling catch up with Java 17"
Diffstat (limited to 'config-model/src')
15 files changed, 130 insertions, 77 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/admin/AdminModel.java b/config-model/src/main/java/com/yahoo/config/model/admin/AdminModel.java index 7fe7c4b9f68..4ae9834b87f 100644 --- a/config-model/src/main/java/com/yahoo/config/model/admin/AdminModel.java +++ b/config-model/src/main/java/com/yahoo/config/model/admin/AdminModel.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config.model.admin; +import com.google.common.collect.ImmutableList; import com.yahoo.config.model.ApplicationConfigProducerRoot; import com.yahoo.config.model.ConfigModel; import com.yahoo.config.model.ConfigModelContext; @@ -64,8 +65,8 @@ public class AdminModel extends ConfigModel { public static class BuilderV2 extends ConfigModelBuilder<AdminModel> { public static final List<ConfigModelId> configModelIds = - List.of(ConfigModelId.fromNameAndVersion("admin", "2.0"), - ConfigModelId.fromNameAndVersion("admin", "1.0")); + ImmutableList.of(ConfigModelId.fromNameAndVersion("admin", "2.0"), + ConfigModelId.fromNameAndVersion("admin", "1.0")); public BuilderV2() { super(AdminModel.class); @@ -97,8 +98,8 @@ public class AdminModel extends ConfigModel { public static class BuilderV4 extends ConfigModelBuilder<AdminModel> { public static final List<ConfigModelId> configModelIds = - List.of(ConfigModelId.fromNameAndVersion("admin", "3.0"), - ConfigModelId.fromNameAndVersion("admin", "4.0")); + ImmutableList.of(ConfigModelId.fromNameAndVersion("admin", "3.0"), + ConfigModelId.fromNameAndVersion("admin", "4.0")); public BuilderV4() { super(AdminModel.class); diff --git a/config-model/src/main/java/com/yahoo/config/model/provision/Host.java b/config-model/src/main/java/com/yahoo/config/model/provision/Host.java index e4bbf55b541..ea7a0bc0504 100644 --- a/config-model/src/main/java/com/yahoo/config/model/provision/Host.java +++ b/config-model/src/main/java/com/yahoo/config/model/provision/Host.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config.model.provision; +import com.google.common.collect.ImmutableList; import com.yahoo.component.Version; import com.yahoo.config.provision.Flavor; @@ -15,12 +16,12 @@ import java.util.Optional; public class Host { private final String hostname; - private final List<String> aliases; + private final ImmutableList<String> aliases; private final Optional<Flavor> flavor; private final Optional<Version> version; public Host(String hostname) { - this(hostname, List.of(), Optional.empty()); + this(hostname, ImmutableList.of(), Optional.empty()); } public Host(String hostname, List<String> hostAliases) { @@ -33,7 +34,7 @@ public class Host { public Host(String hostname, List<String> hostAliases, Optional<Flavor> flavor, Optional<Version> version) { this.hostname = hostname; - this.aliases = List.copyOf(hostAliases); + this.aliases = ImmutableList.copyOf(hostAliases); this.flavor = flavor; this.version = version; } @@ -51,7 +52,7 @@ public class Host { @Override public String toString() { return hostname + (aliases.size() > 0 ? " (aliases: " + aliases + ")" : "" ) + - (flavor.map(value -> " (flavor: " + value + ")").orElse("")); + (flavor.isPresent() ? " (flavor: " + flavor.get() + ")" : ""); } } diff --git a/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java b/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java index 8bdbe574b0e..14ee60bb9a6 100644 --- a/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java +++ b/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java @@ -2,6 +2,7 @@ package com.yahoo.schema.derived; import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels; +import com.google.common.collect.ImmutableList; import com.yahoo.collections.Pair; import com.yahoo.compress.Compressor; import com.yahoo.config.model.api.ModelContext; @@ -85,9 +86,9 @@ public class RawRankProfile implements RankProfilesConfig.Producer { private List<Pair<String, String>> decompress(Compressor.Compression compression) { String propertiesString = new String(compressor.decompress(compression), StandardCharsets.UTF_8); - if (propertiesString.isEmpty()) return List.of(); + if (propertiesString.isEmpty()) return ImmutableList.of(); - List<Pair<String, String>> properties = new ArrayList<>(); + ImmutableList.Builder<Pair<String, String>> properties = new ImmutableList.Builder<>(); for (int pos = 0; pos < propertiesString.length();) { int keyEndPos = propertiesString.indexOf(keyEndMarker, pos); String key = propertiesString.substring(pos, keyEndPos); @@ -97,7 +98,7 @@ public class RawRankProfile implements RankProfilesConfig.Producer { pos = valueEndPos + valueEndMarker.length(); properties.add(new Pair<>(key, value)); } - return List.copyOf(properties); + return properties.build(); } public String getName() { return name; } diff --git a/config-model/src/main/java/com/yahoo/schema/expressiontransforms/ExpressionTransforms.java b/config-model/src/main/java/com/yahoo/schema/expressiontransforms/ExpressionTransforms.java index 42e99f6aa45..132597ee75e 100644 --- a/config-model/src/main/java/com/yahoo/schema/expressiontransforms/ExpressionTransforms.java +++ b/config-model/src/main/java/com/yahoo/schema/expressiontransforms/ExpressionTransforms.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.schema.expressiontransforms; +import com.google.common.collect.ImmutableList; import com.yahoo.searchlib.rankingexpression.RankingExpression; import com.yahoo.searchlib.rankingexpression.transform.ConstantDereferencer; import com.yahoo.searchlib.rankingexpression.transform.ExpressionTransformer; @@ -23,19 +24,19 @@ public class ExpressionTransforms { public ExpressionTransforms() { transforms = - List.of(new TensorFlowFeatureConverter(), - new OnnxFeatureConverter(), - new OnnxModelTransformer(), - new XgboostFeatureConverter(), - new LightGBMFeatureConverter(), - new TokenTransformer(), - new ConstantDereferencer(), - new ConstantTensorTransformer(), - new FunctionInliner(), - new FunctionShadower(), - new TensorMaxMinTransformer(), - new Simplifier(), - new BooleanExpressionTransformer()); + ImmutableList.of(new TensorFlowFeatureConverter(), + new OnnxFeatureConverter(), + new OnnxModelTransformer(), + new XgboostFeatureConverter(), + new LightGBMFeatureConverter(), + new TokenTransformer(), + new ConstantDereferencer(), + new ConstantTensorTransformer(), + new FunctionInliner(), + new FunctionShadower(), + new TensorMaxMinTransformer(), + new Simplifier(), + new BooleanExpressionTransformer()); } public RankingExpression transform(RankingExpression expression, RankProfileTransformContext context) { diff --git a/config-model/src/main/java/com/yahoo/schema/processing/ReservedFunctionNames.java b/config-model/src/main/java/com/yahoo/schema/processing/ReservedFunctionNames.java index e1054c365b0..1ec4d5b58f2 100644 --- a/config-model/src/main/java/com/yahoo/schema/processing/ReservedFunctionNames.java +++ b/config-model/src/main/java/com/yahoo/schema/processing/ReservedFunctionNames.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.schema.processing; +import com.google.common.collect.ImmutableSet; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.schema.RankProfile; import com.yahoo.schema.RankProfileRegistry; @@ -8,10 +9,8 @@ import com.yahoo.schema.Schema; import com.yahoo.searchlib.rankingexpression.parser.RankingExpressionParserConstants; import com.yahoo.vespa.model.container.search.QueryProfiles; -import java.util.Arrays; import java.util.Set; import java.util.logging.Level; -import java.util.stream.Collectors; /** * Issues a warning if some function has a reserved name. This is not necessarily @@ -21,7 +20,7 @@ import java.util.stream.Collectors; */ public class ReservedFunctionNames extends Processor { - private static final Set<String> reservedNames = getReservedNames(); + private static Set<String> reservedNames = getReservedNames(); public ReservedFunctionNames(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { super(schema, deployLogger, rankProfileRegistry, queryProfiles); @@ -45,9 +44,13 @@ public class ReservedFunctionNames extends Processor { } } - private static Set<String> getReservedNames() { - return Arrays.stream(RankingExpressionParserConstants.tokenImage) - .map(token -> token.substring(1, token.length()-1)).collect(Collectors.toUnmodifiableSet()); + private static ImmutableSet<String> getReservedNames() { + ImmutableSet.Builder<String> names = ImmutableSet.builder(); + for (String token : RankingExpressionParserConstants.tokenImage) { + String tokenWithoutQuotes = token.substring(1, token.length()-1); + names.add(tokenWithoutQuotes); + } + return names.build(); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/DefaultMetrics.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/DefaultMetrics.java index 6f4535bf4a1..2348970ed1a 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/DefaultMetrics.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/DefaultMetrics.java @@ -2,11 +2,14 @@ package com.yahoo.vespa.model.admin.monitoring; -import java.util.Collections; + +import com.google.common.collect.ImmutableSet; + import java.util.LinkedHashSet; import java.util.Set; import static com.yahoo.vespa.model.admin.monitoring.DefaultVespaMetrics.defaultVespaMetricSet; +import static java.util.Collections.singleton; /** * Metrics for the 'default' consumer, which is used by default for the generic metrics api and @@ -23,19 +26,20 @@ public class DefaultMetrics { private static MetricSet createMetricSet() { return new MetricSet(defaultMetricSetId, getAllMetrics(), - Set.of(defaultVespaMetricSet)); + singleton(defaultVespaMetricSet)); } private static Set<Metric> getAllMetrics() { - Set<Metric> metrics = new LinkedHashSet<>(); - - addContentMetrics(metrics); - addContainerMetrics(metrics); - addSearchChainMetrics(metrics); - return Collections.unmodifiableSet(metrics); + return ImmutableSet.<Metric>builder() + .addAll(getContentMetrics()) + .addAll(getContainerMetrics()) + .addAll(getSearchChainMetrics()) + .build(); } - private static void addContainerMetrics(Set<Metric> metrics) { + private static Set<Metric> getContainerMetrics() { + Set<Metric> metrics = new LinkedHashSet<>(); + metrics.add(new Metric("http.status.1xx.rate")); metrics.add(new Metric("http.status.2xx.rate")); metrics.add(new Metric("http.status.3xx.rate")); @@ -43,9 +47,13 @@ public class DefaultMetrics { metrics.add(new Metric("http.status.5xx.rate")); metrics.add(new Metric("jdisc.gc.ms.average")); metrics.add(new Metric("mem.heap.free.average")); + + return metrics; } - private static void addSearchChainMetrics(Set<Metric> metrics) { + private static Set<Metric> getSearchChainMetrics() { + Set<Metric> metrics = new LinkedHashSet<>(); + metrics.add(new Metric("queries.rate")); metrics.add(new Metric("query_latency.sum")); metrics.add(new Metric("query_latency.count")); @@ -64,9 +72,13 @@ public class DefaultMetrics { metrics.add(new Metric("degraded_queries.rate")); metrics.add(new Metric("failed_queries.rate")); metrics.add(new Metric("serverActiveThreads.average")); + + return metrics; } - private static void addContentMetrics(Set<Metric> metrics) { + private static Set<Metric> getContentMetrics() { + Set<Metric> metrics = new LinkedHashSet<>(); + metrics.add(new Metric("content.proton.search_protocol.docsum.requested_documents.rate")); metrics.add(new Metric("content.proton.search_protocol.docsum.latency.sum")); metrics.add(new Metric("content.proton.search_protocol.docsum.latency.count")); @@ -102,6 +114,8 @@ public class DefaultMetrics { metrics.add(new Metric("content.proton.documentdb.matching.rank_profile.rerank_time.average")); // TODO: Remove with Vespa 9 metrics.add(new Metric("content.proton.transactionlog.disk_usage.last")); + + return metrics; } private DefaultMetrics() { } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/MetricSet.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/MetricSet.java index fb67100b435..41204ce6e9a 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/MetricSet.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/MetricSet.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.model.admin.monitoring; import java.util.Collection; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.Map; @@ -23,7 +24,7 @@ public class MetricSet { private final Set<MetricSet> children; public MetricSet(String id, Collection<Metric> metrics) { - this(id, metrics, Set.of()); + this(id, metrics, Collections.emptySet()); } public MetricSet(String id, Collection<Metric> metrics, Collection<MetricSet> children) { @@ -56,7 +57,9 @@ public class MetricSet { @Override public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof MetricSet that)) return false; + if (!(o instanceof MetricSet)) return false; + + MetricSet that = (MetricSet) o; return Objects.equals(id, that.id); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/NetworkMetrics.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/NetworkMetrics.java index 2f9c97f0488..4b905f35eab 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/NetworkMetrics.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/NetworkMetrics.java @@ -22,6 +22,10 @@ public class NetworkMetrics { new Metric("net.out.dropped") ); - return new MetricSet("network", dockerNetworkMetrics); + Set<Metric> networkMetrics = ImmutableSet.<Metric>builder() + .addAll(dockerNetworkMetrics) + .build(); + + return new MetricSet("network", networkMetrics); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/SecretStore.java b/config-model/src/main/java/com/yahoo/vespa/model/container/SecretStore.java index 8ddf08a593e..076fe7c0c53 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/SecretStore.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/SecretStore.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.container; - +import com.google.common.collect.ImmutableList; import java.util.ArrayList; import java.util.List; @@ -17,7 +17,7 @@ public class SecretStore { } public List<Group> getGroups() { - return List.copyOf(groups); + return ImmutableList.copyOf(groups); } public static class Group { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ml/ModelsEvaluatorTester.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ml/ModelsEvaluatorTester.java index 1232e32a633..4afde25cafd 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/ml/ModelsEvaluatorTester.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ml/ModelsEvaluatorTester.java @@ -8,6 +8,7 @@ import ai.vespa.rankingexpression.importer.onnx.OnnxImporter; import ai.vespa.rankingexpression.importer.tensorflow.TensorFlowImporter; import ai.vespa.rankingexpression.importer.vespa.VespaImporter; import ai.vespa.rankingexpression.importer.xgboost.XGBoostImporter; +import com.google.common.collect.ImmutableList; import com.yahoo.config.FileReference; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.application.api.FileRegistry; @@ -33,7 +34,6 @@ import java.nio.ByteBuffer; import java.nio.file.Files; import java.nio.file.Path; import java.util.HashMap; -import java.util.List; import java.util.Map; /** @@ -49,7 +49,7 @@ import java.util.Map; */ public class ModelsEvaluatorTester { - private static final List<MlModelImporter> importers = List.of(new TensorFlowImporter(), + private static final ImmutableList<MlModelImporter> importers = ImmutableList.of(new TensorFlowImporter(), new OnnxImporter(), new LightGBMImporter(), new XGBoostImporter(), 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 0722a9dc15a..007e8401c70 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 @@ -1,6 +1,7 @@ // Copyright Yahoo. 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.google.common.collect.ImmutableList; import com.yahoo.component.ComponentId; import com.yahoo.component.ComponentSpecification; import com.yahoo.component.Version; @@ -153,7 +154,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { private final boolean httpServerEnabled; protected DeployLogger log; - public static final List<ConfigModelId> configModelIds = List.of(ConfigModelId.fromName(CONTAINER_TAG)); + public static final List<ConfigModelId> configModelIds = ImmutableList.of(ConfigModelId.fromName(CONTAINER_TAG)); private static final String xmlRendererId = RendererRegistry.xmlRendererId.getName(); private static final String jsonRendererId = RendererRegistry.jsonRendererId.getName(); @@ -216,7 +217,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { addStatusHandlers(cluster, context.getDeployState().isHosted()); addUserHandlers(deployState, cluster, spec, context); - addClients(deployState, spec, cluster); + addClients(deployState, spec, cluster, context); addHttp(deployState, spec, cluster, context); addAccessLogs(deployState, cluster, spec); @@ -379,7 +380,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { // Only consider global endpoints. .filter(endpoint -> endpoint.scope() == ApplicationClusterEndpoint.Scope.global) .flatMap(endpoint -> endpoint.names().stream()) - .collect(Collectors.toCollection(LinkedHashSet::new)); + .collect(Collectors.toCollection(() -> new LinkedHashSet<>())); // Build the comma delimited list of endpoints this container should be known as. // Confusingly called 'rotations' for legacy reasons. @@ -490,7 +491,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { } - protected void addClients(DeployState deployState, Element spec, ApplicationContainerCluster cluster) { + protected void addClients(DeployState deployState, Element spec, ApplicationContainerCluster cluster, ConfigModelContext context) { if (!deployState.isHosted() || !deployState.zone().system().isPublic() || !deployState.featureFlags().enableDataPlaneFilter()) return; List<Client> clients; @@ -768,10 +769,11 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { return new JvmGcOptions(context.getDeployState(), jvmGCOptions).build(); } - private static String getJvmOptions(Element nodesElement, + private static String getJvmOptions(ApplicationContainerCluster cluster, + Element nodesElement, DeployState deployState, boolean legacyOptions) { - return new JvmOptions(nodesElement, deployState, legacyOptions).build(); + return new JvmOptions(cluster, nodesElement, deployState, legacyOptions).build(); } private static String extractAttribute(Element element, String attrName) { @@ -792,7 +794,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { private void extractJvmFromLegacyNodesTag(List<ApplicationContainer> nodes, ApplicationContainerCluster cluster, Element nodesElement, ConfigModelContext context) { - applyNodesTagJvmArgs(nodes, getJvmOptions(nodesElement, context.getDeployState(), true)); + applyNodesTagJvmArgs(nodes, getJvmOptions(cluster, nodesElement, context.getDeployState(), true)); if (cluster.getJvmGCOptions().isEmpty()) { String jvmGCOptions = extractAttribute(nodesElement, VespaDomBuilder.JVM_GC_OPTIONS); @@ -804,7 +806,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { private void extractJvmTag(List<ApplicationContainer> nodes, ApplicationContainerCluster cluster, Element nodesElement, Element jvmElement, ConfigModelContext context) { - applyNodesTagJvmArgs(nodes, getJvmOptions(nodesElement, context.getDeployState(), false)); + applyNodesTagJvmArgs(nodes, getJvmOptions(cluster, nodesElement, context.getDeployState(), false)); applyMemoryPercentage(cluster, jvmElement.getAttribute(VespaDomBuilder.Allocated_MEMORY_ATTRIB_NAME)); String jvmGCOptions = extractAttribute(jvmElement, VespaDomBuilder.GC_OPTIONS); cluster.setJvmGCOptions(buildJvmGCOptions(context, jvmGCOptions)); @@ -1193,12 +1195,14 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { // debug port will not be available in hosted, don't allow private static final Pattern invalidInHostedatttern = Pattern.compile("-Xrunjdwp:transport=.*"); + private final ContainerCluster<?> cluster; private final Element nodesElement; private final DeployLogger logger; private final boolean legacyOptions; private final boolean isHosted; - public JvmOptions(Element nodesElement, DeployState deployState, boolean legacyOptions) { + public JvmOptions(ContainerCluster<?> cluster, Element nodesElement, DeployState deployState, boolean legacyOptions) { + this.cluster = cluster; this.nodesElement = nodesElement; this.logger = deployState.getDeployLogger(); this.legacyOptions = legacyOptions; @@ -1243,9 +1247,10 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { .collect(Collectors.toList()); if (isHosted) invalidOptions.addAll(Arrays.stream(optionList) - .filter(option -> !option.isEmpty()) - .filter(option -> Pattern.matches(invalidInHostedatttern.pattern(), option)) - .sorted().toList()); + .filter(option -> !option.isEmpty()) + .filter(option -> Pattern.matches(invalidInHostedatttern.pattern(), option)) + .sorted() + .collect(Collectors.toList())); if (invalidOptions.isEmpty()) return; @@ -1294,9 +1299,10 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { if (isHosted) { // CMS GC options cannot be used in hosted, CMS is unsupported in JDK 17 invalidOptions.addAll(Arrays.stream(optionList) - .filter(option -> !option.isEmpty()) - .filter(option -> Pattern.matches(invalidCMSPattern.pattern(), option) || - option.equals("-XX:+UseConcMarkSweepGC")).toList()); + .filter(option -> !option.isEmpty()) + .filter(option -> Pattern.matches(invalidCMSPattern.pattern(), option) || + option.equals("-XX:+UseConcMarkSweepGC")) + .collect(Collectors.toList())); } logOrFailInvalidOptions(invalidOptions); diff --git a/config-model/src/test/java/com/yahoo/schema/processing/RankProfileSearchFixture.java b/config-model/src/test/java/com/yahoo/schema/processing/RankProfileSearchFixture.java index 58c514bdda8..15fe8250b71 100644 --- a/config-model/src/test/java/com/yahoo/schema/processing/RankProfileSearchFixture.java +++ b/config-model/src/test/java/com/yahoo/schema/processing/RankProfileSearchFixture.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.schema.processing; +import com.google.common.collect.ImmutableList; import com.yahoo.config.application.api.ApplicationPackage; import ai.vespa.rankingexpression.importer.configmodelview.MlModelImporter; import com.yahoo.config.model.application.provider.BaseDeployLogger; @@ -36,10 +37,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; */ class RankProfileSearchFixture { - private final List<MlModelImporter> importers = List.of(new TensorFlowImporter(), - new OnnxImporter(), - new LightGBMImporter(), - new XGBoostImporter()); + private final ImmutableList<MlModelImporter> importers = ImmutableList.of(new TensorFlowImporter(), + new OnnxImporter(), + new LightGBMImporter(), + new XGBoostImporter()); private final RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); private final QueryProfileRegistry queryProfileRegistry; private final Schema schema; @@ -50,6 +51,10 @@ class RankProfileSearchFixture { return rankProfileRegistry; } + public QueryProfileRegistry getQueryProfileRegistry() { + return queryProfileRegistry; + } + RankProfileSearchFixture(String rankProfiles) throws ParseException { this(MockApplicationPackage.createEmpty(), new QueryProfileRegistry(), rankProfiles); } @@ -108,6 +113,11 @@ class RankProfileSearchFixture { return compiled; } + /** Returns the given uncompiled profile */ + public RankProfile rankProfile(String rankProfile) { + return rankProfileRegistry.get(schema, rankProfile); + } + /** Returns the given compiled profile, or null if not compiled yet or not present at all */ public RankProfile compiledRankProfile(String rankProfile) { return compiledRankProfiles.get(rankProfile); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/monitoring/MetricSetTest.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/monitoring/MetricSetTest.java index 7eec4450f33..8a15d87b6c5 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/admin/monitoring/MetricSetTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/monitoring/MetricSetTest.java @@ -1,10 +1,11 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.admin.monitoring; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; import org.junit.jupiter.api.Test; -import java.util.List; import java.util.Map; import static java.util.Collections.emptyList; @@ -18,9 +19,9 @@ public class MetricSetTest { @Test void metrics_from_children_are_added() { - MetricSet child1 = new MetricSet("child1", List.of(new Metric("child1_metric"))); - MetricSet child2 = new MetricSet("child2", List.of(new Metric("child2_metric"))); - MetricSet parent = new MetricSet("parent", emptyList(), List.of(child1, child2)); + MetricSet child1 = new MetricSet("child1", ImmutableList.of(new Metric("child1_metric"))); + MetricSet child2 = new MetricSet("child2", ImmutableList.of(new Metric("child2_metric"))); + MetricSet parent = new MetricSet("parent", emptyList(), ImmutableList.of(child1, child2)); Map<String, Metric> parentMetrics = parent.getMetrics(); assertEquals(2, parentMetrics.size()); @@ -30,8 +31,8 @@ public class MetricSetTest { @Test void adding_the_same_child_set_twice_has_no_effect() { - MetricSet child = new MetricSet("child", List.of(new Metric("child_metric"))); - MetricSet parent = new MetricSet("parent", emptyList(), List.of(child, child)); + MetricSet child = new MetricSet("child", ImmutableList.of(new Metric("child_metric"))); + MetricSet parent = new MetricSet("parent", emptyList(), ImmutableList.of(child, child)); Map<String, Metric> parentMetrics = parent.getMetrics(); assertEquals(1, parentMetrics.size()); @@ -43,10 +44,16 @@ public class MetricSetTest { String METRIC_NAME = "metric1"; String COMMON_DIMENSION_KEY = "commonKey"; - Map<String, String> childDimensions = Map.of(COMMON_DIMENSION_KEY, "childCommonVal", "childKey", "childVal"); + Map<String, String> childDimensions = ImmutableMap.<String, String>builder() + .put(COMMON_DIMENSION_KEY, "childCommonVal") + .put("childKey", "childVal") + .build(); Metric childMetric = new Metric(METRIC_NAME, "child-output-name", "child-description", childDimensions); - Map<String, String> parentDimensions = Map.of(COMMON_DIMENSION_KEY, "parentCommonVal","parentKey", "parentVal"); + Map<String, String> parentDimensions = ImmutableMap.<String, String>builder() + .put(COMMON_DIMENSION_KEY, "parentCommonVal") + .put("parentKey", "parentVal") + .build(); Metric parentMetric = new Metric(METRIC_NAME, "parent-output-name", "parent-description", parentDimensions); MetricSet child = new MetricSet("set1", Sets.newHashSet(childMetric)); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ValidationTester.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ValidationTester.java index cb535380b18..a7f3d134b57 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ValidationTester.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ValidationTester.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.application.validation; +import com.google.common.collect.ImmutableList; import com.yahoo.collections.Pair; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.model.api.ConfigChangeAction; @@ -76,7 +77,7 @@ public class ValidationTester { Provisioned provisioned = hostProvisioner.startProvisionedRecording(); ApplicationPackage newApp = new MockApplicationPackage.Builder() .withServices(services) - .withSchemas(List.of(MUSIC_SCHEMA, BOOK_SCHEMA)) + .withSchemas(ImmutableList.of(MUSIC_SCHEMA, BOOK_SCHEMA)) .withValidationOverrides(validationOverrides) .build(); VespaModelCreatorWithMockPkg newModelCreator = new VespaModelCreatorWithMockPkg(newApp); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTester.java b/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTester.java index a31d4cd4e20..ed0cedd4e87 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTester.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTester.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.test; +import com.google.common.collect.ImmutableList; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.model.ConfigModelRegistry; import com.yahoo.config.model.NullConfigModelRegistry; @@ -89,7 +90,7 @@ public class VespaModelTester { "-" + Math.round(resources.memoryGb()) + "-" + Math.round(resources.diskGb()), count - i); - hosts.add(new Host(hostname, List.of(), flavor)); + hosts.add(new Host(hostname, ImmutableList.of(), flavor)); } this.hostsByResources.put(resources, hosts); |