summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2020-10-22 19:05:54 +0200
committerJon Bratseth <bratseth@gmail.com>2020-10-22 19:05:54 +0200
commit5f1e7d3d32e43f2ef5c23df482e5d3d9c197ea0e (patch)
tree9e22e21935280b7ddbd7505362e60efa895fa0f3 /node-repository
parent30850e3233a5a1999e25d86d63acf5e8083a4c69 (diff)
Read application once
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java18
1 files changed, 9 insertions, 9 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java
index ffeed74d944..8e691b538a1 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java
@@ -98,25 +98,25 @@ class Activator {
private void rememberResourceChange(ApplicationTransaction transaction, long generation,
NodeList oldNodes, NodeList newNodes) {
- if (nodeRepository.applications().get(transaction.application()).isEmpty()) return; // infrastructure app, hopefully
- Application application = nodeRepository.applications().get(transaction.application()).get();
+ Optional<Application> application = nodeRepository.applications().get(transaction.application());
+ if (application.isEmpty()) return; // infrastructure app, hopefully :-|
var currentNodesByCluster = newNodes.stream()
.collect(Collectors.groupingBy(node -> node.allocation().get().membership().cluster().id()));
- Application modified = application;
+ Application modified = application.get();
for (var clusterEntry : currentNodesByCluster.entrySet()) {
var previousResources = oldNodes.cluster(clusterEntry.getKey()).toResources();
var currentResources = NodeList.copyOf(clusterEntry.getValue()).toResources();
if ( ! previousResources.equals(currentResources)) {
- modified = modified.with(application.cluster(clusterEntry.getKey()).get()
- .with(new ScalingEvent(previousResources,
- currentResources,
- generation,
- nodeRepository.clock().instant())));
+ modified = modified.with(application.get().cluster(clusterEntry.getKey()).get()
+ .with(new ScalingEvent(previousResources,
+ currentResources,
+ generation,
+ nodeRepository.clock().instant())));
}
}
- if (modified != application)
+ if (modified != application.get())
nodeRepository.applications().put(modified, transaction);
}