diff options
10 files changed, 69 insertions, 85 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; diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/FleetControllerOptions.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/FleetControllerOptions.java index 0ad0a59a72a..9c5aaecd468 100644 --- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/FleetControllerOptions.java +++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/FleetControllerOptions.java @@ -138,16 +138,6 @@ public class FleetControllerOptions implements Cloneable { // Resource type -> limit in [0, 1] public Map<String, Double> clusterFeedBlockLimit = Collections.emptyMap(); - // TODO: Replace usage of this by usage where the nodes are explicitly passed (below) - public FleetControllerOptions(String clusterName) { - this.clusterName = clusterName; - maxTransitionTime.put(NodeType.DISTRIBUTOR, 0); - maxTransitionTime.put(NodeType.STORAGE, 5000); - nodes = new TreeSet<>(); - for (int i = 0; i < 10; i++) - nodes.add(new ConfiguredNode(i, false)); - } - public FleetControllerOptions(String clusterName, Collection<ConfiguredNode> nodes) { this.clusterName = clusterName; maxTransitionTime.put(NodeType.DISTRIBUTOR, 0); @@ -158,7 +148,6 @@ public class FleetControllerOptions implements Cloneable { /** Called on reconfiguration of this cluster */ public void setStorageDistribution(Distribution distribution) { this.storageDistribution = distribution; - this.nodes = distribution.getNodes(); } public Duration getMaxDeferredTaskVersionWaitTime() { diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateGeneratorTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateGeneratorTest.java index 0ca8b010191..ba3a1dd7d26 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateGeneratorTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateGeneratorTest.java @@ -1,11 +1,13 @@ -// 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.core; +import com.yahoo.vdslib.distribution.ConfiguredNode; import com.yahoo.vdslib.state.DiskState; import com.yahoo.vdslib.state.Node; import com.yahoo.vdslib.state.NodeState; import com.yahoo.vdslib.state.NodeType; import com.yahoo.vdslib.state.State; +import com.yahoo.vespa.jdk8compat.Set; import org.junit.Test; import java.util.Optional; @@ -902,7 +904,7 @@ public class ClusterStateGeneratorTest { @Test public void generator_params_can_inherit_values_from_controller_options() { - FleetControllerOptions options = new FleetControllerOptions("foocluster"); + FleetControllerOptions options = new FleetControllerOptions("foocluster", Set.of(new ConfiguredNode(0, false))); options.maxPrematureCrashes = 1; options.minStorageNodesUp = 2; options.minDistributorNodesUp = 3; diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java index f8bf387ce41..40eae4f6515 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.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.core; import com.yahoo.jrt.Request; @@ -47,6 +47,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Pattern; import java.util.stream.Collectors; +import java.util.stream.IntStream; import static org.junit.Assert.fail; @@ -59,7 +60,7 @@ public abstract class FleetControllerTest implements Waiter { private static final int DEFAULT_NODE_COUNT = 10; Supervisor supervisor; - protected FakeTimer timer = new FakeTimer(); + protected final FakeTimer timer = new FakeTimer(); boolean usingFakeTimer = false; protected Slobrok slobrok; protected FleetControllerOptions options; @@ -124,9 +125,9 @@ public abstract class FleetControllerTest implements Waiter { } static protected FleetControllerOptions defaultOptions(String clusterName) { - var opts = new FleetControllerOptions(clusterName); - opts.enableTwoPhaseClusterStateActivation = true; // Enable by default, tests can explicitly disable. - return opts; + return defaultOptions(clusterName, IntStream.range(0, DEFAULT_NODE_COUNT) + .mapToObj(i -> new ConfiguredNode(i, false)) + .collect(Collectors.toSet())); } static protected FleetControllerOptions defaultOptions(String clusterName, Collection<ConfiguredNode> nodes) { diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownLiveConfigTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownLiveConfigTest.java index 10d7bc94ae0..aba88ac3d91 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownLiveConfigTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownLiveConfigTest.java @@ -11,10 +11,7 @@ public class GroupAutoTakedownLiveConfigTest extends FleetControllerTest { private long mockConfigGeneration = 1; - - private static FleetControllerOptions createOptions( - DistributionBuilder.GroupBuilder groupBuilder, double minNodeRatio) - { + private static FleetControllerOptions createOptions(DistributionBuilder.GroupBuilder groupBuilder, double minNodeRatio) { FleetControllerOptions options = defaultOptions("mycluster"); options.setStorageDistribution(DistributionBuilder.forHierarchicCluster(groupBuilder)); options.nodes = new HashSet<>(DistributionBuilder.buildConfiguredNodes(groupBuilder.totalNodeCount())); diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java index 896f73ce6bf..c42a54b3528 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java @@ -138,7 +138,7 @@ public class MasterElectionTest extends FleetControllerTest { log.log(Level.INFO, "SHUTTING DOWN FLEET CONTROLLER 2"); fleetControllers.get(2).shutdown(); - // Too few for there to be a master at this point + // Too few for there to be a master at this point for (int i=0; i<fleetControllers.size(); ++i) { if (fleetControllers.get(i).isRunning()) waitForCompleteCycle(i); assertFalse("Fleet controller " + i, fleetControllers.get(i).isMaster()); diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java index 0fee43fafb5..d3cf4ba1bea 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.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.core; import com.yahoo.jrt.ErrorCode; @@ -10,7 +10,6 @@ import com.yahoo.jrt.Supervisor; import com.yahoo.jrt.Target; import com.yahoo.jrt.Transport; import com.yahoo.jrt.slobrok.server.Slobrok; -import java.util.logging.Level; import com.yahoo.vdslib.distribution.ConfiguredNode; import com.yahoo.vdslib.distribution.Distribution; import com.yahoo.vdslib.state.ClusterState; @@ -21,15 +20,15 @@ import com.yahoo.vdslib.state.State; import com.yahoo.vespa.clustercontroller.core.rpc.RpcServer; import com.yahoo.vespa.clustercontroller.core.testutils.LogFormatter; import com.yahoo.vespa.clustercontroller.core.testutils.WaitCondition; -import com.yahoo.vespa.config.content.StorDistributionConfig; import org.junit.Test; import java.util.ArrayList; -import java.util.LinkedList; import java.util.List; import java.util.Set; import java.util.TreeSet; +import java.util.logging.Level; import java.util.logging.Logger; +import java.util.stream.Collectors; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -100,7 +99,7 @@ public class RpcServerTest extends FleetControllerTest { setUpVdsNodes(true, new DummyVdsNodeOptions()); waitForStableSystem(); - assertEquals(true, nodes.get(0).isDistributor()); + assertTrue(nodes.get(0).isDistributor()); log.log(Level.INFO, "Disconnecting distributor 0. Waiting for state to reflect change."); nodes.get(0).disconnect(); nodes.get(19).disconnect(); @@ -470,28 +469,13 @@ public class RpcServerTest extends FleetControllerTest { } } - private StorDistributionConfig getDistConfig(Set<Integer> nodes) { - List<StorDistributionConfig.Group.Nodes.Builder> nodeList = new LinkedList<>(); - for (int i : nodes) { - StorDistributionConfig.Group.Nodes.Builder nodeConfig = new StorDistributionConfig.Group.Nodes.Builder(); - nodeConfig.index(i); - nodeList.add(nodeConfig); - } - StorDistributionConfig.Group.Builder groupConfig = new StorDistributionConfig.Group.Builder(); - groupConfig.nodes(nodeList); - groupConfig.index("0"); - groupConfig.name("foo"); - StorDistributionConfig.Builder distConfig = new StorDistributionConfig.Builder(); - distConfig.group(groupConfig); - return new StorDistributionConfig(distConfig); - } - @Test public void testSetNodeState() throws Exception { startingTest("RpcServerTest::testSetNodeState"); - FleetControllerOptions options = defaultOptions("mycluster"); Set<Integer> nodeIndexes = new TreeSet<>(List.of(4, 6, 9, 10, 14, 16, 21, 22, 23, 25)); - options.setStorageDistribution(new Distribution(getDistConfig(nodeIndexes))); + Set<ConfiguredNode> configuredNodes = nodeIndexes.stream().map(i -> new ConfiguredNode(i, false)).collect(Collectors.toSet()); + FleetControllerOptions options = defaultOptions("mycluster", configuredNodes); + //options.setStorageDistribution(new Distribution(getDistConfig(nodeIndexes))); setUpFleetController(true, options); setUpVdsNodes(true, new DummyVdsNodeOptions(), false, nodeIndexes); waitForState("version:\\d+ distributor:26 .0.s:d .1.s:d .2.s:d .3.s:d .5.s:d .7.s:d .8.s:d .11.s:d .12.s:d .13.s:d .15.s:d .17.s:d .18.s:d .19.s:d .20.s:d .24.s:d storage:26 .0.s:d .1.s:d .2.s:d .3.s:d .5.s:d .7.s:d .8.s:d .11.s:d .12.s:d .13.s:d .15.s:d .17.s:d .18.s:d .19.s:d .20.s:d .24.s:d"); diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SlobrokTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SlobrokTest.java index 5a96af90d68..a77e267c85b 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SlobrokTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SlobrokTest.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.core; import com.yahoo.jrt.slobrok.server.Slobrok; @@ -11,24 +11,7 @@ import java.util.logging.Logger; public class SlobrokTest extends FleetControllerTest { - private static Logger log = Logger.getLogger(SlobrokTest.class.getName()); - - private boolean clusterAvailable() { - boolean ok = true; - ContentCluster cluster = fleetController.getCluster(); - for (NodeInfo info : cluster.getNodeInfo()) { - if (info.getConnectionAttemptCount() > 0) ok = false; - if (info.getLatestNodeStateRequestTime() == null) ok = false; - } - return ok; - } - private void assertClusterAvailable() { - ContentCluster cluster = fleetController.getCluster(); - for (NodeInfo info : cluster.getNodeInfo()) { - assertEquals("Node " + info + " connection attempts.", 0, info.getConnectionAttemptCount()); - assertTrue("Node " + info + " has no last request time.", info.getLatestNodeStateRequestTime() != 0); - } - } + private static final Logger log = Logger.getLogger(SlobrokTest.class.getName()); @Test public void testSingleSlobrokRestart() throws Exception { @@ -113,4 +96,20 @@ public class SlobrokTest extends FleetControllerTest { waitForState("version:\\d+ distributor:10 .0.s:d storage:10"); } + private boolean clusterAvailable() { + boolean ok = true; + ContentCluster cluster = fleetController.getCluster(); + for (NodeInfo info : cluster.getNodeInfo()) { + if (info.getConnectionAttemptCount() > 0) ok = false; + if (info.getLatestNodeStateRequestTime() == null) ok = false; + } + return ok; + } + private void assertClusterAvailable() { + ContentCluster cluster = fleetController.getCluster(); + for (NodeInfo info : cluster.getNodeInfo()) { + assertEquals("Node " + info + " connection attempts.", 0, info.getConnectionAttemptCount()); + assertTrue("Node " + info + " has no last request time.", info.getLatestNodeStateRequestTime() != 0); + } + } } diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicatorTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicatorTest.java index 56cdc46be5a..6f338234b7a 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicatorTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicatorTest.java @@ -1,7 +1,12 @@ -// 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.core.rpc; -import com.yahoo.jrt.*; +import com.yahoo.jrt.ErrorCode; +import com.yahoo.jrt.Request; +import com.yahoo.jrt.RequestWaiter; +import com.yahoo.jrt.Supervisor; +import com.yahoo.jrt.Target; +import com.yahoo.vdslib.distribution.ConfiguredNode; import com.yahoo.vdslib.state.Node; import com.yahoo.vdslib.state.NodeState; import com.yahoo.vdslib.state.NodeType; @@ -75,7 +80,7 @@ public class RPCCommunicatorTest { @Test public void testGenerateNodeStateRequestTimeoutMsWithUpdates() { final RPCCommunicator communicator = new RPCCommunicator(RPCCommunicator.createRealSupervisor(), null /* Timer */, INDEX, 1, 1, 100, 0); - FleetControllerOptions fleetControllerOptions = new FleetControllerOptions(null /*clustername*/); + FleetControllerOptions fleetControllerOptions = new FleetControllerOptions(null /*clustername*/, Set.of(new ConfiguredNode(0, false))); fleetControllerOptions.nodeStateRequestTimeoutEarliestPercentage = 100; fleetControllerOptions.nodeStateRequestTimeoutLatestPercentage = 100; fleetControllerOptions.nodeStateRequestTimeoutMS = NODE_STATE_REQUEST_TIMEOUT_INTERVAL_MAX_MS; |