aboutsummaryrefslogtreecommitdiffstats
path: root/clustercontroller-apps
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-12-14 13:00:02 +0100
committerHarald Musum <musum@verizonmedia.com>2020-12-14 13:00:02 +0100
commite20edfd422c25e75f3e746bb0e3ca93b98279f4e (patch)
treedc89e0aed100af7743d2c4562b3c999fe0b34352 /clustercontroller-apps
parent7505a44f71dab2920d3ec7488910def098563cd4 (diff)
parent7d252bb4f6f85cbfda2eb04b5da765fab7b5d933 (diff)
Merge branch 'master' into hmusum/disallow-clustercontroller-with-no-zookeeper-cluster
Diffstat (limited to 'clustercontroller-apps')
-rw-r--r--clustercontroller-apps/src/main/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterController.java25
1 files changed, 13 insertions, 12 deletions
diff --git a/clustercontroller-apps/src/main/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterController.java b/clustercontroller-apps/src/main/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterController.java
index caad5f7fd29..9020765f777 100644
--- a/clustercontroller-apps/src/main/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterController.java
+++ b/clustercontroller-apps/src/main/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterController.java
@@ -33,6 +33,7 @@ public class ClusterController extends AbstractComponent
* Dependency injection constructor for controller. {@link ZooKeeperProvider} argument given
* to ensure that zookeeper has started before we start polling it.
*/
+ @SuppressWarnings("unused")
@Inject
public ClusterController(ZooKeeperProvider zooKeeperProvider) {
this();
@@ -45,17 +46,9 @@ public class ClusterController extends AbstractComponent
public void setOptions(FleetControllerOptions options, Metric metricImpl) throws Exception {
metricWrapper.updateMetricImplementation(metricImpl);
- if (options.zooKeeperServerAddress != null && !"".equals(options.zooKeeperServerAddress)) {
- // Wipe this path ... it's unclear why
- String path = "/" + options.clusterName + options.fleetControllerIndex;
- Curator curator = Curator.create(options.zooKeeperServerAddress);
- if (curator.framework().checkExists().forPath(path) != null)
- curator.framework().delete().deletingChildrenIfNeeded().forPath(path);
- curator.framework().create().creatingParentsIfNeeded().forPath(path);
- }
+ verifyThatZooKeeperWorks(options);
synchronized (controllers) {
FleetController controller = controllers.get(options.clusterName);
-
if (controller == null) {
StatusHandler.ContainerStatusPageServer statusPageServer = new StatusHandler.ContainerStatusPageServer();
controller = FleetController.create(options, statusPageServer, metricWrapper);
@@ -83,11 +76,9 @@ public class ClusterController extends AbstractComponent
@Override
public Map<String, RemoteClusterControllerTaskScheduler> getFleetControllers() {
- Map<String, RemoteClusterControllerTaskScheduler> m = new LinkedHashMap<>();
synchronized (controllers) {
- m.putAll(controllers);
+ return new LinkedHashMap<>(controllers);
}
- return m;
}
@Override
@@ -104,4 +95,14 @@ public class ClusterController extends AbstractComponent
controller.shutdown();
}
+ /**
+ * Block until we are connected to zookeeper server
+ */
+ private void verifyThatZooKeeperWorks(FleetControllerOptions options) throws Exception {
+ if (options.zooKeeperServerAddress != null && !"".equals(options.zooKeeperServerAddress)) {
+ Curator curator = Curator.create(options.zooKeeperServerAddress);
+ curator.framework().blockUntilConnected();
+ }
+ }
+
}