diff options
author | gjoranv <gv@verizonmedia.com> | 2021-09-09 21:45:41 +0200 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2021-09-13 09:57:42 +0200 |
commit | c41528576df25535e0a30473a1671bb432c2af2d (patch) | |
tree | 4ed772da3902349d0d9044c4893f79f291ca7f58 /hosted-zone-api/src | |
parent | 34adf677b98abd47a2c75f43287878ac8ccef8fc (diff) |
Add Node to SystemInfo
Diffstat (limited to 'hosted-zone-api/src')
4 files changed, 58 insertions, 2 deletions
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()); + } + } |