summaryrefslogtreecommitdiffstats
path: root/node-repository/src
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2022-05-04 12:26:37 +0200
committerMartin Polden <mpolden@mpolden.no>2022-05-04 12:55:06 +0200
commitd5db9e8efaa09c80adc68cbffdda65cd9053fd4e (patch)
treebaa8ab8abde8795c789cf83a6562844b18734f58 /node-repository/src
parentce51f7527963e2188efc6ab7500759da1cb264e5 (diff)
Avoid reading all nodes twice
Diffstat (limited to 'node-repository/src')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java10
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/NodeAcl.java10
2 files changed, 9 insertions, 11 deletions
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<NodeAcl> 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;