summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainer.java26
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/Container.java18
-rwxr-xr-xconfig-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java23
3 files changed, 50 insertions, 17 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainer.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainer.java
index cb8abb919ac..a52b4d915c9 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainer.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainer.java
@@ -1,6 +1,7 @@
-// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container;
+import com.yahoo.cloud.config.ZookeeperServerConfig;
import com.yahoo.config.model.api.container.ContainerServiceType;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.config.provision.NodeResources;
@@ -15,17 +16,19 @@ import com.yahoo.vespa.model.container.component.Component;
*
* @author gjoranv
*/
-public final class ApplicationContainer extends Container implements QrStartConfig.Producer {
+public final class ApplicationContainer extends Container implements
+ QrStartConfig.Producer,
+ ZookeeperServerConfig.Producer {
private static final String defaultHostedJVMArgs = "-XX:+UseOSErrorReporting -XX:+SuppressFatalErrorMessage";
private final boolean isHostedVespa;
- public ApplicationContainer(AbstractConfigProducer parent, String name, int index, boolean isHostedVespa) {
+ public ApplicationContainer(AbstractConfigProducer<?> parent, String name, int index, boolean isHostedVespa) {
this(parent, name, false, index, isHostedVespa);
}
- public ApplicationContainer(AbstractConfigProducer parent, String name, boolean retired, int index, boolean isHostedVespa) {
+ public ApplicationContainer(AbstractConfigProducer<?> parent, String name, boolean retired, int index, boolean isHostedVespa) {
super(parent, name, retired, index, isHostedVespa);
this.isHostedVespa = isHostedVespa;
@@ -51,7 +54,7 @@ public final class ApplicationContainer extends Container implements QrStartConf
@Override
protected ContainerServiceType myServiceType() {
if (parent instanceof ContainerCluster) {
- ContainerCluster cluster = (ContainerCluster)parent;
+ ContainerCluster<?> cluster = (ContainerCluster<?>)parent;
// TODO: The 'qrserver' name is retained for legacy reasons (e.g. system tests and log parsing).
if (cluster.getSearch() != null && cluster.getDocproc() == null && cluster.getDocumentApi() == null) {
return ContainerServiceType.QRSERVER;
@@ -70,6 +73,17 @@ public final class ApplicationContainer extends Container implements QrStartConf
}
private boolean hasDocproc() {
- return (parent instanceof ContainerCluster) && (((ContainerCluster)parent).getDocproc() != null);
+ return (parent instanceof ContainerCluster) && (((ContainerCluster<?>)parent).getDocproc() != null);
}
+
+ @Override
+ public void getConfig(ZookeeperServerConfig.Builder builder) {
+ AbstractConfigProducer<?> parent = getParent();
+ if (parent == null) return;
+
+ if (parent instanceof ApplicationContainerCluster)
+ ((ApplicationContainerCluster) this.parent).getConfig(builder);
+ builder.myid(index());
+ }
+
}
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 e8b56a6190a..6e470b24f9f 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
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container;
import com.yahoo.component.ComponentId;
@@ -58,10 +58,10 @@ public abstract class Container extends AbstractService implements
public static final int BASEPORT = Defaults.getDefaults().vespaWebServicePort();
public static final String SINGLENODE_CONTAINER_SERVICESPEC = "default_singlenode_container";
- /** The cluster this contasiner belongs to, or null if it is not added to any cluster */
- private ContainerCluster owner = null;
+ /** The cluster this container belongs to, or null if it is not added to any cluster */
+ private ContainerCluster<?> owner = null;
- protected final AbstractConfigProducer parent;
+ protected final AbstractConfigProducer<?> parent;
private final String name;
private boolean requireSpecificPorts = true;
@@ -78,11 +78,11 @@ public abstract class Container extends AbstractService implements
private final JettyHttpServer defaultHttpServer;
- protected Container(AbstractConfigProducer parent, String name, int index, boolean isHostedVespa) {
+ protected Container(AbstractConfigProducer<?> parent, String name, int index, boolean isHostedVespa) {
this(parent, name, false, index, isHostedVespa);
}
- protected Container(AbstractConfigProducer parent, String name, boolean retired, int index, boolean isHostedVespa) {
+ protected Container(AbstractConfigProducer<?> parent, String name, boolean retired, int index, boolean isHostedVespa) {
super(parent, name);
this.name = name;
this.parent = parent;
@@ -106,7 +106,7 @@ public abstract class Container extends AbstractService implements
return handlers;
}
- public ComponentGroup getComponents() {
+ public ComponentGroup<?> getComponents() {
return components;
}
@@ -118,7 +118,7 @@ public abstract class Container extends AbstractService implements
addComponent(new SimpleComponent(new ComponentModel(idSpec, classSpec, bundleSpec)));
}
- public final void addHandler(Handler h) {
+ public final void addHandler(Handler<?> h) {
handlers.addComponent(h);
}
@@ -133,7 +133,7 @@ public abstract class Container extends AbstractService implements
}
public Http getHttp() {
- return (parent instanceof ContainerCluster) ? ((ContainerCluster) parent).getHttp() : null;
+ return (parent instanceof ContainerCluster) ? ((ContainerCluster<?>) parent).getHttp() : null;
}
public JettyHttpServer getDefaultHttpServer() {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java
index 415b64a5574..2503f3795b0 100755
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java
@@ -5,6 +5,7 @@ import com.yahoo.cloud.config.ClusterInfoConfig;
import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.cloud.config.CuratorConfig;
import com.yahoo.cloud.config.RoutingProviderConfig;
+import com.yahoo.cloud.config.ZookeeperServerConfig;
import com.yahoo.component.ComponentId;
import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.config.model.deploy.DeployState;
@@ -326,16 +327,34 @@ public class ContainerClusterTest {
public void requireCuratorConfig() {
DeployState state = new DeployState.Builder().build();
MockRoot root = new MockRoot("foo", state);
- ApplicationContainerCluster cluster = new ApplicationContainerCluster(root, "container0", "container1", state);
+ var cluster = new ApplicationContainerCluster(root, "container", "search-cluster", state);
addContainer(root.deployLogger(), cluster, "c1", "host-c1");
addContainer(root.deployLogger(), cluster, "c2", "host-c2");
CuratorConfig.Builder configBuilder = new CuratorConfig.Builder();
cluster.getConfig(configBuilder);
CuratorConfig config = configBuilder.build();
- assertEquals(List.of("host-c1", "host-c2"), config.server().stream().map(CuratorConfig.Server::hostname).collect(Collectors.toList()));
+ assertEquals(List.of("host-c1", "host-c2"),
+ config.server().stream().map(CuratorConfig.Server::hostname).collect(Collectors.toList()));
assertTrue(config.zookeeperLocalhostAffinity());
}
+ @Test
+ public void requireZooKeeperServerConfig() {
+ DeployState state = new DeployState.Builder().build();
+ MockRoot root = new MockRoot("foo", state);
+ var cluster = new ApplicationContainerCluster(root, "container", "search-cluster", state);
+ addContainer(root.deployLogger(), cluster, "c1", "host-c1");
+ addContainer(root.deployLogger(), cluster, "c2", "host-c2");
+ addContainer(root.deployLogger(), cluster, "c3", "host-c3");
+
+ ZookeeperServerConfig.Builder configBuilder = new ZookeeperServerConfig.Builder();
+ cluster.getContainers().get(0).getConfig(configBuilder);
+ ZookeeperServerConfig config = configBuilder.build();
+ assertEquals(List.of("host-c1", "host-c2", "host-c3"),
+ config.server().stream().map(ZookeeperServerConfig.Server::hostname).collect(Collectors.toList()));
+ assertEquals(0, config.myid());
+ }
+
private void verifyTesterApplicationInstalledBundles(Zone zone, List<String> expectedBundleNames) {
ApplicationId appId = ApplicationId.from("tenant", "application", "instance-t");
DeployState state = new DeployState.Builder().properties(