From 4036e208b99167458c66c63f66639c0c3d38c3ed Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Mon, 11 Nov 2019 16:20:31 +0100 Subject: Construct HostResources from a HostSpec --- .../java/com/yahoo/vespa/model/HostResource.java | 20 ++++++++++---------- .../main/java/com/yahoo/vespa/model/HostSystem.java | 9 +-------- 2 files changed, 11 insertions(+), 18 deletions(-) (limited to 'config-model') diff --git a/config-model/src/main/java/com/yahoo/vespa/model/HostResource.java b/config-model/src/main/java/com/yahoo/vespa/model/HostResource.java index 9f523af7ed9..f053c3a3fbe 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/HostResource.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/HostResource.java @@ -6,6 +6,7 @@ import com.yahoo.config.application.api.DeployLogger; import com.yahoo.config.model.api.HostInfo; import com.yahoo.config.provision.ClusterMembership; import com.yahoo.config.provision.Flavor; +import com.yahoo.config.provision.HostSpec; import com.yahoo.config.provision.NodeResources; import java.util.ArrayList; @@ -28,9 +29,9 @@ import java.util.stream.Collectors; */ public class HostResource implements Comparable { - private final HostPorts hostPorts; + private final HostSpec spec; - public HostPorts ports() { return hostPorts; } + private final HostPorts hostPorts; private final Host host; @@ -43,22 +44,19 @@ public class HostResource implements Comparable { private Optional flavor = Optional.empty(); private Optional requestedResources = Optional.empty(); - /** The current Vespa version running on this node, or empty if not known */ - private final Optional version; - /** * Create a new {@link HostResource} bound to a specific {@link com.yahoo.vespa.model.Host}. * * @param host {@link com.yahoo.vespa.model.Host} object to bind to. */ public HostResource(Host host) { - this(host, Optional.empty()); + this(host, new HostSpec(host.getHostname(), Optional.empty())); } - public HostResource(Host host, Optional version) { - this.hostPorts = new HostPorts(host.getHostname()); + public HostResource(Host host, HostSpec spec) { this.host = host; - this.version = version; + this.spec = spec; + this.hostPorts = new HostPorts(host.getHostname()); } /** @@ -69,7 +67,9 @@ public class HostResource implements Comparable { public Host getHost() { return host; } /** Returns the current Vespa version running on this node, or null if not known */ - public Optional version() { return version; } + public Optional version() { return spec.version(); } + + public HostPorts ports() { return hostPorts; } /** * Adds service and allocates resources for it. diff --git a/config-model/src/main/java/com/yahoo/vespa/model/HostSystem.java b/config-model/src/main/java/com/yahoo/vespa/model/HostSystem.java index 6242426548b..f844385839b 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/HostSystem.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/HostSystem.java @@ -127,7 +127,7 @@ public class HostSystem extends AbstractConfigProducer { private HostResource addNewHost(HostSpec hostSpec) { Host host = Host.createHost(this, hostSpec.hostname()); - HostResource hostResource = new HostResource(host, hostSpec.version()); + HostResource hostResource = new HostResource(host, hostSpec); hostResource.setFlavor(hostSpec.flavor()); hostSpec.requestedResources().ifPresent(resources -> hostResource.setRequestedResources(resources)); hostSpec.membership().ifPresent(hostResource::addClusterMembership); @@ -147,13 +147,6 @@ public class HostSystem extends AbstractConfigProducer { public void dumpPortAllocations() { for (HostResource hr : getHosts()) { hr.ports().flushPortReservations(); -/* - System.out.println("port allocations for: "+hr.getHostname()); - NetworkPorts ports = hr.networkPorts().get(); - for (NetworkPorts.Allocation allocation: ports.allocations()) { - System.out.println("port="+allocation.port+" [type="+allocation.serviceType+", cfgId="+allocation.configId+", suffix="+allocation.portSuffix+"]"); - } -*/ } } -- cgit v1.2.3