diff options
author | Martin Polden <mpolden@mpolden.no> | 2020-03-03 19:07:18 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2020-03-03 19:36:52 +0100 |
commit | 44dfcc72d71ea1576b77311ac208a37064692b83 (patch) | |
tree | c100c9b92f5be373617476b2c96a5d727e602c32 /controller-server | |
parent | c9393388464cccabf353c21842cc933bb98252d2 (diff) |
Remove ClusterInfo
Diffstat (limited to 'controller-server')
6 files changed, 5 insertions, 177 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Instance.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Instance.java index 984f6855cb3..d12e7dbc0ca 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Instance.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Instance.java @@ -4,7 +4,6 @@ package com.yahoo.vespa.hosted.controller; import com.google.common.collect.ImmutableMap; import com.yahoo.component.Version; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.zone.ZoneId; @@ -12,7 +11,6 @@ import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationV import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.AssignedRotation; import com.yahoo.vespa.hosted.controller.application.Change; -import com.yahoo.vespa.hosted.controller.application.ClusterInfo; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.application.DeploymentMetrics; import com.yahoo.vespa.hosted.controller.rotation.RotationStatus; @@ -69,7 +67,6 @@ public class Instance { Deployment previousDeployment = deployments.getOrDefault(zone, new Deployment(zone, applicationVersion, version, instant)); Deployment newDeployment = new Deployment(zone, applicationVersion, version, instant, - previousDeployment.clusterInfo(), previousDeployment.metrics().with(warnings), previousDeployment.activity()); return with(newDeployment); @@ -85,12 +82,6 @@ public class Instance { return new Instance(id, deployments.values(), jobPauses, rotations, rotationStatus, change); } - public Instance withClusterInfo(ZoneId zone, Map<ClusterSpec.Id, ClusterInfo> clusterInfo) { - Deployment deployment = deployments.get(zone); - if (deployment == null) return this; // No longer deployed in this zone. - return with(deployment.withClusterInfo(clusterInfo)); - } - public Instance recordActivityAt(Instant instant, ZoneId zone) { Deployment deployment = deployments.get(zone); if (deployment == null) return this; diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ClusterInfo.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ClusterInfo.java deleted file mode 100644 index 803e88beae2..00000000000 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ClusterInfo.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.application; - -import com.yahoo.config.provision.ClusterSpec; - -import java.util.List; - -/** - * Value object of static cluster information, in particular the TCO - * of the hardware used for this cluster. - * - * Some duplication/flattening of flavor info is done to simplify client usage. - * - * @author smorgrav - */ -// TODO(mpolden): Remove when we stop writing these fields. -public class ClusterInfo { - private final String flavor; - private final double flavorCPU; - private final double flavorMem; - private final double flavorDisk; - private final int flavorCost; - private final ClusterSpec.Type clusterType; - private final List<String> hostnames; - - /** - * @param flavor The name of the flavor eg. 'C-2B/24/500' - * @param flavorCost The cost of one node in dollars - * @param flavorCPU The number of cpu cores granted - * @param flavorMem The memory granted in Gb - * @param flavorDisk The disk size granted in Gb - * @param clusterType The vespa cluster type e.g 'container' or 'content' - * @param hostnames All hostnames in this cluster - */ - public ClusterInfo(String flavor, int flavorCost, double flavorCPU, double flavorMem, - double flavorDisk, ClusterSpec.Type clusterType, List<String> hostnames) { - this.flavor = flavor; - this.flavorCost = flavorCost; - this.flavorCPU = flavorCPU; - this.flavorMem = flavorMem; - this.flavorDisk = flavorDisk; - this.clusterType = clusterType; - this.hostnames = hostnames; - } - - /** @return The name of the flavor eg. 'C-2B/24/500' */ - public String getFlavor() { - return flavor; - } - - /** @return The cost of one node in dollars */ - public int getFlavorCost() { return flavorCost; } - - /** @return The disk size granted in Gb */ - public double getFlavorDisk() { return flavorDisk; } - - /** @return The number of cpu cores granted */ - public double getFlavorCPU() { return flavorCPU; } - - /** @return The memory granted in Gb */ - public double getFlavorMem() { return flavorMem; } - - /** @return The vespa cluster type e.g 'container' or 'content' */ - public ClusterSpec.Type getClusterType() { - return clusterType; - } - - /** @return All hostnames in this cluster */ - public List<String> getHostnames() { - return hostnames; - } -} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java index 361dcf9dbf9..200f41c8bcf 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java @@ -2,13 +2,10 @@ package com.yahoo.vespa.hosted.controller.application; import com.yahoo.component.Version; -import com.yahoo.config.provision.ClusterSpec.Id; import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion; import com.yahoo.config.provision.zone.ZoneId; import java.time.Instant; -import java.util.Collections; -import java.util.Map; import java.util.Objects; /** @@ -23,24 +20,19 @@ public class Deployment { private final ApplicationVersion applicationVersion; private final Version version; private final Instant deployTime; - private final Map<Id, ClusterInfo> clusterInfo; private final DeploymentMetrics metrics; private final DeploymentActivity activity; public Deployment(ZoneId zone, ApplicationVersion applicationVersion, Version version, Instant deployTime) { - this(zone, applicationVersion, version, deployTime, Collections.emptyMap(), - DeploymentMetrics.none, DeploymentActivity.none); + this(zone, applicationVersion, version, deployTime, DeploymentMetrics.none, DeploymentActivity.none); } public Deployment(ZoneId zone, ApplicationVersion applicationVersion, Version version, Instant deployTime, - Map<Id, ClusterInfo> clusterInfo, - DeploymentMetrics metrics, - DeploymentActivity activity) { + DeploymentMetrics metrics, DeploymentActivity activity) { this.zone = Objects.requireNonNull(zone, "zone cannot be null"); this.applicationVersion = Objects.requireNonNull(applicationVersion, "applicationVersion cannot be null"); this.version = Objects.requireNonNull(version, "version cannot be null"); this.deployTime = Objects.requireNonNull(deployTime, "deployTime cannot be null"); - this.clusterInfo = Map.copyOf(Objects.requireNonNull(clusterInfo, "clusterInfo cannot be null")); this.metrics = Objects.requireNonNull(metrics, "deploymentMetrics cannot be null"); this.activity = Objects.requireNonNull(activity, "activity cannot be null"); } @@ -65,29 +57,13 @@ public class Deployment { /** Returns activity for this */ public DeploymentActivity activity() { return activity; } - /** Returns information about the clusters allocated to this */ - public Map<Id, ClusterInfo> clusterInfo() { - return clusterInfo; - } - public Deployment recordActivityAt(Instant instant) { - return new Deployment(zone, applicationVersion, version, deployTime, clusterInfo, metrics, + return new Deployment(zone, applicationVersion, version, deployTime, metrics, activity.recordAt(instant, metrics)); } - public Deployment withClusterUtils() { - return new Deployment(zone, applicationVersion, version, deployTime, clusterInfo, metrics, - activity); - } - - public Deployment withClusterInfo(Map<Id, ClusterInfo> newClusterInfo) { - return new Deployment(zone, applicationVersion, version, deployTime, newClusterInfo, metrics, - activity); - } - public Deployment withMetrics(DeploymentMetrics metrics) { - return new Deployment(zone, applicationVersion, version, deployTime, clusterInfo, metrics, - activity); + return new Deployment(zone, applicationVersion, version, deployTime, metrics, activity); } @Override diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java index a15bfd07a66..94f5f116cb7 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java @@ -29,7 +29,6 @@ import com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId; import com.yahoo.vespa.hosted.controller.api.integration.organization.User; import com.yahoo.vespa.hosted.controller.application.AssignedRotation; import com.yahoo.vespa.hosted.controller.application.Change; -import com.yahoo.vespa.hosted.controller.application.ClusterInfo; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.application.DeploymentActivity; import com.yahoo.vespa.hosted.controller.application.DeploymentMetrics; @@ -129,16 +128,6 @@ public class ApplicationSerializer { private static final String jobTypeField = "jobType"; private static final String pausedUntilField = "pausedUntil"; - // ClusterInfo fields - private static final String clusterInfoField = "clusterInfo"; - private static final String clusterInfoFlavorField = "flavor"; - private static final String clusterInfoCostField = "cost"; - private static final String clusterInfoCpuField = "flavorCpu"; - private static final String clusterInfoMemField = "flavorMem"; - private static final String clusterInfoDiskField = "flavorDisk"; - private static final String clusterInfoTypeField = "clusterType"; - private static final String clusterInfoHostnamesField = "hostnames"; - // Deployment metrics fields private static final String deploymentMetricsField = "metrics"; private static final String deploymentMetricsQPSField = "queriesPerSecond"; @@ -211,8 +200,6 @@ public class ApplicationSerializer { object.setString(versionField, deployment.version().toString()); object.setLong(deployTimeField, deployment.at().toEpochMilli()); toSlime(deployment.applicationVersion(), object.setObject(applicationPackageRevisionField)); - // TODO(mpolden): Stop writing this after next release. - clusterInfoToSlime(deployment.clusterInfo(), object); deploymentMetricsToSlime(deployment.metrics(), object); deployment.activity().lastQueried().ifPresent(instant -> object.setLong(lastQueriedField, instant.toEpochMilli())); deployment.activity().lastWritten().ifPresent(instant -> object.setLong(lastWrittenField, instant.toEpochMilli())); @@ -234,26 +221,6 @@ public class ApplicationSerializer { } } - private void clusterInfoToSlime(Map<ClusterSpec.Id, ClusterInfo> clusters, Cursor object) { - Cursor root = object.setObject(clusterInfoField); - for (Map.Entry<ClusterSpec.Id, ClusterInfo> entry : clusters.entrySet()) { - toSlime(entry.getValue(), root.setObject(entry.getKey().value())); - } - } - - private void toSlime(ClusterInfo info, Cursor object) { - object.setString(clusterInfoFlavorField, info.getFlavor()); - object.setLong(clusterInfoCostField, info.getFlavorCost()); - object.setDouble(clusterInfoCpuField, info.getFlavorCPU()); - object.setDouble(clusterInfoMemField, info.getFlavorMem()); - object.setDouble(clusterInfoDiskField, info.getFlavorDisk()); - object.setString(clusterInfoTypeField, info.getClusterType().name()); - Cursor array = object.setArray(clusterInfoHostnamesField); - for (String host : info.getHostnames()) { - array.addString(host); - } - } - private void zoneIdToSlime(ZoneId zone, Cursor object) { object.setString(environmentField, zone.environment().value()); object.setString(regionField, zone.region().value()); @@ -399,7 +366,6 @@ public class ApplicationSerializer { applicationVersionFromSlime(deploymentObject.field(applicationPackageRevisionField)), Version.fromString(deploymentObject.field(versionField).asString()), Instant.ofEpochMilli(deploymentObject.field(deployTimeField).asLong()), - Map.of(), deploymentMetricsFromSlime(deploymentObject.field(deploymentMetricsField)), DeploymentActivity.create(Serializers.optionalInstant(deploymentObject.field(lastQueriedField)), Serializers.optionalInstant(deploymentObject.field(lastWrittenField)), diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java index 008052d1b5d..a73445dfa5a 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java @@ -5,7 +5,6 @@ import com.yahoo.component.Version; import com.yahoo.config.application.api.DeploymentSpec; import com.yahoo.config.application.api.ValidationOverrides; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.security.KeyUtils; import com.yahoo.slime.SlimeUtils; @@ -18,7 +17,6 @@ import com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId; import com.yahoo.vespa.hosted.controller.api.integration.organization.User; import com.yahoo.vespa.hosted.controller.application.AssignedRotation; import com.yahoo.vespa.hosted.controller.application.Change; -import com.yahoo.vespa.hosted.controller.application.ClusterInfo; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.application.DeploymentActivity; import com.yahoo.vespa.hosted.controller.application.DeploymentMetrics; @@ -36,7 +34,6 @@ import java.security.PublicKey; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; @@ -99,7 +96,6 @@ public class ApplicationSerializerTest { Instant activityAt = Instant.parse("2018-06-01T10:15:30.00Z"); deployments.add(new Deployment(zone1, applicationVersion1, Version.fromString("1.2.3"), Instant.ofEpochMilli(3))); // One deployment without cluster info and utils deployments.add(new Deployment(zone2, applicationVersion2, Version.fromString("1.2.3"), Instant.ofEpochMilli(5), - Map.of(), new DeploymentMetrics(2, 3, 4, 5, 6, Optional.of(Instant.now().truncatedTo(ChronoUnit.MILLIS)), Map.of(DeploymentMetrics.Warning.all, 3)), @@ -187,9 +183,6 @@ public class ApplicationSerializerTest { assertEquals(original.require(id1.instance()).change(), serialized.require(id1.instance()).change()); assertEquals(original.require(id3.instance()).change(), serialized.require(id3.instance()).change()); - // Test cluster info - assertEquals(0, serialized.require(id1.instance()).deployments().get(zone2).clusterInfo().size()); - // Test metrics assertEquals(original.metrics().queryServiceQuality(), serialized.metrics().queryServiceQuality(), Double.MIN_VALUE); assertEquals(original.metrics().writeServiceQuality(), serialized.metrics().writeServiceQuality(), Double.MIN_VALUE); @@ -202,21 +195,6 @@ public class ApplicationSerializerTest { assertEquals(original.require(id1.instance()).deployments().get(zone2).metrics().warnings(), serialized.require(id1.instance()).deployments().get(zone2).metrics().warnings()); } - 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; - } - @Test public void testCompleteApplicationDeserialization() throws Exception { byte[] applicationJson = Files.readAllBytes(testData.resolve("complete-application.json")); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java index 810b9c2550c..ae2b2b84e89 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java @@ -9,7 +9,6 @@ import com.yahoo.config.application.api.ValidationId; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationName; import com.yahoo.config.provision.AthenzService; -import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.TenantName; @@ -48,7 +47,6 @@ import com.yahoo.vespa.hosted.controller.api.integration.resource.ResourceSnapsh import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMeteringClient; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.Change; -import com.yahoo.vespa.hosted.controller.application.ClusterInfo; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.application.DeploymentMetrics; import com.yahoo.vespa.hosted.controller.application.TenantAndApplicationId; @@ -1600,19 +1598,10 @@ public class ApplicationApiTest extends ControllerContainerTest { for (Instance instance : application.instances().values()) { for (Deployment deployment : instance.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)); DeploymentMetrics metrics = new DeploymentMetrics(1, 2, 3, 4, 5, Optional.of(Instant.ofEpochMilli(123123)), Map.of()); - lockedApplication = lockedApplication.with(instance.name(), - lockedInstance -> lockedInstance.withClusterInfo(deployment.zone(), clusterInfo) - .with(deployment.zone(), metrics) + lockedInstance -> lockedInstance.with(deployment.zone(), metrics) .recordActivityAt(Instant.parse("2018-06-01T10:15:30.00Z"), deployment.zone())); } deploymentTester.applications().store(lockedApplication); |