diff options
author | Martin Polden <mpolden@mpolden.no> | 2020-02-27 15:36:45 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2020-02-27 15:41:02 +0100 |
commit | c823ca94e123595754097f2f58625ce3234dc076 (patch) | |
tree | 6dc04b4f973bf2df8e1a3b2c70c1b224c8069535 /controller-server | |
parent | 1eddb71c5f4b11f1d44703015fa4e61a8246d91f (diff) |
Remove unused cost field from API
Diffstat (limited to 'controller-server')
11 files changed, 0 insertions, 405 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ClusterCost.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ClusterCost.java deleted file mode 100644 index fb675862320..00000000000 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ClusterCost.java +++ /dev/null @@ -1,95 +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.application; - -import java.util.Objects; - -/** - * Calculate utilization relative to the target utilization, - * tco and waste for one cluster of one deployment. - * - * The target utilization is defined the following assumptions: - * 1. CPU contention starts to cause problems at 0.8 - * 2. Memory management starts to cause problems at 0.7 - * 3. Load is evenly divided between two deployments - each deployments can handle the other. - * 4. Memory and disk are agnostic to query load. - * 5. Peak utilization (daily variations) are twice the size of the average. - * - * With this in mind we get: - * - * CPU: 0.8/2/2 = 0.2 - * Mem: 0.7 - * Disk: 0.7 - * Disk busy: 0.3 - * - * @author smorgrav - */ -public class ClusterCost { - - private final double tco; - private final double waste; - private final ClusterInfo clusterInfo; - private final ClusterUtilization systemUtilization; - private final ClusterUtilization targetUtilization; - private final ClusterUtilization resultUtilization; - - /** - * @param clusterInfo value object with cluster info e.g. the TCO for the hardware used - * @param systemUtilization utilization of system resources (as ratios) - */ - public ClusterCost(ClusterInfo clusterInfo, - ClusterUtilization systemUtilization) { - - Objects.requireNonNull(clusterInfo, "Cluster info cannot be null"); - Objects.requireNonNull(systemUtilization, "Cluster utilization cannot be null"); - - this.clusterInfo = clusterInfo; - this.systemUtilization = systemUtilization; - this.targetUtilization = new ClusterUtilization(0.7,0.2, 0.7, 0.3); - this.resultUtilization = calculateResultUtilization(systemUtilization, targetUtilization); - - this.tco = clusterInfo.getHostnames().size() * clusterInfo.getFlavorCost(); - - double unusedUtilization = 1 - Math.min(1, resultUtilization.getMaxUtilization()); - this.waste = tco * unusedUtilization; - } - - /** @return The TCO in dollars for this cluster (node tco * nodes) */ - public double getTco() { - return tco; - } - - /** @return The amount of dollars spent for unused resources in this cluster */ - public double getWaste() { - return waste; - } - - public ClusterInfo getClusterInfo() { - return clusterInfo; - } - - public ClusterUtilization getSystemUtilization() { - return systemUtilization; - } - - public ClusterUtilization getTargetUtilization() { - return targetUtilization; - } - - public ClusterUtilization getResultUtilization() { - return resultUtilization; - } - - static ClusterUtilization calculateResultUtilization(ClusterUtilization system, ClusterUtilization 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 ClusterUtilization(mem, cpu, disk, diskbusy); - } - - private static double ratio(double a, double b) { - if (b == 0) return 1; - return a/b; - } -} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ClusterUtilization.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ClusterUtilization.java deleted file mode 100644 index ff92ce36d1b..00000000000 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ClusterUtilization.java +++ /dev/null @@ -1,63 +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.application; - -/** - * System resources as _ratios_ of available resources. - * - * Can be for actual readings or target numbers. - * - * @author smorgrav - */ -public class ClusterUtilization { - - 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 ClusterUtilization(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-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentCost.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentCost.java deleted file mode 100644 index 393c14b35d3..00000000000 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentCost.java +++ /dev/null @@ -1,61 +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.application; - -import java.util.HashMap; -import java.util.Map; - -/** - * Calculates cost for for an application deployment. - * - * @author smorgrav - */ -public class DeploymentCost { - - private final double utilization; - private final double waste; - private final double tco; - - private final Map<String, ClusterCost> clusters; - - public DeploymentCost(Map<String, ClusterCost> clusterCosts) { - clusters = new HashMap<>(clusterCosts); - - double tco = 0; - double util = 0; - double waste = 0; - double maxWaste = -1; - - for (ClusterCost costCluster : clusterCosts.values()) { - tco += costCluster.getTco(); - waste += costCluster.getWaste(); - - if (costCluster.getWaste() > maxWaste) { - util = costCluster.getResultUtilization().getMaxUtilization(); - maxWaste = costCluster.getWaste(); - } - } - - this.utilization = util; - this.waste = waste; - this.tco = tco; - } - - public Map<String, ClusterCost> getCluster() { - return clusters; - } - - /** Returns the total monthly cost of ownership for the deployment (sum of all clusters) */ - public double getTco() { - return tco; - } - - /** Returns the utilization of clusters that wastes most money in this deployment */ - public double getUtilization() { - return utilization; - } - - /** Returns the amount of dollars spent and not utilized */ - public double getWaste() { - return waste; - } -} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java index 5e234d31322..dd5d9f3e749 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java @@ -66,10 +66,7 @@ import com.yahoo.vespa.hosted.controller.api.role.SecurityContext; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.AssignedRotation; import com.yahoo.vespa.hosted.controller.application.Change; -import com.yahoo.vespa.hosted.controller.application.ClusterCost; -import com.yahoo.vespa.hosted.controller.application.ClusterUtilization; import com.yahoo.vespa.hosted.controller.application.Deployment; -import com.yahoo.vespa.hosted.controller.application.DeploymentCost; import com.yahoo.vespa.hosted.controller.application.DeploymentMetrics; import com.yahoo.vespa.hosted.controller.application.Endpoint; import com.yahoo.vespa.hosted.controller.application.SystemApplication; @@ -1155,12 +1152,6 @@ public class ApplicationApiHandler extends LoggingRequestHandler { deployment.activity().lastQueriesPerSecond().ifPresent(value -> activity.setDouble("lastQueriesPerSecond", value)); deployment.activity().lastWritesPerSecond().ifPresent(value -> activity.setDouble("lastWritesPerSecond", value)); - // Cost - // TODO(mpolden): Unused, remove this field and related code. - DeploymentCost appCost = new DeploymentCost(Map.of()); - Cursor costObject = response.setObject("cost"); - toSlime(appCost, costObject); - // Metrics DeploymentMetrics metrics = deployment.metrics(); Cursor metricsObject = response.setObject("metrics"); @@ -1950,57 +1941,6 @@ public class ApplicationApiHandler extends LoggingRequestHandler { return controller.versionStatus().versions().stream().anyMatch(v -> v.versionNumber().equals(version)); } - public static void toSlime(DeploymentCost deploymentCost, Cursor object) { - object.setLong("tco", (long)deploymentCost.getTco()); - object.setLong("waste", (long)deploymentCost.getWaste()); - object.setDouble("utilization", deploymentCost.getUtilization()); - Cursor clustersObject = object.setObject("cluster"); - for (Map.Entry<String, ClusterCost> clusterEntry : deploymentCost.getCluster().entrySet()) - toSlime(clusterEntry.getValue(), clustersObject.setObject(clusterEntry.getKey())); - } - - private static void toSlime(ClusterCost 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.setLong("waste", (int)clusterCost.getWaste()); - object.setString("flavor", clusterCost.getClusterInfo().getFlavor()); - object.setDouble("flavorCost", clusterCost.getClusterInfo().getFlavorCost()); - object.setDouble("flavorCpu", clusterCost.getClusterInfo().getFlavorCPU()); - object.setDouble("flavorMem", clusterCost.getClusterInfo().getFlavorMem()); - object.setDouble("flavorDisk", clusterCost.getClusterInfo().getFlavorDisk()); - 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()); - usageObject.setDouble("mem", clusterCost.getSystemUtilization().getMemory()); - usageObject.setDouble("disk", clusterCost.getSystemUtilization().getDisk()); - usageObject.setDouble("diskBusy", clusterCost.getSystemUtilization().getDiskBusy()); - Cursor hostnamesArray = object.setArray("hostnames"); - for (String hostname : clusterCost.getClusterInfo().getHostnames()) - hostnamesArray.addString(hostname); - } - - private static String getResourceName(ClusterUtilization utilization) { - String name = "cpu"; - double max = utilization.getMaxUtilization(); - - if (utilization.getMemory() == max) { - name = "mem"; - } else if (utilization.getDisk() == max) { - name = "disk"; - } else if (utilization.getDiskBusy() == max) { - name = "diskbusy"; - } - - return name; - } - private static boolean recurseOverTenants(HttpRequest request) { return recurseOverApplications(request) || "tenant".equals(request.getProperty("recursive")); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/ClusterCostTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/ClusterCostTest.java deleted file mode 100644 index 6df2d55d52b..00000000000 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/ClusterCostTest.java +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.application; - -import com.yahoo.config.provision.ClusterSpec; -import org.junit.Assert; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author smorgrav - */ -public class ClusterCostTest { - - @Test - public void clusterCost() { - List<String> hostnames = new ArrayList<>(); - hostnames.add("host1"); - hostnames.add("host2"); - ClusterInfo info = new ClusterInfo("test", 100, 10, 10, 10, ClusterSpec.Type.container, hostnames); - ClusterUtilization util = new ClusterUtilization(0.3, 0.2, 0.5, 0.1); - ClusterCost cost = new ClusterCost(info, util); - - // CPU is fully utilized - Assert.assertEquals(200, cost.getTco(), Double.MIN_VALUE); - Assert.assertEquals(0, cost.getWaste(), Double.MIN_VALUE); - - // Set Disk as the most utilized resource - util = new ClusterUtilization(0.3, 0.1, 0.5, 0.1); - cost = new ClusterCost(info, util); - Assert.assertEquals(200, cost.getTco(), Double.MIN_NORMAL); // TCO is independent of utilization - Assert.assertEquals(57.1428571429, cost.getWaste(), 0.001); // Waste is not independent - } -} diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/ClusterUtilizationTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/ClusterUtilizationTest.java deleted file mode 100644 index c930978eb1e..00000000000 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/ClusterUtilizationTest.java +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.application; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author smorgrav - */ -public class ClusterUtilizationTest { - - private static final double delta = Double.MIN_NORMAL; - - @Test - public void getMaxUtilization() { - ClusterUtilization resources = new ClusterUtilization(0.3, 0.1, 0.4, 0.5); - Assert.assertEquals(0.5, resources.getMaxUtilization(), delta); - - resources = new ClusterUtilization(0.3, 0.1, 0.4, 0.0); - Assert.assertEquals(0.4, resources.getMaxUtilization(), delta); - - resources = new ClusterUtilization(0.4, 0.3, 0.3, 0.0); - Assert.assertEquals(0.4, resources.getMaxUtilization(), delta); - - resources = new ClusterUtilization(0.1, 0.3, 0.3, 0.0); - Assert.assertEquals(0.3, resources.getMaxUtilization(), delta); - } - -} diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/DeploymentCostTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/DeploymentCostTest.java deleted file mode 100644 index 2e58253d768..00000000000 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/DeploymentCostTest.java +++ /dev/null @@ -1,38 +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.application; - -import com.yahoo.config.provision.ClusterSpec; -import org.junit.Assert; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author smorgrav - */ -public class DeploymentCostTest { - - @Test - public void deploymentCost() { - Map<String, ClusterCost> clusters = new HashMap<>(); - clusters.put("cluster1", createClusterCost(100, 0.2)); - clusters.put("cluster2", createClusterCost(50, 0.1)); - - DeploymentCost cost = new DeploymentCost(clusters); - Assert.assertEquals(300, cost.getTco(), Double.MIN_VALUE); // 2*100 + 2*50 - Assert.assertEquals(28.5714285714, cost.getWaste(), 0.001); // from cluster2 - Assert.assertEquals(0.7142857142857143, cost.getUtilization(), Double.MIN_VALUE); // from cluster2 - } - - private ClusterCost createClusterCost(int flavorCost, double cpuUtil) { - List<String> hostnames = new ArrayList<>(); - hostnames.add("host1"); - hostnames.add("host2"); - ClusterInfo info = new ClusterInfo("test", flavorCost, 10, 10, 10, ClusterSpec.Type.container, hostnames); - ClusterUtilization util = new ClusterUtilization(0.3, cpuUtil, 0.5, 0.1); - return new ClusterCost(info, util); - } -}
\ No newline at end of file diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment-with-routing-policy.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment-with-routing-policy.json index eb8bf523474..ceea95ab1c8 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment-with-routing-policy.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment-with-routing-policy.json @@ -52,12 +52,6 @@ }, "status": "complete", "activity": {}, - "cost": { - "tco": 0, - "waste": 0, - "utilization": 0.0, - "cluster": {} - }, "metrics": { "queriesPerSecond": 0.0, "writesPerSecond": 0.0, diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment.json index ef8899c0860..ceed4f9a706 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment.json @@ -59,12 +59,6 @@ "lastQueriesPerSecond": 1.0, "lastWritesPerSecond": 2.0 }, - "cost": { - "tco": 0, - "waste": 0, - "utilization": 0.0, - "cluster": {} - }, "metrics": { "queriesPerSecond": 1.0, "writesPerSecond": 2.0, diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/dev-us-east-1.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/dev-us-east-1.json index cc930c94051..9d73b14aa6a 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/dev-us-east-1.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/dev-us-east-1.json @@ -28,12 +28,6 @@ "lastQueriesPerSecond": 1.0, "lastWritesPerSecond": 2.0 }, - "cost": { - "tco": 0, - "waste": 0, - "utilization": 0.0, - "cluster": {} - }, "metrics": { "queriesPerSecond": 1.0, "writesPerSecond": 2.0, diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/prod-us-central-1.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/prod-us-central-1.json index 436c2767b3e..6dc8f986a01 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/prod-us-central-1.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/prod-us-central-1.json @@ -62,12 +62,6 @@ "lastQueriesPerSecond": 1.0, "lastWritesPerSecond": 2.0 }, - "cost": { - "tco": 0, - "waste": 0, - "utilization": 0.0, - "cluster": {} - }, "metrics": { "queriesPerSecond": 1.0, "writesPerSecond": 2.0, |