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 d98ea0ffc252..d82984919446 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 @@ -36,7 +36,7 @@ public SystemInfoProvider(ConfigserverConfig csConfig, applicationIdConfig.instance()), new Zone(Environment.valueOf(csConfig.environment()), csConfig.region()), new Cloud(csConfig.cloud()), - new Cluster(ciConfig.nodeCount(), ciConfig.nodeIndices()), + new Cluster(ciConfig.clusterId(), 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 0d9a64097593..213f2883da0c 100644 --- a/hosted-zone-api/abi-spec.json +++ b/hosted-zone-api/abi-spec.json @@ -41,6 +41,8 @@ ], "methods": [ "public void (int, java.util.List)", + "public void (java.lang.String, int, java.util.List)", + "public java.lang.String id()", "public int size()", "public java.util.List indices()", "public boolean equals(java.lang.Object)", 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 218545383e6e..ce278848f290 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 @@ -12,15 +12,25 @@ */ public class Cluster { + private final String id; private final int size; private final List indices; + // TODO: Remove on Vespa 9 + @Deprecated(forRemoval = true) public Cluster(int size, List indices) { - Objects.requireNonNull(indices, "Indices cannot be null!"); + this("default", size, indices); + } + + public Cluster(String id, int size, List indices) { + this.id = Objects.requireNonNull(id); this.size = size; - this.indices = Collections.unmodifiableList(indices); + this.indices = List.copyOf(Objects.requireNonNull(indices)); } + /** Returns the id of this cluster set in services.xml */ + public String id() { return id; } + /** Returns the number of nodes in this cluster. */ public int size() { return size; } @@ -32,15 +42,16 @@ public List indices() { @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Cluster cluster = (Cluster) o; - return size == cluster.size && - indices.equals(cluster.indices); + if ( ! (o instanceof Cluster other)) return false; + if ( ! this.id.equals(other.id)) return false; + if ( this.size != other.size) return false; + if ( ! this.indices.equals(other.indices)) return false; + return true; } @Override public int hashCode() { - return Objects.hash(size, indices); + return Objects.hash(id, size, 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 2bae9f0c9e28..d97bba51c716 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 @@ -18,7 +18,7 @@ void testSystemInfo() { ApplicationId application = new ApplicationId("tenant1", "application1", "instance1"); Zone zone = new Zone(Environment.dev, "us-west-1"); Cloud cloud = new Cloud("aws"); - Cluster cluster = new Cluster(1, List.of()); + Cluster cluster = new Cluster("clusterId", 1, List.of()); Node node = new Node(0); SystemInfo info = new SystemInfo(application, zone, cloud, cluster, node); @@ -59,9 +59,11 @@ void testZone() { @Test void testCluster() { + String id = "clusterId"; int size = 1; var indices = List.of(1); - Cluster cluster = new Cluster(size, indices); + Cluster cluster = new Cluster("clusterId", size, indices); + assertEquals(id, cluster.id()); assertEquals(size, cluster.size()); assertEquals(indices, cluster.indices()); }