summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2021-10-04 10:41:10 +0200
committerGitHub <noreply@github.com>2021-10-04 10:41:10 +0200
commitba2347b6c4733fbddca32989dae65c0ce8ef939a (patch)
tree0618163fe8125d88a450cbac0f9ec9ca09184032
parent7371274583e76a1b4ba2a0d9ba001048c58d38de (diff)
parentc8c404b9de976e7e874f500be46d1268e696cf6d (diff)
Merge pull request #19404 from vespa-engine/add-node-indices-to-zone-api
Expose node indices of a container cluster via SystemInfo
-rwxr-xr-xconfig-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java1
-rwxr-xr-xconfig-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java1
-rw-r--r--configdefinitions/src/vespa/cluster-info.def1
-rw-r--r--container-disc/src/main/java/com/yahoo/container/jdisc/SystemInfoProvider.java2
-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
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