summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-02-02 17:38:14 +0100
committerJon Bratseth <bratseth@gmail.com>2022-02-02 17:38:14 +0100
commitaa8494e90a9027af4b23de9d121d0b5aa3915abc (patch)
tree473cba27fe4e21defaf332e6960b6a6701fdcdd6 /config-model
parentf095e16d4fa4b919fb1bf1a7f509322638d0fa6b (diff)
Produce LinkedHashSets to get deterministic order
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java11
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/HostResource.java3
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java11
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/AutoscalingMetrics.java3
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java2
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/IndexingModeChangeValidator.java5
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/http/BlockFeedGlobalEndpointsFilter.java3
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/GlobalDistributionValidator.java7
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/cluster/GlobalDistributionBuilder.java6
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/utils/internal/ReflectionUtil.java3
10 files changed, 28 insertions, 26 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java
index 6e1f428ee49..4dca5cfab27 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java
@@ -32,14 +32,13 @@ import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
-
-import static java.util.Collections.emptySet;
-import static java.util.stream.Collectors.toSet;
+import java.util.stream.Collectors;
/**
* @author baldersheim
@@ -439,17 +438,17 @@ public class DocumentModelBuilder {
private static Set<NewDocumentType.Name> convertDocumentReferencesToNames(Optional<DocumentReferences> documentReferences) {
if (!documentReferences.isPresent()) {
- return emptySet();
+ return Set.of();
}
return documentReferences.get().referenceMap().values().stream()
.map(documentReference -> documentReference.targetSearch().getDocument())
.map(documentType -> new NewDocumentType.Name(documentType.getName()))
- .collect(toSet());
+ .collect(Collectors.toCollection(() -> new LinkedHashSet<>()));
}
private static Set<String> convertTemporaryImportedFieldsToNames(TemporaryImportedFields importedFields) {
if (importedFields == null) {
- return emptySet();
+ return Set.of();
}
return Collections.unmodifiableSet(importedFields.fields().keySet());
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/HostResource.java b/config-model/src/main/java/com/yahoo/vespa/model/HostResource.java
index 8f804229dd0..05aa125b808 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/HostResource.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/HostResource.java
@@ -9,6 +9,7 @@ import com.yahoo.config.provision.NodeResources;
import java.util.ArrayList;
import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -103,7 +104,7 @@ public class HostResource implements Comparable<HostResource> {
public HostInfo getHostInfo() {
return new HostInfo(getHostname(), services.values().stream()
.map(Service::getServiceInfo)
- .collect(Collectors.toSet()));
+ .collect(Collectors.toCollection(() -> new LinkedHashSet<>())));
}
/** The real resources available for Vespa processes on this node, after subtracting infrastructure overhead. */
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 91dbb56d20d..076c3f52fed 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
@@ -87,9 +87,7 @@ import java.util.stream.Collectors;
import static com.yahoo.config.codegen.ConfiggenUtil.createClassName;
import static com.yahoo.text.StringUtilities.quote;
import static java.util.stream.Collectors.toMap;
-import static java.util.stream.Collectors.toSet;
import static java.util.stream.Collectors.toUnmodifiableMap;
-import static java.util.stream.Collectors.toUnmodifiableSet;
/**
* <p>
@@ -229,7 +227,7 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri
private static Set<String> documentTypesWithIndex(ContentCluster content) {
Set<String> typesWithIndexMode = content.getSearch().getDocumentTypesWithIndexedCluster().stream()
.map(type -> type.getFullName().getName())
- .collect(toSet());
+ .collect(Collectors.toCollection(() -> new LinkedHashSet<>()));
Set<String> typesWithIndexedFields = content.getSearch().getIndexed() == null
? Set.of()
@@ -239,9 +237,10 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri
.allConcreteFields()
.stream().anyMatch(SDField::doesIndexing))
.map(database -> database.getInputDocType())
- .collect(toSet());
+ .collect(Collectors.toCollection(() -> new LinkedHashSet<>()));
- return typesWithIndexMode.stream().filter(typesWithIndexedFields::contains).collect(toUnmodifiableSet());
+ return typesWithIndexMode.stream().filter(typesWithIndexedFields::contains)
+ .collect(Collectors.toCollection(() -> new LinkedHashSet<>()));
}
private void propagateRestartOnDeploy() {
@@ -695,7 +694,7 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri
.map(HostResource::spec)
.filter(spec -> spec.membership().isPresent())
.map(spec -> spec.membership().get().cluster().id())
- .collect(Collectors.toSet());
+ .collect(Collectors.toCollection(() -> new LinkedHashSet<>()));
}
@Override
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/AutoscalingMetrics.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/AutoscalingMetrics.java
index 50f3a21a4fb..26e3d952080 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/AutoscalingMetrics.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/AutoscalingMetrics.java
@@ -4,6 +4,7 @@ package com.yahoo.vespa.model.admin.monitoring;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@@ -48,7 +49,7 @@ public class AutoscalingMetrics {
}
private static Set<Metric> toMetrics(List<String> metrics) {
- return metrics.stream().map(Metric::new).collect(Collectors.toSet());
+ return metrics.stream().map(Metric::new).collect(Collectors.toCollection(() -> new LinkedHashSet<>()));
}
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java
index 7bfd57de323..4ba809a58ba 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java
@@ -140,7 +140,7 @@ public class Validation {
Set<ClusterSpec.Id> clustersToBeRestarted = actions.stream()
.filter(action -> action.getType() == ConfigChangeAction.Type.RESTART)
.map(action -> action.clusterId())
- .collect(Collectors.toSet());
+ .collect(Collectors.toCollection(() -> new LinkedHashSet<>()));
for (var clusterToRestart : clustersToBeRestarted) {
var containerCluster = model.getContainerClusters().get(clusterToRestart.value());
if (containerCluster != null)
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/IndexingModeChangeValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/IndexingModeChangeValidator.java
index 30abb9b445f..a3872d9354b 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/IndexingModeChangeValidator.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/IndexingModeChangeValidator.java
@@ -13,13 +13,12 @@ import com.yahoo.vespa.model.search.SearchNode;
import java.time.Instant;
import java.util.ArrayList;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-import static java.util.stream.Collectors.toSet;
-
/**
* Returns any change to the indexing mode of a cluster.
*
@@ -91,7 +90,7 @@ public class IndexingModeChangeValidator implements ChangeValidator {
private static Set<String> toDocumentTypeNames(List<NewDocumentType> types) {
return types.stream()
.map(type -> type.getFullName().getName())
- .collect(toSet());
+ .collect(Collectors.toCollection(() -> new LinkedHashSet<>()));
}
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/http/BlockFeedGlobalEndpointsFilter.java b/config-model/src/main/java/com/yahoo/vespa/model/container/http/BlockFeedGlobalEndpointsFilter.java
index 8e8f02e6773..167dac4c57e 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/http/BlockFeedGlobalEndpointsFilter.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/http/BlockFeedGlobalEndpointsFilter.java
@@ -12,6 +12,7 @@ import com.yahoo.vespa.model.clients.ContainerDocumentApi;
import com.yahoo.vespa.model.container.ContainerCluster;
import java.util.Collection;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@@ -40,7 +41,7 @@ public class BlockFeedGlobalEndpointsFilter extends Filter implements RuleBasedF
public void getConfig(RuleBasedFilterConfig.Builder builder) {
Set<String> hostNames = endpoints.stream()
.flatMap(e -> e.names().stream())
- .collect(Collectors.toSet());
+ .collect(Collectors.toCollection(() -> new LinkedHashSet<>()));
if(hostNames.size() > 0) {
Collection<String> hostnamesSorted = hostNames.stream().sorted().collect(Collectors.toList());
RuleBasedFilterConfig.Rule.Builder rule = new RuleBasedFilterConfig.Rule.Builder()
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/GlobalDistributionValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/content/GlobalDistributionValidator.java
index 4ea07ae06de..235128f7a62 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/GlobalDistributionValidator.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/GlobalDistributionValidator.java
@@ -3,12 +3,13 @@ package com.yahoo.vespa.model.content;
import com.yahoo.documentmodel.NewDocumentType;
+import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
import static java.util.stream.Collectors.joining;
-import static java.util.stream.Collectors.toSet;
/**
* Performs the following validations:
@@ -29,7 +30,7 @@ public class GlobalDistributionValidator {
private static void verifyReferredDocumentsArePresent(Map<String, NewDocumentType> documentDefinitions) {
Set<NewDocumentType.Name> unknowDocuments = getReferencedDocuments(documentDefinitions)
.filter(name -> !documentDefinitions.containsKey(name.toString()))
- .collect(toSet());
+ .collect(Collectors.toCollection(() -> new LinkedHashSet<>()));
if (!unknowDocuments.isEmpty()) {
throw new IllegalArgumentException("The following document types are referenced from other documents, " +
"but are not listed in services.xml: " + asPrintableString(unknowDocuments.stream()));
@@ -41,7 +42,7 @@ public class GlobalDistributionValidator {
Set<NewDocumentType> nonGlobalReferencedDocuments = getReferencedDocuments(documentDefinitions)
.map(name -> documentDefinitions.get(name.toString()))
.filter(documentType -> !globallyDistributedDocuments.contains(documentType))
- .collect(toSet());
+ .collect(Collectors.toCollection(() -> new LinkedHashSet<>()));
if (!nonGlobalReferencedDocuments.isEmpty()) {
throw new IllegalArgumentException("The following document types are referenced from other documents, " +
"but are not globally distributed: " + asPrintableString(toDocumentNameStream(nonGlobalReferencedDocuments)));
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/GlobalDistributionBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/GlobalDistributionBuilder.java
index a4231105f42..1cab6cd462d 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/GlobalDistributionBuilder.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/GlobalDistributionBuilder.java
@@ -5,10 +5,10 @@ import com.yahoo.documentmodel.NewDocumentType;
import com.yahoo.vespa.model.builder.xml.dom.ModelElement;
import java.util.Collections;
+import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
-
-import static java.util.stream.Collectors.toSet;
+import java.util.stream.Collectors;
/**
* Determines the set of document types that are configured to be globally distributed.
@@ -32,7 +32,7 @@ public class GlobalDistributionBuilder {
.filter(GlobalDistributionBuilder::isGloballyDistributed)
.map(GlobalDistributionBuilder::getDocumentName)
.map(this::getDocumentType)
- .collect(toSet());
+ .collect(Collectors.toCollection(() -> new LinkedHashSet<>()));
}
private static boolean isGloballyDistributed(ModelElement e) {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/utils/internal/ReflectionUtil.java b/config-model/src/main/java/com/yahoo/vespa/model/utils/internal/ReflectionUtil.java
index 3ba536b4e9b..0ad28d37e93 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/utils/internal/ReflectionUtil.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/utils/internal/ReflectionUtil.java
@@ -10,6 +10,7 @@ import com.yahoo.vespa.model.ConfigProducer;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@@ -31,7 +32,7 @@ public final class ReflectionUtil {
return interfaces.rawTypes().stream()
.filter(ReflectionUtil::isConcreteProducer)
.map(i -> createConfigKeyFromInstance(i.getEnclosingClass(), configId))
- .collect(Collectors.toSet());
+ .collect(Collectors.toCollection(() -> new LinkedHashSet<>()));
}
/**