aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/config/model/provision
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2020-10-12 08:11:59 +0200
committerJon Bratseth <bratseth@gmail.com>2020-10-12 08:11:59 +0200
commit0c006afda8be00c251cfe05dfa2d2d0d0b5aa286 (patch)
tree1b059caaa8947c4d662e0b12455c6246c2df1818 /config-model/src/main/java/com/yahoo/config/model/provision
parent982a1b1804b8773be2c5db13535fa0b0e33928b1 (diff)
Defer changes until restart
In container clusters, if it is determined that a restart is required to swicth to a new config generation, mark that config as applicable only after a restart. This avoids wasting resources on a config change just before a restart, and the potential of prematurely applying config changes which depend on other changes which are not effective before a restart has been done.
Diffstat (limited to 'config-model/src/main/java/com/yahoo/config/model/provision')
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java31
1 files changed, 19 insertions, 12 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 4c6dccebae4..4302a4dcd48 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
@@ -48,6 +48,9 @@ public class InMemoryProvisioner implements HostProvisioner {
/** Hosts which should be returned as retired */
private final Set<String> retiredHostNames;
+ /** If false, nodes returned will have the resources of the host, if true node resources will be as requested */
+ private final boolean sharedHosts;
+
/** Free hosts of each resource size */
private final ListMap<NodeResources, Host> freeNodes = new ListMap<>();
private final Map<ClusterSpec, List<HostSpec>> allocations = new LinkedHashMap<>();
@@ -63,33 +66,34 @@ public class InMemoryProvisioner implements HostProvisioner {
private Provisioned provisioned = new Provisioned();
/** Creates this with a number of nodes with resources 1, 3, 9, 1 */
- public InMemoryProvisioner(int nodeCount) {
- this(nodeCount, defaultResources);
+ public InMemoryProvisioner(int nodeCount, boolean sharedHosts) {
+ this(nodeCount, defaultResources, sharedHosts);
}
/** Creates this with a number of nodes with given resources */
- public InMemoryProvisioner(int nodeCount, NodeResources resources) {
- this(Map.of(resources, createHostInstances(nodeCount)), true, false, 0);
+ public InMemoryProvisioner(int nodeCount, NodeResources resources, boolean sharedHosts) {
+ this(Map.of(resources, createHostInstances(nodeCount)), true, false, sharedHosts, 0);
}
/** Creates this with a set of host names of the flavor 'default' */
- public InMemoryProvisioner(boolean failOnOutOfCapacity, String... hosts) {
- this(Map.of(defaultResources, toHostInstances(hosts)), failOnOutOfCapacity, false, 0);
+ public InMemoryProvisioner(boolean failOnOutOfCapacity, boolean sharedHosts, String... hosts) {
+ this(Map.of(defaultResources, toHostInstances(hosts)), failOnOutOfCapacity, false, sharedHosts, 0);
}
/** Creates this with a set of hosts of the flavor 'default' */
- public InMemoryProvisioner(Hosts hosts, boolean failOnOutOfCapacity, String ... retiredHostNames) {
- this(Map.of(defaultResources, hosts.asCollection()), failOnOutOfCapacity, false, 0, retiredHostNames);
+ public InMemoryProvisioner(Hosts hosts, boolean failOnOutOfCapacity, boolean sharedHosts, String ... retiredHostNames) {
+ this(Map.of(defaultResources, hosts.asCollection()), failOnOutOfCapacity, false, sharedHosts, 0, retiredHostNames);
}
/** Creates this with a set of hosts of the flavor 'default' */
- public InMemoryProvisioner(Hosts hosts, boolean failOnOutOfCapacity, int startIndexForClusters, String ... retiredHostNames) {
- this(Map.of(defaultResources, hosts.asCollection()), failOnOutOfCapacity, false, startIndexForClusters, retiredHostNames);
+ public InMemoryProvisioner(Hosts hosts, boolean failOnOutOfCapacity, boolean sharedHosts, int startIndexForClusters, String ... retiredHostNames) {
+ this(Map.of(defaultResources, hosts.asCollection()), failOnOutOfCapacity, false, sharedHosts, startIndexForClusters, retiredHostNames);
}
public InMemoryProvisioner(Map<NodeResources, Collection<Host>> hosts,
boolean failOnOutOfCapacity,
boolean useMaxResources,
+ boolean sharedHosts,
int startIndexForClusters,
String ... retiredHostNames) {
this.failOnOutOfCapacity = failOnOutOfCapacity;
@@ -97,8 +101,9 @@ public class InMemoryProvisioner implements HostProvisioner {
for (Map.Entry<NodeResources, Collection<Host>> hostsWithResources : hosts.entrySet())
for (Host host : hostsWithResources.getValue())
freeNodes.put(hostsWithResources.getKey(), host);
- this.retiredHostNames = Set.of(retiredHostNames);
+ this.sharedHosts = sharedHosts;
this.startIndexForClusters = startIndexForClusters;
+ this.retiredHostNames = Set.of(retiredHostNames);
}
private static Collection<Host> toHostInstances(String[] hostnames) {
@@ -160,6 +165,7 @@ public class InMemoryProvisioner implements HostProvisioner {
if (retiredHostNames.contains(host.hostname()))
i.set(retire(host));
}
+
return allocation;
}
@@ -212,8 +218,9 @@ public class InMemoryProvisioner implements HostProvisioner {
Host newHost = freeNodes.removeValue(hostResources.get(), 0);
if (freeNodes.get(hostResources.get()).isEmpty()) freeNodes.removeAll(hostResources.get());
ClusterMembership membership = ClusterMembership.from(clusterGroup, nextIndex++);
+ NodeResources resources = sharedHosts ? requestedResources : hostResources.get();
allocation.add(new HostSpec(newHost.hostname(),
- hostResources.get(), hostResources.get(), requestedResources,
+ resources, resources, requestedResources,
membership,
newHost.version(), Optional.empty(),
Optional.empty()));