diff options
author | Martin Polden <mpolden@mpolden.no> | 2019-05-20 13:00:19 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2019-05-20 13:04:18 +0200 |
commit | 588c95846e0b0a7a0cf69d1466a96b94c49841c0 (patch) | |
tree | 4101693a134def1e8f9db7683242239cbb181f13 /controller-server | |
parent | 5ece630571b9bc81fc3dfb0023ac40f153197c26 (diff) |
Cleanup
Diffstat (limited to 'controller-server')
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java index c9b07ada854..496e09954e5 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java @@ -8,11 +8,9 @@ import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList; import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryClientInterface; import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode; -import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.vespa.hosted.controller.application.ClusterInfo; import com.yahoo.vespa.hosted.controller.application.Deployment; -import java.io.IOException; import java.time.Duration; import java.util.HashMap; import java.util.List; @@ -22,8 +20,8 @@ import java.util.logging.Logger; import java.util.stream.Collectors; /** - * Maintain info about hardware, hostnames and cluster specifications. - * <p> + * Maintains information about hardware, hostnames and cluster specifications. + * * This is used to calculate cost metrics for the application api. * * @author smorgrav @@ -42,17 +40,17 @@ public class ClusterInfoMaintainer extends Maintainer { this.nodeRepositoryClient = nodeRepositoryClient; } - private static String clusterid(NodeRepositoryNode node) { + private static String clusterId(NodeRepositoryNode node) { return node.getMembership().clusterid; } - private Map<ClusterSpec.Id, ClusterInfo> getClusterInfo(NodeList nodes, ZoneId zone) { + private Map<ClusterSpec.Id, ClusterInfo> getClusterInfo(NodeList nodes) { Map<ClusterSpec.Id, ClusterInfo> infoMap = new HashMap<>(); // Group nodes by clusterid Map<String, List<NodeRepositoryNode>> clusters = nodes.nodes().stream() .filter(node -> node.getMembership() != null) - .collect(Collectors.groupingBy(ClusterInfoMaintainer::clusterid)); + .collect(Collectors.groupingBy(ClusterInfoMaintainer::clusterId)); // For each cluster - get info for (String id : clusters.keySet()) { @@ -65,16 +63,6 @@ public class ClusterInfoMaintainer extends Maintainer { double cpu = 0; double mem = 0; double disk = 0; - // TODO: This code was never run. Reenable when flavours are available from a FlavorRegistry or something, or remove. - /*if (zone.nodeFlavors().isPresent()) { - Optional<Flavor> flavorOptional = zone.nodeFlavors().get().getFlavor(node.flavor); - if ((flavorOptional.isPresent())) { - Flavor flavor = flavorOptional.get(); - cpu = flavor.getMinCpuCores(); - mem = flavor.getMinMainMemoryAvailableGb(); - disk = flavor.getMinMainMemoryAvailableGb(); - } - }*/ // Add to map List<String> hostnames = clusterNodes.stream().map(NodeRepositoryNode::getHostname).collect(Collectors.toList()); @@ -96,12 +84,11 @@ public class ClusterInfoMaintainer extends Maintainer { deploymentId.applicationId().tenant().value(), deploymentId.applicationId().application().value(), deploymentId.applicationId().instance().value()); - Map<ClusterSpec.Id, ClusterInfo> clusterInfo = getClusterInfo(nodes, deployment.zone()); + Map<ClusterSpec.Id, ClusterInfo> clusterInfo = getClusterInfo(nodes); controller().applications().lockIfPresent(application.id(), lockedApplication -> controller.applications().store(lockedApplication.withClusterInfo(deployment.zone(), clusterInfo))); - } - catch (IOException | IllegalArgumentException e) { - log.log(Level.WARNING, "Failing getting cluster info of for " + deploymentId, e); + } catch (Exception e) { + log.log(Level.WARNING, "Failing getting cluster information for " + deploymentId, e); } } } |