diff options
6 files changed, 76 insertions, 13 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/CommonConfigsProducer.java b/config-model/src/main/java/com/yahoo/config/model/CommonConfigsProducer.java index fad097d1edb..094b11dcbc7 100644 --- a/config-model/src/main/java/com/yahoo/config/model/CommonConfigsProducer.java +++ b/config-model/src/main/java/com/yahoo/config/model/CommonConfigsProducer.java @@ -21,7 +21,6 @@ import com.yahoo.vespa.config.content.AllClustersBucketSpacesConfig; * This interface describes the configs that are produced by the model producer root. * * @author Ulf Lilleengen - * @since 5.1 */ public interface CommonConfigsProducer extends DocumentmanagerConfig.Producer, DocumenttypesConfig.Producer, diff --git a/container-disc/src/main/java/com/yahoo/container/jdisc/SystemInfoProvider.java b/container-disc/src/main/java/com/yahoo/container/jdisc/SystemInfoProvider.java index a34b7506666..39c4b108aa6 100644 --- a/container-disc/src/main/java/com/yahoo/container/jdisc/SystemInfoProvider.java +++ b/container-disc/src/main/java/com/yahoo/container/jdisc/SystemInfoProvider.java @@ -1,12 +1,14 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.container.jdisc; +import ai.vespa.cloud.ApplicationId; import ai.vespa.cloud.Cluster; import ai.vespa.cloud.Environment; import ai.vespa.cloud.Node; import ai.vespa.cloud.SystemInfo; import ai.vespa.cloud.Zone; import com.google.inject.Inject; +import com.yahoo.cloud.config.ApplicationIdConfig; import com.yahoo.cloud.config.ClusterInfoConfig; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.component.AbstractComponent; @@ -24,8 +26,14 @@ public class SystemInfoProvider extends AbstractComponent implements Provider<Sy private final SystemInfo instance; @Inject - public SystemInfoProvider(ConfigserverConfig csConfig, QrConfig qrConfig, ClusterInfoConfig ciConfig) { - this.instance = new SystemInfo(new Zone(Environment.valueOf(csConfig.environment()), csConfig.region()), + public SystemInfoProvider(ConfigserverConfig csConfig, + QrConfig qrConfig, + ClusterInfoConfig ciConfig, + ApplicationIdConfig applicationIdConfig) { + this.instance = new SystemInfo(new ApplicationId(applicationIdConfig.tenant(), + applicationIdConfig.application(), + applicationIdConfig.instance()), + new Zone(Environment.valueOf(csConfig.environment()), csConfig.region()), new Cluster(ciConfig.nodeCount(), ciConfig.nodeIndices()), new Node(qrConfig.nodeIndex())); } diff --git a/container-search/src/test/java/com/yahoo/search/searchers/test/RateLimitingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/searchers/test/RateLimitingSearcherTestCase.java index cb1a44b8afd..4ee57112960 100755 --- a/container-search/src/test/java/com/yahoo/search/searchers/test/RateLimitingSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/searchers/test/RateLimitingSearcherTestCase.java @@ -45,9 +45,9 @@ public class RateLimitingSearcherTestCase { ManualClock clock = new ManualClock(); MetricReceiver.MockReceiver metric = new MetricReceiver.MockReceiver(); - Chain<Searcher> chain = new Chain<Searcher>("test", new RateLimitingSearcher(new RateLimitingConfig(rateLimitingConfig), - new ClusterInfoConfig(clusterInfoConfig), - metric, clock), + Chain<Searcher> chain = new Chain<>("test", new RateLimitingSearcher(new RateLimitingConfig(rateLimitingConfig), + new ClusterInfoConfig(clusterInfoConfig), + metric, clock), new CostSettingSearcher()); assertEquals("'rate' request are available initially", 2, tryRequests(chain, "id1")); assertTrue("However, don't reject if we dryRun", executeWasAllowed(chain, "id1", true)); diff --git a/hosted-zone-api/src/main/java/ai/vespa/cloud/ApplicationId.java b/hosted-zone-api/src/main/java/ai/vespa/cloud/ApplicationId.java new file mode 100644 index 00000000000..46780d17a13 --- /dev/null +++ b/hosted-zone-api/src/main/java/ai/vespa/cloud/ApplicationId.java @@ -0,0 +1,46 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package ai.vespa.cloud; + +import java.util.Objects; + +/** + * The application id this is running as. + * This is a combination of a tenant, application, and instance name. + * + * @author bratseth + */ +public class ApplicationId { + + private final String tenant; + private final String application; + private final String instance; + + public ApplicationId(String tenant, String application, String instance) { + this.tenant = tenant; + this.application = application; + this.instance = instance; + } + + public String tenant() { return tenant; } + public String application() { return application; } + public String instance() { return instance; } + + @Override + public boolean equals(Object o) { + if (o == this) return true; + if ( ! (o instanceof ApplicationId)) return false; + ApplicationId other = (ApplicationId)o; + if ( ! other.tenant.equals(this.tenant)) return false; + if ( ! other.application.equals(this.application)) return false; + if ( ! other.instance.equals(this.instance)) return false; + return true; + } + + @Override + public int hashCode() { return Objects.hash(tenant, application, instance); } + + /** Returns the string tenant.application.instance */ + @Override + public String toString() { return tenant + "." + application + "." + instance; } + +} diff --git a/hosted-zone-api/src/main/java/ai/vespa/cloud/SystemInfo.java b/hosted-zone-api/src/main/java/ai/vespa/cloud/SystemInfo.java index 15b06d40948..3789c49fe82 100644 --- a/hosted-zone-api/src/main/java/ai/vespa/cloud/SystemInfo.java +++ b/hosted-zone-api/src/main/java/ai/vespa/cloud/SystemInfo.java @@ -11,19 +11,27 @@ import java.util.Objects; */ public class SystemInfo { + private final ApplicationId application; private final Zone zone; private final Cluster cluster; private final Node node; + public SystemInfo(ApplicationId application, Zone zone, Cluster cluster, Node node) { + this.application = Objects.requireNonNull(application, "Application cannot be null"); + this.zone = Objects.requireNonNull(zone, "Zone cannot be null"); + this.cluster = Objects.requireNonNull(cluster, "Cluster cannot be null"); + this.node = Objects.requireNonNull(node, "Node cannot be null"); + } + + /** @deprecated pass an application id */ + @Deprecated // Remove on Vespa 8 public SystemInfo(Zone zone, Cluster cluster, Node node) { - Objects.requireNonNull(zone, "Zone cannot be null!"); - Objects.requireNonNull(cluster, "Cluster cannot be null!"); - Objects.requireNonNull(node, "Node cannot be null!"); - this.zone = zone; - this.cluster = cluster; - this.node = node; + this(new ApplicationId("default", "default", "default"), zone, cluster, node); } + /** Returns the application this is running as a part of */ + public ApplicationId application() { return application; } + /** Returns the zone this is running in */ public Zone zone() { return zone; } diff --git a/hosted-zone-api/src/test/java/ai/vespa/cloud/SystemInfoTest.java b/hosted-zone-api/src/test/java/ai/vespa/cloud/SystemInfoTest.java index 7f6921ab114..c14955d6614 100644 --- a/hosted-zone-api/src/test/java/ai/vespa/cloud/SystemInfoTest.java +++ b/hosted-zone-api/src/test/java/ai/vespa/cloud/SystemInfoTest.java @@ -15,11 +15,13 @@ public class SystemInfoTest { @Test public void testSystemInfo() { + ApplicationId application = new ApplicationId("tenant1", "application1", "instance1"); Zone zone = new Zone(Environment.dev, "us-west-1"); Cluster cluster = new Cluster(1, List.of()); Node node = new Node(0); - SystemInfo info = new SystemInfo(zone, cluster, node); + SystemInfo info = new SystemInfo(application, zone, cluster, node); + assertEquals(application, info.application()); assertEquals(zone, info.zone()); assertEquals(cluster, info.cluster()); assertEquals(node, info.node()); |