aboutsummaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorArne Juul <arnej@yahoo-inc.com>2019-03-04 11:37:33 +0000
committerArne Juul <arnej@yahoo-inc.com>2019-03-04 11:37:33 +0000
commit5bd754273e36fb325eef738d896e182be66456df (patch)
tree7949e35a56a1fada20aab52131aa777305199340 /config-model
parent570671d0634376e53072d5ec90833c06c9fbf92a (diff)
simplify dynamic container setup
* instead of explictly finding the next available dynamic port, and then forcing the dynamic container to use that one, just make that container instance relax its requirements. This should end up allocating the same port as before in the normal case, but works better when reusing previous port allocations.
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/HostPorts.java3
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/Container.java10
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/Content.java2
3 files changed, 11 insertions, 4 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/HostPorts.java b/config-model/src/main/java/com/yahoo/vespa/model/HostPorts.java
index 7d4b1916eaa..c11cdb8246f 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/HostPorts.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/HostPorts.java
@@ -67,11 +67,12 @@ public class HostPorts {
/**
* Returns the baseport of the first available port range of length numPorts,
* or 0 if there is no range of that length available.
+ * TODO: remove this API
*
* @param numPorts The length of the desired port range.
* @return The baseport of the first available range, or 0 if no range is available.
*/
- public int nextAvailableBaseport(int numPorts) {
+ int nextAvailableBaseport(int numPorts) {
int range = 0;
int port = BASE_PORT;
for (; port < BASE_PORT + MAX_PORTS && (range < numPorts); port++) {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java b/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java
index 414125f3cc4..007c595b843 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java
@@ -55,6 +55,7 @@ public abstract class Container extends AbstractService implements
protected final AbstractConfigProducer parent;
private final String name;
private final boolean isHostedVespa;
+ private boolean requireSpecificPorts = true;
private String clusterName = null;
private Optional<String> hostResponseHeaderKey = Optional.empty();
@@ -210,7 +211,12 @@ public abstract class Container extends AbstractService implements
@Override
public int getWantedPort() {
- return getHttp() == null ? BASEPORT: 0;
+ return requiresWantedPort() ? BASEPORT: 0;
+ }
+
+ /** instance can use any port number for its default HTTP server */
+ public void useDynamicPorts() {
+ requireSpecificPorts = false;
}
/**
@@ -218,7 +224,7 @@ public abstract class Container extends AbstractService implements
*/
@Override
public boolean requiresWantedPort() {
- return getHttp() == null;
+ return requireSpecificPorts && (getHttp() == null);
}
public boolean requiresConsecutivePorts() {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java b/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java
index 12e4aaeca0e..e3702b0e260 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java
@@ -327,7 +327,7 @@ public class Content extends ConfigModel {
Container docprocService = new ContainerImpl(indexingCluster, containerName, index,
modelContext.getDeployState().isHosted());
index++;
- docprocService.setBasePort(host.ports().nextAvailableBaseport(docprocService.getPortCount()));
+ docprocService.useDynamicPorts();
docprocService.setHostResource(host);
docprocService.initService(modelContext.getDeployLogger());
nodes.add(docprocService);