summaryrefslogtreecommitdiffstats
path: root/controller-server/src
diff options
context:
space:
mode:
authortoby <smorgrav@yahoo-inc.com>2017-10-18 12:46:34 +0200
committertoby <smorgrav@yahoo-inc.com>2017-10-18 12:46:34 +0200
commit8f417af81fe1d5c011636eb9eeedf5a3c68775cf (patch)
tree793517cd753c1dac0d75b95b72f0ecced1ee636b /controller-server/src
parent3758f1bd35f87e22b99459c7c8f4a0b1b1e367d5 (diff)
Avoid NPE when cluster utilizations are updated but not cluster info
Diffstat (limited to 'controller-server/src')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ClusterCost.java5
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java9
2 files changed, 12 insertions, 2 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ClusterCost.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ClusterCost.java
index 985d6173b29..1b2ad9f938a 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ClusterCost.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ClusterCost.java
@@ -1,6 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.application;
+import java.util.Objects;
+
/**
* Calculate utilization relative to the target utilization,
* tco and waste for one cluster of one deployment.
@@ -36,6 +38,9 @@ public class ClusterCost {
public ClusterCost(ClusterInfo clusterInfo,
ClusterUtilization systemUtilization) {
+ Objects.requireNonNull(clusterInfo, "Cluster info cannot be null");
+ Objects.requireNonNull(systemUtilization, "Cluster utilization cannot be null");
+
this.clusterInfo = clusterInfo;
this.systemUtilization = systemUtilization;
this.targetUtilization = new ClusterUtilization(0.7,0.2, 0.7, 0.3);
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java
index 05a7f9667ba..98ae5ed1762 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java
@@ -38,7 +38,7 @@ public class Deployment {
Objects.requireNonNull(deployTime, "deployTime cannot be null");
Objects.requireNonNull(clusterUtils, "clusterUtils cannot be null");
Objects.requireNonNull(clusterInfo, "clusterInfo cannot be null");
- Objects.requireNonNull(clusterInfo, "deployment metrics cannot be null");
+ Objects.requireNonNull(metrics, "deployment metrics cannot be null");
this.zone = zone;
this.revision = revision;
this.version = version;
@@ -94,7 +94,12 @@ public class Deployment {
Map<String, ClusterCost> costClusters = new HashMap<>();
for (Id clusterId : clusterUtils.keySet()) {
- costClusters.put(clusterId.value(), new ClusterCost(clusterInfo.get(clusterId), clusterUtils.get(clusterId)));
+
+ // Only include cluster cost if we have both cluster utilization and cluster info
+ if (clusterInfo.containsKey(clusterId)) {
+ costClusters.put(clusterId.value(), new ClusterCost(clusterInfo.get(clusterId),
+ clusterUtils.get(clusterId)));
+ }
}
return new DeploymentCost(costClusters);