diff options
Diffstat (limited to 'hosted-zone-api/src/main/java/ai/vespa/cloud/Cluster.java')
-rw-r--r-- | hosted-zone-api/src/main/java/ai/vespa/cloud/Cluster.java | 25 |
1 files changed, 18 insertions, 7 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 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); } } |