aboutsummaryrefslogtreecommitdiffstats
path: root/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java
diff options
context:
space:
mode:
Diffstat (limited to 'config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java')
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java41
1 files changed, 10 insertions, 31 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java b/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java
index 9b1fb45a548..e061c5d07ee 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java
@@ -6,7 +6,7 @@ import java.util.Optional;
/**
* A capacity request.
*
- * @author lulf
+ * @author Ulf Lilleengen
* @author bratseth
*/
public final class Capacity {
@@ -16,28 +16,28 @@ public final class Capacity {
private final boolean required;
private final Optional<String> flavor;
-
+
private final NodeType type;
- private Capacity(int nodeCount, boolean required, Optional<String> flavor, NodeType type) {
+ private Capacity(int nodeCount, Optional<String> flavor, boolean required, NodeType type) {
this.nodeCount = nodeCount;
- this.flavor = flavor;
this.required = required;
+ this.flavor = flavor;
this.type = type;
}
/** Returns the number of nodes requested */
public int nodeCount() { return nodeCount; }
- /** Returns whether the requested number of nodes must be met exactly for a request for this to succeed */
- public boolean isRequired() { return required; }
-
/**
* The node flavor requested, or empty if no particular flavor is specified.
* This may be satisfied by the requested flavor or a suitable replacement
*/
public Optional<String> flavor() { return flavor; }
+ /** Returns whether the requested number of nodes must be met exactly for a request for this to succeed */
+ public boolean isRequired() { return required; }
+
/**
* Returns the node type (role) requested. This is tenant nodes by default.
* If some other type is requested the node count and flavor may be ignored
@@ -52,37 +52,16 @@ public final class Capacity {
/** Creates this from a desired node count: The request may be satisfied with a smaller number of nodes. */
public static Capacity fromNodeCount(int capacity) {
- return fromNodeCount(capacity, Optional.empty());
- }
- /** Creates this from a desired node count: The request may be satisfied with a smaller number of nodes. */
- public static Capacity fromNodeCount(int nodeCount, String flavor) {
- return fromNodeCount(nodeCount, Optional.of(flavor));
- }
- /** Creates this from a desired node count: The request may be satisfied with a smaller number of nodes. */
- public static Capacity fromNodeCount(int nodeCount, Optional<String> flavor) {
- return new Capacity(nodeCount, false, flavor, NodeType.tenant);
- }
-
- /** Creates this from a required node count: Requests must fail unless the node count can be satisfied exactly */
- public static Capacity fromRequiredNodeCount(int nodeCount) {
- return fromRequiredNodeCount(nodeCount, Optional.empty());
- }
- /** Creates this from a required node count: Requests must fail unless the node count can be satisfied exactly */
- public static Capacity fromRequiredNodeCount(int nodeCount, String flavor) {
- return fromRequiredNodeCount(nodeCount, Optional.of(flavor));
- }
- /** Creates this from a required node count: Requests must fail unless the node count can be satisfied exactly */
- public static Capacity fromRequiredNodeCount(int nodeCount, Optional<String> flavor) {
- return new Capacity(nodeCount, true, flavor, NodeType.tenant);
+ return fromNodeCount(capacity, Optional.empty(), false);
}
public static Capacity fromNodeCount(int nodeCount, Optional<String> flavor, boolean required) {
- return new Capacity(nodeCount, required, flavor, NodeType.tenant);
+ return new Capacity(nodeCount, flavor, required, NodeType.tenant);
}
/** Creates this from a node type */
public static Capacity fromRequiredNodeType(NodeType type) {
- return new Capacity(0, true, Optional.empty(), type);
+ return new Capacity(0, Optional.empty(), true, type);
}
}