summaryrefslogtreecommitdiffstats
path: root/hosted-zone-api
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2021-10-01 18:05:37 +0200
committergjoranv <gv@verizonmedia.com>2021-10-01 18:24:58 +0200
commitc8c404b9de976e7e874f500be46d1268e696cf6d (patch)
tree489671d9fec51eedfddf3540b044429e8b448076 /hosted-zone-api
parente7e38302b5b962c501f98c38878d496a20846e64 (diff)
Expose node indices of a container cluster via SystemInfo
Diffstat (limited to 'hosted-zone-api')
-rw-r--r--hosted-zone-api/abi-spec.json5
-rw-r--r--hosted-zone-api/src/main/java/ai/vespa/cloud/Cluster.java12
-rw-r--r--hosted-zone-api/src/test/java/ai/vespa/cloud/SystemInfoTest.java8
3 files changed, 20 insertions, 5 deletions
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