Search in sources :

Example 1 with ClusterUtilization

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

the class ClusterUtilizationMaintainer method maintain.

@Override
protected void maintain() {
    for (Application application : ApplicationList.from(controller().applications().asList()).notPullRequest().asList()) {
        for (Deployment deployment : application.deployments().values()) {
            Map<ClusterSpec.Id, ClusterUtilization> clusterUtilization = getUpdatedClusterUtilizations(application.id(), deployment.zone());
            controller().applications().lockIfPresent(application.id(), lockedApplication -> controller().applications().store(lockedApplication.withClusterUtilization(deployment.zone(), clusterUtilization)));
        }
    }
}
Also used : Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) ClusterUtilization(com.yahoo.vespa.hosted.controller.application.ClusterUtilization) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) ApplicationId(com.yahoo.config.provision.ApplicationId) Application(com.yahoo.vespa.hosted.controller.Application)

Example 2 with ClusterUtilization

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

the class ClusterUtilizationMaintainer method getUpdatedClusterUtilizations.

private Map<ClusterSpec.Id, ClusterUtilization> getUpdatedClusterUtilizations(ApplicationId app, ZoneId zone) {
    Map<String, MetricsService.SystemMetrics> systemMetrics = controller.metricsService().getSystemMetrics(app, zone);
    Map<ClusterSpec.Id, ClusterUtilization> utilizationMap = new HashMap<>();
    for (Map.Entry<String, MetricsService.SystemMetrics> metrics : systemMetrics.entrySet()) {
        MetricsService.SystemMetrics systemMetric = metrics.getValue();
        ClusterUtilization utilization = new ClusterUtilization(systemMetric.memUtil() / 100, systemMetric.cpuUtil() / 100, systemMetric.diskUtil() / 100, 0);
        utilizationMap.put(new ClusterSpec.Id(metrics.getKey()), utilization);
    }
    return utilizationMap;
}
Also used : HashMap(java.util.HashMap) MetricsService(com.yahoo.vespa.hosted.controller.api.integration.MetricsService) ClusterSpec(com.yahoo.config.provision.ClusterSpec) ClusterUtilization(com.yahoo.vespa.hosted.controller.application.ClusterUtilization) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) ApplicationId(com.yahoo.config.provision.ApplicationId) Map(java.util.Map) HashMap(java.util.HashMap)

Example 3 with ClusterUtilization

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

the class ApplicationSerializerTest method createClusterUtils.

private Map<ClusterSpec.Id, ClusterUtilization> createClusterUtils(int clusters, double inc) {
    Map<ClusterSpec.Id, ClusterUtilization> result = new HashMap<>();
    ClusterUtilization util = new ClusterUtilization(0, 0, 0, 0);
    for (int cluster = 0; cluster < clusters; cluster++) {
        double agg = cluster * inc;
        result.put(ClusterSpec.Id.from("id" + cluster), new ClusterUtilization(util.getMemory() + agg, util.getCpu() + agg, util.getDisk() + agg, util.getDiskBusy() + agg));
    }
    return result;
}
Also used : HashMap(java.util.HashMap) ClusterUtilization(com.yahoo.vespa.hosted.controller.application.ClusterUtilization) 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 4 with ClusterUtilization

use of com.yahoo.vespa.hosted.controller.application.ClusterUtilization 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

ApplicationId (com.yahoo.config.provision.ApplicationId)4 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)4 ClusterUtilization (com.yahoo.vespa.hosted.controller.application.ClusterUtilization)4 HashMap (java.util.HashMap)3 Application (com.yahoo.vespa.hosted.controller.Application)2 IssueId (com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId)2 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)2 ClusterSpec (com.yahoo.config.provision.ClusterSpec)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 MetricsService (com.yahoo.vespa.hosted.controller.api.integration.MetricsService)1 ApplicationMetrics (com.yahoo.vespa.hosted.controller.api.integration.MetricsService.ApplicationMetrics)1 ClusterInfo (com.yahoo.vespa.hosted.controller.application.ClusterInfo)1 DeploymentMetrics (com.yahoo.vespa.hosted.controller.application.DeploymentMetrics)1 RotationId (com.yahoo.vespa.hosted.controller.rotation.RotationId)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1