diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-11-11 16:20:31 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-11-11 16:20:31 +0100 |
commit | 4036e208b99167458c66c63f66639c0c3d38c3ed (patch) | |
tree | 8203e9611a6e55b66b2158aadec3c5474741abc3 /config-model | |
parent | eef849ac5d308b9e910fc4f679a9360acf459239 (diff) |
Construct HostResources from a HostSpec
Diffstat (limited to 'config-model')
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/HostResource.java | 20 | ||||
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/HostSystem.java | 9 |
2 files changed, 11 insertions, 18 deletions
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<HostResource> { - 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<HostResource> { private Optional<Flavor> flavor = Optional.empty(); private Optional<NodeResources> requestedResources = Optional.empty(); - /** The current Vespa version running on this node, or empty if not known */ - private final Optional<Version> 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> 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<HostResource> { public Host getHost() { return host; } /** Returns the current Vespa version running on this node, or null if not known */ - public Optional<Version> version() { return version; } + public Optional<Version> 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<Host> { 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<Host> { 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+"]"); - } -*/ } } |