diff options
7 files changed, 24 insertions, 6 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java index d05650b10b5..69bcd4b87bb 100755 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java @@ -555,6 +555,7 @@ public abstract class ContainerCluster<CONTAINER extends Container> public void getConfig(ClusterInfoConfig.Builder builder) { builder.clusterId(name); builder.nodeCount(containers.size()); + containers.forEach(c -> builder.nodeIndices(c.index())); for (Service service : getDescendantServices()) { builder.services.add(new ClusterInfoConfig.Services.Builder() diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java index 7b5efad9647..6f575ef7ea3 100755 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java @@ -56,6 +56,7 @@ public class ContainerClusterTest { ClusterInfoConfig config = getClusterInfoConfig(cluster); assertEquals("name", config.clusterId()); assertEquals(2, config.nodeCount()); + assertEquals(List.of(0, 0), config.nodeIndices()); // both containers are created with index 0 assertEquals(2, config.services().size()); Iterator<ClusterInfoConfig.Services> iterator = config.services().iterator(); diff --git a/configdefinitions/src/vespa/cluster-info.def b/configdefinitions/src/vespa/cluster-info.def index f5e94ad61b3..05ab2cd1613 100644 --- a/configdefinitions/src/vespa/cluster-info.def +++ b/configdefinitions/src/vespa/cluster-info.def @@ -5,6 +5,7 @@ namespace=cloud.config # clusterId is same as clustername in model clusterId string nodeCount int +nodeIndices[] int services[].index int default=-1 services[].hostname string default="(nohostname)" 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 de9e20c3c6d..b64a085764d 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 @@ -26,7 +26,7 @@ public class SystemInfoProvider extends AbstractComponent implements Provider<Sy @Inject 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 Cluster(ciConfig.nodeCount(), ciConfig.nodeIndices()), new Node(qrConfig.nodeIndex())); } diff --git a/hosted-zone-api/abi-spec.json b/hosted-zone-api/abi-spec.json index e3b68d09135..00b776922d4 100644 --- a/hosted-zone-api/abi-spec.json +++ b/hosted-zone-api/abi-spec.json @@ -6,8 +6,9 @@ "public" ], "methods": [ - "public void <init>(int)", - "public int size()" + "public void <init>(int, java.util.List)", + "public int size()", + "public java.util.List indices()" ], "fields": [] }, 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 6e064b09d7a..5db68b9d5b3 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,5 +1,8 @@ package ai.vespa.cloud; +import java.util.Collections; +import java.util.List; + /** * The properties of a cluster of nodes. * @@ -8,12 +11,19 @@ package ai.vespa.cloud; public class Cluster { private final int size; + private final List<Integer> indices; - public Cluster(int size) { + public Cluster(int size, List<Integer> indices) { this.size = size; + this.indices = Collections.unmodifiableList(indices); } /** Returns the number of nodes in this cluster. */ public int size() { return size; } + /** Returns a list of node indices in this cluster. */ + public List<Integer> indices() { + return indices; + } + } 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 6bdb38eb735..85e17527110 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 @@ -3,6 +3,8 @@ package ai.vespa.cloud; import org.junit.Test; +import java.util.List; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -14,7 +16,7 @@ public class SystemInfoTest { @Test public void testSystemInfo() { Zone zone = new Zone(Environment.dev, "us-west-1"); - Cluster cluster = new Cluster(1); + Cluster cluster = new Cluster(1, List.of()); Node node = new Node(0); SystemInfo info = new SystemInfo(zone, cluster, node); @@ -54,8 +56,10 @@ public class SystemInfoTest { @Test public void testCluster() { int size = 1; - Cluster cluster = new Cluster(size); + var indices = List.of(1); + Cluster cluster = new Cluster(size, indices); assertEquals(size, cluster.size()); + assertEquals(indices, cluster.indices()); } @Test |