diff options
author | Håkon Hallingstad <hakon@yahooinc.com> | 2023-10-19 15:48:47 +0200 |
---|---|---|
committer | Håkon Hallingstad <hakon@yahooinc.com> | 2023-10-19 15:48:47 +0200 |
commit | fffc880abe70c5af4de1f2af9539689d0de1e198 (patch) | |
tree | 24c36640b8252216416e25c2d32bc6ffaf7f560c /node-repository | |
parent | b35b2fff2b856e642a2e4562e4aea79a8f185065 (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.java | 8 |
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; } /** |