summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-11-27 08:43:05 +0100
committerHarald Musum <musum@verizonmedia.com>2020-11-27 08:43:05 +0100
commit448b47928d2784d2ce31896e31532e1208699b89 (patch)
tree5416f286b1840c72a7bd0f1806a28d8c086ed698 /config-model
parent371e9b50738dafc28c7ab2aea6495d26ecd6c0c9 (diff)
Id needs to be set for each container
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainer.java22
-rwxr-xr-xconfig-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java23
2 files changed, 37 insertions, 8 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..e1c4bdc3cba 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,13 @@ 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) {
+ ((ApplicationContainerCluster)parent).getConfig(builder);
+ builder.myid(index());
+ }
+
}
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(