aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne H Juul <arnej27959@users.noreply.github.com>2019-08-04 19:40:07 +0200
committerGitHub <noreply@github.com>2019-08-04 19:40:07 +0200
commitd0e5d87988013462ef4399c8eba9dd2bf8c2203e (patch)
tree225f35284a1708578a5466d30bb7d2ba4769fb11
parent7843f858c90dd58a996860e4e3910cc5a66e0f63 (diff)
Revert "Arnej/refactor requestor api 4"
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/AbstractService.java18
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/ConfigProxy.java11
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/ConfigSentinel.java14
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/HostPorts.java31
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/Logd.java12
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/NetworkPortRequestor.java17
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/PortAllocBridge.java48
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/admin/Configserver.java22
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/admin/LogForwarder.java10
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/admin/Logserver.java9
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/admin/Slobrok.java22
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainer.java29
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/Container.java60
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/ContentNode.java13
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/generic/service/Service.java5
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/Dispatch.java14
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java16
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/TransactionLogServer.java6
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/HostPortsTest.java18
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/HostResourceTest.java12
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerTest.java5
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigValueChangeValidatorTest.java4
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StartupCommandChangeValidatorTest.java4
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/test/ApiService.java4
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/test/ModelAmendingTestCase.java4
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/test/ParentService.java4
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/test/SimpleService.java10
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/utils/FileSenderTest.java4
28 files changed, 185 insertions, 241 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/AbstractService.java b/config-model/src/main/java/com/yahoo/vespa/model/AbstractService.java
index 72c475fb091..06cdfa5e664 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/AbstractService.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/AbstractService.java
@@ -196,6 +196,16 @@ public abstract class AbstractService extends AbstractConfigProducer<AbstractCon
}
/**
+ * Override if the services does not require consecutive port numbers. I.e. if any ports
+ * in addition to the baseport should be allocated from Vespa's default port range.
+ *
+ * @return true by default
+ */
+ public boolean requiresConsecutivePorts() {
+ return true;
+ }
+
+ /**
* Gets the ports metainfo object. The service implementation
* must populate this object in the constructor.
*/
@@ -444,6 +454,14 @@ public abstract class AbstractService extends AbstractConfigProducer<AbstractCon
this.basePort = wantedPort;
}
+ /** Temporary hack: reserve port with index 0
+ * Must be done this way since the system test framework
+ * currently uses the first port as container http port.
+ */
+ public void reservePortPrepended(int port, String suffix) {
+ ports.add(0, hostResource.ports().requireNetworkPort(port, this, suffix));
+ }
+
public void setHostResource(HostResource hostResource) {
this.hostResource = hostResource;
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/ConfigProxy.java b/config-model/src/main/java/com/yahoo/vespa/model/ConfigProxy.java
index adb49fff9df..4fe13c8bede 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/ConfigProxy.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/ConfigProxy.java
@@ -30,12 +30,6 @@ public class ConfigProxy extends AbstractService {
setProp("clustername", "admin");
}
- @Override
- public void allocatePorts(int start, PortAllocBridge from) {
- if (start == 0) start = BASEPORT;
- from.requirePort(start, "rpc");
- }
-
/**
* Returns the desired base port for this service.
*/
@@ -53,4 +47,9 @@ public class ConfigProxy extends AbstractService {
*/
public int getPortCount() { return 1; }
+ @Override
+ public String[] getPortSuffixes() {
+ return new String[]{"rpc"};
+ }
+
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/ConfigSentinel.java b/config-model/src/main/java/com/yahoo/vespa/model/ConfigSentinel.java
index d15db6b4a55..3f1202ccfd7 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/ConfigSentinel.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/ConfigSentinel.java
@@ -14,8 +14,6 @@ import com.yahoo.config.provision.Zone;
*/
public class ConfigSentinel extends AbstractService implements SentinelConfig.Producer {
- static final int BASEPORT = 19097;
-
private final ApplicationId applicationId;
private final Zone zone;
@@ -34,13 +32,6 @@ public class ConfigSentinel extends AbstractService implements SentinelConfig.Pr
setProp("clustername", "admin");
}
- @Override
- public void allocatePorts(int start, PortAllocBridge from) {
- if (start == 0) start = BASEPORT;
- from.requirePort(start++, "rpc");
- from.requirePort(start++, "http");
- }
-
/**
* Returns the desired base port for this service.
*/
@@ -57,6 +48,11 @@ public class ConfigSentinel extends AbstractService implements SentinelConfig.Pr
public int getPortCount() { return 2; }
@Override
+ public String[] getPortSuffixes() {
+ return new String[]{ "rpc", "http" };
+ }
+
+ @Override
public int getHealthPort() {return getRelativePort(1); }
/**
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 5f55c78c1e4..69b692e3ad9 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
@@ -137,9 +137,34 @@ public class HostPorts {
/** Allocate all ports for a service */
List<Integer> allocatePorts(NetworkPortRequestor service, int wantedPort) {
- PortAllocBridge allocator = new PortAllocBridge(this, service);
- service.allocatePorts(wantedPort, allocator);
- return allocator.result();
+ List<Integer> ports = new ArrayList<>();
+ final int count = service.getPortCount();
+ if (count < 1)
+ return ports;
+
+ String[] suffixes = service.getPortSuffixes();
+ if (suffixes.length != count) {
+ throw new IllegalArgumentException("service "+service+" had "+suffixes.length+" port suffixes, but port count "+count+", mismatch");
+ }
+
+ if (wantedPort > 0) {
+ boolean force = service.requiresWantedPort();
+ if (service.requiresConsecutivePorts()) {
+ for (int i = 0; i < count; i++) {
+ ports.add(wantNetworkPort(wantedPort+i, service, suffixes[i], force));
+ }
+ } else {
+ ports.add(wantNetworkPort(wantedPort, service, suffixes[0], force));
+ for (int i = 1; i < count; i++) {
+ ports.add(allocateNetworkPort(service, suffixes[i]));
+ }
+ }
+ } else {
+ for (int i = 0; i < count; i++) {
+ ports.add(allocateNetworkPort(service, suffixes[i]));
+ }
+ }
+ return ports;
}
public void flushPortReservations() {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/Logd.java b/config-model/src/main/java/com/yahoo/vespa/model/Logd.java
index 300f35b62d3..3c7f1ba6cfa 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/Logd.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/Logd.java
@@ -14,7 +14,6 @@ public class Logd
extends AbstractService
implements LogdConfig.Producer
{
- static final int BASEPORT = 19089;
/**
* Creates a new Logd instance.
@@ -26,12 +25,6 @@ public class Logd
portsMeta.on(0).tag("http").tag("state");
}
- @Override
- public void allocatePorts(int start, PortAllocBridge from) {
- if (start == 0) start = BASEPORT;
- from.wantPort(start, "http");
- }
-
/**
* Logd needs a state port.
*
@@ -39,6 +32,11 @@ public class Logd
*/
public int getPortCount() { return 1; }
+ @Override
+ public String[] getPortSuffixes() {
+ return new String[]{"http"};
+ }
+
/** Returns the desired base port for this service. */
public int getWantedPort() { return 19089; }
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/NetworkPortRequestor.java b/config-model/src/main/java/com/yahoo/vespa/model/NetworkPortRequestor.java
index f8337219f54..96870ee30d8 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/NetworkPortRequestor.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/NetworkPortRequestor.java
@@ -26,9 +26,6 @@ public interface NetworkPortRequestor {
*/
default int getWantedPort() { return 0; }
- /** allocate the ports you need */
- void allocatePorts(int start, PortAllocBridge from);
-
/**
* Returns the number of ports needed by this service.
* User-defined ports for container http servers should not be counted, as those
@@ -44,4 +41,18 @@ public interface NetworkPortRequestor {
* @return true if this Service requires the wanted base port.
*/
default boolean requiresWantedPort() { return false; }
+
+ /**
+ * Override if the services does not require consecutive port numbers. I.e. if any ports
+ * in addition to the baseport should be allocated from Vespa's default port range.
+ *
+ * @return true by default
+ */
+ default boolean requiresConsecutivePorts() { return true; }
+
+ /**
+ * Return names for each port requested.
+ * The size of the returned array must be equal to getPortCount().
+ */
+ String[] getPortSuffixes();
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/PortAllocBridge.java b/config-model/src/main/java/com/yahoo/vespa/model/PortAllocBridge.java
deleted file mode 100644
index ac518b3a7d9..00000000000
--- a/config-model/src/main/java/com/yahoo/vespa/model/PortAllocBridge.java
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-package com.yahoo.vespa.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * API for allocating network ports
- * This class acts as a bridge between NetworkPortRequestor and HostPorts
- * for a single call to allocatePorts(), gathering the resulting port
- * allocations in a list of integers.
- * @author arnej
- */
-public class PortAllocBridge {
-
- private HostPorts host;
- private NetworkPortRequestor service;
- private List<Integer> ports = new ArrayList<>();
-
- public PortAllocBridge(HostPorts host, NetworkPortRequestor service) {
- this.host = host;
- this.service = service;
- }
-
- public int requirePort(int port, String suffix) {
- int got = host.requireNetworkPort(port, service, suffix);
- ports.add(got);
- return got;
- }
-
- public int wantPort(int port, String suffix) {
- int got = host.wantNetworkPort(port, service, suffix);
- ports.add(got);
- return got;
- }
-
- public int allocatePort(String suffix) {
- int got = host.allocateNetworkPort(service, suffix);
- ports.add(got);
- return got;
- }
-
- public List<Integer> result() {
- return ports;
- }
-
-}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/Configserver.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/Configserver.java
index 7c31da19cf8..e8ca03b277d 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/admin/Configserver.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/Configserver.java
@@ -3,8 +3,6 @@ package com.yahoo.vespa.model.admin;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.model.AbstractService;
-import com.yahoo.vespa.model.PortAllocBridge;
-
/**
* Represents a Configserver. There may be one or more Configservers in a
@@ -32,21 +30,6 @@ public class Configserver extends AbstractService {
setProp("clustername", "admin");
}
- @Override
- public void allocatePorts(int start, PortAllocBridge from) {
- if (requiresWantedPort()) {
- from.requirePort(start++, "rpc");
- from.requirePort(start++, "http");
- } else if (start == 0) {
- from.allocatePort("rpc");
- from.allocatePort("http");
- } else {
- from.wantPort(start++, "rpc");
- from.wantPort(start++, "http");
- }
- }
-
-
/**
* Returns the desired base port for this service.
*/
@@ -67,6 +50,11 @@ public class Configserver extends AbstractService {
*/
public int getPortCount() { return 2; }
+ @Override
+ public String[] getPortSuffixes() {
+ return new String[]{ "rpc", "http" };
+ }
+
private int getConfigServerRpcPort() {
return getRelativePort(0);
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/LogForwarder.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/LogForwarder.java
index f93a3b39ad6..1f77b96244f 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/admin/LogForwarder.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/LogForwarder.java
@@ -4,7 +4,6 @@ package com.yahoo.vespa.model.admin;
import com.yahoo.cloud.config.LogforwarderConfig;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.model.AbstractService;
-import com.yahoo.vespa.model.PortAllocBridge;
public class LogForwarder extends AbstractService implements LogforwarderConfig.Producer {
@@ -51,10 +50,6 @@ public class LogForwarder extends AbstractService implements LogforwarderConfig.
return new Config(null, null, null, null);
}
- // LogForwarder does not need any ports.
- @Override
- public void allocatePorts(int start, PortAllocBridge from) { }
-
/**
* LogForwarder does not need any ports.
*
@@ -62,6 +57,11 @@ public class LogForwarder extends AbstractService implements LogforwarderConfig.
*/
public int getPortCount() { return 0; }
+ @Override
+ public String[] getPortSuffixes() {
+ return null;
+ }
+
/**
* @return The command used to start LogForwarder
*/
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/Logserver.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/Logserver.java
index cdc3fd4c4d4..eca8fd40e69 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/admin/Logserver.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/Logserver.java
@@ -3,7 +3,6 @@ package com.yahoo.vespa.model.admin;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.model.AbstractService;
-import com.yahoo.vespa.model.PortAllocBridge;
/**
* Represents the Logserver. There is exactly one logserver in a Vespa
@@ -69,12 +68,8 @@ public class Logserver extends AbstractService {
}
@Override
- public void allocatePorts(int start, PortAllocBridge from) {
- int port = (start == 0) ? getWantedPort() : start;
- from.requirePort(port++, "rpc");
- from.requirePort(port++, "unused/1");
- from.requirePort(port++, "unused/2");
- from.requirePort(port++, "unused/3");
+ public String[] getPortSuffixes() {
+ return new String[]{ "rpc", "unused/1", "unused/2", "unused/3" };
}
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/Slobrok.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/Slobrok.java
index 43f02f8b6d4..2c4fa83d02b 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/admin/Slobrok.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/Slobrok.java
@@ -4,7 +4,6 @@ package com.yahoo.vespa.model.admin;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.config.core.StateserverConfig;
import com.yahoo.vespa.model.AbstractService;
-import com.yahoo.vespa.model.PortAllocBridge;
/**
* Represents a Slobrok service.
@@ -14,8 +13,6 @@ import com.yahoo.vespa.model.PortAllocBridge;
public class Slobrok extends AbstractService implements StateserverConfig.Producer {
private static final long serialVersionUID = 1L;
- public final static int BASEPORT = 19099;
-
@Override
public void getConfig(StateserverConfig.Builder builder) {
builder.httpport(getHealthPort());
@@ -35,9 +32,14 @@ public class Slobrok extends AbstractService implements StateserverConfig.Produc
}
@Override
+ public boolean requiresConsecutivePorts() {
+ return false;
+ }
+
+ @Override
public int getWantedPort() {
if (getId() == 1) {
- return BASEPORT;
+ return 19099;
} else {
return 0;
}
@@ -47,13 +49,6 @@ public class Slobrok extends AbstractService implements StateserverConfig.Produc
return "exec $ROOT/sbin/vespa-slobrok -p " + getRpcPort() + " -c " + getConfigId();
}
- @Override
- public void allocatePorts(int start, PortAllocBridge from) {
- if (start == 0) start = BASEPORT;
- from.wantPort(start, "rpc");
- from.allocatePort("http");
- }
-
/**
* @return The number of ports needed by the slobrok.
*/
@@ -61,6 +56,11 @@ public class Slobrok extends AbstractService implements StateserverConfig.Produc
return 2;
}
+ @Override
+ public String[] getPortSuffixes() {
+ return new String[] { "rpc", "http" };
+ }
+
/**
* @return The port on which this slobrok should respond
*/
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainer.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainer.java
index 01168c59442..2a698233713 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainer.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainer.java
@@ -13,7 +13,6 @@ import ai.vespa.metricsproxy.service.VespaServicesConfig;
import com.yahoo.config.model.api.container.ContainerServiceType;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.config.provision.ClusterMembership;
-import com.yahoo.vespa.model.PortAllocBridge;
import com.yahoo.vespa.model.container.Container;
import java.util.LinkedHashMap;
@@ -59,15 +58,6 @@ public class MetricsProxyContainer extends Container implements
}
int metricsRpcPortOffset() {
- if (numHttpServerPorts != 2) {
- throw new IllegalArgumentException("expecting 2 http server ports");
- }
- if (numMessageBusPorts() != 0) {
- throw new IllegalArgumentException("expecting 0 message bus ports");
- }
- if (numRpcPorts() != 1) {
- throw new IllegalArgumentException("expecting 1 rpc port");
- }
return numHttpServerPorts + numMessageBusPorts() + numRpcPorts();
}
@@ -76,11 +66,9 @@ public class MetricsProxyContainer extends Container implements
return METRICS_PROXY_CONTAINER;
}
- static public int BASEPORT = 19092;
-
@Override
public int getWantedPort() {
- return BASEPORT;
+ return 19092;
}
@Override
@@ -90,12 +78,8 @@ public class MetricsProxyContainer extends Container implements
// Must have predictable ports for both http and rpc.
@Override
- public void allocatePorts(int start, PortAllocBridge from) {
- if (start == 0) start = BASEPORT;
- from.wantPort(start++, "http");
- from.wantPort(start++, "http/1");
- from.wantPort(start++, "rpc/admin");
- from.wantPort(start++, "rpc/metrics");
+ public boolean requiresConsecutivePorts() {
+ return true;
}
@Override
@@ -110,6 +94,13 @@ public class MetricsProxyContainer extends Container implements
}
@Override
+ public String[] getPortSuffixes() {
+ var suffixes = super.getPortSuffixes();
+ suffixes[metricsRpcPortOffset()] = "rpc/metrics";
+ return suffixes;
+ }
+
+ @Override
public void getConfig(RpcConnectorConfig.Builder builder) {
builder.port(getRelativePort(metricsRpcPortOffset()));
}
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 3bc68e4a879..52abe8e8fde 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
@@ -14,7 +14,6 @@ import com.yahoo.osgi.provider.model.ComponentModel;
import com.yahoo.search.config.QrStartConfig;
import com.yahoo.vespa.defaults.Defaults;
import com.yahoo.vespa.model.AbstractService;
-import com.yahoo.vespa.model.PortAllocBridge;
import com.yahoo.vespa.model.application.validation.RestartConfigs;
import com.yahoo.vespa.model.container.component.Component;
import com.yahoo.vespa.model.container.component.ComponentGroup;
@@ -158,6 +157,8 @@ public abstract class Container extends AbstractService implements
if (getHttp() == null) {
initDefaultJettyConnector();
+ } else {
+ reserveHttpPortsPrepended();
}
tagServers();
@@ -180,6 +181,14 @@ public abstract class Container extends AbstractService implements
}
}
+ private void reserveHttpPortsPrepended() {
+ if (getHttp() != null && getHttp().getHttpServer() != null) {
+ for (ConnectorFactory connectorFactory : getHttp().getHttpServer().getConnectorFactories()) {
+ reservePortPrepended(getPort(connectorFactory), "http/" + connectorFactory.getName());
+ }
+ }
+ }
+
private int getPort(ConnectorFactory connectorFactory) {
return connectorFactory.getListenPort();
}
@@ -224,8 +233,12 @@ public abstract class Container extends AbstractService implements
return requireSpecificPorts && (getHttp() == null);
}
+ public boolean requiresConsecutivePorts() {
+ return false;
+ }
+
/**
- * @return the number of ports needed by the Container
+ * @return the number of ports needed by the Container except those reserved manually(reservePortPrepended)
*/
public int getPortCount() {
// TODO Vespa 8: remove +2, only here for historical reasons
@@ -234,39 +247,30 @@ public abstract class Container extends AbstractService implements
}
@Override
- public void allocatePorts(int start, PortAllocBridge from) {
- if (start == 0) start = BASEPORT;
- int off = 2;
- if (getHttp() == null) {
- if (requireSpecificPorts) {
- from.requirePort(start, "http");
- } else {
- from.allocatePort("http");
- }
- from.allocatePort("http/1");
- } else if (getHttp().getHttpServer() == null) {
- // no http server ports
- } else {
- for (ConnectorFactory connectorFactory : getHttp().getHttpServer().getConnectorFactories()) {
- int port = getPort(connectorFactory);
- String name = "http/" + connectorFactory.getName();
- from.requirePort(port, name);
- }
+ public String[] getPortSuffixes() {
+ // TODO clean up this mess
+ int n = getPortCount();
+ String[] suffixes = new String[n];
+ int off = 0;
+ int httpPorts = (getHttp() != null) ? 0 : numHttpServerPorts;
+ if (httpPorts > 0) {
+ suffixes[off++] = "http";
+ }
+ for (int i = 1; i < httpPorts; i++) {
+ suffixes[off++] = "http/" + i;
}
if (messageBusEnabled()) {
- from.allocatePort("messaging");
- ++off;
+ suffixes[off++] = "messaging";
}
if (rpcServerEnabled()) {
- from.allocatePort("rpc/admin");
- ++off;
+ suffixes[off++] = "rpc/admin";
}
- // TODO: remove this
- if (getHttp() == null) {
- from.allocatePort("unused/" + off);
+ while (off < n) {
+ suffixes[off] = "unused/" + off;
++off;
- from.allocatePort("unused/" + off);
}
+ assert (off == n);
+ return suffixes;
}
/**
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentNode.java b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentNode.java
index 9a8a57f12ea..d25396c6a50 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentNode.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentNode.java
@@ -8,7 +8,6 @@ import com.yahoo.vespa.config.content.core.StorServerConfig;
import com.yahoo.vespa.config.content.core.StorStatusConfig;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.model.AbstractService;
-import com.yahoo.vespa.model.PortAllocBridge;
import com.yahoo.vespa.model.application.validation.RestartConfigs;
/**
@@ -57,16 +56,8 @@ public abstract class ContentNode extends AbstractService
public int getPortCount() { return 3; }
@Override
- public void allocatePorts(int start, PortAllocBridge from) {
- if (start == 0) {
- from.allocatePort("messaging");
- from.allocatePort("rpc");
- from.allocatePort("http");
- } else {
- from.wantPort(start++, "messaging");
- from.wantPort(start++, "rpc");
- from.wantPort(start++, "http");
- }
+ public String[] getPortSuffixes() {
+ return new String[] { "messaging", "rpc", "http" };
}
@Override
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/generic/service/Service.java b/config-model/src/main/java/com/yahoo/vespa/model/generic/service/Service.java
index 325f511edf1..0d30bade53c 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/generic/service/Service.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/generic/service/Service.java
@@ -3,7 +3,6 @@ package com.yahoo.vespa.model.generic.service;
import com.yahoo.vespa.model.AbstractService;
import com.yahoo.vespa.model.HostResource;
-import com.yahoo.vespa.model.PortAllocBridge;
/**
* An application specific generic service
@@ -25,7 +24,9 @@ public class Service extends AbstractService {
}
@Override
- public void allocatePorts(int start, PortAllocBridge from) { }
+ public String[] getPortSuffixes() {
+ return null;
+ }
@Override
public String getStartupCommand() {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/Dispatch.java b/config-model/src/main/java/com/yahoo/vespa/model/search/Dispatch.java
index 2e821a67cb2..c50f772d8d0 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/Dispatch.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/search/Dispatch.java
@@ -5,7 +5,6 @@ import com.yahoo.vespa.config.search.core.FdispatchrcConfig;
import com.yahoo.vespa.config.search.core.PartitionsConfig;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.model.AbstractService;
-import com.yahoo.vespa.model.PortAllocBridge;
import com.yahoo.vespa.model.application.validation.RestartConfigs;
import com.yahoo.vespa.model.content.SearchCoverage;
@@ -231,17 +230,14 @@ public class Dispatch extends AbstractService implements SearchInterface,
}
}
- @Override
- public void allocatePorts(int start, PortAllocBridge from) {
- // NB: ignore "start"
- from.allocatePort("rpc");
- from.allocatePort("fs4");
- from.allocatePort("health");
- }
-
/**
* @return the number of ports needed
*/
public int getPortCount() { return 3; }
+ @Override
+ public String[] getPortSuffixes() {
+ return new String[]{ "rpc", "fs4", "health" };
+ }
+
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java
index c4acf8b5b0b..21882ee640a 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java
@@ -16,7 +16,6 @@ import com.yahoo.vespa.config.content.core.StorStatusConfig;
import com.yahoo.vespa.config.search.core.ProtonConfig;
import static com.yahoo.vespa.defaults.Defaults.getDefaults;
import com.yahoo.vespa.model.AbstractService;
-import com.yahoo.vespa.model.PortAllocBridge;
import com.yahoo.vespa.model.admin.monitoring.Monitoring;
import com.yahoo.vespa.model.application.validation.RestartConfigs;
import com.yahoo.vespa.model.builder.xml.dom.VespaDomBuilder;
@@ -159,16 +158,6 @@ public class SearchNode extends AbstractService implements
return nodeSpec;
}
- @Override
- public void allocatePorts(int start, PortAllocBridge from) {
- // NB: ignore "start"
- from.allocatePort("rpc");
- from.allocatePort("fs4");
- from.allocatePort("future/4");
- from.allocatePort("unused/3");
- from.allocatePort("health");
- }
-
/**
* Returns the number of ports needed by this service.
*
@@ -179,6 +168,11 @@ public class SearchNode extends AbstractService implements
return 5;
}
+ @Override
+ public String[] getPortSuffixes() {
+ return new String[] { "rpc", "fs4", "future/4", "unused/3", "health" };
+ }
+
/**
* Returns the RPC port used by this searchnode.
*
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/TransactionLogServer.java b/config-model/src/main/java/com/yahoo/vespa/model/search/TransactionLogServer.java
index 2c457940f24..4f854800c05 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/TransactionLogServer.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/search/TransactionLogServer.java
@@ -5,7 +5,6 @@ import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.searchlib.TranslogserverConfig;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.model.AbstractService;
-import com.yahoo.vespa.model.PortAllocBridge;
import com.yahoo.vespa.model.builder.xml.dom.VespaDomBuilder;
import org.w3c.dom.Element;
@@ -40,9 +39,8 @@ public class TransactionLogServer extends AbstractService {
}
@Override
- public void allocatePorts(int start, PortAllocBridge from) {
- // NB: ignore "start"
- from.allocatePort("tls");
+ public String[] getPortSuffixes() {
+ return new String[]{"tls"};
}
/**
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/HostPortsTest.java b/config-model/src/test/java/com/yahoo/vespa/model/HostPortsTest.java
index 7ce840c13f8..1ded447993c 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/HostPortsTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/HostPortsTest.java
@@ -114,12 +114,8 @@ public class HostPortsTest {
super(parent, "slobrok."+number);
}
@Override public int getPortCount() { return 1; }
+ @Override public String[] getPortSuffixes() { return new String[]{"http"}; }
@Override public String getServiceType() { return "slobrok"; }
-
- @Override
- public void allocatePorts(int start, PortAllocBridge from) {
- from.allocatePort("http");
- }
}
private static int counter = 0;
@@ -142,16 +138,12 @@ public class HostPortsTest {
public int getPortCount() { return portCount; }
@Override
- public void allocatePorts(int start, PortAllocBridge from) {
+ public String[] getPortSuffixes() {
+ String[] suffixes = new String[portCount];
for (int i = 0; i < portCount; i++) {
- String suffix = "generic." + i;
- if (start == 0) {
- from.allocatePort(suffix);
- } else {
- from.requirePort(start++, suffix);
- }
+ suffixes[i] = "generic." + i;
}
+ return suffixes;
}
-
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/HostResourceTest.java b/config-model/src/test/java/com/yahoo/vespa/model/HostResourceTest.java
index 0624c2cd23a..02b77bdb375 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/HostResourceTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/HostResourceTest.java
@@ -122,16 +122,12 @@ public class HostResourceTest {
public int getPortCount() { return portCount; }
@Override
- public void allocatePorts(int start, PortAllocBridge from) {
+ public String[] getPortSuffixes() {
+ String[] suffixes = new String[portCount];
for (int i = 0; i < portCount; i++) {
- String suffix = "generic." + i;
- if (start == 0) {
- from.allocatePort(suffix);
- } else {
- from.requirePort(start++, suffix);
- }
+ suffixes[i] = "generic." + i;
}
+ return suffixes;
}
-
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerTest.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerTest.java
index ef56a42cf1a..5d3bcd58f3d 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerTest.java
@@ -62,6 +62,7 @@ public class MetricsProxyContainerTest {
MetricsProxyContainer container = (MetricsProxyContainer)model.id2producer().get(CONTAINER_CONFIG_ID);
assertEquals(19092, container.getSearchPort());
assertEquals(19092, container.getHealthPort());
+ assertEquals("http", container.getPortSuffixes()[0]);
assertTrue(container.getPortsMeta().getTagsAt(0).contains("http"));
assertTrue(container.getPortsMeta().getTagsAt(0).contains("state"));
@@ -77,6 +78,8 @@ public class MetricsProxyContainerTest {
assertTrue(container.getPortsMeta().getTagsAt(offset).contains("rpc"));
assertTrue(container.getPortsMeta().getTagsAt(offset).contains("metrics"));
+ assertEquals("rpc/metrics", container.getPortSuffixes()[offset]);
+
RpcConnectorConfig config = getRpcConnectorConfig(model);
assertEquals(19095, config.port());
}
@@ -90,6 +93,8 @@ public class MetricsProxyContainerTest {
assertEquals(2, container.getPortsMeta().getTagsAt(offset).size());
assertTrue(container.getPortsMeta().getTagsAt(offset).contains("rpc"));
assertTrue(container.getPortsMeta().getTagsAt(offset).contains("admin"));
+
+ assertEquals("rpc/admin", container.getPortSuffixes()[offset]);
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigValueChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigValueChangeValidatorTest.java
index bb209e58e24..9318130bb4f 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigValueChangeValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigValueChangeValidatorTest.java
@@ -12,7 +12,6 @@ import com.yahoo.config.model.test.MockRoot;
import com.yahoo.vespa.model.AbstractService;
import com.yahoo.vespa.model.Host;
import com.yahoo.vespa.model.HostResource;
-import com.yahoo.vespa.model.PortAllocBridge;
import com.yahoo.vespa.model.VespaModel;
import com.yahoo.vespa.model.application.validation.RestartConfigs;
import com.yahoo.config.application.api.ValidationOverrides;
@@ -248,7 +247,8 @@ public class ConfigValueChangeValidatorTest {
return 0;
}
- @Override public void allocatePorts(int start, PortAllocBridge from) { }
+ @Override
+ public String[] getPortSuffixes() { return null; }
}
private static class SimpleConfigProducer extends AbstractConfigProducer<AbstractConfigProducer<?>>
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StartupCommandChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StartupCommandChangeValidatorTest.java
index c0b5ddd5d58..2b04b026ee7 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StartupCommandChangeValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StartupCommandChangeValidatorTest.java
@@ -8,7 +8,6 @@ import com.yahoo.config.model.test.MockRoot;
import com.yahoo.vespa.model.AbstractService;
import com.yahoo.vespa.model.Host;
import com.yahoo.vespa.model.HostResource;
-import com.yahoo.vespa.model.PortAllocBridge;
import com.yahoo.vespa.model.application.validation.change.StartupCommandChangeValidator;
import org.junit.Test;
@@ -77,6 +76,7 @@ public class StartupCommandChangeValidatorTest {
return 0;
}
- @Override public void allocatePorts(int start, PortAllocBridge from) { }
+ @Override
+ public String[] getPortSuffixes() { return null; }
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/test/ApiService.java b/config-model/src/test/java/com/yahoo/vespa/model/test/ApiService.java
index e9726903e49..6f06eb3e482 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/test/ApiService.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/test/ApiService.java
@@ -3,7 +3,6 @@ package com.yahoo.vespa.model.test;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.model.AbstractService;
-import com.yahoo.vespa.model.PortAllocBridge;
/**
* This is a service for testing the plugin exchange mechanism in the
@@ -37,5 +36,6 @@ public class ApiService extends AbstractService implements com.yahoo.test.Standa
public int getPortCount() { return 0; }
- @Override public void allocatePorts(int start, PortAllocBridge from) { }
+ @Override
+ public String[] getPortSuffixes() { return null; }
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/test/ModelAmendingTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/test/ModelAmendingTestCase.java
index 7ef89ded733..a8e946bcea1 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/test/ModelAmendingTestCase.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/test/ModelAmendingTestCase.java
@@ -13,7 +13,6 @@ import com.yahoo.config.model.builder.xml.ConfigModelId;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.model.AbstractService;
import com.yahoo.vespa.model.HostResource;
-import com.yahoo.vespa.model.PortAllocBridge;
import com.yahoo.vespa.model.VespaModel;
import com.yahoo.vespa.model.container.ContainerCluster;
import com.yahoo.vespa.model.container.ContainerModel;
@@ -128,7 +127,8 @@ public class ModelAmendingTestCase {
return 0;
}
- @Override public void allocatePorts(int start, PortAllocBridge from) { }
+ @Override
+ public String[] getPortSuffixes() { return null; }
}
public static class AdminModelAmender extends ConfigModel {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/test/ParentService.java b/config-model/src/test/java/com/yahoo/vespa/model/test/ParentService.java
index 96b5f98db86..b7887262ed5 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/test/ParentService.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/test/ParentService.java
@@ -4,7 +4,6 @@ package com.yahoo.vespa.model.test;
import com.yahoo.test.StandardConfig.Builder;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.model.AbstractService;
-import com.yahoo.vespa.model.PortAllocBridge;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -58,5 +57,6 @@ public class ParentService extends AbstractService implements com.yahoo.test.Sta
public int getPortCount() { return 0; }
- @Override public void allocatePorts(int start, PortAllocBridge from) { }
+ @Override
+ public String[] getPortSuffixes() { return null; }
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/test/SimpleService.java b/config-model/src/test/java/com/yahoo/vespa/model/test/SimpleService.java
index 553e0813038..8a5bbe36a73 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/test/SimpleService.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/test/SimpleService.java
@@ -4,7 +4,6 @@ package com.yahoo.vespa.model.test;
import com.yahoo.test.StandardConfig.Builder;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.model.AbstractService;
-import com.yahoo.vespa.model.PortAllocBridge;
import java.util.HashMap;
@@ -40,13 +39,8 @@ public class SimpleService extends AbstractService implements com.yahoo.test.Sta
public int getPortCount() { return 5; }
@Override
- public void allocatePorts(int start, PortAllocBridge from) {
- if (start == 0) start = getWantedPort();
- from.wantPort(start++, "a");
- from.wantPort(start++, "b");
- from.wantPort(start++, "c");
- from.wantPort(start++, "d");
- from.wantPort(start++, "e");
+ public String[] getPortSuffixes() {
+ return new String[]{ "a", "b", "c", "d", "e" };
}
// Make sure this service is listed in the sentinel config
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/utils/FileSenderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/utils/FileSenderTest.java
index 80b29120744..79646dacaa9 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/utils/FileSenderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/utils/FileSenderTest.java
@@ -9,7 +9,6 @@ import com.yahoo.config.model.producer.UserConfigRepo;
import com.yahoo.config.model.test.MockRoot;
import com.yahoo.vespa.config.*;
import com.yahoo.vespa.model.AbstractService;
-import com.yahoo.vespa.model.PortAllocBridge;
import com.yahoo.vespa.model.SimpleConfigProducer;
import org.junit.Before;
import org.junit.Test;
@@ -174,6 +173,7 @@ public class FileSenderTest {
return 0;
}
- @Override public void allocatePorts(int start, PortAllocBridge from) { }
+ @Override
+ public String[] getPortSuffixes() { return null; }
}
}