diff options
author | Harald Musum <musum@verizonmedia.com> | 2021-02-08 22:53:19 +0100 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2021-02-08 22:53:19 +0100 |
commit | ed4492de5dcb7150a2ba33d70ad7ce02ceec0fb0 (patch) | |
tree | eced089e19fb081ae22df105088fab5c65be615d /clustercontroller-apps | |
parent | 414568759416e98f41b248660b78465e67c8268a (diff) |
Cleanup: Remove unnecessary and unused methods, simplify
Diffstat (limited to 'clustercontroller-apps')
2 files changed, 24 insertions, 17 deletions
diff --git a/clustercontroller-apps/src/main/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurer.java b/clustercontroller-apps/src/main/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurer.java index 9f439cbd992..df778028325 100644 --- a/clustercontroller-apps/src/main/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurer.java +++ b/clustercontroller-apps/src/main/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurer.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.clustercontroller.apps.clustercontroller; import com.yahoo.jdisc.Metric; @@ -19,31 +19,36 @@ import java.util.Map; */ public class ClusterControllerClusterConfigurer { - private final FleetControllerOptions options = new FleetControllerOptions(null); + private final FleetControllerOptions options; public ClusterControllerClusterConfigurer(ClusterController controller, StorDistributionConfig distributionConfig, FleetcontrollerConfig fleetcontrollerConfig, SlobroksConfig slobroksConfig, ZookeepersConfig zookeepersConfig, - Metric metricImpl) throws Exception - { - configure(distributionConfig); - configure(fleetcontrollerConfig); - configure(slobroksConfig); - configure(zookeepersConfig); + Metric metricImpl) throws Exception { + this.options = configure(distributionConfig, fleetcontrollerConfig, slobroksConfig, zookeepersConfig); if (controller != null) { controller.setOptions(options, metricImpl); } } - public FleetControllerOptions getOptions() { return options; } + FleetControllerOptions getOptions() { return options; } - private void configure(StorDistributionConfig config) { - options.setStorageDistribution(new Distribution(config)); + private static FleetControllerOptions configure(StorDistributionConfig distributionConfig, + FleetcontrollerConfig fleetcontrollerConfig, + SlobroksConfig slobroksConfig, + ZookeepersConfig zookeepersConfig) { + Distribution distribution = new Distribution(distributionConfig); + FleetControllerOptions options = new FleetControllerOptions(fleetcontrollerConfig.cluster_name(), distribution.getNodes()); + options.setStorageDistribution(distribution); + configure(options, fleetcontrollerConfig); + configure(options, slobroksConfig); + configure(options, zookeepersConfig); + return options; } - private void configure(FleetcontrollerConfig config) { + private static void configure(FleetControllerOptions options, FleetcontrollerConfig config) { options.clusterName = config.cluster_name(); options.fleetControllerIndex = config.index(); options.fleetControllerCount = config.fleet_controller_count(); @@ -80,7 +85,7 @@ public class ClusterControllerClusterConfigurer { options.clusterFeedBlockLimit = Map.copyOf(config.cluster_feed_block_limit()); } - private void configure(SlobroksConfig config) { + private static void configure(FleetControllerOptions options, SlobroksConfig config) { String[] specs = new String[config.slobrok().size()]; for (int i = 0; i < config.slobrok().size(); i++) { specs[i] = config.slobrok().get(i).connectionspec(); @@ -88,11 +93,11 @@ public class ClusterControllerClusterConfigurer { options.slobrokConnectionSpecs = specs; } - private void configure(ZookeepersConfig config) { + private static void configure(FleetControllerOptions options, ZookeepersConfig config) { options.zooKeeperServerAddress = verifyZooKeeperAddress(config.zookeeperserverlist()); } - private String verifyZooKeeperAddress(String zooKeeperServerAddress) { + private static String verifyZooKeeperAddress(String zooKeeperServerAddress) { if (zooKeeperServerAddress == null || "".equals(zooKeeperServerAddress)) { throw new IllegalArgumentException("zookeeper server address must be set, was '" + zooKeeperServerAddress + "'"); } diff --git a/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerTest.java b/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerTest.java index f4df8a4e2a3..c7e3e896586 100644 --- a/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerTest.java +++ b/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerTest.java @@ -2,8 +2,10 @@ package com.yahoo.vespa.clustercontroller.apps.clustercontroller; import com.yahoo.jdisc.Metric; +import com.yahoo.vdslib.distribution.ConfiguredNode; import com.yahoo.vespa.clustercontroller.core.FleetController; import com.yahoo.vespa.clustercontroller.core.FleetControllerOptions; +import com.yahoo.vespa.jdk8compat.Set; import org.junit.Before; import org.junit.Test; @@ -18,7 +20,7 @@ import static org.junit.Assert.assertNull; */ public class ClusterControllerTest { - private FleetControllerOptions options = new FleetControllerOptions("storage"); + private FleetControllerOptions options = new FleetControllerOptions("storage", Set.of(new ConfiguredNode(0, false))); private final Metric metric = new Metric() { @Override @@ -31,7 +33,7 @@ public class ClusterControllerTest { @Before public void setUp() { - options = new FleetControllerOptions("storage"); + options = new FleetControllerOptions("storage", Set.of(new ConfiguredNode(0, false))); options.zooKeeperServerAddress = null; options.slobrokConfigId = "raw:"; options.slobrokConnectionSpecs = null; |