summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/config
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2019-08-14 18:30:01 +0200
committerGitHub <noreply@github.com>2019-08-14 18:30:01 +0200
commitfc6ebf45c0ef126043eb9db4cf613958ce665411 (patch)
tree3aafe7f83ce7c4ea397d6beb523728655ddf1ade /config-model/src/main/java/com/yahoo/config
parent3f195083487971540f877c0d31688d5953263680 (diff)
parent5e4d389713bbe56fe55d490d8b31c64c2b4eae02 (diff)
Merge pull request #10274 from vespa-engine/bratseth/remove-allocation-by-flavor
Bratseth/remove allocation by flavor
Diffstat (limited to 'config-model/src/main/java/com/yahoo/config')
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java22
1 files changed, 12 insertions, 10 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java b/config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java
index 2439475e95c..448bd91c374 100644
--- a/config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java
+++ b/config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java
@@ -33,6 +33,8 @@ import java.util.Set;
*/
public class InMemoryProvisioner implements HostProvisioner {
+ private static final NodeResources defaultResources = new NodeResources(1, 3, 9);
+
/**
* If this is true an exception is thrown when all nodes are used.
* If false this will simply return nodes best effort, preferring to satisfy the
@@ -54,27 +56,27 @@ public class InMemoryProvisioner implements HostProvisioner {
/** Use this index as start index for all clusters */
private final int startIndexForClusters;
- /** Creates this with a number of nodes of the flavor 'default' */
+ /** Creates this with a number of nodes with resources 1, 3, 9 */
public InMemoryProvisioner(int nodeCount) {
- this(Collections.singletonMap(NodeResources.fromLegacyName("default"),
+ this(Collections.singletonMap(defaultResources,
createHostInstances(nodeCount)), true, 0);
}
/** Creates this with a set of host names of the flavor 'default' */
public InMemoryProvisioner(boolean failOnOutOfCapacity, String... hosts) {
- this(Collections.singletonMap(NodeResources.fromLegacyName("default"),
+ this(Collections.singletonMap(defaultResources,
toHostInstances(hosts)), failOnOutOfCapacity, 0);
}
/** Creates this with a set of hosts of the flavor 'default' */
public InMemoryProvisioner(Hosts hosts, boolean failOnOutOfCapacity, String ... retiredHostNames) {
- this(Collections.singletonMap(NodeResources.fromLegacyName("default"),
+ this(Collections.singletonMap(defaultResources,
hosts.asCollection()), failOnOutOfCapacity, 0, retiredHostNames);
}
/** Creates this with a set of hosts of the flavor 'default' */
public InMemoryProvisioner(Hosts hosts, boolean failOnOutOfCapacity, int startIndexForClusters, String ... retiredHostNames) {
- this(Collections.singletonMap(NodeResources.fromLegacyName("default"),
+ this(Collections.singletonMap(defaultResources,
hosts.asCollection()), failOnOutOfCapacity, startIndexForClusters, retiredHostNames);
}
@@ -110,9 +112,9 @@ public class InMemoryProvisioner implements HostProvisioner {
@Override
public HostSpec allocateHost(String alias) {
if (legacyMapping.containsKey(alias)) return legacyMapping.get(alias);
- List<Host> defaultHosts = freeNodes.get(NodeResources.fromLegacyName("default"));
- if (defaultHosts.isEmpty()) throw new IllegalArgumentException("No more hosts of default flavor available");
- Host newHost = freeNodes.removeValue(NodeResources.fromLegacyName("default"), 0);
+ List<Host> defaultHosts = freeNodes.get(defaultResources);
+ if (defaultHosts.isEmpty()) throw new IllegalArgumentException("No more hosts with default resources available");
+ Host newHost = freeNodes.removeValue(defaultResources, 0);
HostSpec hostSpec = new HostSpec(newHost.hostname(), newHost.aliases(), newHost.flavor(), Optional.empty(), newHost.version());
legacyMapping.put(alias, hostSpec);
return hostSpec;
@@ -128,11 +130,11 @@ public class InMemoryProvisioner implements HostProvisioner {
int capacity = failOnOutOfCapacity || requestedCapacity.isRequired()
? requestedCapacity.nodeCount()
- : Math.min(requestedCapacity.nodeCount(), freeNodes.get(NodeResources.fromLegacyName("default")).size() + totalAllocatedTo(cluster));
+ : Math.min(requestedCapacity.nodeCount(), freeNodes.get(defaultResources).size() + totalAllocatedTo(cluster));
if (groups > capacity)
groups = capacity;
- NodeResources nodeResources = requestedCapacity.nodeResources().orElse(NodeResources.fromLegacyName("default"));
+ NodeResources nodeResources = requestedCapacity.nodeResources().orElse(defaultResources);
List<HostSpec> allocation = new ArrayList<>();
if (groups == 1) {