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)));
}
}
}
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;
}
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;
}
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);
});
}
}
Aggregations