summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@yahooinc.com>2023-10-19 15:48:47 +0200
committerHåkon Hallingstad <hakon@yahooinc.com>2023-10-19 15:48:47 +0200
commitfffc880abe70c5af4de1f2af9539689d0de1e198 (patch)
tree24c36640b8252216416e25c2d32bc6ffaf7f560c /node-repository
parentb35b2fff2b856e642a2e4562e4aea79a8f185065 (diff)
Define IP.Pool size
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/IP.java8
1 files changed, 8 insertions, 0 deletions
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 b4968c66a67..264e981558a 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
@@ -222,6 +222,14 @@ public record IP() {
this.hostnames = List.copyOf(Objects.requireNonNull(hostnames, "hostnames must be non-null"));
}
+ /** The number of hosts in this pool: each host has a name and/or one or two IP addresses. */
+ public long size() {
+ return hostnames().isEmpty() ?
+ Math.max(ipAddresses.addresses.stream().filter(IP::isV4).count(),
+ ipAddresses.addresses.stream().filter(IP::isV6).count()) :
+ hostnames().size();
+ }
+
public List<String> ips() { return ipAddresses.addresses; }
/**