aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/Container.java9
-rw-r--r--container-core/src/main/resources/configdefinitions/container.qr.def5
-rw-r--r--container-disc/src/main/java/com/yahoo/container/jdisc/SystemInfoProvider.java7
-rw-r--r--hosted-zone-api/src/main/java/ai/vespa/cloud/Cluster.java7
-rw-r--r--hosted-zone-api/src/main/java/ai/vespa/cloud/Node.java34
-rw-r--r--hosted-zone-api/src/main/java/ai/vespa/cloud/SystemInfo.java8
-rw-r--r--hosted-zone-api/src/test/java/ai/vespa/cloud/SystemInfoTest.java11
7 files changed, 73 insertions, 8 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java b/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java
index cd596038137..b915453b593 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java
@@ -310,11 +310,12 @@ public abstract class Container extends AbstractService implements
@Override
public void getConfig(QrConfig.Builder builder) {
builder.rpc(new Rpc.Builder()
- .enabled(rpcServerEnabled())
- .port(getRpcPort())
- .slobrokId(serviceSlobrokId()))
+ .enabled(rpcServerEnabled())
+ .port(getRpcPort())
+ .slobrokId(serviceSlobrokId()))
.filedistributor(filedistributorConfig())
- .discriminator((clusterName != null ? clusterName + "." : "" ) + name);
+ .discriminator((clusterName != null ? clusterName + "." : "" ) + name)
+ .nodeIndex(index);
}
/** Returns the jvm args set explicitly for this node */
diff --git a/container-core/src/main/resources/configdefinitions/container.qr.def b/container-core/src/main/resources/configdefinitions/container.qr.def
index fe44b04e9d5..9d9b84eb428 100644
--- a/container-core/src/main/resources/configdefinitions/container.qr.def
+++ b/container-core/src/main/resources/configdefinitions/container.qr.def
@@ -23,5 +23,10 @@ rpc.slobrokId string default="" restart
## this string will be unique for every QRS in a Vespa application.
discriminator string default="qrserver.0" restart
+## Index of this container inside the cluster. Guaranteed to be non-negative
+## and unique for every container in a cluster, but not necessarily contiguous
+## or starting from zero.
+nodeIndex int default=0
+
## Force restart of container on deploy, and defer any changes until restart
restartOnDeploy bool default=false restart
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 b25517ec1f7..e5103eb11b9 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
@@ -2,11 +2,13 @@
package com.yahoo.container.jdisc;
import ai.vespa.cloud.Environment;
+import ai.vespa.cloud.Node;
import ai.vespa.cloud.SystemInfo;
import ai.vespa.cloud.Zone;
import com.google.inject.Inject;
import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.component.AbstractComponent;
+import com.yahoo.container.QrConfig;
import com.yahoo.container.di.componentgraph.Provider;
/**
@@ -20,8 +22,9 @@ public class SystemInfoProvider extends AbstractComponent implements Provider<Sy
private final SystemInfo instance;
@Inject
- public SystemInfoProvider(ConfigserverConfig config) {
- this.instance = new SystemInfo(new Zone(Environment.valueOf(config.environment()), config.region()));
+ public SystemInfoProvider(ConfigserverConfig csConfig, QrConfig qrConfig) {
+ this.instance = new SystemInfo(new Zone(Environment.valueOf(csConfig.environment()), csConfig.region()),
+ new Node(qrConfig.nodeIndex()));
}
@Override
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
new file mode 100644
index 00000000000..9c2dd10f146
--- /dev/null
+++ b/hosted-zone-api/src/main/java/ai/vespa/cloud/Cluster.java
@@ -0,0 +1,7 @@
+package ai.vespa.cloud;
+
+/**
+ * @author gjoranv
+ */
+public class Cluster {
+}
diff --git a/hosted-zone-api/src/main/java/ai/vespa/cloud/Node.java b/hosted-zone-api/src/main/java/ai/vespa/cloud/Node.java
new file mode 100644
index 00000000000..19ef2757b6c
--- /dev/null
+++ b/hosted-zone-api/src/main/java/ai/vespa/cloud/Node.java
@@ -0,0 +1,34 @@
+package ai.vespa.cloud;
+
+import java.util.Objects;
+
+/**
+ * A node that is part of a cluster of e.g. Jdisc containers.
+ *
+ * @author gjoranv
+ */
+public class Node {
+
+ private final int index;
+
+ public Node(int index) {
+ this.index = index;
+ }
+
+ /** Returns the unique index for this node in the cluster.
+ * Indices are non-negative, but not necessarily contiguous or starting from zero. */
+ public int index() { return index; }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Node node = (Node) o;
+ return index == node.index;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(index);
+ }
+}
diff --git a/hosted-zone-api/src/main/java/ai/vespa/cloud/SystemInfo.java b/hosted-zone-api/src/main/java/ai/vespa/cloud/SystemInfo.java
index 0ac93861275..c00a199e5bb 100644
--- a/hosted-zone-api/src/main/java/ai/vespa/cloud/SystemInfo.java
+++ b/hosted-zone-api/src/main/java/ai/vespa/cloud/SystemInfo.java
@@ -10,12 +10,18 @@ package ai.vespa.cloud;
public class SystemInfo {
private final Zone zone;
+ private final Node node;
- public SystemInfo(Zone zone) {
+ public SystemInfo(Zone zone, Node node) {
this.zone = zone;
+ this.node = node;
}
/** Returns the zone this is running in */
public Zone zone() { return zone; }
+
+ /** Returns the node this is running on */
+ public Node node() { return node; }
+
}
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 6bc8b395e00..9f66d4949bc 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
@@ -14,8 +14,10 @@ public class SystemInfoTest {
@Test
public void testSystemInfo() {
Zone zone = new Zone(Environment.dev, "us-west-1");
- SystemInfo info = new SystemInfo(zone);
+ Node node = new Node(0);
+ SystemInfo info = new SystemInfo(zone, node);
assertEquals(zone, info.zone());
+ assertEquals(node, info.node());
}
@Test
@@ -46,4 +48,11 @@ public class SystemInfoTest {
}
}
+ @Test
+ public void testNode() {
+ int index = 0;
+ Node node = new Node(index);
+ assertEquals(index, node.index());
+ }
+
}