summaryrefslogtreecommitdiffstats
path: root/config-provisioning/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'config-provisioning/src/main/java/com')
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/Flavor.java48
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/NodeFlavors.java22
2 files changed, 7 insertions, 63 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/Flavor.java b/config-provisioning/src/main/java/com/yahoo/config/provision/Flavor.java
index 93ca0a77806..dd33cd58d1d 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/Flavor.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/Flavor.java
@@ -22,7 +22,6 @@ public class Flavor {
private final Type type;
private final double bandwidth;
private final boolean retired;
- private List<Flavor> replacesFlavors;
/** The hardware resources of this flavor */
private NodeResources resources;
@@ -39,7 +38,6 @@ public class Flavor {
flavorConfig.fastDisk() ? NodeResources.DiskSpeed.fast : NodeResources.DiskSpeed.slow);
this.bandwidth = flavorConfig.bandwidth();
this.retired = flavorConfig.retired();
- this.replacesFlavors = new ArrayList<>();
}
/** Creates a *node* flavor from a node resources spec */
@@ -51,7 +49,6 @@ public class Flavor {
this.type = Type.DOCKER_CONTAINER;
this.bandwidth = 1;
this.retired = false;
- this.replacesFlavors = List.of();
this.resources = resources;
}
@@ -94,54 +91,15 @@ public class Flavor {
/** Convenience, returns getType() == Type.DOCKER_CONTAINER */
public boolean isDocker() { return type == Type.DOCKER_CONTAINER; }
- /**
- * Returns the canonical name of this flavor - which is the name which should be used as an interface to users.
- * The canonical name of this flavor is:
- * <ul>
- * <li>If it replaces one flavor, the canonical name of the flavor it replaces
- * <li>If it replaces multiple or no flavors - itself
- * </ul>
- *
- * The logic is that we can use this to capture the gritty details of configurations in exact flavor names
- * but also encourage users to refer to them by a common name by letting such flavor variants declare that they
- * replace the canonical name we want. However, if a node replaces multiple names, we have no basis for choosing one
- * of them as the canonical, so we return the current as canonical.
- */
public String canonicalName() {
- return isCanonical() ? name : replacesFlavors.get(0).canonicalName();
+ return name;
}
- /** Returns whether this is a canonical flavor */
- public boolean isCanonical() {
- return replacesFlavors.size() != 1;
- }
-
/**
- * The flavors this (directly) replaces.
- * This is immutable if this is frozen, and a mutable list otherwise.
- */
- public List<Flavor> replaces() { return replacesFlavors; }
-
- /**
- * Returns whether this flavor satisfies the requested flavor, either directly
- * (by being the same), or by directly or indirectly replacing it
+ * Returns whether this flavor satisfies the requested flavor
*/
public boolean satisfies(Flavor flavor) {
- if (this.equals(flavor)) {
- return true;
- }
- if (this.retired) {
- return false;
- }
- for (Flavor replaces : replacesFlavors)
- if (replaces.satisfies(flavor))
- return true;
- return false;
- }
-
- /** Irreversibly freezes the content of this */
- public void freeze() {
- replacesFlavors = List.copyOf(replacesFlavors);
+ return this.equals(flavor);
}
@Override
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/NodeFlavors.java b/config-provisioning/src/main/java/com/yahoo/config/provision/NodeFlavors.java
index 5dbfc413de4..a76c50702c6 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/NodeFlavors.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/NodeFlavors.java
@@ -68,25 +68,11 @@ public class NodeFlavors {
for (FlavorsConfig.Flavor flavorConfig : config.flavor()) {
flavors.put(flavorConfig.name(), new Flavor(flavorConfig));
}
- // Second pass, set flavorReplacesConfig to point to correct flavor.
- for (FlavorsConfig.Flavor flavorConfig : config.flavor()) {
- Flavor flavor = flavors.get(flavorConfig.name());
- for (FlavorsConfig.Flavor.Replaces flavorReplacesConfig : flavorConfig.replaces()) {
- if (! flavors.containsKey(flavorReplacesConfig.name())) {
- throw new IllegalStateException("Replaces for " + flavor.name() +
- " pointing to a non existing flavor: " + flavorReplacesConfig.name());
- }
- flavor.replaces().add(flavors.get(flavorReplacesConfig.name()));
- }
- flavor.freeze();
- }
- // Third pass, ensure that retired flavors have a replacement
+
+ // Ensure that retired flavors have a replacement
for (Flavor flavor : flavors.values()) {
- if (flavor.isRetired() && !hasReplacement(flavors.values(), flavor)) {
- throw new IllegalStateException(
- String.format("Flavor '%s' is retired, but has no replacement", flavor.name())
- );
- }
+ if (flavor.isRetired() && !hasReplacement(flavors.values(), flavor))
+ throw new IllegalStateException(String.format("Flavor '%s' is retired, but has no replacement", flavor.name()));
}
return flavors.values();
}