summaryrefslogtreecommitdiffstats
path: root/config-provisioning
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2020-03-25 20:33:29 +0100
committerJon Bratseth <bratseth@verizonmedia.com>2020-03-25 20:33:29 +0100
commit1df9ad9d901df540fcb5c0fe463b3e3df5228482 (patch)
tree62978f407663bb0e5b36b50d24b31bc764efa235 /config-provisioning
parent34d5d8e4539462eb69045fc2def38d2529ba4288 (diff)
Move ClusterResources to config-provision
Diffstat (limited to 'config-provisioning')
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/ClusterResources.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterResources.java b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterResources.java
new file mode 100644
index 00000000000..8ea40010b80
--- /dev/null
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterResources.java
@@ -0,0 +1,59 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.config.provision;
+
+import java.util.Objects;
+
+/**
+ * The resources of a cluster
+ *
+ * @author bratseth
+ */
+public class ClusterResources {
+
+ /** The node count in the cluster */
+ private final int nodes;
+
+ /** The number of node groups in the cluster */
+ private final int groups;
+
+ /** The resources of each node in the cluster */
+ private final NodeResources nodeResources;
+
+ public ClusterResources(int nodes, int groups, NodeResources nodeResources) {
+ this.nodes = nodes;
+ this.groups = groups;
+ this.nodeResources = nodeResources;
+ }
+
+ /** Returns the total number of allocated nodes (over all groups) */
+ public int nodes() { return nodes; }
+ public int groups() { return groups; }
+ public NodeResources nodeResources() { return nodeResources; }
+
+ public ClusterResources with(NodeResources resources) {
+ return new ClusterResources(nodes, groups, resources);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) return true;
+ if ( ! (o instanceof ClusterResources)) return false;
+
+ ClusterResources other = (ClusterResources)o;
+ if (other.nodes != this.nodes) return false;
+ if (other.groups != this.groups) return false;
+ if (other.nodeResources != this.nodeResources) return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(nodes, groups, nodeResources);
+ }
+
+ @Override
+ public String toString() {
+ return "cluster resources: " + nodes + " * " + nodeResources + (groups > 1 ? " in " + groups + " groups" : "");
+ }
+
+}