diff options
author | Håkon Hallingstad <hakon@verizonmedia.com> | 2021-07-28 12:19:25 +0200 |
---|---|---|
committer | Håkon Hallingstad <hakon@verizonmedia.com> | 2021-07-28 12:56:02 +0200 |
commit | d24031c95eb561edcac408e3f6f676a1960cd3ee (patch) | |
tree | 9336abe36e4e6c5f6d9a5a63fa68a0d49646be70 | |
parent | 8a450d4b8d7553c37a6361711b424df01a876637 (diff) |
OrchestrationParams
7 files changed, 304 insertions, 1 deletions
diff --git a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ClusterId.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ClusterId.java index d7995b41616..40fdbd52a92 100644 --- a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ClusterId.java +++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ClusterId.java @@ -14,6 +14,8 @@ public class ClusterId { public static final ClusterId CONTROLLER = new ClusterId("controller"); public static final ClusterId CONFIG_SERVER_HOST = new ClusterId("configserver-host"); public static final ClusterId CONTROLLER_HOST = new ClusterId("controller-host"); + public static final ClusterId PROXY_HOST = new ClusterId("proxy-host"); + public static final ClusterId ROUTING = new ClusterId("routing"); public static final ClusterId TENANT_HOST = new ClusterId("tenant-host"); private final String id; diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/ApplicationParams.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/ApplicationParams.java new file mode 100644 index 00000000000..caadadcad21 --- /dev/null +++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/ApplicationParams.java @@ -0,0 +1,63 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.orchestrator.policy; + +import com.yahoo.vespa.applicationmodel.ClusterId; +import com.yahoo.vespa.applicationmodel.ServiceClusterKey; +import com.yahoo.vespa.applicationmodel.ServiceType; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Per-application parameters controlling the orchestration. + * + * @author hakonhall + */ +public class ApplicationParams { + + private static final ApplicationParams DEFAULT = new ApplicationParams.Builder().build(); + + private final Map<ServiceClusterKey, ClusterParams> clusterParams; + + public static class Builder { + private final Map<ServiceClusterKey, ClusterParams> clusterParams = new HashMap<>(); + + public Builder() {} + + public Builder add(ClusterId clusterId, ServiceType serviceType, ClusterParams clusterParams) { + this.clusterParams.put(new ServiceClusterKey(clusterId, serviceType), clusterParams); + return this; + } + + public ApplicationParams build() { + return new ApplicationParams(clusterParams); + } + } + + public static ApplicationParams getDefault() { + return DEFAULT; + } + + private ApplicationParams(Map<ServiceClusterKey, ClusterParams> clusterParams) { + this.clusterParams = Map.copyOf(clusterParams); + } + + public ClusterParams clusterParamsFor(ClusterId clusterId, ServiceType serviceType) { + var key = new ServiceClusterKey(clusterId, serviceType); + return clusterParams.getOrDefault(key, ClusterParams.getDefault()); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ApplicationParams that = (ApplicationParams) o; + return clusterParams.equals(that.clusterParams); + } + + @Override + public int hashCode() { + return Objects.hash(clusterParams); + } +} diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/ClusterParams.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/ClusterParams.java new file mode 100644 index 00000000000..b6f90ab7302 --- /dev/null +++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/ClusterParams.java @@ -0,0 +1,61 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.orchestrator.policy; + +import java.util.Objects; +import java.util.OptionalInt; + +/** + * Parameters controlling orchestration of a particular service cluster of an implied application. + * + * @author hakonhall + */ +public class ClusterParams { + + private static final ClusterParams DEFAULT = new ClusterParams.Builder().build(); + + private final int size; + + public static class Builder { + private int size = 0; + + public Builder() {} + + public Builder setSize(int size) { + this.size = size; + return this; + } + + public ClusterParams build() { + return new ClusterParams(size); + } + } + + public static ClusterParams getDefault() { + return DEFAULT; + } + + private ClusterParams(int size) { + this.size = size; + } + + /** + * The expected and ideal number of members of the cluster: Count missing services as down, + * and expected to be added to the application soon. + */ + public OptionalInt size() { + return size > 0 ? OptionalInt.of(size) : OptionalInt.empty(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ClusterParams that = (ClusterParams) o; + return size == that.size; + } + + @Override + public int hashCode() { + return Objects.hash(size); + } +} diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaOrchestration.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaOrchestration.java new file mode 100644 index 00000000000..311bbb5ea8b --- /dev/null +++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaOrchestration.java @@ -0,0 +1,103 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.orchestrator.policy; + +import com.yahoo.cloud.config.ConfigserverConfig; +import com.yahoo.vespa.applicationmodel.ClusterId; +import com.yahoo.vespa.applicationmodel.ServiceType; +import com.yahoo.vespa.service.duper.ConfigServerApplication; +import com.yahoo.vespa.service.duper.ConfigServerHostApplication; +import com.yahoo.vespa.service.duper.ControllerApplication; +import com.yahoo.vespa.service.duper.ControllerHostApplication; +import com.yahoo.vespa.service.duper.ProxyApplication; +import com.yahoo.vespa.service.duper.ProxyHostApplication; + +/** + * Creates orchestration parameters for hosted Vespa. + * + * @author hakonhall + */ +public class HostedVespaOrchestration { + public static OrchestrationParams create(ConfigserverConfig configserverConfig) { + // We'll create parameters for both the controller and config server applications, even though + // only one of them is present, as (a) no harm is done by having the extra parameters, and + // (b) it leads to simpler code below. + + return new OrchestrationParams.Builder() + + // Controller host + .addApplicationParams(new ControllerHostApplication().getApplicationId(), + new ApplicationParams + .Builder() + .add(ClusterId.CONTROLLER, + ServiceType.HOST_ADMIN, + new ClusterParams + .Builder() + .setSize(configserverConfig.zookeeperserver().size()) + .build()) + .build()) + + // Controller + .addApplicationParams(new ControllerApplication().getApplicationId(), + new ApplicationParams + .Builder() + .add(ClusterId.CONTROLLER, + ServiceType.CONTROLLER, + new ClusterParams + .Builder() + .setSize(configserverConfig.zookeeperserver().size()) + .build()) + .build()) + + // Config server host + .addApplicationParams(new ConfigServerHostApplication().getApplicationId(), + new ApplicationParams + .Builder() + .add(ClusterId.CONFIG_SERVER_HOST, + ServiceType.HOST_ADMIN, + new ClusterParams + .Builder() + .setSize(configserverConfig.zookeeperserver().size()) + .build()) + .build()) + + // Config server + .addApplicationParams(new ConfigServerApplication().getApplicationId(), + new ApplicationParams + .Builder() + .add(ClusterId.CONFIG_SERVER, + ServiceType.CONFIG_SERVER, + new ClusterParams + .Builder() + .setSize(configserverConfig.zookeeperserver().size()) + .build()) + .build()) + + // Proxy host + .addApplicationParams(new ProxyHostApplication().getApplicationId(), + new ApplicationParams + .Builder() + .add(ClusterId.PROXY_HOST, + ServiceType.HOST_ADMIN, + new ClusterParams + .Builder() + // todo: get the number of proxy nodes + .setSize(0) + .build()) + .build()) + + // Proxy + .addApplicationParams(new ProxyApplication().getApplicationId(), + new ApplicationParams + .Builder() + .add(ClusterId.ROUTING, + ServiceType.CONTAINER, + new ClusterParams + .Builder() + // todo: get the number of proxy nodes + .setSize(0) + .build()) + .build()) + + .build(); + } +} diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/OrchestrationParams.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/OrchestrationParams.java new file mode 100644 index 00000000000..7519564b080 --- /dev/null +++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/OrchestrationParams.java @@ -0,0 +1,53 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.orchestrator.policy; + +import com.yahoo.config.provision.ApplicationId; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Parameters controlling orchestration. + * + * @author hakonhall + */ +public class OrchestrationParams { + private final Map<ApplicationId, ApplicationParams> applicationParams; + + public static class Builder { + private final Map<ApplicationId, ApplicationParams> applicationParams = new HashMap<>(); + + public Builder() {} + + public Builder addApplicationParams(ApplicationId applicationId, ApplicationParams params) { + this.applicationParams.put(applicationId, params); + return this; + } + + public OrchestrationParams build() { + return new OrchestrationParams(applicationParams); + } + } + + private OrchestrationParams(Map<ApplicationId, ApplicationParams> applicationParams) { + this.applicationParams = Map.copyOf(applicationParams); + } + + public ApplicationParams getApplicationParams(ApplicationId applicationId) { + return applicationParams.getOrDefault(applicationId, ApplicationParams.getDefault()); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + OrchestrationParams that = (OrchestrationParams) o; + return applicationParams.equals(that.applicationParams); + } + + @Override + public int hashCode() { + return Objects.hash(applicationParams); + } +} diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/InfraApplication.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/InfraApplication.java index 1bdf1ff67d9..c53d47ee6a3 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/InfraApplication.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/InfraApplication.java @@ -35,7 +35,7 @@ import java.util.stream.Collectors; */ public abstract class InfraApplication implements InfraApplicationApi { - private static final TenantName TENANT_NAME = TenantName.from("hosted-vespa"); + static final TenantName TENANT_NAME = TenantName.from("hosted-vespa"); private final ApplicationId applicationId; private final Capacity capacity; diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ProxyApplication.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ProxyApplication.java new file mode 100644 index 00000000000..7bc4facbfa8 --- /dev/null +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ProxyApplication.java @@ -0,0 +1,21 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.service.duper; + +import com.yahoo.config.provision.ApplicationId; + +/** + * The proxy application is an ordinary non-infrastructure application. Still, it may be useful + * to refer to e.g. the ApplicationId of the proxy application, hence this class. + * + * @author hakonhall + */ +public class ProxyApplication { + private static final ApplicationId APPLICATION_ID = new ApplicationId.Builder() + .tenant(InfraApplication.TENANT_NAME) + .applicationName("routing") + .build(); + + public ApplicationId getApplicationId() { + return APPLICATION_ID; + } +} |