Search in sources :

Example 1 with ClusterInfo

use of com.yahoo.vespa.hosted.controller.application.ClusterInfo in project vespa by vespa-engine.

the class ApplicationSerializerTest method createClusterInfo.

private Map<ClusterSpec.Id, ClusterInfo> createClusterInfo(int clusters, int hosts) {
    Map<ClusterSpec.Id, ClusterInfo> result = new HashMap<>();
    for (int cluster = 0; cluster < clusters; cluster++) {
        List<String> hostnames = new ArrayList<>();
        for (int host = 0; host < hosts; host++) {
            hostnames.add("hostname" + cluster * host + host);
        }
        result.put(ClusterSpec.Id.from("id" + cluster), new ClusterInfo("flavor" + cluster, 10, 2, 4, 50, ClusterSpec.Type.content, hostnames));
    }
    return result;
}
Also used : ClusterInfo(com.yahoo.vespa.hosted.controller.application.ClusterInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ApplicationId(com.yahoo.config.provision.ApplicationId) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) RotationId(com.yahoo.vespa.hosted.controller.rotation.RotationId) IssueId(com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId)

Example 2 with ClusterInfo

use of com.yahoo.vespa.hosted.controller.application.ClusterInfo in project vespa by vespa-engine.

the class ClusterInfoMaintainer method getClusterInfo.

private Map<ClusterSpec.Id, ClusterInfo> getClusterInfo(NodeList nodes, ZoneId zone) {
    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));
    // For each cluster - get info
    for (String id : clusters.keySet()) {
        List<NodeRepositoryNode> clusterNodes = clusters.get(id);
        // Assume they are all equal and use first node as a representative for the cluster
        NodeRepositoryNode node = clusterNodes.get(0);
        // Extract flavor info
        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());
        ClusterInfo inf = new ClusterInfo(node.getFlavor(), node.getCost(), cpu, mem, disk, ClusterSpec.Type.from(node.getMembership().clustertype), hostnames);
        infoMap.put(new ClusterSpec.Id(id), inf);
    }
    return infoMap;
}
Also used : NodeRepositoryNode(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) ClusterSpec(com.yahoo.config.provision.ClusterSpec) IOException(java.io.IOException) HashMap(java.util.HashMap) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) Level(java.util.logging.Level) ApplicationList(com.yahoo.vespa.hosted.controller.application.ApplicationList) List(java.util.List) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) Duration(java.time.Duration) Map(java.util.Map) ClusterInfo(com.yahoo.vespa.hosted.controller.application.ClusterInfo) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) NodeList(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList) Application(com.yahoo.vespa.hosted.controller.Application) Controller(com.yahoo.vespa.hosted.controller.Controller) HashMap(java.util.HashMap) NodeRepositoryNode(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode) ClusterSpec(com.yahoo.config.provision.ClusterSpec) ClusterInfo(com.yahoo.vespa.hosted.controller.application.ClusterInfo) ApplicationList(com.yahoo.vespa.hosted.controller.application.ApplicationList) List(java.util.List) NodeList(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)

Example 3 with ClusterInfo

use of com.yahoo.vespa.hosted.controller.application.ClusterInfo in project vespa by vespa-engine.

the class ClusterInfoMaintainer method maintain.

@Override
protected void maintain() {
    for (Application application : ApplicationList.from(controller().applications().asList()).notPullRequest().asList()) {
        for (Deployment deployment : application.deployments().values()) {
            DeploymentId deploymentId = new DeploymentId(application.id(), deployment.zone());
            try {
                NodeList nodes = controller.nodeRepositoryClient().listNodes(deploymentId.zoneId(), deploymentId.applicationId().tenant().value(), deploymentId.applicationId().application().value(), deploymentId.applicationId().instance().value());
                Map<ClusterSpec.Id, ClusterInfo> clusterInfo = getClusterInfo(nodes, deployment.zone());
                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);
            }
        }
    }
}
Also used : DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) ClusterInfo(com.yahoo.vespa.hosted.controller.application.ClusterInfo) NodeList(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) IOException(java.io.IOException) Application(com.yahoo.vespa.hosted.controller.Application)

Example 4 with ClusterInfo

use of com.yahoo.vespa.hosted.controller.application.ClusterInfo in project vespa by vespa-engine.

the class ApplicationApiTest method setDeploymentMaintainedInfo.

/**
 * Cluster info, utilization and application and deployment metrics are maintained async by maintainers.
 *
 * This sets these values as if the maintainers has been ran.
 *
 * @param controllerTester
 */
private void setDeploymentMaintainedInfo(ContainerControllerTester controllerTester) {
    for (Application application : controllerTester.controller().applications().asList()) {
        controllerTester.controller().applications().lockOrThrow(application.id(), lockedApplication -> {
            lockedApplication = lockedApplication.with(new ApplicationMetrics(0.5, 0.7));
            for (Deployment deployment : application.deployments().values()) {
                Map<ClusterSpec.Id, ClusterInfo> clusterInfo = new HashMap<>();
                List<String> hostnames = new ArrayList<>();
                hostnames.add("host1");
                hostnames.add("host2");
                clusterInfo.put(ClusterSpec.Id.from("cluster1"), new ClusterInfo("flavor1", 37, 2, 4, 50, ClusterSpec.Type.content, hostnames));
                Map<ClusterSpec.Id, ClusterUtilization> clusterUtils = new HashMap<>();
                clusterUtils.put(ClusterSpec.Id.from("cluster1"), new ClusterUtilization(0.3, 0.6, 0.4, 0.3));
                DeploymentMetrics metrics = new DeploymentMetrics(1, 2, 3, 4, 5);
                lockedApplication = lockedApplication.withClusterInfo(deployment.zone(), clusterInfo).withClusterUtilization(deployment.zone(), clusterUtils).with(deployment.zone(), metrics);
            }
            controllerTester.controller().applications().store(lockedApplication);
        });
    }
}
Also used : DeploymentMetrics(com.yahoo.vespa.hosted.controller.application.DeploymentMetrics) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) ClusterInfo(com.yahoo.vespa.hosted.controller.application.ClusterInfo) ClusterUtilization(com.yahoo.vespa.hosted.controller.application.ClusterUtilization) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) IssueId(com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId) ApplicationId(com.yahoo.config.provision.ApplicationId) PropertyId(com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId) UserId(com.yahoo.vespa.hosted.controller.api.identifiers.UserId) ScrewdriverId(com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId) ApplicationMetrics(com.yahoo.vespa.hosted.controller.api.integration.MetricsService.ApplicationMetrics) Application(com.yahoo.vespa.hosted.controller.Application)

Aggregations

ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)4 ClusterInfo (com.yahoo.vespa.hosted.controller.application.ClusterInfo)4 Application (com.yahoo.vespa.hosted.controller.Application)3 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)3 HashMap (java.util.HashMap)3 ApplicationId (com.yahoo.config.provision.ApplicationId)2 DeploymentId (com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId)2 NodeList (com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList)2 IssueId (com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ClusterSpec (com.yahoo.config.provision.ClusterSpec)1 Controller (com.yahoo.vespa.hosted.controller.Controller)1 PropertyId (com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId)1 ScrewdriverId (com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId)1 UserId (com.yahoo.vespa.hosted.controller.api.identifiers.UserId)1 ApplicationMetrics (com.yahoo.vespa.hosted.controller.api.integration.MetricsService.ApplicationMetrics)1 NodeRepositoryNode (com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode)1 ApplicationList (com.yahoo.vespa.hosted.controller.application.ApplicationList)1 ClusterUtilization (com.yahoo.vespa.hosted.controller.application.ClusterUtilization)1