From d5db9e8efaa09c80adc68cbffdda65cd9053fd4e Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Wed, 4 May 2022 12:26:37 +0200 Subject: Avoid reading all nodes twice --- .../java/com/yahoo/vespa/hosted/provision/NodeRepository.java | 10 ++++------ .../java/com/yahoo/vespa/hosted/provision/node/NodeAcl.java | 10 +++++----- 2 files changed, 9 insertions(+), 11 deletions(-) (limited to 'node-repository/src/main') diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java index a387bc28aa4..4cf6b9e0ac1 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java @@ -34,7 +34,6 @@ import com.yahoo.vespa.orchestrator.Orchestrator; import java.time.Clock; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * The top level singleton in the node repo, providing access to all its state as child objects. @@ -182,10 +181,10 @@ public class NodeRepository extends AbstractComponent { public NodeRepoStats computeStats() { return NodeRepoStats.computeOver(this); } - /** Returns the time keeper of this system */ + /** Returns the time-keeper of this */ public Clock clock() { return clock; } - /** Returns the zone of this system */ + /** Returns the zone of this */ public Zone zone() { return zone; } /** The number of nodes we should ensure has free capacity for node failures whenever possible */ @@ -200,9 +199,8 @@ public class NodeRepository extends AbstractComponent { public List getChildAcls(Node host) { if ( ! host.type().isHost()) throw new IllegalArgumentException("Only hosts have children"); NodeList allNodes = nodes().list(); - return nodes().list().childrenOf(host).asList().stream() - .map(childNode -> childNode.acl(allNodes, loadBalancers)) - .collect(Collectors.toUnmodifiableList()); + return allNodes.childrenOf(host) + .mapToList(childNode -> childNode.acl(allNodes, loadBalancers)); } /** Removes this application: all nodes are set dirty. */ diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/NodeAcl.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/NodeAcl.java index ac24c83e129..0b226d5acc7 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/NodeAcl.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/NodeAcl.java @@ -81,9 +81,9 @@ public class NodeAcl { // Tenant nodes in other states than ready, trust: // - config servers // - proxy nodes - // - parents of the nodes in the same application: If some of the nodes are on a different IP versions - // or only a subset of them are dual-stacked, the communication between the nodes may be NATed - // with via parent's IP address. + // - parents of the nodes in the same application: If some nodes are on a different IP version + // or only a subset of them are dual-stacked, the communication between the nodes may be NAT-ed + // via parent's IP address trustedNodes.addAll(allNodes.nodeType(NodeType.config).asList()); trustedNodes.addAll(allNodes.nodeType(NodeType.proxy).asList()); node.allocation().ifPresent(allocation -> @@ -91,9 +91,9 @@ public class NodeAcl { if (node.state() == Node.State.ready) { // Tenant nodes in state ready, trust: - // - All tenant nodes in zone. When a ready node is allocated to a an application there's a brief + // - All tenant nodes in zone. When a ready node is allocated to an application there's a brief // window where current ACLs have not yet been applied on the node. To avoid service disruption - // during this window, ready tenant nodes trust all other tenant nodes. + // during this window, ready tenant nodes trust all other tenant nodes trustedNodes.addAll(allNodes.nodeType(NodeType.tenant).asList()); } break; -- cgit v1.2.3