diff options
Diffstat (limited to 'controller-server/src/main/java/com')
2 files changed, 0 insertions, 94 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 deleted file mode 100644 index 88c1a48653a..00000000000 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.maintenance; - -import com.yahoo.config.provision.ClusterSpec; -import com.yahoo.config.provision.HostName; -import com.yahoo.vespa.hosted.controller.Application; -import com.yahoo.vespa.hosted.controller.Controller; -import com.yahoo.vespa.hosted.controller.Instance; -import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; -import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node; -import com.yahoo.vespa.hosted.controller.api.integration.configserver.NodeRepository; -import com.yahoo.vespa.hosted.controller.application.ClusterInfo; -import com.yahoo.vespa.hosted.controller.application.Deployment; - -import java.time.Duration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.stream.Collectors; - -/** - * Maintains information about hardware, hostnames and cluster specifications. - * - * This is used to calculate cost metrics for the application api. - * - * @author smorgrav - */ -public class ClusterInfoMaintainer extends Maintainer { - - private static final Logger log = Logger.getLogger(ClusterInfoMaintainer.class.getName()); - - private final Controller controller; - private final NodeRepository nodeRepository; - - ClusterInfoMaintainer(Controller controller, Duration duration, JobControl jobControl) { - super(controller, duration, jobControl); - this.controller = controller; - this.nodeRepository = controller.serviceRegistry().configServer().nodeRepository(); - } - - private Map<ClusterSpec.Id, ClusterInfo> getClusterInfo(List<Node> nodes) { - Map<ClusterSpec.Id, ClusterInfo> infoMap = new HashMap<>(); - - // Group nodes by clusterid - Map<String, List<Node>> clusters = nodes.stream().collect(Collectors.groupingBy(Node::clusterId)); - - // For each cluster - get info - for (String id : clusters.keySet()) { - List<Node> clusterNodes = clusters.get(id); - - // Assume they are all equal and use first node as a representative for the cluster - Node node = clusterNodes.get(0); - - // Add to map - List<String> hostnames = clusterNodes.stream() - .map(Node::hostname) - .map(HostName::value) - .collect(Collectors.toList()); - ClusterInfo info = new ClusterInfo(node.flavor(), node.cost(), - node.resources().vcpu(), node.resources().memoryGb(), node.resources().diskGb(), - ClusterSpec.Type.from(node.clusterType().name()), hostnames); - infoMap.put(new ClusterSpec.Id(id), info); - } - - return infoMap; - } - - @Override - protected void maintain() { - for (Application application : controller().applications().asList()) { - for (Instance instance : application.instances().values()) { - for (Deployment deployment : instance.deployments().values()) { - DeploymentId deploymentId = new DeploymentId(instance.id(), deployment.zone()); - try { - var nodes = nodeRepository.list(deploymentId.zoneId(), deploymentId.applicationId()); - Map<ClusterSpec.Id, ClusterInfo> clusterInfo = getClusterInfo(nodes); - controller().applications().lockApplicationIfPresent(application.id(), lockedApplication -> - controller.applications().store(lockedApplication.with(instance.name(), - locked -> locked.withClusterInfo(deployment.zone(), clusterInfo)))); - } - catch (Exception e) { - log.log(Level.WARNING, "Failing getting cluster information for " + deploymentId, e); - } - } - } - } - } - -} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java index ec209c5ed98..18fe96fc9b2 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java @@ -32,7 +32,6 @@ public class ControllerMaintenance extends AbstractComponent { private final VersionStatusUpdater versionStatusUpdater; private final Upgrader upgrader; private final ReadyJobsTrigger readyJobsTrigger; - private final ClusterInfoMaintainer clusterInfoMaintainer; private final DeploymentMetricsMaintainer deploymentMetricsMaintainer; private final ApplicationOwnershipConfirmer applicationOwnershipConfirmer; private final SystemUpgrader systemUpgrader; @@ -64,7 +63,6 @@ public class ControllerMaintenance extends AbstractComponent { versionStatusUpdater = new VersionStatusUpdater(controller, Duration.ofMinutes(3), jobControl); upgrader = new Upgrader(controller, maintenanceInterval, jobControl, curator); readyJobsTrigger = new ReadyJobsTrigger(controller, Duration.ofMinutes(1), jobControl); - clusterInfoMaintainer = new ClusterInfoMaintainer(controller, Duration.ofHours(2), jobControl); deploymentMetricsMaintainer = new DeploymentMetricsMaintainer(controller, Duration.ofMinutes(5), jobControl); applicationOwnershipConfirmer = new ApplicationOwnershipConfirmer(controller, Duration.ofHours(12), jobControl, controller.serviceRegistry().ownershipIssues()); systemUpgrader = new SystemUpgrader(controller, Duration.ofMinutes(1), jobControl); @@ -95,7 +93,6 @@ public class ControllerMaintenance extends AbstractComponent { versionStatusUpdater.deconstruct(); upgrader.deconstruct(); readyJobsTrigger.deconstruct(); - clusterInfoMaintainer.deconstruct(); deploymentMetricsMaintainer.deconstruct(); applicationOwnershipConfirmer.deconstruct(); systemUpgrader.deconstruct(); |