blob: 218545383e6ecc98fce1bac72127abc5f07bd7d0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.cloud;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* The properties of a cluster of nodes.
*
* @author gjoranv
*/
public class Cluster {
private final int size;
private final List<Integer> indices;
public Cluster(int size, List<Integer> indices) {
Objects.requireNonNull(indices, "Indices cannot be null!");
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;
}
@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);
}
@Override
public int hashCode() {
return Objects.hash(size, indices);
}
}
|