diff options
4 files changed, 32 insertions, 3 deletions
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 e5103eb11b9..de9e20c3c6d 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,11 +1,13 @@ // Copyright Verizon Media. 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.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.ClusterInfoConfig; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.component.AbstractComponent; import com.yahoo.container.QrConfig; @@ -22,8 +24,9 @@ public class SystemInfoProvider extends AbstractComponent implements Provider<Sy private final SystemInfo instance; @Inject - public SystemInfoProvider(ConfigserverConfig csConfig, QrConfig qrConfig) { + public SystemInfoProvider(ConfigserverConfig csConfig, QrConfig qrConfig, ClusterInfoConfig ciConfig) { this.instance = new SystemInfo(new Zone(Environment.valueOf(csConfig.environment()), csConfig.region()), + new Cluster(ciConfig.nodeCount()), new Node(qrConfig.nodeIndex())); } diff --git a/hosted-zone-api/src/main/java/ai/vespa/cloud/Cluster.java b/hosted-zone-api/src/main/java/ai/vespa/cloud/Cluster.java index 9c2dd10f146..6e064b09d7a 100644 --- a/hosted-zone-api/src/main/java/ai/vespa/cloud/Cluster.java +++ b/hosted-zone-api/src/main/java/ai/vespa/cloud/Cluster.java @@ -1,7 +1,19 @@ package ai.vespa.cloud; /** + * The properties of a cluster of nodes. + * * @author gjoranv */ public class Cluster { + + private final int size; + + public Cluster(int size) { + this.size = size; + } + + /** Returns the number of nodes in this cluster. */ + public int size() { return size; } + } 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 c00a199e5bb..706959438eb 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 @@ -10,16 +10,20 @@ package ai.vespa.cloud; public class SystemInfo { private final Zone zone; + private final Cluster cluster; private final Node node; - public SystemInfo(Zone zone, Node node) { + public SystemInfo(Zone zone, Cluster cluster, Node node) { this.zone = zone; + this.cluster = cluster; this.node = node; } /** Returns the zone this is running in */ public Zone zone() { return zone; } + /** Returns the cluster this is part of */ + public Cluster cluster() { return cluster; } /** Returns the node this is running on */ public Node node() { return node; } 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 9f66d4949bc..6bdb38eb735 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 @@ -14,9 +14,12 @@ public class SystemInfoTest { @Test public void testSystemInfo() { Zone zone = new Zone(Environment.dev, "us-west-1"); + Cluster cluster = new Cluster(1); Node node = new Node(0); - SystemInfo info = new SystemInfo(zone, node); + + SystemInfo info = new SystemInfo(zone, cluster, node); assertEquals(zone, info.zone()); + assertEquals(cluster, info.cluster()); assertEquals(node, info.node()); } @@ -49,6 +52,13 @@ public class SystemInfoTest { } @Test + public void testCluster() { + int size = 1; + Cluster cluster = new Cluster(size); + assertEquals(size, cluster.size()); + } + + @Test public void testNode() { int index = 0; Node node = new Node(index); |