aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHÃ¥kon Hallingstad <hakon.hallingstad@gmail.com>2023-09-18 09:59:08 +0200
committerGitHub <noreply@github.com>2023-09-18 09:59:08 +0200
commit100f2608bee853ea17ab543c3a8bfcfce4a3ac39 (patch)
treed39ca8a6aa8dc920a3f18989975f6d41265f55c8
parentcf09db5052f0f64d08a2eb2a516d965660aafdb7 (diff)
parent6bd9903af69137d142534510a9502d5f276617b9 (diff)
Merge pull request #28509 from vespa-engine/hakonhall/additionalIpAddresses-list
Change primary and pool IPs from Set to List
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java35
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryNode.java13
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java10
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeList.java4
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityChecker.java6
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/IP.java97
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java16
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisionedHost.java5
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodePatcher.java9
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java2
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesV2ApiHandler.java5
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockHostProvisioner.java6
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockNodeRepository.java5
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeListMicroBenchmarkTest.java11
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTest.java6
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTester.java5
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityCheckerTester.java24
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainerTest.java3
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostResumeProvisionerTest.java12
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporterTest.java8
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailTester.java4
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirerTest.java2
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/SpareCapacityMaintainerTest.java8
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/node/IPTest.java15
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializerTest.java10
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/AllocationSimulator.java11
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ContainerImagesTest.java4
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicAllocationTest.java9
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTest.java3
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTester.java5
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/HostCapacityTest.java34
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/LoadBalancerProvisionerTest.java2
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidateTest.java7
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java8
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTester.java13
35 files changed, 186 insertions, 231 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java
index 0b0664cd3bf..a02cb96272f 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java
@@ -15,7 +15,6 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
-import java.util.Set;
import java.util.UUID;
/**
@@ -70,9 +69,9 @@ public class Node {
private final Optional<ClusterType> exclusiveToClusterType;
private final Map<String, String> reports;
private final List<Event> history;
- private final Set<String> ipAddresses;
- private final Set<String> additionalIpAddresses;
- private final Set<String> additionalHostnames;
+ private final List<String> ipAddresses;
+ private final List<String> additionalIpAddresses;
+ private final List<String> additionalHostnames;
private final Optional<String> switchHostname;
private final Optional<String> modelName;
private final Environment environment;
@@ -87,8 +86,8 @@ public class Node {
ClusterType clusterType, String group, int index, boolean retired, boolean wantToRetire, boolean wantToDeprovision,
boolean wantToRebuild, boolean down, Optional<TenantName> reservedTo, Optional<ApplicationId> exclusiveTo,
DockerImage wantedDockerImage, DockerImage currentDockerImage, Optional<ClusterType> exclusiveToClusterType, Map<String, String> reports,
- List<Event> history, Set<String> ipAddresses, Set<String> additionalIpAddresses,
- Set<String> additionalHostnames, Optional<String> switchHostname,
+ List<Event> history, List<String> ipAddresses, List<String> additionalIpAddresses,
+ List<String> additionalHostnames, Optional<String> switchHostname,
Optional<String> modelName, Environment environment, CloudAccount cloudAccount) {
this.id = Objects.requireNonNull(id, "id must be non-null");
this.hostname = Objects.requireNonNull(hostname, "hostname must be non-null");
@@ -129,9 +128,9 @@ public class Node {
this.down = down;
this.reports = Map.copyOf(Objects.requireNonNull(reports, "reports must be non-null"));
this.history = List.copyOf(Objects.requireNonNull(history, "history must be non-null"));
- this.ipAddresses = Set.copyOf(Objects.requireNonNull(ipAddresses, "ipAddresses must be non-null"));
- this.additionalIpAddresses = Set.copyOf(Objects.requireNonNull(additionalIpAddresses, "additionalIpAddresses must be non-null"));
- this.additionalHostnames = Set.copyOf(Objects.requireNonNull(additionalHostnames, "additionalHostnames must be non-null"));
+ this.ipAddresses = List.copyOf(Objects.requireNonNull(ipAddresses, "ipAddresses must be non-null"));
+ this.additionalIpAddresses = List.copyOf(Objects.requireNonNull(additionalIpAddresses, "additionalIpAddresses must be non-null"));
+ this.additionalHostnames = List.copyOf(Objects.requireNonNull(additionalHostnames, "additionalHostnames must be non-null"));
this.switchHostname = Objects.requireNonNull(switchHostname, "switchHostname must be non-null");
this.modelName = Objects.requireNonNull(modelName, "modelName must be non-null");
this.environment = Objects.requireNonNull(environment, "environment must be non-ull");
@@ -320,17 +319,17 @@ public class Node {
}
/** IP addresses of this */
- public Set<String> ipAddresses() {
+ public List<String> ipAddresses() {
return ipAddresses;
}
/** Additional IP addresses available on this, usable by child nodes */
- public Set<String> additionalIpAddresses() {
+ public List<String> additionalIpAddresses() {
return additionalIpAddresses;
}
/** Additional hostnames available on this, usable by child nodes */
- public Set<String> additionalHostnames() {
+ public List<String> additionalHostnames() {
return additionalHostnames;
}
@@ -502,9 +501,9 @@ public class Node {
private Optional<ClusterType> exclusiveToClusterType = Optional.empty();
private Map<String, String> reports = Map.of();
private List<Event> history = List.of();
- private Set<String> ipAddresses = Set.of();
- private Set<String> additionalIpAddresses = Set.of();
- private Set<String> additionalHostnames = Set.of();
+ private List<String> ipAddresses = List.of();
+ private List<String> additionalIpAddresses = List.of();
+ private List<String> additionalHostnames = List.of();
private Optional<String> switchHostname = Optional.empty();
private Optional<String> modelName = Optional.empty();
private Environment environment = Environment.unknown;
@@ -758,17 +757,17 @@ public class Node {
return this;
}
- public Builder ipAddresses(Set<String> ipAdresses) {
+ public Builder ipAddresses(List<String> ipAdresses) {
this.ipAddresses = ipAdresses;
return this;
}
- public Builder additionalIpAddresses(Set<String> additionalIpAddresses) {
+ public Builder additionalIpAddresses(List<String> additionalIpAddresses) {
this.additionalIpAddresses = additionalIpAddresses;
return this;
}
- public Builder additionalHostnames(Set<String> additionalHostnames) {
+ public Builder additionalHostnames(List<String> additionalHostnames) {
this.additionalHostnames = additionalHostnames;
return this;
}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryNode.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryNode.java
index 34a7c1a6f7c..fd2424694d0 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryNode.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryNode.java
@@ -10,7 +10,6 @@ import com.fasterxml.jackson.databind.JsonNode;
import java.util.List;
import java.util.Map;
-import java.util.Set;
/**
* The wire format of a node retrieved from the node repository.
@@ -32,9 +31,9 @@ public class NodeRepositoryNode {
@JsonProperty("hostname")
private String hostname;
@JsonProperty("ipAddresses")
- private Set<String> ipAddresses;
+ private List<String> ipAddresses;
@JsonProperty("additionalIpAddresses")
- private Set<String> additionalIpAddresses;
+ private List<String> additionalIpAddresses;
@JsonProperty("additionalHostnames")
private List<String> additionalHostnames;
@JsonProperty("flavor")
@@ -148,19 +147,19 @@ public class NodeRepositoryNode {
this.hostname = hostname;
}
- public Set<String> getIpAddresses() {
+ public List<String> getIpAddresses() {
return ipAddresses;
}
- public Set<String> getAdditionalIpAddresses() {
+ public List<String> getAdditionalIpAddresses() {
return additionalIpAddresses;
}
- public void setIpAddresses(Set<String> ipAddresses) {
+ public void setIpAddresses(List<String> ipAddresses) {
this.ipAddresses = ipAddresses;
}
- public void setAdditionalIpAddresses(Set<String> additionalIpAddresses) {
+ public void setAdditionalIpAddresses(List<String> additionalIpAddresses) {
this.additionalIpAddresses = additionalIpAddresses;
}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java
index 8db8e7c2cf8..24159b88a9b 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java
@@ -74,7 +74,7 @@ public final class Node implements Nodelike {
private final Optional<Allocation> allocation;
/** Creates a node builder in the initial state (reserved) */
- public static Node.Builder reserve(Set<String> ipAddresses, String hostname, String parentHostname, NodeResources resources, NodeType type) {
+ public static Node.Builder reserve(List<String> ipAddresses, String hostname, String parentHostname, NodeResources resources, NodeType type) {
return new Node.Builder(UUID.randomUUID().toString(), hostname, new Flavor(resources), State.reserved, type)
.ipConfig(IP.Config.ofEmptyPool(ipAddresses))
.parentHostname(parentHostname);
@@ -127,11 +127,11 @@ public final class Node implements Nodelike {
if (state == State.ready && type.isHost()) {
requireNonEmpty(ipConfig.primary(), "A " + type + " must have at least one primary IP address in state " + state);
- requireNonEmpty(ipConfig.pool().asSet(), "A " + type + " must have a non-empty IP address pool in state " + state);
+ requireNonEmpty(ipConfig.pool().ips(), "A " + type + " must have a non-empty IP address pool in state " + state);
}
if (parentHostname.isPresent()) {
- if (!ipConfig.pool().asSet().isEmpty()) throw new IllegalArgumentException("A child node cannot have an IP address pool");
+ if (!ipConfig.pool().ips().isEmpty()) throw new IllegalArgumentException("A child node cannot have an IP address pool");
if (modelName.isPresent()) throw new IllegalArgumentException("A child node cannot have model name set");
if (switchHostname.isPresent()) throw new IllegalArgumentException("A child node cannot have switch hostname set");
if (status.wantToRebuild()) throw new IllegalArgumentException("A child node cannot be rebuilt");
@@ -635,7 +635,7 @@ public final class Node implements Nodelike {
return value;
}
- private static Set<String> requireNonEmpty(Set<String> values, String message) {
+ private static List<String> requireNonEmpty(List<String> values, String message) {
if (values == null || values.isEmpty())
throw new IllegalArgumentException(message);
return values;
@@ -828,7 +828,7 @@ public final class Node implements Nodelike {
return this;
}
- public Builder ipConfigWithEmptyPool(Set<String> primary) {
+ public Builder ipConfigWithEmptyPool(List<String> primary) {
this.ipConfig = IP.Config.ofEmptyPool(primary);
return this;
}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeList.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeList.java
index f355e66b1e4..2d2d8d934d8 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeList.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeList.java
@@ -331,7 +331,7 @@ public class NodeList extends AbstractFilteringList<Node, NodeList> {
public int eventuallyUnusedIpAddressCount(Node host) {
// The count in this method relies on the size of the IP address pool if that's non-empty,
// otherwise fall back to the address/hostname pool.
- if (host.ipConfig().pool().asSet().isEmpty()) {
+ if (host.ipConfig().pool().ips().isEmpty()) {
Set<String> allHostnames = cache().keySet();
return (int) host.ipConfig().pool().hostnames().stream()
.filter(hostname -> !allHostnames.contains(hostname.value()))
@@ -341,7 +341,7 @@ public class NodeList extends AbstractFilteringList<Node, NodeList> {
old != null ? old : stream().flatMap(node -> node.ipConfig().primary().stream())
.collect(Collectors.toUnmodifiableSet())
);
- return (int) host.ipConfig().pool().asSet().stream()
+ return (int) host.ipConfig().pool().ips().stream()
.filter(address -> !allIps.contains(address))
.count();
}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityChecker.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityChecker.java
index f3ea326a3c0..d37ef50ca46 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityChecker.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityChecker.java
@@ -83,7 +83,7 @@ public class CapacityChecker {
}
private Optional<HostFailurePath> greedyHeuristicFindFailurePath(Map<Node, Integer> heuristic) {
- if (hosts.size() == 0) return Optional.empty();
+ if (hosts.isEmpty()) return Optional.empty();
List<Node> parentRemovalPriorityList = heuristic.entrySet().stream()
.sorted(this::hostMitigationOrder)
@@ -127,12 +127,12 @@ public class CapacityChecker {
for (var host : hosts) {
NodeResources hostResources = host.flavor().resources();
int occupiedIps = 0;
- Set<String> ipPool = host.ipConfig().pool().asSet();
+ Set<String> ipPool = Set.copyOf(host.ipConfig().pool().ips());
for (var child : nodeChildren.get(host)) {
hostResources = hostResources.subtract(child.resources().justNumbers());
occupiedIps += (int)child.ipConfig().primary().stream().filter(ipPool::contains).count();
}
- availableResources.put(host, new AllocationResources(hostResources, host.ipConfig().pool().asSet().size() - occupiedIps));
+ availableResources.put(host, new AllocationResources(hostResources, host.ipConfig().pool().ips().size() - occupiedIps));
}
return availableResources;
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/IP.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/IP.java
index ca4b2c99ef0..d9eba6cc8a5 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/IP.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/IP.java
@@ -14,10 +14,9 @@ import com.yahoo.vespa.hosted.provision.persistence.NameResolver;
import com.yahoo.vespa.hosted.provision.persistence.NameResolver.RecordType;
import java.net.InetAddress;
-import java.util.Collections;
+import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
@@ -37,7 +36,7 @@ import static com.yahoo.config.provision.NodeType.proxyhost;
public record IP() {
/** IP version. Can be compared with ==, !=, and equals(). */
- public static class Version {
+ public static class Version implements Comparable<Version> {
public static final Version v4 = new Version(4);
public static final Version v6 = new Version(6);
@@ -59,6 +58,9 @@ public record IP() {
public RecordType toForwardRecordType() { return is4() ? RecordType.A : RecordType.AAAA; }
@Override
+ public int compareTo(Version that) { return Integer.compare(this.version, that.version); }
+
+ @Override
public String toString() { return "IPv" + version; }
@Override
@@ -98,46 +100,33 @@ public record IP() {
return 0;
};
- /** IP configuration of a node */
- public record Config(Set<String> primary, Pool pool) {
-
- public static final Config EMPTY = Config.ofEmptyPool(Set.of());
+ /**
+ * IP configuration of a node
+ *
+ * @param primary The primary addresses of this. These addresses are used when communicating with the node itself
+ * @param pool The IP address pool available on a node
+ */
+ public record Config(List<String> primary, Pool pool) {
- public static Config ofEmptyPool(Set<String> primary) {
- return new Config(primary, Pool.EMPTY);
- }
+ public static final Config EMPTY = Config.ofEmptyPool();
- public static Config of(Set<String> primary, Set<String> ipPool, List<HostName> hostnames) {
- return new Config(primary, new Pool(IpAddresses.of(ipPool), hostnames));
- }
+ public static Config ofEmptyPool(String... primary) { return ofEmptyPool(List.of(primary)); }
+ public static Config ofEmptyPool(List<String> primary) { return of(primary, List.of(), List.of()); }
+ public static Config of(List<String> primary, List<String> ips, List<HostName> hostnames) { return new Config(primary, Pool.of(ips, hostnames)); }
+ public static Config of(List<String> primary, List<String> ips) { return of(primary, ips, List.of()); }
- public static Config of(Set<String> primary, Set<String> pool) {
- return of(primary, pool, List.of());
- }
-
- /** DO NOT USE: Public for NodeSerializer. */
- public Config(Set<String> primary, Pool pool) {
- this.primary = Collections.unmodifiableSet(new LinkedHashSet<>(Objects.requireNonNull(primary, "primary must be non-null")));
+ public Config(List<String> primary, Pool pool) {
+ this.primary = List.copyOf(Objects.requireNonNull(primary, "primary must be non-null"));
this.pool = Objects.requireNonNull(pool, "pool must be non-null");
}
- /** The primary addresses of this. These addresses are used when communicating with the node itself */
- public Set<String> primary() {
- return primary;
- }
-
- /** Returns the IP address pool available on a node */
- public Pool pool() {
- return pool;
- }
-
/** Returns a copy of this with pool set to given value */
public Config withPool(Pool pool) {
return new Config(primary, pool);
}
/** Returns a copy of this with pool set to given value */
- public Config withPrimary(Set<String> primary) {
+ public Config withPrimary(List<String> primary) {
return new Config(primary, pool);
}
@@ -157,8 +146,8 @@ public record IP() {
var addresses = new HashSet<>(node.ipConfig().primary());
var otherAddresses = new HashSet<>(other.ipConfig().primary());
if (node.type().isHost()) { // Addresses of a host can never overlap with any other nodes
- addresses.addAll(node.ipConfig().pool().asSet());
- otherAddresses.addAll(other.ipConfig().pool().asSet());
+ addresses.addAll(node.ipConfig().pool().ips());
+ otherAddresses.addAll(other.ipConfig().pool().ips());
}
otherAddresses.removeIf(otherIp -> !ipSpace.contains(otherIp, other.cloudAccount()));
otherAddresses.retainAll(addresses);
@@ -191,15 +180,15 @@ public record IP() {
}
/** A list of IP addresses and their protocol */
- record IpAddresses(Set<String> addresses, Stack stack) {
+ record IpAddresses(List<String> addresses, Stack stack) {
- public IpAddresses(Set<String> addresses, Stack stack) {
- this.addresses = Collections.unmodifiableSet(new LinkedHashSet<>(Objects.requireNonNull(addresses, "addresses must be non-null")));
+ public IpAddresses(List<String> addresses, Stack stack) {
+ this.addresses = List.copyOf(Objects.requireNonNull(addresses, "addresses must be non-null"));
this.stack = Objects.requireNonNull(stack, "type must be non-null");
}
/** Create addresses of the given set */
- private static IpAddresses of(Set<String> addresses) {
+ private static IpAddresses of(List<String> addresses) {
long ipv6AddrCount = addresses.stream().filter(IP::isV6).count();
if (ipv6AddrCount == addresses.size()) { // IPv6-only
return new IpAddresses(addresses, Stack.ipv6);
@@ -247,12 +236,11 @@ public record IP() {
*/
public record Pool(IpAddresses ipAddresses, List<HostName> hostnames) {
- public static final Pool EMPTY = new Pool(IpAddresses.of(Set.of()), List.of());
+ public static final Pool EMPTY = Pool.of(List.of(), List.of());
- /** Create a new pool containing given ipAddresses */
- public static Pool of(Set<String> ipAddresses, List<HostName> hostnames) {
- IpAddresses ips = IpAddresses.of(ipAddresses);
- return new Pool(ips, hostnames);
+ /** Create a new pool containing given ips */
+ public static Pool of(List<String> ips, List<HostName> hostnames) {
+ return new Pool(IpAddresses.of(ips), hostnames);
}
public Pool(IpAddresses ipAddresses, List<HostName> hostnames) {
@@ -260,9 +248,7 @@ public record IP() {
this.hostnames = List.copyOf(Objects.requireNonNull(hostnames, "hostnames must be non-null"));
}
- public Set<String> asSet() {
- return ipAddresses.addresses;
- }
+ public List<String> ips() { return ipAddresses.addresses; }
/**
* Find a free allocation in this pool. Note that the allocation is not final until it is assigned to a node
@@ -278,7 +264,7 @@ public record IP() {
.findFirst();
}
- Set<String> unusedIps = findUnusedIpAddresses(nodes);
+ List<String> unusedIps = findUnusedIpAddresses(nodes);
if (context.allocateFromUnusedHostname())
return findUnusedHostnames(nodes).findFirst().map(hostname -> Allocation.fromHostname(context, hostname, ipAddresses.stack, unusedIps));
@@ -308,11 +294,11 @@ public record IP() {
*
* @param nodes a list of all nodes in the repository
*/
- public Set<String> findUnusedIpAddresses(NodeList nodes) {
- Set<String> unusedAddresses = new LinkedHashSet<>(asSet());
- nodes.matching(node -> node.ipConfig().primary().stream().anyMatch(ip -> asSet().contains(ip)))
+ public List<String> findUnusedIpAddresses(NodeList nodes) {
+ List<String> unusedAddresses = new ArrayList<>(ips());
+ nodes.matching(node -> node.ipConfig().primary().stream().anyMatch(ip -> ips().contains(ip)))
.forEach(node -> unusedAddresses.removeAll(node.ipConfig().primary()));
- return Collections.unmodifiableSet(unusedAddresses);
+ return unusedAddresses;
}
private Stream<HostName> findUnusedHostnames(NodeList nodes) {
@@ -320,7 +306,7 @@ public record IP() {
return hostnames.stream().filter(hostname -> !usedHostnames.contains(hostname.value()));
}
- public Pool withIpAddresses(Set<String> ipAddresses) {
+ public Pool withIpAddresses(List<String> ipAddresses) {
return Pool.of(ipAddresses, hostnames);
}
@@ -423,13 +409,13 @@ public record IP() {
return new Allocation(hostname4, Optional.of(addresses.get(0)), Optional.empty());
}
- private static Allocation fromHostname(Context context, HostName hostname, IpAddresses.Stack stack, Set<String> unusedIps) {
+ private static Allocation fromHostname(Context context, HostName hostname, IpAddresses.Stack stack, List<String> unusedIps) {
Optional<String> ipv4Address = resolveAndVerify(context, hostname, stack, IP.Version.v4, unusedIps);
Optional<String> ipv6Address = resolveAndVerify(context, hostname, stack, IP.Version.v6, unusedIps);
return new Allocation(hostname.value(), ipv4Address, ipv6Address);
}
- private static Optional<String> resolveAndVerify(Context context, HostName hostname, IpAddresses.Stack stack, Version version, Set<String> unusedIps) {
+ private static Optional<String> resolveAndVerify(Context context, HostName hostname, IpAddresses.Stack stack, Version version, List<String> unusedIps) {
if (context.hasIpNotInDns(version)) {
List<String> candidates = unusedIps.stream()
.filter(a -> IP.Version.fromIpAddress(a).equals(version))
@@ -463,9 +449,8 @@ public record IP() {
}
/** All IP addresses in this */
- public Set<String> addresses() {
- return Stream.concat(ipv4Address.stream(), ipv6Address.stream())
- .collect(Collectors.toUnmodifiableSet());
+ public List<String> addresses() {
+ return Stream.concat(ipv4Address.stream(), ipv6Address.stream()).toList();
}
}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java
index 358c94895d1..870e678a250 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.persistence;
-import com.google.common.collect.ImmutableSet;
import com.yahoo.component.Version;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ApplicationName;
@@ -41,7 +40,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
-import java.util.Set;
/**
* Serializes a node to/from JSON.
@@ -153,8 +151,8 @@ public class NodeSerializer {
private void toSlime(Node node, Cursor object) {
object.setString(hostnameKey, node.hostname());
object.setString(stateKey, toString(node.state()));
- toSlime(node.ipConfig().primary(), object.setArray(ipAddressesKey));
- toSlime(node.ipConfig().pool().asSet(), object.setArray(ipAddressPoolKey));
+ toSlime(node.ipConfig().primary(), object.setArray(ipAddressesKey), true);
+ toSlime(node.ipConfig().pool().ips(), object.setArray(ipAddressPoolKey), true);
toSlime(node.ipConfig().pool().hostnames(), object);
object.setString(idKey, node.id());
node.extraId().ifPresent(id -> object.setString(extraIdKey, id));
@@ -233,10 +231,10 @@ public class NodeSerializer {
object.setString(agentKey, toString(event.agent()));
}
- private void toSlime(Set<String> ipAddresses, Cursor array) {
+ private void toSlime(List<String> addresses, Cursor array, boolean dummyDueToErasure) {
// Validating IP address string literals is expensive, so we do it at serialization time instead of Node
// construction time
- ipAddresses.stream().map(IP::parse).sorted(IP.NATURAL_ORDER).map(IP::asString).forEach(array::addString);
+ addresses.stream().map(IP::parse).sorted(IP.NATURAL_ORDER).map(IP::asString).forEach(array::addString);
}
private void toSlime(List<HostName> hostnames, Cursor object) {
@@ -380,10 +378,10 @@ public class NodeSerializer {
return SlimeUtils.optionalString(object).map(DockerImage::fromString);
}
- private Set<String> ipAddressesFromSlime(Inspector object, String key) {
- ImmutableSet.Builder<String> ipAddresses = ImmutableSet.builder();
+ private List<String> ipAddressesFromSlime(Inspector object, String key) {
+ var ipAddresses = new ArrayList<String>();
object.field(key).traverse((ArrayTraverser) (i, item) -> ipAddresses.add(item.asString()));
- return ipAddresses.build();
+ return ipAddresses;
}
private List<HostName> hostnamesFromSlime(Inspector object) {
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisionedHost.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisionedHost.java
index c9fd1d08759..460b1bd23a0 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisionedHost.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisionedHost.java
@@ -18,7 +18,6 @@ import java.time.Duration;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
-import java.util.Set;
/**
* Describes a single newly provisioned host by {@link HostProvisioner}.
@@ -65,7 +64,7 @@ public class ProvisionedHost {
/** Generate {@link Node} instance representing the provisioned physical host */
public Node generateHost(Duration hostTTL) {
- Node.Builder builder = Node.create(id, IP.Config.of(Set.of(), Set.of(), nodeHostnames), hostHostname, hostFlavor, hostType)
+ Node.Builder builder = Node.create(id, IP.Config.of(List.of(), List.of(), nodeHostnames), hostHostname, hostFlavor, hostType)
.status(Status.initial().withOsVersion(OsVersion.EMPTY.withCurrent(Optional.of(osVersion))))
.cloudAccount(cloudAccount);
exclusiveToApplicationId.ifPresent(builder::exclusiveToApplicationId);
@@ -76,7 +75,7 @@ public class ProvisionedHost {
/** Generate {@link Node} instance representing the node running on this physical host */
public Node generateNode() {
- return Node.reserve(Set.of(), nodeHostname(), hostHostname, nodeResources, hostType.childNodeType())
+ return Node.reserve(List.of(), nodeHostname(), hostHostname, nodeResources, hostType.childNodeType())
.cloudAccount(cloudAccount)
.build();
}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodePatcher.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodePatcher.java
index 5915f02ec4f..9f1ab3dc3d5 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodePatcher.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodePatcher.java
@@ -41,7 +41,6 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import java.util.TreeSet;
import java.util.stream.Stream;
import static com.yahoo.config.provision.NodeResources.DiskSpeed.fast;
@@ -282,8 +281,8 @@ public class NodePatcher {
private Node applyIpconfigField(Node node, String name, Inspector value, LockedNodeList nodes) {
return switch (name) {
- case "ipAddresses" -> IP.Config.verify(node.with(node.ipConfig().withPrimary(asStringSet(value))), nodes, nodeRepository.zone());
- case "additionalIpAddresses" -> IP.Config.verify(node.with(node.ipConfig().withPool(node.ipConfig().pool().withIpAddresses(asStringSet(value)))), nodes, nodeRepository.zone());
+ case "ipAddresses" -> IP.Config.verify(node.with(node.ipConfig().withPrimary(asStringList(value))), nodes, nodeRepository.zone());
+ case "additionalIpAddresses" -> IP.Config.verify(node.with(node.ipConfig().withPool(node.ipConfig().pool().withIpAddresses(asStringList(value)))), nodes, nodeRepository.zone());
case "additionalHostnames" -> IP.Config.verify(node.with(node.ipConfig().withPool(node.ipConfig().pool().withHostnames(asHostnames(value)))), nodes, nodeRepository.zone());
default -> throw new IllegalArgumentException("Could not apply field '" + name + "' on a node: No such modifiable field");
};
@@ -336,11 +335,11 @@ public class NodePatcher {
return node.with(trustStoreItems);
}
- private Set<String> asStringSet(Inspector field) {
+ private List<String> asStringList(Inspector field) {
if ( ! field.type().equals(Type.ARRAY))
throw new IllegalArgumentException("Expected an ARRAY value, got a " + field.type());
- TreeSet<String> strings = new TreeSet<>();
+ var strings = new ArrayList<String>();
for (int i = 0; i < field.entries(); i++) {
Inspector entry = field.entry(i);
if ( ! entry.type().equals(Type.STRING))
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java
index e3960cc5db5..2b908efde94 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java
@@ -182,7 +182,7 @@ class NodesResponse extends SlimeJsonResponse {
toSlime(node.history().events(), object.setArray("history"));
toSlime(node.history().log(), object.setArray("log"));
ipAddressesToSlime(node.ipConfig().primary(), object.setArray("ipAddresses"));
- ipAddressesToSlime(node.ipConfig().pool().asSet(), object.setArray("additionalIpAddresses"));
+ ipAddressesToSlime(node.ipConfig().pool().ips(), object.setArray("additionalIpAddresses"));
hostnamesToSlime(node.ipConfig().pool().hostnames(), object);
node.reports().toSlime(object, "reports");
node.modelName().ifPresent(modelName -> object.setString("modelName", modelName));
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesV2ApiHandler.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesV2ApiHandler.java
index 28f99b02e60..79dc7fe72a8 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesV2ApiHandler.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesV2ApiHandler.java
@@ -55,7 +55,6 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
@@ -282,9 +281,9 @@ public class NodesV2ApiHandler extends ThreadedHttpRequestHandler {
}
private Node createNode(Inspector inspector) {
- Set<String> ipAddresses = new HashSet<>();
+ var ipAddresses = new ArrayList<String>();
inspector.field("ipAddresses").traverse((ArrayTraverser) (i, item) -> ipAddresses.add(item.asString()));
- Set<String> ipAddressPool = new HashSet<>();
+ var ipAddressPool = new ArrayList<String>();
inspector.field("additionalIpAddresses").traverse((ArrayTraverser) (i, item) -> ipAddressPool.add(item.asString()));
List<HostName> hostnames = new ArrayList<>();
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockHostProvisioner.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockHostProvisioner.java
index 03923853594..5cdb08d6fc6 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockHostProvisioner.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockHostProvisioner.java
@@ -109,7 +109,7 @@ public class MockHostProvisioner implements HostProvisioner {
Map<String, IP.Config> result = new HashMap<>();
result.put(host.hostname(), createIpConfig(host));
host.ipConfig().pool().hostnames().forEach(hostname ->
- result.put(hostname.value(), IP.Config.ofEmptyPool(nameResolver.resolveAll(hostname.value()))));
+ result.put(hostname.value(), IP.Config.ofEmptyPool(List.copyOf(nameResolver.resolveAll(hostname.value())))));
return new HostIpConfig(result, Optional.empty());
}
@@ -238,8 +238,8 @@ public class MockHostProvisioner implements HostProvisioner {
public IP.Config createIpConfig(Node node) {
if (!node.type().isHost()) throw new IllegalArgumentException("Node " + node + " is not a host");
int hostIndex = Integer.parseInt(node.hostname().replaceAll("^[a-z]+|-\\d+$", ""));
- Set<String> addresses = Set.of("::" + hostIndex + ":0");
- Set<String> ipAddressPool = new HashSet<>();
+ var addresses = List.of("::" + hostIndex + ":0");
+ var ipAddressPool = new ArrayList<String>();
if (!behaviour(Behaviour.failDnsUpdate)) {
nameResolver.addRecord(node.hostname(), addresses.iterator().next());
int i = 1;
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockNodeRepository.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockNodeRepository.java
index 086639d7276..72225763381 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockNodeRepository.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockNodeRepository.java
@@ -52,7 +52,6 @@ import java.time.Clock;
import java.time.Instant;
import java.time.ZoneId;
import java.util.ArrayList;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
@@ -274,8 +273,8 @@ public class MockNodeRepository extends NodeRepository {
}
private IP.Config ipConfig(int nodeIndex, int primarySize, int poolSize) {
- var primary = new LinkedHashSet<String>();
- var ipPool = new LinkedHashSet<String>();
+ var primary = new ArrayList<String>();
+ var ipPool = new ArrayList<String>();
for (int i = 1; i <= primarySize + poolSize; i++) {
var set = primary;
if (i > primarySize) {
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeListMicroBenchmarkTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeListMicroBenchmarkTest.java
index 85338bdb2b4..b275cb8a4c6 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeListMicroBenchmarkTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeListMicroBenchmarkTest.java
@@ -16,12 +16,9 @@ import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
import java.util.Random;
-import java.util.Set;
-import java.util.stream.Collectors;
/**
* @author hmusum
@@ -64,7 +61,7 @@ public class NodeListMicroBenchmarkTest {
private List<Node> createHosts() {
List<Node> hosts = new ArrayList<>();
for (int i = 0; i < hostCount; i++) {
- hosts.add(Node.create("host" + i, IP.Config.of(Set.of("::1"), createIps(), List.of()),
+ hosts.add(Node.create("host" + i, IP.Config.of(List.of("::1"), createIps(), List.of()),
"host" + i, getFlavor("host"), NodeType.host).build());
}
return hosts;
@@ -74,7 +71,7 @@ public class NodeListMicroBenchmarkTest {
List<Node> nodes = new ArrayList<>();
for (int i = 0; i < 10; i++) {
nodeCounter++;
- Node node = Node.reserve(Set.of("::2"), "node" + nodeCounter, parentHostname, resources0, NodeType.tenant).build();
+ Node node = Node.reserve(List.of("::2"), "node" + nodeCounter, parentHostname, resources0, NodeType.tenant).build();
nodes.add(node);
}
return nodes;
@@ -92,11 +89,11 @@ public class NodeListMicroBenchmarkTest {
return nodeFlavors.getFlavor(name).orElseThrow(() -> new RuntimeException("Unknown flavor"));
}
- private Set<String> createIps() {
+ private List<String> createIps() {
// Allow 4 containers
int start = 2;
int count = 4;
- Set<String> ipAddressPool = new LinkedHashSet<>();
+ var ipAddressPool = new ArrayList<String>();
for (int i = start; i < (start + count); i++) {
ipAddressPool.add("::" + i);
}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTest.java
index 5148d2a635c..852502c2f4f 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTest.java
@@ -64,9 +64,9 @@ public class NodeRepositoryTest {
Environment.prod,
RegionName.from("aws-us-east-1a"));
NodeRepositoryTester tester = new NodeRepositoryTester(zone);
- IP.Config ipConfig = IP.Config.of(Set.of("1.2.3.4", "10.2.3.4"), Set.of("1.2.3.4", "10.2.3.4"));
- IP.Config publicIpConfig = IP.Config.of(Set.of("1.2.3.4"), Set.of("1.2.3.4"));
- IP.Config privateIpConfig = IP.Config.of(Set.of("10.2.3.4"), Set.of("10.2.3.4"));
+ IP.Config ipConfig = IP.Config.of(List.of("1.2.3.4", "10.2.3.4"), List.of("1.2.3.4", "10.2.3.4"));
+ IP.Config publicIpConfig = IP.Config.of(List.of("1.2.3.4"), List.of("1.2.3.4"));
+ IP.Config privateIpConfig = IP.Config.of(List.of("10.2.3.4"), List.of("10.2.3.4"));
Node host1 = Node.create("id1", ipConfig, "host1", tester.nodeFlavors().getFlavorOrThrow("default"), NodeType.host)
.build();
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTester.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTester.java
index bf714cd9df1..a6cdcd0b998 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTester.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTester.java
@@ -20,7 +20,6 @@ import com.yahoo.vespa.hosted.provision.testutils.OrchestratorMock;
import java.util.List;
import java.util.Optional;
-import java.util.Set;
/**
* @author bratseth
@@ -78,8 +77,8 @@ public class NodeRepositoryTester {
}
private Node addNode(String id, String hostname, String parentHostname, Flavor flavor, NodeType type) {
- Set<String> ips = nodeRepository.nameResolver().resolveAll(hostname);
- IP.Config ipConfig = IP.Config.of(ips, type.isHost() ? ips : Set.of());
+ List<String> ips = List.copyOf(nodeRepository.nameResolver().resolveAll(hostname));
+ IP.Config ipConfig = IP.Config.of(ips, type.isHost() ? ips : List.of());
Node node = Node.create(id, ipConfig, hostname, flavor, type).parentHostname(parentHostname).build();
return nodeRepository.nodes().addNodes(List.of(node), Agent.system).get(0);
}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityCheckerTester.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityCheckerTester.java
index eedf4946e3a..5544251f021 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityCheckerTester.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityCheckerTester.java
@@ -43,8 +43,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static org.junit.Assert.assertTrue;
@@ -108,8 +106,8 @@ public class CapacityCheckerTester {
child.minMainMemoryAvailableGb = cnr.memoryGb();
child.minDiskAvailableGb = cnr.diskGb();
child.fastDisk = true;
- child.ipAddresses = Set.of();
- child.additionalIpAddresses = Set.of();
+ child.ipAddresses = List.of();
+ child.additionalIpAddresses = List.of();
child.owner = new NodeModel.OwnerModel();
child.owner.tenant = tenant + j / childCombinations;
child.owner.application = application;
@@ -140,7 +138,7 @@ public class CapacityCheckerTester {
String childHostName = parentName + "-v6-" + k + parentRoot;
childModel.id = childHostName;
childModel.hostname = childHostName;
- childModel.ipAddresses = Set.of(String.format("%04X::%04X", i, k));
+ childModel.ipAddresses = List.of(String.format("%04X::%04X", i, k));
childModel.membership.index = j / distinctChildren.size();
childModel.parentHostname = Optional.of(hostname);
@@ -151,12 +149,12 @@ public class CapacityCheckerTester {
}
final int hostindex = i;
- Set<String> availableIps = IntStream.range(0, childrenPerHost + excessIps)
+ List<String> availableIps = IntStream.range(0, childrenPerHost + excessIps)
.mapToObj(n -> String.format("%04X::%04X", hostindex, n))
- .collect(Collectors.toSet());
+ .toList();
NodeResources nr = containingNodeResources(childResources, excessCapacity);
- Node node = Node.create(hostname, IP.Config.of(Set.of("::"), availableIps), hostname,
+ Node node = Node.create(hostname, IP.Config.of(List.of("::"), availableIps), hostname,
new Flavor(nr), NodeType.host).build();
hosts.computeIfAbsent(tenantHostApp, (ignored) -> new ArrayList<>())
.add(node);
@@ -172,10 +170,10 @@ public class CapacityCheckerTester {
String hostname = parentName + parentRoot;
final int hostId = i;
- Set<String> availableIps = IntStream.range(2000, 2000 + ips)
+ List<String> availableIps = IntStream.range(2000, 2000 + ips)
.mapToObj(n -> String.format("%04X::%04X", hostId, n))
- .collect(Collectors.toSet());
- Node node = Node.create(hostname, IP.Config.of(Set.of("::" + (1000 + hostId)), availableIps), hostname,
+ .toList();
+ Node node = Node.create(hostname, IP.Config.of(List.of("::" + (1000 + hostId)), availableIps), hostname,
new Flavor(capacity), NodeType.host).build();
hosts.add(node);
}
@@ -256,8 +254,8 @@ public class CapacityCheckerTester {
@JsonProperty double minCpuCores;
@JsonProperty double bandwidth;
@JsonProperty boolean fastDisk;
- @JsonProperty Set<String> ipAddresses;
- @JsonProperty Set<String> additionalIpAddresses;
+ @JsonProperty List<String> ipAddresses;
+ @JsonProperty List<String> additionalIpAddresses;
@JsonProperty OwnerModel owner;
@JsonProperty MembershipModel membership;
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainerTest.java
index d51a3e72622..549237441c8 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainerTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainerTest.java
@@ -61,7 +61,6 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
-import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Stream;
@@ -847,7 +846,7 @@ public class HostCapacityMaintainerTest {
false));
List<com.yahoo.config.provision.HostName> hostnames = Stream.of(additionalHostnames).map(com.yahoo.config.provision.HostName::of).toList();
Node.Builder builder = Node.create("fake-id-" + hostname, hostname, flavor, state, nodeType)
- .ipConfig(IP.Config.of(state == Node.State.active ? Set.of("::1") : Set.of(), Set.of(), hostnames))
+ .ipConfig(IP.Config.of(state == Node.State.active ? List.of("::1") : List.of(), List.of(), hostnames))
.hostTTL(hostTTL);
parentHostname.ifPresent(builder::parentHostname);
allocation.ifPresent(builder::allocation);
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostResumeProvisionerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostResumeProvisionerTest.java
index f7c9d46801c..165e120e781 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostResumeProvisionerTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostResumeProvisionerTest.java
@@ -59,10 +59,10 @@ public class HostResumeProvisionerTest {
Node host = tester.nodeRepository().nodes().node("host100").orElseThrow();
Node node = tester.nodeRepository().nodes().node("host100-1").orElseThrow();
assertTrue("No IP addresses assigned",
- Stream.of(host, node).map(n -> n.ipConfig().primary()).allMatch(Set::isEmpty));
+ Stream.of(host, node).map(n -> n.ipConfig().primary()).allMatch(List::isEmpty));
- Node hostNew = host.with(host.ipConfig().withPrimary(Set.of("::100:0")).withPool(host.ipConfig().pool().withIpAddresses(Set.of("::100:1", "::100:2"))));
- Node nodeNew = node.with(IP.Config.ofEmptyPool(Set.of("::100:1")));
+ Node hostNew = host.with(host.ipConfig().withPrimary(List.of("::100:0")).withPool(host.ipConfig().pool().withIpAddresses(List.of("::100:1", "::100:2"))));
+ Node nodeNew = node.with(IP.Config.ofEmptyPool("::100:1"));
hostResumeProvisioner.maintain();
assertEquals(hostNew.ipConfig(), tester.nodeRepository().nodes().node("host100").get().ipConfig());
@@ -79,12 +79,12 @@ public class HostResumeProvisionerTest {
hostResumeProvisioner.maintain();
assertTrue("No IP addresses written as DNS updates are failing",
- provisioning.get().stream().allMatch(host -> host.ipConfig().pool().asSet().isEmpty()));
+ provisioning.get().stream().allMatch(host -> host.ipConfig().pool().ips().isEmpty()));
hostProvisioner.without(MockHostProvisioner.Behaviour.failDnsUpdate);
hostResumeProvisioner.maintain();
assertTrue("IP addresses written as DNS updates are succeeding",
- provisioning.get().stream().noneMatch(host -> host.ipConfig().pool().asSet().isEmpty()));
+ provisioning.get().stream().noneMatch(host -> host.ipConfig().pool().ips().isEmpty()));
}
@Test
@@ -95,7 +95,7 @@ public class HostResumeProvisionerTest {
Node host = tester.nodeRepository().nodes().node("host100").orElseThrow();
Node node = tester.nodeRepository().nodes().node("host100-1").orElseThrow();
assertTrue("No IP addresses assigned",
- Stream.of(host, node).map(n -> n.ipConfig().primary()).allMatch(Set::isEmpty));
+ Stream.of(host, node).map(n -> n.ipConfig().primary()).allMatch(List::isEmpty));
hostResumeProvisioner.maintain();
assertEquals(Set.of("host100", "host100-1"), tester.nodeRepository().nodes().list(Node.State.failed).hostnames());
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporterTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporterTest.java
index 3091f82143d..1e2a6805ad1 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporterTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporterTest.java
@@ -190,22 +190,22 @@ public class MetricsReporterTest {
NodeRepository nodeRepository = tester.nodeRepository();
// Allow 4 containers
- Set<String> ipAddressPool = Set.of("::2", "::3", "::4", "::5");
+ var ipAddressPool = List.of("::2", "::3", "::4", "::5");
- Node dockerHost = Node.create("node-id-1", IP.Config.of(Set.of("::1"), ipAddressPool), "dockerHost",
+ Node dockerHost = Node.create("node-id-1", IP.Config.of(List.of("::1"), ipAddressPool), "dockerHost",
nodeFlavors.getFlavorOrThrow("host"), NodeType.host).build();
nodeRepository.nodes().addNodes(List.of(dockerHost), Agent.system);
nodeRepository.nodes().deallocateRecursively("dockerHost", Agent.system, getClass().getSimpleName());
tester.move(Node.State.ready, "dockerHost");
- Node container1 = Node.reserve(Set.of("::2"), "container1",
+ Node container1 = Node.reserve(List.of("::2"), "container1",
"dockerHost", new NodeResources(1, 3, 2, 1), NodeType.tenant).build();
container1 = container1.with(allocation(Optional.of("app1"), container1).get());
try (Mutex lock = nodeRepository.nodes().lockUnallocated()) {
nodeRepository.nodes().addReservedNodes(new LockedNodeList(List.of(container1), lock));
}
- Node container2 = Node.reserve(Set.of("::3"), "container2",
+ Node container2 = Node.reserve(List.of("::3"), "container2",
"dockerHost", new NodeResources(2, 4, 4, 1), NodeType.tenant).build();
container2 = container2.with(allocation(Optional.of("app2"), container2).get());
try (Mutex lock = nodeRepository.nodes().lockUnallocated()) {
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailTester.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailTester.java
index 00ae9ac5a9d..384c511dfe5 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailTester.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailTester.java
@@ -242,8 +242,8 @@ public class NodeFailTester {
int lastOctetOfPoolAddress = 0;
for (int i = startIndex; i < startIndex + count; i++) {
String hostname = "host" + i;
- Set<String> ipPool = nodeType.isHost() ? Set.of("127.0." + i + "." + (++lastOctetOfPoolAddress)) : Set.of();
- IP.Config ipConfig = IP.Config.of(nodeRepository.nameResolver().resolveAll(hostname),
+ List<String> ipPool = nodeType.isHost() ? List.of("127.0." + i + "." + (++lastOctetOfPoolAddress)) : List.of();
+ IP.Config ipConfig = IP.Config.of(List.copyOf(nodeRepository.nameResolver().resolveAll(hostname)),
ipPool);
Node.Builder builder = Node.create("node" + i, ipConfig, hostname, flavor, nodeType);
parentHostname.ifPresent(builder::parentHostname);
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirerTest.java
index d0ac59b1e15..5e39602145a 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirerTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirerTest.java
@@ -237,7 +237,7 @@ public class RetiredExpirerTest {
MockNameResolver nameResolver = (MockNameResolver) tester.nodeRepository().nameResolver();
String ipv4 = "127.0.1.4";
nameResolver.addRecord(retiredNode.hostname(), ipv4);
- Node node = Node.create(retiredNode.hostname(), IP.Config.of(Set.of(ipv4), Set.of()), retiredNode.hostname(),
+ Node node = Node.create(retiredNode.hostname(), IP.Config.ofEmptyPool(ipv4), retiredNode.hostname(),
tester.asFlavor("default", NodeType.config), NodeType.config).build();
var nodes = List.of(node);
nodes = nodeRepository.nodes().addNodes(nodes, Agent.system);
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/SpareCapacityMaintainerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/SpareCapacityMaintainerTest.java
index da64fa2fd64..afdb88b22e1 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/SpareCapacityMaintainerTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/SpareCapacityMaintainerTest.java
@@ -36,8 +36,6 @@ import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static org.junit.Assert.assertEquals;
@@ -328,11 +326,11 @@ public class SpareCapacityMaintainerTest {
}
private IP.Config ipConfig(int id, boolean host) {
- return IP.Config.of(Set.of(String.format("%04X::%04X", id, 0)),
+ return IP.Config.of(List.of(String.format("%04X::%04X", id, 0)),
host ? IntStream.range(0, 10)
.mapToObj(n -> String.format("%04X::%04X", id, n))
- .collect(Collectors.toSet())
- : Set.of());
+ .toList()
+ : List.of());
}
private void dumpState() {
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/node/IPTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/node/IPTest.java
index ecf7697f781..1c513e78de1 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/node/IPTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/node/IPTest.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.node;
-import com.google.common.collect.ImmutableSet;
import com.yahoo.config.provision.CloudName;
import com.yahoo.config.provision.HostName;
import com.yahoo.config.provision.NodeFlavors;
@@ -12,7 +11,7 @@ import com.yahoo.vespa.hosted.provision.provisioning.FlavorConfigBuilder;
import com.yahoo.vespa.hosted.provision.testutils.MockNameResolver;
import org.junit.Test;
-import java.util.LinkedHashSet;
+import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
@@ -76,7 +75,7 @@ public class IPTest {
@Test
public void test_find_allocation_ipv6_only() {
- IP.Pool pool = createNode(ImmutableSet.of(
+ IP.Pool pool = createNode(List.of(
"::1",
"::2",
"::3"
@@ -159,15 +158,15 @@ public class IPTest {
.addRecord("node1", "2600:1f10:::2")
.addRecord("node2", "2600:1f10:::3");
- IP.Config config = IP.Config.of(Set.of("2600:1f10:::1"),
- Set.of("2600:1f10:::2", "2600:1f10:::3"),
+ IP.Config config = IP.Config.of(List.of("2600:1f10:::1"),
+ List.of("2600:1f10:::2", "2600:1f10:::3"),
List.of(HostName.of("node1"), HostName.of("node2")));
IP.Pool pool = config.pool();
Optional<IP.Allocation> allocation = pool.findAllocation(contextOf(true), emptyList);
}
private IP.Pool testPool(boolean dualStack) {
- var addresses = new LinkedHashSet<String>();
+ var addresses = new ArrayList<String>();
addresses.add("127.0.0.1");
addresses.add("127.0.0.2");
addresses.add("127.0.0.3");
@@ -202,8 +201,8 @@ public class IPTest {
return pool;
}
- private static Node createNode(Set<String> ipAddresses) {
- return Node.create("id1", IP.Config.of(Set.of("127.0.0.1"), ipAddresses),
+ private static Node createNode(List<String> ipAddresses) {
+ return Node.create("id1", IP.Config.of(List.of("127.0.0.1"), ipAddresses),
"host1", nodeFlavors.getFlavorOrThrow("default"), NodeType.host).build();
}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializerTest.java
index 6e2d1e7fcd6..76cd9f0ec23 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializerTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializerTest.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.persistence;
-import com.google.common.collect.ImmutableSet;
import com.yahoo.component.Version;
import com.yahoo.component.Vtag;
import com.yahoo.config.provision.ApplicationId;
@@ -42,7 +41,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
-import java.util.Set;
import java.util.stream.Collectors;
import static com.yahoo.config.provision.NodeResources.Architecture;
@@ -251,7 +249,7 @@ public class NodeSerializerTest {
@Test
public void serialize_parent_hostname() {
final String parentHostname = "parent.yahoo.com";
- Node node = Node.create("myId", IP.Config.of(Set.of("127.0.0.1"), Set.of()), "myHostname", nodeFlavors.getFlavorOrThrow("default"), NodeType.tenant)
+ Node node = Node.create("myId", IP.Config.of(List.of("127.0.0.1"), List.of()), "myHostname", nodeFlavors.getFlavorOrThrow("default"), NodeType.tenant)
.parentHostname(parentHostname)
.build();
@@ -264,7 +262,7 @@ public class NodeSerializerTest {
public void serializes_multiple_ip_addresses() {
byte[] nodeWithMultipleIps = createNodeJson("node4.yahoo.tld", "127.0.0.4", "::4");
Node deserializedNode = nodeSerializer.fromJson(nodeWithMultipleIps);
- assertEquals(ImmutableSet.of("127.0.0.4", "::4"), deserializedNode.ipConfig().primary());
+ assertEquals(List.of("127.0.0.4", "::4"), deserializedNode.ipConfig().primary());
}
@Test
@@ -273,7 +271,7 @@ public class NodeSerializerTest {
// Test round-trip with address pool
node = node.with(node.ipConfig().withPool(IP.Pool.of(
- Set.of("::1", "::2", "::3"),
+ List.of("::1", "::2", "::3"),
List.of(HostName.of("a"), HostName.of("b"), HostName.of("c")))));
Node copy = nodeSerializer.fromJson(nodeSerializer.toJson(node));
assertEquals(node.ipConfig(), copy.ipConfig());
@@ -536,7 +534,7 @@ public class NodeSerializerTest {
private Node createNode() {
return Node.create("myId",
- IP.Config.of(Set.of("127.0.0.1"), Set.of()),
+ IP.Config.of(List.of("127.0.0.1"), List.of()),
"myHostname",
nodeFlavors.getFlavorOrThrow("default"),
NodeType.tenant).build();
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/AllocationSimulator.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/AllocationSimulator.java
index 9a88b4664b0..12f5dd2a005 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/AllocationSimulator.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/AllocationSimulator.java
@@ -15,11 +15,8 @@ import com.yahoo.vespa.hosted.provision.node.IP;
import javax.swing.JFrame;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
import java.util.Optional;
-import java.util.Set;
/**
@@ -77,17 +74,15 @@ public class AllocationSimulator {
Node.Builder builder = Node.create("fake", hostname, flavor,
parent.isPresent() ? Node.State.ready : Node.State.active,
parent.isPresent() ? NodeType.tenant : NodeType.host)
- .ipConfig(IP.Config.of(Set.of("127.0.0.1"), parent.isPresent() ? Set.of() : getAdditionalIP(), List.of()));
+ .ipConfig(IP.Config.of(List.of("127.0.0.1"), parent.isPresent() ? List.of() : getAdditionalIP(), List.of()));
parent.ifPresent(builder::parentHostname);
allocation(tenant, flavor).ifPresent(builder::allocation);
return builder.build();
}
- private Set<String> getAdditionalIP() {
- Set<String> h = new HashSet<String>();
- Collections.addAll(h, "::1", "::2", "::3", "::4", "::5", "::6", "::7", "::8");
- return h;
+ private List<String> getAdditionalIP() {
+ return List.of("::1", "::2", "::3", "::4", "::5", "::6", "::7", "::8");
}
private Optional<Allocation> allocation(Optional<String> tenant, Flavor flavor) {
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ContainerImagesTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ContainerImagesTest.java
index 4537aaef45b..76b7b7e4bc7 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ContainerImagesTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ContainerImagesTest.java
@@ -12,8 +12,8 @@ import com.yahoo.vespa.hosted.provision.node.Allocation;
import com.yahoo.vespa.hosted.provision.node.Generation;
import org.junit.Test;
+import java.util.List;
import java.util.Optional;
-import java.util.Set;
import static org.junit.Assert.assertEquals;
@@ -71,7 +71,7 @@ public class ContainerImagesTest {
if (gpu) {
resources = resources.with(new NodeResources.GpuResources(1, 16));
}
- Node.Builder b = Node.reserve(Set.of("::1"), type + "1", "parent1", resources, type);
+ Node.Builder b = Node.reserve(List.of("::1"), type + "1", "parent1", resources, type);
b.allocation(new Allocation(ApplicationId.defaultId(),
ClusterMembership.from("container/id1/4/37",
Version.fromString("1.2.3"),
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicAllocationTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicAllocationTest.java
index 7cf1b0d5177..a00a9b63d93 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicAllocationTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicAllocationTest.java
@@ -10,9 +10,9 @@ import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.Environment;
import com.yahoo.config.provision.Flavor;
import com.yahoo.config.provision.HostSpec;
+import com.yahoo.config.provision.NodeAllocationException;
import com.yahoo.config.provision.NodeResources;
import com.yahoo.config.provision.NodeType;
-import com.yahoo.config.provision.NodeAllocationException;
import com.yahoo.config.provision.ProvisionLock;
import com.yahoo.config.provision.RegionName;
import com.yahoo.config.provision.SystemName;
@@ -29,7 +29,6 @@ import com.yahoo.vespa.hosted.provision.node.IP;
import org.junit.Test;
import java.time.Instant;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -341,8 +340,8 @@ public class DynamicAllocationTest {
tester.activate(application, hosts);
NodeList activeNodes = tester.nodeRepository().nodes().list().owner(application);
- assertEquals(Set.of("127.0.127.2", "::2"), activeNodes.asList().get(1).ipConfig().primary());
- assertEquals(Set.of("127.0.127.13", "::d"), activeNodes.asList().get(0).ipConfig().primary());
+ assertEquals(List.of("127.0.127.2", "::2"), activeNodes.asList().get(1).ipConfig().primary());
+ assertEquals(List.of("127.0.127.13", "::d"), activeNodes.asList().get(0).ipConfig().primary());
}
@Test
@@ -535,7 +534,7 @@ public class DynamicAllocationTest {
}
private void addAndAssignNode(ApplicationId id, String hostname, String parentHostname, ClusterSpec clusterSpec, NodeResources flavor, int index, ProvisioningTester tester) {
- Node node1a = Node.create("open1", IP.Config.of(Set.of("127.0.233." + index), Set.of()), hostname,
+ Node node1a = Node.create("open1", IP.Config.ofEmptyPool("127.0.233." + index), hostname,
new Flavor(flavor), NodeType.tenant).parentHostname(parentHostname).build();
ClusterMembership clusterMembership1 = ClusterMembership.from(
clusterSpec.with(Optional.of(ClusterSpec.Group.from(0))), index); // Need to add group here so that group is serialized in node allocation
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTest.java
index 54703b40781..eac0f7c7243 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTest.java
@@ -545,7 +545,8 @@ public class DynamicProvisioningTest {
for (var host : hosts) {
try (var nodeLock = nodeRepository.nodes().lockAndGetRequired(host.hostname())) {
var node = nodeLock.node();
- nodeRepository.nodes().write(node.with(node.ipConfig().withPrimary(nodeRepository.nameResolver().resolveAll(node.hostname()))), nodeLock);
+ List<String> primary = List.copyOf(nodeRepository.nameResolver().resolveAll(node.hostname()));
+ nodeRepository.nodes().write(node.with(node.ipConfig().withPrimary(primary)), nodeLock);
}
}
}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTester.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTester.java
index c982b195787..ebac6071a14 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTester.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTester.java
@@ -29,7 +29,6 @@ import com.yahoo.vespa.hosted.provision.testutils.InMemoryProvisionLogger;
import java.time.Duration;
import java.util.List;
import java.util.Optional;
-import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -116,9 +115,9 @@ public class DynamicProvisioningTester {
public void makeReady(String hostname) {
Node node = nodeRepository().nodes().node(hostname).get();
- provisioningTester.patchNode(node, (n) -> n.with(IP.Config.of(Set.of("::" + 0 + ":0"), Set.of())));
+ provisioningTester.patchNode(node, (n) -> n.with(IP.Config.ofEmptyPool("::" + 0 + ":0")));
Node host = nodeRepository().nodes().node(node.parentHostname().get()).get();
- host = host.with(IP.Config.of(Set.of("::" + 0 + ":0"), Set.of("::" + 0 + ":2")));
+ host = host.with(IP.Config.of(List.of("::" + 0 + ":0"), List.of("::" + 0 + ":2")));
if (host.state() == Node.State.provisioned)
provisioningTester.move(Node.State.ready, host);
}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/HostCapacityTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/HostCapacityTest.java
index 35d6cdbf5d0..3a717ffade8 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/HostCapacityTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/HostCapacityTest.java
@@ -13,9 +13,7 @@ import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
-import java.util.LinkedHashSet;
import java.util.List;
-import java.util.Set;
import java.util.stream.Stream;
import static org.junit.Assert.assertEquals;
@@ -48,21 +46,21 @@ public class HostCapacityTest {
NodeFlavors nodeFlavors = FlavorConfigBuilder.createDummies("host", "docker");
// Create hosts
- host1 = Node.create("host1", IP.Config.of(Set.of("::1"), createIps(2, 4), List.of()), "host1", nodeFlavors.getFlavorOrThrow("host"), NodeType.host).build();
- host2 = Node.create("host2", IP.Config.of(Set.of("::11"), createIps(12, 3), List.of()), "host2", nodeFlavors.getFlavorOrThrow("host"), NodeType.host).build();
- host3 = Node.create("host3", IP.Config.of(Set.of("::21"), createIps(22, 2), List.of()), "host3", nodeFlavors.getFlavorOrThrow("host"), NodeType.host).build();
- host4 = Node.create("host3", IP.Config.of(Set.of("::21"), createIps(50, 0), List.of()), "host4", nodeFlavors.getFlavorOrThrow("host"), NodeType.host).build();
+ host1 = Node.create("host1", IP.Config.of(List.of("::1"), createIps(2, 4), List.of()), "host1", nodeFlavors.getFlavorOrThrow("host"), NodeType.host).build();
+ host2 = Node.create("host2", IP.Config.of(List.of("::11"), createIps(12, 3), List.of()), "host2", nodeFlavors.getFlavorOrThrow("host"), NodeType.host).build();
+ host3 = Node.create("host3", IP.Config.of(List.of("::21"), createIps(22, 2), List.of()), "host3", nodeFlavors.getFlavorOrThrow("host"), NodeType.host).build();
+ host4 = Node.create("host3", IP.Config.of(List.of("::21"), createIps(50, 0), List.of()), "host4", nodeFlavors.getFlavorOrThrow("host"), NodeType.host).build();
// Add two containers to host1
- var nodeA = Node.reserve(Set.of("::2"), "nodeA", "host1", resources0, NodeType.tenant).build();
- var nodeB = Node.reserve(Set.of("::3"), "nodeB", "host1", resources0, NodeType.tenant).build();
+ var nodeA = Node.reserve(List.of("::2"), "nodeA", "host1", resources0, NodeType.tenant).build();
+ var nodeB = Node.reserve(List.of("::3"), "nodeB", "host1", resources0, NodeType.tenant).build();
// Add two containers to host 2 (same as host 1)
- var nodeC = Node.reserve(Set.of("::12"), "nodeC", "host2", resources0, NodeType.tenant).build();
- var nodeD = Node.reserve(Set.of("::13"), "nodeD", "host2", resources0, NodeType.tenant).build();
+ var nodeC = Node.reserve(List.of("::12"), "nodeC", "host2", resources0, NodeType.tenant).build();
+ var nodeD = Node.reserve(List.of("::13"), "nodeD", "host2", resources0, NodeType.tenant).build();
// Add a larger container to host3
- var nodeE = Node.reserve(Set.of("::22"), "nodeE", "host3", resources1, NodeType.tenant).build();
+ var nodeE = Node.reserve(List.of("::22"), "nodeE", "host3", resources1, NodeType.tenant).build();
// init host capacity
nodes = new ArrayList<>(List.of(host1, host2, host3, nodeA, nodeB, nodeC, nodeD, nodeE));
@@ -81,7 +79,7 @@ public class HostCapacityTest {
assertFalse(capacity.hasCapacity(host4, resources1)); // No IPs available
// Add a new node to host1 to deplete the memory resource
- Node nodeF = Node.reserve(Set.of("::6"), "nodeF", "host1", resources0, NodeType.tenant).build();
+ Node nodeF = Node.reserve(List.of("::6"), "nodeF", "host1", resources0, NodeType.tenant).build();
nodes.add(nodeF);
capacity = new HostCapacity(new LockedNodeList(nodes, () -> {}), hostResourcesCalculator);
assertFalse(capacity.hasCapacity(host1, resources0));
@@ -133,9 +131,9 @@ public class HostCapacityTest {
@Test
public void verifyCapacityFromAddresses() {
- Node nodeA = Node.reserve(Set.of("::2"), "nodeA", "host1", resources0, NodeType.tenant).build();
- Node nodeB = Node.reserve(Set.of("::3"), "nodeB", "host1", resources0, NodeType.tenant).build();
- Node nodeC = Node.reserve(Set.of("::4"), "nodeC", "host1", resources0, NodeType.tenant).build();
+ Node nodeA = Node.reserve(List.of("::2"), "nodeA", "host1", resources0, NodeType.tenant).build();
+ Node nodeB = Node.reserve(List.of("::3"), "nodeB", "host1", resources0, NodeType.tenant).build();
+ Node nodeC = Node.reserve(List.of("::4"), "nodeC", "host1", resources0, NodeType.tenant).build();
// host1 is a host with resources = 7-100-120-5 (7 vcpus, 100G memory, 120G disk, and 5Gbps),
// while nodeA-C have resources = resources0 = 1-30-20-1.5
@@ -180,7 +178,7 @@ public class HostCapacityTest {
"host", // 7-100-120-5
"docker"); // 2- 40- 40-0.5 = resources1
- return Node.create(hostHostname, IP.Config.of(Set.of("::1"), Set.of(), hostnames), hostHostname,
+ return Node.create(hostHostname, IP.Config.of(List.of("::1"), List.of(), hostnames), hostHostname,
nodeFlavors.getFlavorOrThrow("host"), NodeType.host).build();
}
@@ -190,9 +188,9 @@ public class HostCapacityTest {
return capacity.hasCapacity(host, requestedCapacity);
}
- private Set<String> createIps(int start, int count) {
+ private List<String> createIps(int start, int count) {
// Allow 4 containers
- Set<String> ipAddressPool = new LinkedHashSet<>();
+ var ipAddressPool = new ArrayList<String>();
for (int i = start; i < (start + count); i++) {
ipAddressPool.add("::" + i);
}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/LoadBalancerProvisionerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/LoadBalancerProvisionerTest.java
index cbe12a8202b..29277c7cea0 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/LoadBalancerProvisionerTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/LoadBalancerProvisionerTest.java
@@ -492,7 +492,7 @@ public class LoadBalancerProvisionerTest {
private void assignIps(NodeList nodes) {
try (var lock = tester.nodeRepository().nodes().lockUnallocated()) {
for (int i = 0; i < nodes.size(); i++) {
- tester.nodeRepository().nodes().write(nodes.asList().get(i).with(IP.Config.EMPTY.withPrimary(Set.of("127.0.0." + i))), lock);
+ tester.nodeRepository().nodes().write(nodes.asList().get(i).with(IP.Config.EMPTY.withPrimary(List.of("127.0.0." + i))), lock);
}
}
}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidateTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidateTest.java
index c82b29c7d65..fac1111e616 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidateTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidateTest.java
@@ -12,7 +12,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import java.util.Set;
import static org.junit.Assert.assertEquals;
@@ -134,7 +133,7 @@ public class NodeCandidateTest {
private static Node node(String hostname, Node.State state) {
return Node.create(hostname, hostname, new Flavor(new NodeResources(2, 2, 2, 2)), state, NodeType.tenant)
- .ipConfigWithEmptyPool(Set.of("::1")).build();
+ .ipConfigWithEmptyPool(List.of("::1")).build();
}
private static NodeCandidate node(String hostname,
@@ -144,9 +143,9 @@ public class NodeCandidateTest {
boolean exclusiveSwitch) {
Node node = Node.create(hostname, hostname, new Flavor(nodeResources), Node.State.ready, NodeType.tenant)
.parentHostname(hostname + "parent")
- .ipConfigWithEmptyPool(Set.of("::1")).build();
+ .ipConfigWithEmptyPool(List.of("::1")).build();
Node parent = Node.create(hostname + "parent", hostname, new Flavor(totalHostResources), Node.State.ready, NodeType.host)
- .ipConfig(IP.Config.of(Set.of("::1"), Set.of("::2")))
+ .ipConfig(IP.Config.of(List.of("::1"), List.of("::2")))
.build();
return new NodeCandidate.ConcreteNodeCandidate(node, false, totalHostResources.subtract(allocatedHostResources), Optional.of(parent),
false, exclusiveSwitch, false, true, false);
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java
index cb4644f179f..f0b47f04fb1 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java
@@ -981,10 +981,10 @@ public class ProvisioningTest {
// Add 2 config server hosts and 2 config servers
Flavor flavor = tester.nodeRepository().flavors().getFlavorOrThrow("default");
List<Node> nodes = List.of(
- Node.create("cfghost1", IP.Config.of(Set.of("::1:0"), Set.of("::1:1")), "cfghost1", flavor, NodeType.confighost).build(),
- Node.create("cfghost2", IP.Config.of(Set.of("::2:0"), Set.of("::2:1")), "cfghost2", flavor, NodeType.confighost).ipConfig(IP.Config.of(Set.of("::2:0"), Set.of("::2:1"), List.of())).build(),
- Node.create("cfg1", IP.Config.of(Set.of("::1:1"), Set.of()), "cfg1", flavor, NodeType.config).parentHostname("cfghost1").build(),
- Node.create("cfg2", IP.Config.of(Set.of("::2:1"), Set.of()), "cfg2", flavor, NodeType.config).parentHostname("cfghost2").build());
+ Node.create("cfghost1", IP.Config.of(List.of("::1:0"), List.of("::1:1")), "cfghost1", flavor, NodeType.confighost).build(),
+ Node.create("cfghost2", IP.Config.of(List.of("::2:0"), List.of("::2:1")), "cfghost2", flavor, NodeType.confighost).ipConfig(IP.Config.of(List.of("::2:0"), List.of("::2:1"), List.of())).build(),
+ Node.create("cfg1", IP.Config.of(List.of("::1:1"), List.of()), "cfg1", flavor, NodeType.config).parentHostname("cfghost1").build(),
+ Node.create("cfg2", IP.Config.of(List.of("::2:1"), List.of()), "cfg2", flavor, NodeType.config).parentHostname("cfghost2").build());
tester.move(Node.State.ready, tester.nodeRepository().nodes().addNodes(nodes, Agent.system));
InfraApplication cfgHostApp = new ConfigServerHostApplication();
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTester.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTester.java
index be8c84141b5..6e78c4aa275 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTester.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTester.java
@@ -66,7 +66,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
@@ -212,7 +211,7 @@ public class ProvisioningTester {
try (var lock = nodeRepository.nodes().lockAndGetRequired(prepared.hostname())) {
Node node = lock.node();
if (node.ipConfig().primary().isEmpty()) {
- node = node.with(IP.Config.of(Set.of("::" + 0 + ":0"), Set.of()));
+ node = node.with(IP.Config.of(List.of("::" + 0 + ":0"), List.of()));
nodeRepository.nodes().write(node, lock);
}
if (node.parentHostname().isEmpty()) continue;
@@ -220,7 +219,7 @@ public class ProvisioningTester {
if (parent.state() == Node.State.active) continue;
NestedTransaction t = new NestedTransaction();
if (parent.ipConfig().primary().isEmpty())
- parent = parent.with(IP.Config.of(Set.of("::" + 0 + ":0"), Set.of("::" + 0 + ":2")));
+ parent = parent.with(IP.Config.of(List.of("::" + 0 + ":0"), List.of("::" + 0 + ":2")));
nodeRepository.nodes().activate(List.of(parent), new ApplicationTransaction(new ProvisionLock(application, () -> { }), t));
t.commit();
}
@@ -450,11 +449,11 @@ public class ProvisioningTester {
String ipv6 = String.format("::%x", nextIP);
nameResolver.addRecord(hostname, ipv4, ipv6);
- HashSet<String> hostIps = new HashSet<>();
+ var hostIps = new ArrayList<String>();
hostIps.add(ipv4);
hostIps.add(ipv6);
- Set<String> ipAddressPool = new LinkedHashSet<>();
+ var ipAddressPool = new ArrayList<String>();
for (int poolIp = 1; poolIp <= ipAddressPoolSize; poolIp++) {
nextIP++;
String nodeHostname = hostnameParts[0] + "-" + poolIp + (hostnameParts.length > 1 ? "." + hostnameParts[1] : "");
@@ -485,7 +484,7 @@ public class ProvisioningTester {
String ipv4 = "127.0.1." + i;
nameResolver.addRecord(hostname, ipv4);
- Node node = Node.create(hostname, IP.Config.of(Set.of(ipv4), Set.of()), hostname,
+ Node node = Node.create(hostname, IP.Config.of(List.of(ipv4), List.of()), hostname,
nodeFlavors.getFlavorOrThrow(flavor), NodeType.config).build();
nodes.add(node);
}
@@ -553,7 +552,7 @@ public class ProvisioningTester {
List<Node> nodes = new ArrayList<>(count);
for (int i = startIndex; i < count + startIndex; i++) {
String hostname = nodeNamer.apply(i);
- IP.Config ipConfig = IP.Config.of(nodeRepository.nameResolver().resolveAll(hostname), Set.of());
+ IP.Config ipConfig = IP.Config.of(List.copyOf(nodeRepository.nameResolver().resolveAll(hostname)), List.of());
Node node = Node.create("node-id", ipConfig, hostname, new Flavor(resources), nodeType)
.parentHostname(parentHostname)
.build();