summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-10-08 11:38:37 +0200
committerGitHub <noreply@github.com>2022-10-08 11:38:37 +0200
commit14e1b2febd40c3fa89d09b64569b4634f5594acc (patch)
tree053637840dee3a6d432002611720eafce37949d5
parent36bc9cc2d6d01746c42e3041d4e2f000ebb4a7dd (diff)
parent7b0ddd490f1ed63b4fc9b679e411aee2222efa8d (diff)
Merge pull request #24355 from vespa-engine/bratseth/cluster-id
Add id() to Cluster
-rw-r--r--container-disc/src/main/java/com/yahoo/container/jdisc/SystemInfoProvider.java2
-rw-r--r--hosted-zone-api/abi-spec.json2
-rw-r--r--hosted-zone-api/src/main/java/ai/vespa/cloud/Cluster.java25
-rw-r--r--hosted-zone-api/src/test/java/ai/vespa/cloud/SystemInfoTest.java6
4 files changed, 25 insertions, 10 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 d98ea0ffc25..d8298491944 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 class SystemInfoProvider extends AbstractComponent implements Provider<Sy
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 0d9a6409759..213f2883da0 100644
--- a/hosted-zone-api/abi-spec.json
+++ b/hosted-zone-api/abi-spec.json
@@ -41,6 +41,8 @@
],
"methods": [
"public void <init>(int, java.util.List)",
+ "public void <init>(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 218545383e6..ce278848f29 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 @@ import java.util.Objects;
*/
public class Cluster {
+ private final String id;
private final int size;
private final List<Integer> indices;
+ // TODO: Remove on Vespa 9
+ @Deprecated(forRemoval = true)
public Cluster(int size, List<Integer> indices) {
- Objects.requireNonNull(indices, "Indices cannot be null!");
+ this("default", size, indices);
+ }
+
+ public Cluster(String id, int size, List<Integer> 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 class Cluster {
@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 2bae9f0c9e2..d97bba51c71 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 @@ public class SystemInfoTest {
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 @@ public class SystemInfoTest {
@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());
}