diff options
author | Jon Bratseth <bratseth@gmail.com> | 2020-05-22 14:08:22 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2020-05-22 14:08:22 +0200 |
commit | 2a7af074f571fb557f3bdc756be131a15288bff6 (patch) | |
tree | 653b610a73a357e81375b4bb4f612775bbf48a29 /config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java | |
parent | f1b06c72b6e6d1dbe8c6596b0fe8ec8c6f13a9f2 (diff) |
Clean up HostSpec constructors
Diffstat (limited to 'config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java')
-rw-r--r-- | config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java | 22 |
1 files changed, 11 insertions, 11 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 1a1ed000478..6e21d0688ad 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 @@ -118,8 +118,7 @@ public class InMemoryProvisioner implements HostProvisioner { 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); - // Note: Always returns HostSpec with empty dockerImageRepo, which is OK since this method is never used when docker image repo is set - return new HostSpec(newHost.hostname(), newHost.aliases(), newHost.flavor(), Optional.empty(), newHost.version(), Optional.empty()); + return new HostSpec(newHost.hostname(), List.of(alias)); } @Override @@ -173,12 +172,12 @@ public class InMemoryProvisioner implements HostProvisioner { private HostSpec retire(HostSpec host) { return new HostSpec(host.hostname(), - host.aliases(), - host.flavor(), - Optional.of(host.membership().get().retire()), + host.realResources(), + host.advertisedResources(), + host.requestedResources().orElse(NodeResources.unspecified()), + host.membership().get().retire(), host.version(), Optional.empty(), - Optional.empty(), host.dockerImageRepo()); } @@ -190,7 +189,7 @@ public class InMemoryProvisioner implements HostProvisioner { // Check if the current allocations are compatible with the new request for (int i = allocation.size() - 1; i >= 0; i--) { Optional<NodeResources> currentResources = allocation.get(0).flavor().map(Flavor::resources); - if (currentResources.isEmpty() || requestedResources == NodeResources.unspecified) continue; + if (currentResources.isEmpty() || requestedResources.isUnspecified()) continue; if (!currentResources.get().compatibleWith(requestedResources)) { HostSpec removed = allocation.remove(i); freeNodes.put(currentResources.get(), new Host(removed.hostname())); // Return the node back to free pool @@ -202,7 +201,7 @@ public class InMemoryProvisioner implements HostProvisioner { // Find the smallest host that can fit the requested requested Optional<NodeResources> hostResources = freeNodes.keySet().stream() .sorted(new MemoryDiskCpu()) - .filter(resources -> requestedResources == NodeResources.unspecified || resources.satisfies(requestedResources)) + .filter(resources -> requestedResources.isUnspecified() || resources.satisfies(requestedResources)) .findFirst(); if (hostResources.isEmpty()) { if (canFail) @@ -214,10 +213,11 @@ 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++); - allocation.add(new HostSpec(newHost.hostname(), newHost.aliases(), - hostResources.map(Flavor::new), Optional.of(membership), + allocation.add(new HostSpec(newHost.hostname(), + hostResources.get(), hostResources.get(), requestedResources, + membership, newHost.version(), Optional.empty(), - requestedResources == NodeResources.unspecified ? Optional.empty() : Optional.of(requestedResources))); + Optional.empty())); } nextIndexInCluster.put(new Pair<>(clusterGroup.type(), clusterGroup.id()), nextIndex); |