diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2021-02-23 20:31:27 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2021-02-23 20:31:27 +0100 |
commit | fb3f11c9d17e6039edc3d82f465e153865d30eb1 (patch) | |
tree | 9c42f8aac78e2906b06881ca180ddacc1100279e /config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerCluster.java | |
parent | 8d30b5628589f5506c15b69dcea695eb8f6c044b (diff) |
Compute whether cluster-controller ZK members are joining
Diffstat (limited to 'config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerCluster.java')
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerCluster.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerCluster.java index 495a70cdf14..feac7e5a92d 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerCluster.java @@ -4,13 +4,22 @@ package com.yahoo.vespa.model.admin.clustercontroller; import com.google.common.base.Joiner; import com.yahoo.cloud.config.ZookeeperServerConfig; import com.yahoo.cloud.config.ZookeepersConfig; +import com.yahoo.config.model.api.Model; +import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.model.producer.AbstractConfigProducer; +import com.yahoo.config.provision.AllocatedHosts; +import com.yahoo.config.provision.HostSpec; +import com.yahoo.net.HostName; import com.yahoo.vespa.model.Service; import com.yahoo.vespa.model.admin.Configserver; import com.yahoo.vespa.model.container.Container; import java.util.ArrayList; import java.util.Collection; +import java.util.Set; +import java.util.stream.Collectors; + +import static java.util.stream.Collectors.toUnmodifiableSet; /** * Used if clustercontroller is run standalone (not as part of the config server ZooKeeper cluster) @@ -24,9 +33,16 @@ public class ClusterControllerCluster extends AbstractConfigProducer<ClusterCont private static final int ZK_CLIENT_PORT = 2181; // Must match the default in CuratorConfig private ClusterControllerContainerCluster containerCluster = null; + private final Set<String> previousHosts; - public ClusterControllerCluster(AbstractConfigProducer<?> parent, String subId) { + public ClusterControllerCluster(AbstractConfigProducer<?> parent, String subId, DeployState deployState) { super(parent, subId); + this.previousHosts = deployState.getPreviousModel().stream() + .map(Model::allocatedHosts) + .map(AllocatedHosts::getHosts) + .flatMap(Collection::stream) + .map(HostSpec::hostname) + .collect(toUnmodifiableSet()); } @Override @@ -37,6 +53,7 @@ public class ClusterControllerCluster extends AbstractConfigProducer<ClusterCont ZookeeperServerConfig.Server.Builder serverBuilder = new ZookeeperServerConfig.Server.Builder(); serverBuilder.hostname(container.getHostName()); serverBuilder.id(container.index()); + serverBuilder.joining( ! previousHosts.isEmpty() && ! previousHosts.contains(container.getHostName())); builder.server(serverBuilder); } } |