summaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authortoby <smorgrav@yahoo-inc.com>2017-09-27 14:37:10 +0200
committertoby <smorgrav@yahoo-inc.com>2017-10-10 13:37:59 +0200
commit4ab41186b4e8197532a1cd13ed6ada30f5f26f59 (patch)
tree22ced06991defca126725f92a56226d5040a871e /controller-api
parentd440b79e005d7cf9ede08daac2e40ab22641bc53 (diff)
Fold cost api into the application API - take 1
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/InstanceInformation.java3
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/Cost.java116
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostApplication.java69
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostCluster.java72
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostClusterInfo.java36
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostResources.java62
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/package-info.java5
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/restapi/CostJsonModel.java73
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/restapi/CostJsonModelAdapter.java113
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/restapi/CostResource.java41
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/restapi/package-info.java5
-rw-r--r--controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostResourcesTest.java29
12 files changed, 0 insertions, 624 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/InstanceInformation.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/InstanceInformation.java
index c8f913d82a8..391aaa4639e 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/InstanceInformation.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/InstanceInformation.java
@@ -2,7 +2,6 @@
package com.yahoo.vespa.hosted.controller.api.application.v4.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.yahoo.vespa.hosted.controller.api.integration.cost.restapi.CostJsonModel;
import com.yahoo.vespa.hosted.controller.api.identifiers.GitBranch;
import com.yahoo.vespa.hosted.controller.api.identifiers.GitCommit;
import com.yahoo.vespa.hosted.controller.api.identifiers.GitRepository;
@@ -29,6 +28,4 @@ public class InstanceInformation {
public GitRepository gitRepository;
public GitBranch gitBranch;
public GitCommit gitCommit;
-
- public CostJsonModel.Application cost;
}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/Cost.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/Cost.java
deleted file mode 100644
index 70fce483c38..00000000000
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/Cost.java
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.controller.api.integration.cost;
-
-import com.yahoo.config.provision.ApplicationId;
-import com.yahoo.config.provision.Zone;
-import com.yahoo.vespa.hosted.controller.common.NotFoundCheckedException;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Calculate cost, hardware utilization and waste for Vespa.
- * <p>
- * Cost refers to the total cost ownership aka TCO.
- * <p>
- * We define a target utilization for each cluster in an application and compares this
- * to the actual utilization. Cost is then the TCO for the hardware used multiplied with
- * the relative utilization. Waste is the difference between target and ideal cost.
- *
- * @author smorgrav
- */
-public interface Cost {
-
- /**
- * Get application costs for all applications across all zones.
- *
- * @return A list of all application costs in all zones
- */
- default List<CostApplication> getApplicationCost() {
- List<CostApplication> costApplications = new ArrayList<>();
- getApplications().forEach((zone, list) -> {
- list.forEach(app -> {
- try {
- costApplications.add(getApplicationCost(zone, app));
- } catch (NotFoundCheckedException e) {
- // Application removed after fetched in getApplications ?
- // TODO Log
- }
- });
-
- });
-
- return costApplications;
- }
-
- /**
- * Get application costs for a specific application.
- *
- * @param zone The zone - the combination of a environment and region e.g 'test.us-east-1'
- * @param app ApplicationId e.g tenant:application:instance
- * @return The cost of one application
- */
- default CostApplication getApplicationCost(Zone zone, ApplicationId app)
- throws NotFoundCheckedException {
-
- Map<String, CostClusterInfo> info = getClusterInfo(zone, app);
- Map<String, CostResources> util = getClusterUtilization(zone, app);
- CostResources target = getTargetUtilization(zone, app);
-
- Map<String, CostCluster> costClusters = new HashMap<>();
- for (String clusterId : util.keySet()) {
- costClusters.put(clusterId, new CostCluster(info.get(clusterId), util.get(clusterId), target));
- }
-
- return new CostApplication(zone, app, costClusters);
- }
-
- /**
- * Provides target utilization - default targets are cased on the following assumptions:
- *
- * 1. CPU contention starts to be noticeable at 80% and spikes are 2x average
- * 2. Query load is perfectly load-balanced between two zones, cpu needs to handle fail-over - thus 2x load
- * 3. Memory contention (and especially sys cpu usage from memory management) increases after 90%
- * 4. Memory consumptions spikes over average with ~20%
- * 5. Memory and disk usage is independent of query load
- *
- * The default targets are:
- * CPU: 0.2
- * MEM: 0.7
- * DISK: 0.7
- * DISKBUSY: 0.3
- *
- * @param zone The zone - the combination of a environment and region e.g 'test.us-east-1'
- * @param app ApplicationId e.g tenant:application:instance
- * @return Target utilization
- */
- default CostResources getTargetUtilization(Zone zone, ApplicationId app) {
- return new CostResources(0.7, 0.2, 0.7, 0.3);
- }
-
- /**
- * @return Map from zone to app for all known zones and applications
- */
- Map<Zone, List<ApplicationId>> getApplications();
-
- /**
- * Provides information about the clusters in the application like
- * what hardware that it is using, the TCO for the hardware and the hostnames in the cluster.
- *
- * @param zone The zone - the combination of a environment and region e.g 'test.us-east-1'
- * @param app ApplicationId e.g tenant:application:instance
- * @return Map between cluster id to cluster info
- */
- Map<String, CostClusterInfo> getClusterInfo(Zone zone, ApplicationId app);
-
- /**
- * Provides the ratio of available hardware used (e.g cpu, mem, disk) each in the range: [0,1].
- *
- * @param zone The zone - the combination of a environment and region e.g 'test.us-east-1'
- * @param app ApplicationId e.g tenant:application:instance
- * @return Map between cluster id to resource utilization
- */
- Map<String, CostResources> getClusterUtilization(Zone zone, ApplicationId app);
-}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostApplication.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostApplication.java
deleted file mode 100644
index 89948cc69ac..00000000000
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostApplication.java
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.controller.api.integration.cost;
-
-import com.yahoo.config.provision.ApplicationId;
-import com.yahoo.config.provision.Zone;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Calculates cost for for an application instance.
- *
- * @author smorgrav
- */
-public class CostApplication {
-
- private final Zone zone;
- private final ApplicationId appId;
- private final double utilization;
- private final double waste;
- private final double tco;
-
- private final Map<String, CostCluster> clusters;
-
- public CostApplication(Zone zone, ApplicationId appId, Map<String, CostCluster> clusterCosts) {
- this.zone = zone;
- this.appId = appId;
- clusters = new HashMap<>(clusterCosts);
-
- double tco = 0;
- double util = 0;
- double waste = 0;
-
- for (CostCluster costCluster : clusterCosts.values()) {
- tco += costCluster.getTco();
- waste += costCluster.getWaste();
- int nodesInCluster = costCluster.getClusterInfo().getHostnames().size();
- util = Math.max(util, nodesInCluster*costCluster.getResultUtilization().getMaxUtilization());
- }
-
- this.utilization = util;
- this.waste = waste;
- this.tco = tco;
- }
-
- public Zone getZone() {
- return zone;
- }
-
- public ApplicationId getAppId() {
- return appId;
- }
-
- public Map<String, CostCluster> getCluster() {
- return clusters;
- }
-
- public double getTco() {
- return tco;
- }
-
- public double getUtilization() {
- return utilization;
- }
-
- public double getWaste() {
- return waste;
- }
-}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostCluster.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostCluster.java
deleted file mode 100644
index be0aea6122d..00000000000
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostCluster.java
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.controller.api.integration.cost;
-
-/**
- * Calculate tco and waste for one cluster within one Vespa application in one zone.
- *
- * @author smorgrav
- */
-public class CostCluster {
- private final double tco;
- private final double waste;
- private final CostClusterInfo clusterInfo;
- private final CostResources systemUtilization;
- private final CostResources targetUtilization;
- private final CostResources resultUtilization;
-
- /**
- * @param clusterInfo Value object with cluster info e.g. the TCO for the hardware used
- * @param systemUtilization Utilization of system resources (as ratios)
- * @param targetUtilization Target utilization (ratios - usually less than 1.0)
- */
- public CostCluster(CostClusterInfo clusterInfo,
- CostResources systemUtilization,
- CostResources targetUtilization) {
-
- this.clusterInfo = clusterInfo;
- this.systemUtilization = systemUtilization;
- this.targetUtilization = targetUtilization;
- this.resultUtilization = calculateResultUtilization(systemUtilization, targetUtilization);
-
- this.tco = clusterInfo.getFlavor().cost() * Math.min(1, this.resultUtilization.getMaxUtilization());
- this.waste = clusterInfo.getFlavor().cost() - tco;
- }
-
- public double getTco() {
- return tco;
- }
-
- public double getWaste() {
- return waste;
- }
-
- public CostClusterInfo getClusterInfo() {
- return clusterInfo;
- }
-
- public CostResources getSystemUtilization() {
- return systemUtilization;
- }
-
- public CostResources getTargetUtilization() {
- return targetUtilization;
- }
-
- public CostResources getResultUtilization() {
- return resultUtilization;
- }
-
- static CostResources calculateResultUtilization(CostResources system, CostResources target) {
- double cpu = ratio(system.getCpu(),target.getCpu());
- double mem = ratio(system.getMemory(),target.getMemory());
- double disk = ratio(system.getDisk(),target.getDisk());
- double diskbusy = ratio(system.getDiskBusy(),target.getDiskBusy());
-
- return new CostResources(mem, cpu, disk, diskbusy);
- }
-
- private static double ratio(double a, double b) {
- if (b == 0) return 1;
- return a/b;
- }
-}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostClusterInfo.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostClusterInfo.java
deleted file mode 100644
index 0fe408352dc..00000000000
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostClusterInfo.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.yahoo.vespa.hosted.controller.api.integration.cost;// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-import com.yahoo.config.provision.ClusterSpec;
-import com.yahoo.config.provision.Flavor;
-
-import java.util.List;
-
-/**
- * Value object of static cluster information, in particular the TCO
- * of the hardware used for this cluster.
- *
- * @author smorgrav
- */
-public class CostClusterInfo {
- private final Flavor flavor;
- private final ClusterSpec.Type clusterType;
- private final List<String> hostnames;
-
- CostClusterInfo(Flavor flavor, ClusterSpec.Type clusterType, List<String> hostnames) {
- this.flavor = flavor;
- this.clusterType = clusterType;
- this.hostnames = hostnames;
- }
-
- public Flavor getFlavor() {
- return flavor;
- }
-
- public ClusterSpec.Type getClusterType() {
- return clusterType;
- }
-
- public List<String> getHostnames() {
- return hostnames;
- }
-}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostResources.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostResources.java
deleted file mode 100644
index bb5887ebc99..00000000000
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostResources.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.yahoo.vespa.hosted.controller.api.integration.cost;// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-/**
- * System resources as _ratios_ of available resources.
- *
- * Can be for actual readings or target numbers.
- *
- * @author smorgrav
- */
-public class CostResources {
-
- private final double memory;
- private final double cpu;
- private final double disk;
- private final double diskBusy;
- private final double maxUtilization;
-
- /**
- * Resource utilization as ratios. The ratio is normally between 0 and 1 where
- * one is fully utilized but can be higher as it consumes more than it are guaranteed.
- *
- * @param memory Memory utilization
- * @param cpu CPU utilization
- * @param disk Disk utilization
- * @param diskBusy Disk busy
- */
- public CostResources(double memory, double cpu, double disk, double diskBusy) {
- this.memory = memory;
- this.cpu = cpu;
- this.disk = disk;
- this.diskBusy = diskBusy;
-
- double maxUtil = Math.max(cpu, disk);
- maxUtil = Math.max(maxUtil, memory);
- this.maxUtilization = Math.max(maxUtil, diskBusy);
- }
-
- /** @return The utilization ratio of the resource that is utilized the most. */
- public double getMaxUtilization() {
- return maxUtilization;
- }
-
- /** @return The utilization ratio for memory */
- public double getMemory() {
- return memory;
- }
-
- /** @return The utilization ratio for cpu */
- public double getCpu() {
- return cpu;
- }
-
- /** @return The utilization ratio for disk */
- public double getDisk() {
- return disk;
- }
-
- /** @return The disk busy ratio */
- public double getDiskBusy() {
- return diskBusy;
- }
-}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/package-info.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/package-info.java
deleted file mode 100644
index f08e6cc9b36..00000000000
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/package-info.java
+++ /dev/null
@@ -1,5 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-@ExportPackage
-package com.yahoo.vespa.hosted.controller.api.integration.cost;
-
-import com.yahoo.osgi.annotation.ExportPackage;
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/restapi/CostJsonModel.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/restapi/CostJsonModel.java
deleted file mode 100644
index d384baa94ca..00000000000
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/restapi/CostJsonModel.java
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.controller.api.integration.cost.restapi;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * JSON datamodel for the cost api.
- *
- * @author smorgrav
- */
-public class CostJsonModel {
-
- @JsonIgnoreProperties(ignoreUnknown = true)
- public static class Application {
-
- @JsonProperty
- public String zone;
- @JsonProperty
- public String tenant;
- @JsonProperty
- public String app;
- @JsonProperty
- public int tco;
- @JsonProperty
- public double utilization;
- @JsonProperty
- public double waste;
- @JsonProperty
- public Map<String, Cluster> cluster;
- }
-
- @JsonIgnoreProperties(ignoreUnknown = true)
- public static class Cluster {
-
- @JsonProperty
- public int count;
- @JsonProperty
- public String resource;
- @JsonProperty
- public double utilization;
- @JsonProperty
- public int tco;
- @JsonProperty
- public String flavor;
- @JsonProperty
- public int waste;
- @JsonProperty
- public String type;
- @JsonProperty
- public HardwareResources util;
- @JsonProperty
- public HardwareResources usage;
- @JsonProperty
- public List<String> hostnames;
- }
-
- @JsonIgnoreProperties(ignoreUnknown = true)
- public static class HardwareResources {
-
- @JsonProperty
- public double mem;
- @JsonProperty
- public double disk;
- @JsonProperty
- public double cpu;
- @JsonProperty("diskbusy")
- public double diskBusy;
- }
-}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/restapi/CostJsonModelAdapter.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/restapi/CostJsonModelAdapter.java
deleted file mode 100644
index 101d56f134c..00000000000
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/restapi/CostJsonModelAdapter.java
+++ /dev/null
@@ -1,113 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.controller.api.integration.cost.restapi;
-
-import com.yahoo.config.provision.Flavor;
-import com.yahoo.slime.Cursor;
-import com.yahoo.vespa.hosted.controller.api.integration.cost.CostApplication;
-import com.yahoo.vespa.hosted.controller.api.integration.cost.CostCluster;
-import com.yahoo.vespa.hosted.controller.api.integration.cost.CostResources;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Serializing and de-serializing cost model
- *
- * @author smorgrav
- */
-public class CostJsonModelAdapter {
-
- public static CostJsonModel.Application toJsonModel(CostApplication appCost) {
- CostJsonModel.Application app = new CostJsonModel.Application();
- app.zone = appCost.getZone().toString();
- app.tenant = appCost.getAppId().tenant().value();
- app.app = appCost.getAppId().application().value();
- app.tco = (int)appCost.getTco();
- app.utilization = appCost.getUtilization();
- app.waste = appCost.getWaste();
- app.cluster = new HashMap<>();
- Map<String, CostCluster> clusterMap = appCost.getCluster();
- for (String key : clusterMap.keySet()) {
- app.cluster.put(key, toJsonModel(clusterMap.get(key)));
- }
-
- return app;
- }
-
- public static void toSlime(CostApplication appCost, Cursor object) {
- object.setString("zone", appCost.getZone().toString());
- object.setString("tenant", appCost.getAppId().tenant().value());
- object.setString("app", appCost.getAppId().application().value() + "." + appCost.getAppId().instance().value());
- object.setLong("tco", (long)appCost.getTco());
- object.setDouble("utilization", appCost.getUtilization());
- object.setDouble("waste", appCost.getWaste());
- Cursor clustersObject = object.setObject("cluster");
- for (Map.Entry<String, CostCluster> clusterEntry : appCost.getCluster().entrySet())
- toSlime(clusterEntry.getValue(), clustersObject.setObject(clusterEntry.getKey()));
- }
-
- public static CostJsonModel.Cluster toJsonModel(CostCluster clusterCost) {
- CostJsonModel.Cluster cluster = new CostJsonModel.Cluster();
- cluster.count = clusterCost.getClusterInfo().getHostnames().size();
- cluster.resource = getResourceName(clusterCost.getResultUtilization());
- cluster.utilization = clusterCost.getResultUtilization().getMaxUtilization();
- cluster.tco = (int)clusterCost.getTco();
- cluster.flavor = clusterCost.getClusterInfo().getFlavor().toString();
- cluster.waste = (int)clusterCost.getWaste();
- cluster.type = clusterCost.getClusterInfo().getClusterType().name();
- cluster.util = new CostJsonModel.HardwareResources();
- cluster.util.cpu = clusterCost.getResultUtilization().getCpu();
- cluster.util.mem = clusterCost.getResultUtilization().getMemory();
- cluster.util.disk = clusterCost.getResultUtilization().getDisk();
- cluster.util.diskBusy = clusterCost.getResultUtilization().getDiskBusy();
-
- Flavor flavor = clusterCost.getClusterInfo().getFlavor();
- cluster.usage = new CostJsonModel.HardwareResources();
- cluster.usage.cpu = flavor.getMinCpuCores() * clusterCost.getSystemUtilization().getCpu();
- cluster.usage.mem = flavor.getMinMainMemoryAvailableGb() * clusterCost.getSystemUtilization().getMemory();
- cluster.usage.disk = flavor.getMinDiskAvailableGb() * clusterCost.getSystemUtilization().getDisk();
- cluster.usage.diskBusy = clusterCost.getSystemUtilization().getDiskBusy();
- cluster.hostnames = new ArrayList<>(clusterCost.getClusterInfo().getHostnames());
-
- return cluster;
- }
-
- private static void toSlime(CostCluster clusterCost, Cursor object) {
- object.setLong("count", clusterCost.getClusterInfo().getHostnames().size());
- object.setString("resource", getResourceName(clusterCost.getResultUtilization()));
- object.setDouble("utilization", clusterCost.getResultUtilization().getMaxUtilization());
- object.setLong("tco", (int)clusterCost.getTco());
- object.setString("flavor", clusterCost.getClusterInfo().getClusterType().name());
- object.setLong("waste", (int)clusterCost.getWaste());
- object.setString("type", clusterCost.getClusterInfo().getClusterType().name());
- Cursor utilObject = object.setObject("util");
- utilObject.setDouble("cpu", clusterCost.getResultUtilization().getCpu());
- utilObject.setDouble("mem", clusterCost.getResultUtilization().getMemory());
- utilObject.setDouble("disk", clusterCost.getResultUtilization().getDisk());
- utilObject.setDouble("diskBusy", clusterCost.getResultUtilization().getDiskBusy());
- Cursor usageObject = object.setObject("usage");
- usageObject.setDouble("cpu", clusterCost.getSystemUtilization().getCpu() * 100);
- usageObject.setDouble("mem", clusterCost.getSystemUtilization().getMemory() * 100);
- usageObject.setDouble("disk", clusterCost.getSystemUtilization().getDisk() * 100);
- usageObject.setDouble("diskBusy", clusterCost.getSystemUtilization().getDiskBusy() * 100);
- Cursor hostnamesArray = object.setArray("hostnames");
- for (String hostname : clusterCost.getClusterInfo().getHostnames())
- hostnamesArray.addString(hostname);
- }
-
- private static String getResourceName(CostResources resources) {
- String name = "cpu";
- double max = resources.getMaxUtilization();
-
- if (resources.getMemory() == max) {
- name = "mem";
- } else if (resources.getDisk() == max) {
- name = "disk";
- } else if (resources.getDiskBusy() == max) {
- name = "diskbusy";
- }
-
- return name;
- }
-}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/restapi/CostResource.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/restapi/CostResource.java
deleted file mode 100644
index 571460d666c..00000000000
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/restapi/CostResource.java
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.controller.api.integration.cost.restapi;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import java.util.List;
-
-/**
- * Cost and Utilization APi for hosted Vespa.
- *
- * Used to give insight to PEG and application owners about
- * TOC and if the application is reasonable scaled.
- *
- * @author smorgrav
- */
-@Path("v1")
-@Produces(MediaType.APPLICATION_JSON)
-public interface CostResource {
-
- @GET
- @Path("/analysis/cpu")
- List<CostJsonModel.Application> getCPUAnalysis();
-
- @GET
- @Produces("text/csv")
- @Path("/csv")
- String getCSV();
-
- @GET
- @Path("/apps")
- List<CostJsonModel.Application> getApplicationsCost();
-
- @GET
- @Path("/apps/{environment}/{region}/{application}")
- CostJsonModel.Application getApplicationCost(@PathParam("application") String appName,
- @PathParam("region") String regionName,
- @PathParam("environment") String envName);
-}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/restapi/package-info.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/restapi/package-info.java
deleted file mode 100644
index 3c3bb7e7076..00000000000
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/restapi/package-info.java
+++ /dev/null
@@ -1,5 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-@ExportPackage
-package com.yahoo.vespa.hosted.controller.api.integration.cost.restapi;
-
-import com.yahoo.osgi.annotation.ExportPackage;
diff --git a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostResourcesTest.java b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostResourcesTest.java
deleted file mode 100644
index a7ed2f90548..00000000000
--- a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostResourcesTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-package com.yahoo.vespa.hosted.controller.api.integration.cost;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * @author smorgrav
- */
-public class CostResourcesTest {
-
- private static double delta = Double.MIN_EXPONENT;
-
- @Test
- public void getMaxUtilization() throws Exception {
- CostResources resources = new CostResources(0.3, 0.1, 0.4, 0.5);
- Assert.assertEquals(0.5, resources.getMaxUtilization(), delta);
-
- resources = new CostResources(0.3, 0.1, 0.4, 0.0);
- Assert.assertEquals(0.4, resources.getMaxUtilization(), delta);
-
- resources = new CostResources(0.4, 0.3, 0.3, 0.0);
- Assert.assertEquals(0.4, resources.getMaxUtilization(), delta);
-
- resources = new CostResources(0.1, 0.3, 0.3, 0.0);
- Assert.assertEquals(0.3, resources.getMaxUtilization(), delta);
- }
-} \ No newline at end of file