summaryrefslogtreecommitdiffstats
path: root/config-provisioning
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-06-26 17:38:08 +0200
committerJon Bratseth <bratseth@oath.com>2018-06-26 17:38:08 +0200
commite49550176a0a000941412f874efd95b21e424183 (patch)
treee0aaf35c2d5225caca40568b88d01f61f387792c /config-provisioning
parent31bce0b6fea68f8551045f7aca8706bae1ff060d (diff)
Don't fail on out of capacity on bootstrap
Diffstat (limited to 'config-provisioning')
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java54
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java13
2 files changed, 20 insertions, 47 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 299b7282e4a..5204da08307 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
@@ -15,13 +15,16 @@ public final class Capacity {
private final boolean required;
+ private final boolean canFail;
+
private final Optional<String> flavor;
private final NodeType type;
- private Capacity(int nodeCount, Optional<String> flavor, boolean required, NodeType type) {
+ private Capacity(int nodeCount, Optional<String> flavor, boolean required, boolean canFail, NodeType type) {
this.nodeCount = nodeCount;
this.required = required;
+ this.canFail = canFail;
this.flavor = flavor;
this.type = type;
}
@@ -39,6 +42,13 @@ public final class Capacity {
public boolean isRequired() { return required; }
/**
+ * Returns true if an exception should be thrown if the specified capacity can not be satisfied
+ * (to whatever policies are applied and taking required true/false into account).
+ * Returns false if it is preferable to still succeed with partially satisfied capacity.
+ */
+ public boolean canFail() { return canFail; }
+
+ /**
* 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
* and all nodes of the requested type returned instead.
@@ -52,46 +62,22 @@ 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(), false);
+ return fromNodeCount(capacity, Optional.empty(), false, true);
}
+ // TODO: Remove after July 2018
+ @Deprecated
public static Capacity fromNodeCount(int nodeCount, Optional<String> flavor, boolean required) {
- return new Capacity(nodeCount, flavor, required, NodeType.tenant);
- }
-
- /** Creates this from a node type */
- public static Capacity fromRequiredNodeType(NodeType type) {
- return new Capacity(0, Optional.empty(), true, type);
- }
-
- /** Creates this from a desired node count: The request may be satisfied with a smaller number of nodes. */
- // TODO: Remove after April 2018
- 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. */
- // TODO: Remove after April 2018
- public static Capacity fromNodeCount(int nodeCount, Optional<String> flavor) {
- return new Capacity(nodeCount, flavor, false, NodeType.tenant);
+ return new Capacity(nodeCount, flavor, required, true, NodeType.tenant);
}
- /** Creates this from a required node count: Requests must fail unless the node count can be satisfied exactly */
- // TODO: Remove after April 2018
- public static Capacity fromRequiredNodeCount(int nodeCount) {
- return fromRequiredNodeCount(nodeCount, Optional.empty());
+ public static Capacity fromNodeCount(int nodeCount, Optional<String> flavor, boolean required, boolean canFail) {
+ return new Capacity(nodeCount, flavor, required, canFail, NodeType.tenant);
}
- /** Creates this from a required node count: Requests must fail unless the node count can be satisfied exactly */
- // TODO: Remove after April 2018
- 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 */
- // TODO: Remove after April 2018
- public static Capacity fromRequiredNodeCount(int nodeCount, Optional<String> flavor) {
- return new Capacity(nodeCount, flavor, true, NodeType.tenant);
+ /** Creates this from a node type */
+ public static Capacity fromRequiredNodeType(NodeType type) {
+ return new Capacity(0, Optional.empty(), true, false, type);
}
}
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java
index 837e062e356..caacabd09b5 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java
@@ -51,11 +51,6 @@ public final class ClusterSpec {
*/
public boolean isExclusive() { return exclusive; }
- // TODO: Remove after April 2018
- public ClusterSpec changeGroup(Optional<Group> newGroup) {
- return with(newGroup);
- }
-
public ClusterSpec with(Optional<Group> newGroup) {
return new ClusterSpec(type, id, newGroup, vespaVersion, exclusive);
}
@@ -64,18 +59,10 @@ public final class ClusterSpec {
return new ClusterSpec(type, id, groupId, vespaVersion, exclusive);
}
- // TODO: Remove after April 2018
- public static ClusterSpec request(Type type, Id id, Version vespaVersion) {
- return request(type, id, vespaVersion, false);
- }
public static ClusterSpec request(Type type, Id id, Version vespaVersion, boolean exclusive) {
return new ClusterSpec(type, id, Optional.empty(), vespaVersion, exclusive);
}
- // TODO: Remove after April 2018
- public static ClusterSpec from(Type type, Id id, Group groupId, Version vespaVersion) {
- return new ClusterSpec(type, id, Optional.of(groupId), vespaVersion, false);
- }
public static ClusterSpec from(Type type, Id id, Group groupId, Version vespaVersion, boolean exclusive) {
return new ClusterSpec(type, id, Optional.of(groupId), vespaVersion, exclusive);
}