summaryrefslogtreecommitdiffstats
path: root/clustercontroller-core
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2019-09-03 08:16:35 +0200
committerHarald Musum <musum@verizonmedia.com>2019-09-03 08:16:35 +0200
commite1356fadd445fbf7d58d2c3f0574dea092964c08 (patch)
tree2ba233aad5996abc0600cf45223bab878da0cb26 /clustercontroller-core
parent7e26976e385c864da3b8bebaf63d4648bee694b2 (diff)
Cleanup tests, no functional changes
Diffstat (limited to 'clustercontroller-core')
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentCluster.java8
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/LegacyIndexPageRequestHandler.java4
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/statuspage/VdsClusterHtmlRenderer.java (renamed from clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/statuspage/VdsClusterHtmlRendrer.java)5
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/AggregatedStatsMergePendingCheckerTest.java17
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterFixture.java56
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java6
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateGeneratorTest.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateViewTest.java12
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregatorTest.java11
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsChangeTrackerTest.java14
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterHtmlRendrerTest.java24
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterStatsBuilder.java4
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStatsBuilder.java4
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseTest.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DistributionBitCountTest.java1
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DistributionBuilder.java22
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyCommunicator.java26
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyVdsNode.java74
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyVdsNodeOptions.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventLogTest.java1
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FakeTimer.java4
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java131
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownLiveConfigTest.java11
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownTest.java4
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculatorTest.java5
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/LeafGroupsTest.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MaintenanceWhenPendingGlobalMergesTest.java4
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java43
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NoZooKeeperTest.java4
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeSlobrokConfigurationMembershipTest.java4
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java6
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java20
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcVersionAutoDowngradeTest.java1
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandlerTest.java4
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeTest.java53
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateGatherTest.java4
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateVersionTrackerTest.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StatusPagesTest.java27
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SystemStateBroadcasterTest.java8
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperTestServer.java10
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/HostInfoTest.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/ClusterEventWithDescription.java3
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/EventForNode.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/EventTimeIs.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/EventTypeIs.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/HasStateReasonForNode.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/NodeEventForBucketSpace.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/NodeEventWithDescription.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterControllerMock.java12
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java49
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java11
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java27
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/StateRestApiTest.java14
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicatorTest.java37
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/WaitCondition.java20
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/WaitTask.java6
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/Waiter.java6
57 files changed, 384 insertions, 457 deletions
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentCluster.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentCluster.java
index 43412311436..ddb9357f11f 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentCluster.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentCluster.java
@@ -10,7 +10,7 @@ import com.yahoo.vdslib.distribution.ConfiguredNode;
import com.yahoo.vdslib.state.*;
import com.yahoo.vdslib.distribution.Distribution;
import com.yahoo.vdslib.distribution.Group;
-import com.yahoo.vespa.clustercontroller.core.status.statuspage.VdsClusterHtmlRendrer;
+import com.yahoo.vespa.clustercontroller.core.status.statuspage.VdsClusterHtmlRenderer;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.requests.SetUnitStateRequest;
import java.util.*;
@@ -42,7 +42,7 @@ public class ContentCluster {
}
public void writeHtmlState(
- final VdsClusterHtmlRendrer vdsClusterHtmlRendrer,
+ final VdsClusterHtmlRenderer vdsClusterHtmlRenderer,
final StringBuilder sb,
final Timer timer,
final ClusterStateBundle state,
@@ -51,8 +51,8 @@ public class ContentCluster {
final FleetControllerOptions options,
final EventLog eventLog) {
- final VdsClusterHtmlRendrer.Table table =
- vdsClusterHtmlRendrer.createNewClusterHtmlTable(clusterName, slobrokGenerationCount);
+ final VdsClusterHtmlRenderer.Table table =
+ vdsClusterHtmlRenderer.createNewClusterHtmlTable(clusterName, slobrokGenerationCount);
final List<Group> groups = LeafGroups.enumerateFrom(distribution.getRootGroup());
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/LegacyIndexPageRequestHandler.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/LegacyIndexPageRequestHandler.java
index 6d11c4f1239..f799492d164 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/LegacyIndexPageRequestHandler.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/LegacyIndexPageRequestHandler.java
@@ -6,7 +6,7 @@ import com.yahoo.vespa.clustercontroller.core.*;
import com.yahoo.vespa.clustercontroller.core.Timer;
import com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse;
import com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageServer;
-import com.yahoo.vespa.clustercontroller.core.status.statuspage.VdsClusterHtmlRendrer;
+import com.yahoo.vespa.clustercontroller.core.status.statuspage.VdsClusterHtmlRenderer;
import java.util.*;
@@ -62,7 +62,7 @@ public class LegacyIndexPageRequestHandler implements StatusPageServer.RequestHa
if (masterElectionHandler.isAmongNthFirst(data.getOptions().stateGatherCount)) {
// Table overview of all the nodes
cluster.writeHtmlState(
- new VdsClusterHtmlRendrer(),
+ new VdsClusterHtmlRenderer(),
content,
timer,
stateVersionTracker.getVersionedClusterStateBundle(),
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/statuspage/VdsClusterHtmlRendrer.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/statuspage/VdsClusterHtmlRenderer.java
index 0daa9ff7d37..6d21aa430a2 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/statuspage/VdsClusterHtmlRendrer.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/statuspage/VdsClusterHtmlRenderer.java
@@ -15,11 +15,10 @@ import java.util.Map;
import java.util.TimeZone;
import java.util.TreeMap;
-
/**
- * Renders webpage with status regarding cluster.
+ * Renders web page with cluster status.
*/
-public class VdsClusterHtmlRendrer {
+public class VdsClusterHtmlRenderer {
private static final TimeZone utcTimeZone = TimeZone.getTimeZone("UTC");
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/AggregatedStatsMergePendingCheckerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/AggregatedStatsMergePendingCheckerTest.java
index 304579cf75a..65e6e0c2a03 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/AggregatedStatsMergePendingCheckerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/AggregatedStatsMergePendingCheckerTest.java
@@ -15,38 +15,37 @@ public class AggregatedStatsMergePendingCheckerTest {
private final AggregatedClusterStats mockAggregatedStats = mock(AggregatedClusterStats.class);
private final AggregatedStatsMergePendingChecker checker;
- public Fixture(ContentClusterStatsBuilder builder,
- boolean hasUpdatesFromAllDistributors,
- double minMergeCompletionRatio) {
+ Fixture(ContentClusterStatsBuilder builder,
+ boolean hasUpdatesFromAllDistributors,
+ double minMergeCompletionRatio) {
when(mockAggregatedStats.getStats()).thenReturn(builder.build());
when(mockAggregatedStats.hasUpdatesFromAllDistributors()).thenReturn(hasUpdatesFromAllDistributors);
this.checker = new AggregatedStatsMergePendingChecker(mockAggregatedStats, minMergeCompletionRatio);
}
- public static Fixture fromBucketsPending(long bucketsPending) {
+ static Fixture fromBucketsPending(long bucketsPending) {
return new Fixture(new ContentClusterStatsBuilder()
.add(1, "default", 5, bucketsPending),
true, 1.0);
}
- public static Fixture fromBucketsPending(long bucketsPending,
- double minMergeCompletionRatio) {
+ static Fixture fromBucketsPending(long bucketsPending, double minMergeCompletionRatio) {
return new Fixture(new ContentClusterStatsBuilder()
.add(1, "default", 5, bucketsPending),
true, minMergeCompletionRatio);
}
- public static Fixture fromInvalidBucketStats() {
+ static Fixture fromInvalidBucketStats() {
return new Fixture(new ContentClusterStatsBuilder()
.add(1, "default"),
true, 1.0);
}
- public static Fixture fromIncompleteStats() {
+ static Fixture fromIncompleteStats() {
return new Fixture(new ContentClusterStatsBuilder(), false, 1.0);
}
- public boolean mayHaveMergesPending(String bucketSpace, int contentNodeIndex) {
+ boolean mayHaveMergesPending(String bucketSpace, int contentNodeIndex) {
return checker.mayHaveMergesPending(bucketSpace, contentNodeIndex);
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterFixture.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterFixture.java
index 5692e961cbe..2df9279e450 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterFixture.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterFixture.java
@@ -24,9 +24,9 @@ public class ClusterFixture {
public final ContentCluster cluster;
public final Distribution distribution;
public final FakeTimer timer;
- public final EventLogInterface eventLog;
- public final StateChangeHandler nodeStateChangeHandler;
- public final ClusterStateGenerator.Params params = new ClusterStateGenerator.Params();
+ private final EventLogInterface eventLog;
+ final StateChangeHandler nodeStateChangeHandler;
+ private final ClusterStateGenerator.Params params = new ClusterStateGenerator.Params();
public ClusterFixture(ContentCluster cluster, Distribution distribution) {
this.cluster = cluster;
@@ -37,7 +37,7 @@ public class ClusterFixture {
this.params.cluster(this.cluster);
}
- public StateChangeHandler createNodeStateChangeHandlerForCluster() {
+ private StateChangeHandler createNodeStateChangeHandlerForCluster() {
final int controllerIndex = 0;
MetricUpdater metricUpdater = new MetricUpdater(new NoMetricReporter(), controllerIndex);
return new StateChangeHandler(timer, eventLog, metricUpdater);
@@ -51,7 +51,7 @@ public class ClusterFixture {
return this;
}
- public ClusterFixture markEntireClusterDown() {
+ ClusterFixture markEntireClusterDown() {
cluster.clusterInfo().getConfiguredNodes().forEach((idx, node) -> {
reportStorageNodeState(idx, State.DOWN);
reportDistributorNodeState(idx, State.DOWN);
@@ -69,7 +69,7 @@ public class ClusterFixture {
nodeInfo.setReportedState(nodeState, timer.getCurrentTimeInMillis());
}
- public ClusterFixture reportStorageNodeState(final int index, State state, String description) {
+ ClusterFixture reportStorageNodeState(final int index, State state, String description) {
final Node node = new Node(NodeType.STORAGE, index);
final NodeState nodeState = new NodeState(NodeType.STORAGE, state);
nodeState.setDescription(description);
@@ -77,23 +77,23 @@ public class ClusterFixture {
return this;
}
- public ClusterFixture reportStorageNodeState(final int index, State state) {
+ ClusterFixture reportStorageNodeState(final int index, State state) {
return reportStorageNodeState(index, state, "mockdesc");
}
- public ClusterFixture reportStorageNodeState(final int index, NodeState nodeState) {
+ ClusterFixture reportStorageNodeState(final int index, NodeState nodeState) {
doReportNodeState(new Node(NodeType.STORAGE, index), nodeState);
return this;
}
- public ClusterFixture reportDistributorNodeState(final int index, State state) {
+ ClusterFixture reportDistributorNodeState(final int index, State state) {
final Node node = new Node(NodeType.DISTRIBUTOR, index);
final NodeState nodeState = new NodeState(NodeType.DISTRIBUTOR, state);
doReportNodeState(node, nodeState);
return this;
}
- public ClusterFixture reportDistributorNodeState(final int index, NodeState nodeState) {
+ ClusterFixture reportDistributorNodeState(final int index, NodeState nodeState) {
doReportNodeState(new Node(NodeType.DISTRIBUTOR, index), nodeState);
return this;
}
@@ -108,18 +108,18 @@ public class ClusterFixture {
nodeStateChangeHandler.proposeNewNodeState(stateBefore, nodeInfo, nodeState);
}
- public ClusterFixture proposeStorageNodeWantedState(final int index, State state, String description) {
+ ClusterFixture proposeStorageNodeWantedState(final int index, State state, String description) {
final Node node = new Node(NodeType.STORAGE, index);
final NodeState nodeState = new NodeState(NodeType.STORAGE, state);
doProposeWantedState(node, nodeState, description);
return this;
}
- public ClusterFixture proposeStorageNodeWantedState(final int index, State state) {
+ ClusterFixture proposeStorageNodeWantedState(final int index, State state) {
return proposeStorageNodeWantedState(index, state, "mockdesc");
}
- public ClusterFixture proposeDistributorWantedState(final int index, State state) {
+ ClusterFixture proposeDistributorWantedState(final int index, State state) {
final ClusterState stateBefore = rawGeneratedClusterState();
final Node node = new Node(NodeType.DISTRIBUTOR, index);
final NodeState nodeState = new NodeState(NodeType.DISTRIBUTOR, state);
@@ -131,12 +131,12 @@ public class ClusterFixture {
return this;
}
- public ClusterFixture disableAutoClusterTakedown() {
+ ClusterFixture disableAutoClusterTakedown() {
setMinNodesUp(0, 0, 0.0, 0.0);
return this;
}
- public ClusterFixture setMinNodesUp(int minDistNodes, int minStorNodes, double minDistRatio, double minStorRatio) {
+ ClusterFixture setMinNodesUp(int minDistNodes, int minStorNodes, double minDistRatio, double minStorRatio) {
params.minStorageNodesUp(minStorNodes)
.minDistributorNodesUp(minDistNodes)
.minRatioOfStorageNodesUp(minStorRatio)
@@ -144,7 +144,7 @@ public class ClusterFixture {
return this;
}
- public ClusterFixture setMinNodeRatioPerGroup(double upRatio) {
+ ClusterFixture setMinNodeRatioPerGroup(double upRatio) {
params.minNodeRatioPerGroup(upRatio);
return this;
}
@@ -154,22 +154,22 @@ public class ClusterFixture {
return this;
}
- static public Map<NodeType, Integer> buildTransitionTimeMap(int distributorTransitionTime, int storageTransitionTime) {
+ static Map<NodeType, Integer> buildTransitionTimeMap(int distributorTransitionTime, int storageTransitionTime) {
Map<NodeType, Integer> maxTransitionTime = new TreeMap<>();
maxTransitionTime.put(NodeType.DISTRIBUTOR, distributorTransitionTime);
maxTransitionTime.put(NodeType.STORAGE, storageTransitionTime);
return maxTransitionTime;
}
- public void disableTransientMaintenanceModeOnDown() {
+ void disableTransientMaintenanceModeOnDown() {
this.params.transitionTimes(0);
}
- public void enableTransientMaintenanceModeOnDown(final int transitionTimeMs) {
+ void enableTransientMaintenanceModeOnDown(final int transitionTimeMs) {
this.params.transitionTimes(transitionTimeMs);
}
- public ClusterFixture markNodeAsConfigRetired(int nodeIndex) {
+ ClusterFixture markNodeAsConfigRetired(int nodeIndex) {
Set<ConfiguredNode> configuredNodes = new HashSet<>(cluster.getConfiguredNodes().values());
configuredNodes.remove(new ConfiguredNode(nodeIndex, false));
configuredNodes.add(new ConfiguredNode(nodeIndex, true));
@@ -177,20 +177,20 @@ public class ClusterFixture {
return this;
}
- public AnnotatedClusterState annotatedGeneratedClusterState() {
+ AnnotatedClusterState annotatedGeneratedClusterState() {
params.currentTimeInMilllis(timer.getCurrentTimeInMillis());
return ClusterStateGenerator.generatedStateFrom(params);
}
- public ClusterState rawGeneratedClusterState() {
+ private ClusterState rawGeneratedClusterState() {
return annotatedGeneratedClusterState().getClusterState();
}
- public String generatedClusterState() {
+ String generatedClusterState() {
return annotatedGeneratedClusterState().getClusterState().toString();
}
- public String verboseGeneratedClusterState() {
+ String verboseGeneratedClusterState() {
return annotatedGeneratedClusterState().getClusterState().toString(true);
}
@@ -203,7 +203,7 @@ public class ClusterFixture {
return new ClusterFixture(cluster, distribution);
}
- public static ClusterFixture forHierarchicCluster(DistributionBuilder.GroupBuilder root) {
+ static ClusterFixture forHierarchicCluster(DistributionBuilder.GroupBuilder root) {
List<ConfiguredNode> nodes = DistributionBuilder.buildConfiguredNodes(root.totalNodeCount());
Distribution distribution = DistributionBuilder.forHierarchicCluster(root);
ContentCluster cluster = new ContentCluster("foo", nodes, distribution, 0, 0.0);
@@ -211,7 +211,7 @@ public class ClusterFixture {
return new ClusterFixture(cluster, distribution);
}
- public ClusterStateGenerator.Params generatorParams() {
+ ClusterStateGenerator.Params generatorParams() {
return new ClusterStateGenerator.Params().cluster(cluster);
}
@@ -219,11 +219,11 @@ public class ClusterFixture {
return this.cluster;
}
- public static Node storageNode(int index) {
+ static Node storageNode(int index) {
return new Node(NodeType.STORAGE, index);
}
- public static Node distributorNode(int index) {
+ static Node distributorNode(int index) {
return new Node(NodeType.DISTRIBUTOR, index);
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java
index 339d305e823..9ec3902fc1d 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java
@@ -1,7 +1,11 @@
// Copyright 2018 Yahoo Holdings. 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.state.*;
+import com.yahoo.vdslib.state.ClusterState;
+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 org.junit.Test;
import java.util.function.Function;
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 958fc1ae232..2f91e569b89 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,7 +1,6 @@
// Copyright 2017 Yahoo Holdings. 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;
@@ -9,7 +8,6 @@ import com.yahoo.vdslib.state.NodeType;
import com.yahoo.vdslib.state.State;
import org.junit.Test;
-import java.util.List;
import java.util.Optional;
import static com.yahoo.vespa.clustercontroller.core.matchers.HasStateReasonForNode.hasStateReasonForNode;
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateViewTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateViewTest.java
index b456965d549..b7f4b0c7ddb 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateViewTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateViewTest.java
@@ -13,16 +13,14 @@ import static org.mockito.Mockito.*;
/**
* @author hakonhall
- * @since 5.34
*/
public class ClusterStateViewTest {
- final NodeInfo nodeInfo = mock(NodeInfo.class);
- final Node node = mock(Node.class);
- final ClusterStatsAggregator statsAggregator = mock(ClusterStatsAggregator.class);
- final ClusterState clusterState = mock(ClusterState.class);
- final ClusterStateView clusterStateView = new ClusterStateView(clusterState, statsAggregator);
+ private final NodeInfo nodeInfo = mock(NodeInfo.class);
+ private final ClusterStatsAggregator statsAggregator = mock(ClusterStatsAggregator.class);
+ private final ClusterState clusterState = mock(ClusterState.class);
+ private final ClusterStateView clusterStateView = new ClusterStateView(clusterState, statsAggregator);
- HostInfo createHostInfo(String version) {
+ private HostInfo createHostInfo(String version) {
return HostInfo.createHostInfo("{ \"cluster-state-version\": " + version + " }");
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregatorTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregatorTest.java
index 7f313b31a6c..9a295e95fff 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregatorTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregatorTest.java
@@ -4,7 +4,7 @@ package com.yahoo.vespa.clustercontroller.core;
import com.google.common.collect.Sets;
import org.junit.Test;
-import java.util.*;
+import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -12,19 +12,18 @@ import static org.junit.Assert.assertTrue;
/**
* @author hakonhall
- * @since 5.34
*/
public class ClusterStatsAggregatorTest {
private static class Fixture {
private ClusterStatsAggregator aggregator;
- public Fixture(Set<Integer> distributorNodes,
+ Fixture(Set<Integer> distributorNodes,
Set<Integer> contentNodes) {
aggregator = new ClusterStatsAggregator(distributorNodes, contentNodes);
}
- public void update(int distributorIndex, ContentClusterStatsBuilder clusterStats) {
+ void update(int distributorIndex, ContentClusterStatsBuilder clusterStats) {
aggregator.updateForDistributor(distributorIndex, clusterStats.build());
}
@@ -36,14 +35,14 @@ public class ClusterStatsAggregatorTest {
assertEquals(expectedStats.build(), aggregator.getAggregatedStatsForDistributor(distributorIndex));
}
- public boolean hasUpdatesFromAllDistributors() {
+ boolean hasUpdatesFromAllDistributors() {
return aggregator.getAggregatedStats().hasUpdatesFromAllDistributors();
}
}
private static class FourNodesFixture extends Fixture {
- public FourNodesFixture() {
+ FourNodesFixture() {
super(distributorNodes(1, 2), contentNodes(3, 4));
update(1, new ContentClusterStatsBuilder()
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsChangeTrackerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsChangeTrackerTest.java
index 6261469beca..2d0c4296c28 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsChangeTrackerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsChangeTrackerTest.java
@@ -14,17 +14,17 @@ public class ClusterStatsChangeTrackerTest {
private static class StatsBuilder {
private final ContentClusterStatsBuilder builder = new ContentClusterStatsBuilder();
- public StatsBuilder bucketsPending(int contentNodeIndex) {
+ StatsBuilder bucketsPending(int contentNodeIndex) {
builder.add(contentNodeIndex, "global", 5, 1);
return this;
}
- public StatsBuilder inSync(int contentNodeIndex) {
+ StatsBuilder inSync(int contentNodeIndex) {
builder.add(contentNodeIndex, "global", 5, 0);
return this;
}
- public ContentClusterStats build() {
+ ContentClusterStats build() {
return builder.build();
}
}
@@ -47,17 +47,17 @@ public class ClusterStatsChangeTrackerTest {
tracker = new ClusterStatsChangeTracker(aggregator.getAggregatedStats(), minMergeCompletionRatio);
}
- public static Fixture empty() {
+ static Fixture empty() {
return new Fixture(Sets.newHashSet(0, 1), 1.0);
}
- public static Fixture fromStats(StatsBuilder builder) {
+ static Fixture fromStats(StatsBuilder builder) {
Fixture result = new Fixture(Sets.newHashSet(0, 1), 1.0);
result.updateStats(builder);
return result;
}
- public void newAggregatedStats(StatsBuilder builder) {
+ void newAggregatedStats(StatsBuilder builder) {
aggregator = new ClusterStatsAggregator(Sets.newHashSet(1), contentNodeIndices);
updateStats(builder);
tracker.updateAggregatedStats(aggregator.getAggregatedStats(), minMergeCompletionRatio);
@@ -67,7 +67,7 @@ public class ClusterStatsChangeTrackerTest {
aggregator.updateForDistributor(1, builder.build());
}
- public boolean statsHaveChanged() {
+ boolean statsHaveChanged() {
return tracker.statsHaveChanged();
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterHtmlRendrerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterHtmlRendrerTest.java
index 9a3edf8e681..11b07c037ae 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterHtmlRendrerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterHtmlRendrerTest.java
@@ -4,7 +4,7 @@ package com.yahoo.vespa.clustercontroller.core;
import com.google.common.collect.Sets;
import com.yahoo.vdslib.state.ClusterState;
import com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo;
-import com.yahoo.vespa.clustercontroller.core.status.statuspage.VdsClusterHtmlRendrer;
+import com.yahoo.vespa.clustercontroller.core.status.statuspage.VdsClusterHtmlRenderer;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONWriter;
import org.junit.Before;
@@ -12,30 +12,28 @@ import org.junit.Test;
import java.io.StringWriter;
import java.io.Writer;
-import java.text.ParseException;
import java.util.TreeMap;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
public class ContentClusterHtmlRendrerTest {
- VdsClusterHtmlRendrer rendrer = new VdsClusterHtmlRendrer();
- final static int slobrokGeneration = 34;
- final static String clusterName = "clustername";
- final TreeMap<Integer, NodeInfo> storageNodeInfoByIndex = new TreeMap<>();
- final TreeMap<Integer, NodeInfo> distributorNodeInfoByIndex = new TreeMap<>();
- String result;
+ private VdsClusterHtmlRenderer renderer = new VdsClusterHtmlRenderer();
+ private final static int slobrokGeneration = 34;
+ private final static String clusterName = "clustername";
+ private final TreeMap<Integer, NodeInfo> storageNodeInfoByIndex = new TreeMap<>();
+ private final TreeMap<Integer, NodeInfo> distributorNodeInfoByIndex = new TreeMap<>();
+ private String result;
@Before
- public void before() throws JSONException, ParseException {
+ public void before() throws JSONException {
final ClusterStateBundle stateBundle = ClusterStateBundle.ofBaselineOnly(
AnnotatedClusterState.withoutAnnotations(
ClusterState.stateFromString("version:34633 bits:24 distributor:211 storage:211")));
- final ClusterState state = stateBundle.getBaselineClusterState();
final EventLog eventLog = new EventLog(new FakeTimer(), null);
- final VdsClusterHtmlRendrer.Table table = rendrer.createNewClusterHtmlTable(clusterName, slobrokGeneration);
+ final VdsClusterHtmlRenderer.Table table = renderer.createNewClusterHtmlTable(clusterName, slobrokGeneration);
final ContentCluster contentCluster = mock(ContentCluster.class);
@@ -71,7 +69,7 @@ public class ContentClusterHtmlRendrerTest {
}
@Test
- public void testVtagRendering() throws Exception {
+ public void testVtagRendering() {
// 9 distribution nodes should have green tag on release1.
assertThat(result.split("<td bgcolor=\"#c0ffc0\" align=\"right\"><nobr>release1</nobr></td>").length, is(10));
// 1 distribution node should have warning on release1bad.
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterStatsBuilder.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterStatsBuilder.java
index dd0205658cb..ce79b492638 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterStatsBuilder.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterStatsBuilder.java
@@ -15,7 +15,7 @@ public class ContentClusterStatsBuilder {
return add(nodeIndex, bucketSpace, ContentNodeStats.BucketSpaceStats.of(bucketsTotal, bucketsPending));
}
- public ContentClusterStatsBuilder addInvalid(int nodeIndex, String bucketSpace, long bucketsTotal, long bucketsPending) {
+ ContentClusterStatsBuilder addInvalid(int nodeIndex, String bucketSpace, long bucketsTotal, long bucketsPending) {
return add(nodeIndex, bucketSpace, ContentNodeStats.BucketSpaceStats.invalid(bucketsTotal, bucketsPending));
}
@@ -38,7 +38,7 @@ public class ContentClusterStatsBuilder {
return this;
}
- public ContentClusterStats build() {
+ ContentClusterStats build() {
Map<Integer, ContentNodeStats> nodeToStatsMap = new HashMap<>();
stats.forEach((nodeIndex, nodeStatsBuilder) ->
nodeToStatsMap.put(nodeIndex, nodeStatsBuilder.build()));
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStatsBuilder.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStatsBuilder.java
index f4d5b86d6da..f3cce04198d 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStatsBuilder.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStatsBuilder.java
@@ -13,7 +13,7 @@ public class ContentNodeStatsBuilder {
this.nodeIndex = nodeIndex;
}
- public static ContentNodeStatsBuilder forNode(int nodeIndex) {
+ static ContentNodeStatsBuilder forNode(int nodeIndex) {
return new ContentNodeStatsBuilder(nodeIndex);
}
@@ -26,7 +26,7 @@ public class ContentNodeStatsBuilder {
return this;
}
- public ContentNodeStats build() {
+ ContentNodeStats build() {
return new ContentNodeStats(nodeIndex, stats);
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseTest.java
index 27dcd009c96..327a0e229fc 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseTest.java
@@ -27,7 +27,7 @@ public class DatabaseTest extends FleetControllerTest {
private static Logger log = Logger.getLogger(DatabaseTest.class.getName());
// Note: different semantics than FleetControllerTest.setWantedState
- protected void setWantedState(Node n, NodeState ns, Map<Node, NodeState> wantedStates) {
+ private void setWantedState(Node n, NodeState ns, Map<Node, NodeState> wantedStates) {
int rpcPort = fleetController.getRpcPort();
if (supervisor == null) {
supervisor = new Supervisor(new Transport());
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DistributionBitCountTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DistributionBitCountTest.java
index 77164b678c6..dc19770568e 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DistributionBitCountTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DistributionBitCountTest.java
@@ -6,7 +6,6 @@ import com.yahoo.vdslib.state.ClusterState;
import com.yahoo.vdslib.state.NodeState;
import com.yahoo.vdslib.state.NodeType;
import com.yahoo.vdslib.state.State;
-import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DistributionBuilder.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DistributionBuilder.java
index e2eefd02c5f..67a676d388f 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DistributionBuilder.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DistributionBuilder.java
@@ -12,46 +12,46 @@ import java.util.stream.IntStream;
public class DistributionBuilder {
// TODO support nested groups
- public static class GroupBuilder {
+ static class GroupBuilder {
final int groupCount;
- public List<Integer> groupsWithNodeCount;
+ List<Integer> groupsWithNodeCount;
- public GroupBuilder(int groupCount) {
+ GroupBuilder(int groupCount) {
this.groupCount = groupCount;
}
- public GroupBuilder(int... nodeCounts) {
+ GroupBuilder(int... nodeCounts) {
this.groupCount = nodeCounts.length;
this.groupsWithNodeCount = IntStream.of(nodeCounts).boxed()
.collect(Collectors.toList());
}
- public GroupBuilder eachWithNodeCount(int nodeCount) {
+ GroupBuilder eachWithNodeCount(int nodeCount) {
groupsWithNodeCount = IntStream.range(0, groupCount)
.map(i -> nodeCount).boxed()
.collect(Collectors.toList());
return this;
}
- public int totalNodeCount() {
+ int totalNodeCount() {
return groupsWithNodeCount.stream().reduce(0, Integer::sum);
}
- public String groupDistributionSpec() {
+ String groupDistributionSpec() {
return IntStream.range(0, groupCount).mapToObj(i -> "1")
.collect(Collectors.joining("|")) + "|*";
}
}
- public static GroupBuilder withGroups(int groups) {
+ static GroupBuilder withGroups(int groups) {
return new GroupBuilder(groups);
}
- public static GroupBuilder withGroupNodes(int... nodeCounts) {
+ static GroupBuilder withGroupNodes(int... nodeCounts) {
return new GroupBuilder(nodeCounts);
}
- public static List<ConfiguredNode> buildConfiguredNodes(int nodeCount) {
+ static List<ConfiguredNode> buildConfiguredNodes(int nodeCount) {
return IntStream.range(0, nodeCount)
.mapToObj(i -> new ConfiguredNode(i, false))
.collect(Collectors.toList());
@@ -82,7 +82,7 @@ public class DistributionBuilder {
return new Distribution(new StorDistributionConfig(configBuilder));
}
- public static Distribution forHierarchicCluster(GroupBuilder root) {
+ static Distribution forHierarchicCluster(GroupBuilder root) {
List<ConfiguredNode> nodes = buildConfiguredNodes(root.totalNodeCount());
StorDistributionConfig.Builder configBuilder = new StorDistributionConfig.Builder();
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyCommunicator.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyCommunicator.java
index 8314839336e..5d5daa25e30 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyCommunicator.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyCommunicator.java
@@ -16,18 +16,18 @@ import java.util.TreeMap;
public class DummyCommunicator implements Communicator, NodeLookup {
List<Node> newNodes;
- Timer timer;
+ private Timer timer;
private boolean shouldDeferDistributorClusterStateAcks = false;
private List<Pair<Waiter<SetClusterStateRequest>, DummySetClusterStateRequest>> deferredClusterStateAcks = new ArrayList<>();
- public void setShouldDeferDistributorClusterStateAcks(boolean shouldDeferDistributorClusterStateAcks) {
+ void setShouldDeferDistributorClusterStateAcks(boolean shouldDeferDistributorClusterStateAcks) {
this.shouldDeferDistributorClusterStateAcks = shouldDeferDistributorClusterStateAcks;
}
- class DummyGetNodeStateRequest extends GetNodeStateRequest {
+ static class DummyGetNodeStateRequest extends GetNodeStateRequest {
Waiter<GetNodeStateRequest> waiter;
- public DummyGetNodeStateRequest(NodeInfo nodeInfo, Waiter<GetNodeStateRequest> waiter) {
+ DummyGetNodeStateRequest(NodeInfo nodeInfo, Waiter<GetNodeStateRequest> waiter) {
super(nodeInfo);
this.waiter = waiter;
@@ -39,17 +39,17 @@ public class DummyCommunicator implements Communicator, NodeLookup {
}
}
- public class DummySetClusterStateRequest extends SetClusterStateRequest {
+ public static class DummySetClusterStateRequest extends SetClusterStateRequest {
- public DummySetClusterStateRequest(NodeInfo nodeInfo, ClusterState state) {
+ DummySetClusterStateRequest(NodeInfo nodeInfo, ClusterState state) {
super(nodeInfo, state.getVersion());
}
}
- public class DummyActivateClusterStateVersionRequest extends ActivateClusterStateVersionRequest {
+ public static class DummyActivateClusterStateVersionRequest extends ActivateClusterStateVersionRequest {
- public DummyActivateClusterStateVersionRequest(NodeInfo nodeInfo, int stateVersion) {
+ DummyActivateClusterStateVersionRequest(NodeInfo nodeInfo, int stateVersion) {
super(nodeInfo, stateVersion);
}
@@ -57,7 +57,7 @@ public class DummyCommunicator implements Communicator, NodeLookup {
private Map<Node, DummyGetNodeStateRequest> getNodeStateRequests = new TreeMap<>();
- public DummyCommunicator(List<Node> nodeList, Timer timer) {
+ DummyCommunicator(List<Node> nodeList, Timer timer) {
this.newNodes = nodeList;
this.timer = timer;
}
@@ -74,11 +74,11 @@ public class DummyCommunicator implements Communicator, NodeLookup {
}
- public boolean setNodeState(Node node, State state, String description) throws Exception {
+ public boolean setNodeState(Node node, State state, String description) {
return setNodeState(node, new NodeState(node.getType(), state).setDescription(description), "");
}
- public boolean setNodeState(Node node, NodeState state, String hostInfo) throws Exception {
+ public boolean setNodeState(Node node, NodeState state, String hostInfo) {
DummyGetNodeStateRequest req = getNodeStateRequests.remove(node);
if (req == null) {
@@ -113,12 +113,12 @@ public class DummyCommunicator implements Communicator, NodeLookup {
waiter.done(req);
}
- public void sendAllDeferredDistributorClusterStateAcks() {
+ void sendAllDeferredDistributorClusterStateAcks() {
deferredClusterStateAcks.forEach(reqAndWaiter -> reqAndWaiter.getFirst().done(reqAndWaiter.getSecond()));
deferredClusterStateAcks.clear();
}
- public void sendPartialDeferredDistributorClusterStateAcks() {
+ void sendPartialDeferredDistributorClusterStateAcks() {
if (deferredClusterStateAcks.isEmpty()) {
throw new IllegalStateException("Tried to send partial ACKs with no ACKs deferred");
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyVdsNode.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyVdsNode.java
index 27415cde407..b611d573ff5 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyVdsNode.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyVdsNode.java
@@ -1,8 +1,17 @@
// Copyright 2017 Yahoo Holdings. 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.*;
+import com.yahoo.jrt.Acceptor;
+import com.yahoo.jrt.ErrorCode;
+import com.yahoo.jrt.Int32Value;
+import com.yahoo.jrt.ListenFailedException;
+import com.yahoo.jrt.Method;
+import com.yahoo.jrt.Request;
+import com.yahoo.jrt.Spec;
import com.yahoo.jrt.StringValue;
+import com.yahoo.jrt.StringValue;
+import com.yahoo.jrt.Supervisor;
+import com.yahoo.jrt.Transport;
import com.yahoo.jrt.slobrok.api.BackOffPolicy;
import com.yahoo.jrt.slobrok.api.Register;
import com.yahoo.jrt.slobrok.api.SlobrokList;
@@ -11,8 +20,12 @@ import com.yahoo.vdslib.state.*;
import com.yahoo.vespa.clustercontroller.core.rpc.RPCCommunicator;
import com.yahoo.vespa.clustercontroller.core.rpc.RPCUtil;
-import java.net.UnknownHostException;
-import java.util.*;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.TreeMap;
import java.util.logging.Logger;
import java.util.stream.Collectors;
@@ -25,7 +38,7 @@ public class DummyVdsNode {
public static Logger log = Logger.getLogger(DummyVdsNode.class.getName());
- private String slobrokConnectionSpecs[];
+ private String[] slobrokConnectionSpecs;
private String clusterName;
private NodeType type;
private int index;
@@ -39,15 +52,14 @@ public class DummyVdsNode {
private final Timer timer;
private boolean failSetSystemStateRequests = false;
private boolean resetTimestampOnReconnect = false;
- private long startTimestamp;
private Map<Node, Long> highestStartTimestamps = new TreeMap<Node, Long>();
- public int timedOutStateReplies = 0;
- public int outdatedStateReplies = 0;
- public int immediateStateReplies = 0;
- public int setNodeStateReplies = 0;
+ int timedOutStateReplies = 0;
+ int outdatedStateReplies = 0;
+ int immediateStateReplies = 0;
+ int setNodeStateReplies = 0;
private boolean registeredInSlobrok = false;
- class Req {
+ static class Req {
Request request;
long timeout;
@@ -56,7 +68,7 @@ public class DummyVdsNode {
this.timeout = timeout;
}
}
- class BackOff implements BackOffPolicy {
+ static class BackOff implements BackOffPolicy {
public void reset() {}
public double get() { return 0.01; }
public boolean shouldWarn(double v) { return false; }
@@ -113,11 +125,7 @@ public class DummyVdsNode {
nodeState.setStartTimestamp(timer.getCurrentTimeInMillis() / 1000);
}
- public void resetStartTimestamp() {
- resetTimestampOnReconnect = true;
- }
-
- public int getPendingNodeStateCount() { return waitingRequests.size(); }
+ int getPendingNodeStateCount() { return waitingRequests.size(); }
public void shutdown() {
messageResponder.interrupt();
@@ -125,9 +133,9 @@ public class DummyVdsNode {
disconnect();
}
- public int connect() throws ListenFailedException, UnknownHostException {
+ public int connect() throws ListenFailedException {
if (resetTimestampOnReconnect) {
- startTimestamp = timer.getCurrentTimeInMillis() / 1000;
+ long startTimestamp = timer.getCurrentTimeInMillis() / 1000;
nodeState.setStartTimestamp(startTimestamp);
resetTimestampOnReconnect = false;
}
@@ -146,23 +154,23 @@ public class DummyVdsNode {
return (registeredInSlobrok && supervisor != null);
}
- public void registerSlobrok() {
+ void registerSlobrok() {
register.registerName(getSlobrokName());
register.registerName(getSlobrokName() + "/default");
registeredInSlobrok = true;
}
- public void disconnectSlobrok() {
+ void disconnectSlobrok() {
register.unregisterName(getSlobrokName());
register.unregisterName(getSlobrokName() + "/default");
registeredInSlobrok = false;
}
- public void disconnect() { disconnectImmediately(); }
- public void disconnectImmediately() { disconnect(false, 0, false); }
- public void disconnectBreakConnection() { disconnect(true, FleetControllerTest.timeoutMS, false); }
- public void disconnectAsShutdown() { disconnect(true, FleetControllerTest.timeoutMS, true); }
- public void disconnect(boolean waitForPendingNodeStateRequest, long timeoutms, boolean setStoppingStateFirst) {
+ void disconnect() { disconnectImmediately(); }
+ void disconnectImmediately() { disconnect(false, 0, false); }
+ void disconnectBreakConnection() { disconnect(true, FleetControllerTest.timeoutMS, false); }
+ void disconnectAsShutdown() { disconnect(true, FleetControllerTest.timeoutMS, true); }
+ private void disconnect(boolean waitForPendingNodeStateRequest, long timeoutms, boolean setStoppingStateFirst) {
log.log(LogLevel.DEBUG, "Dummy node " + DummyVdsNode.this.toString() + ": Breaking connection." + (waitForPendingNodeStateRequest ? " Waiting for pending state first." : ""));
if (waitForPendingNodeStateRequest) {
this.waitForPendingGetNodeStateRequest(timeoutms);
@@ -198,7 +206,7 @@ public class DummyVdsNode {
public int getStateCommunicationVersion() { return stateCommunicationVersion; }
- public void waitForSystemStateVersion(int version, long timeout) {
+ void waitForSystemStateVersion(int version, long timeout) {
try {
long startTime = System.currentTimeMillis();
while (getLatestSystemStateVersion().orElse(-1) < version) {
@@ -233,7 +241,7 @@ public class DummyVdsNode {
}
}
- public void waitForPendingGetNodeStateRequest(long timeout) {
+ private void waitForPendingGetNodeStateRequest(long timeout) {
long startTime = System.currentTimeMillis();
long endTime = startTime + timeout;
log.log(LogLevel.DEBUG, "Dummy node " + this + " waiting for pending node state request.");
@@ -261,7 +269,7 @@ public class DummyVdsNode {
}
}
- public void replyToPendingNodeStateRequests() {
+ void replyToPendingNodeStateRequests() {
for(Req req : waitingRequests) {
log.log(LogLevel.DEBUG, "Dummy node " + this + " answering pending node state request.");
req.request.returnValues().add(new StringValue(nodeState.serialize()));
@@ -297,7 +305,7 @@ public class DummyVdsNode {
}
}
- public List<ClusterState> getSystemStatesReceived() {
+ List<ClusterState> getSystemStatesReceived() {
synchronized(timer) {
return clusterStateBundles.stream()
.map(ClusterStateBundle::getBaselineClusterState)
@@ -320,11 +328,11 @@ public class DummyVdsNode {
public ClusterState getClusterState() {
return Optional.ofNullable(getClusterStateBundle())
- .map(b -> b.getBaselineClusterState())
+ .map(ClusterStateBundle::getBaselineClusterState)
.orElse(null);
}
- public String getSlobrokName() {
+ String getSlobrokName() {
return "storage/cluster." + clusterName + "/" + type + "/" + index;
}
@@ -415,7 +423,7 @@ public class DummyVdsNode {
}
}
- public boolean sendGetNodeStateReply(int index) {
+ boolean sendGetNodeStateReply(int index) {
for (Iterator<Req> it = waitingRequests.iterator(); it.hasNext(); ) {
Req r = it.next();
if (r.request.parameters().size() > 2 && r.request.parameters().get(2).asInt32() == index) {
@@ -488,7 +496,7 @@ public class DummyVdsNode {
}
}
- public void failSetSystemState(boolean failSystemStateRequests) {
+ void failSetSystemState(boolean failSystemStateRequests) {
synchronized (timer) {
this.failSetSystemStateRequests = failSystemStateRequests;
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyVdsNodeOptions.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyVdsNodeOptions.java
index bf63aebe022..30e7c9a8417 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyVdsNodeOptions.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyVdsNodeOptions.java
@@ -9,5 +9,5 @@ import com.yahoo.vespa.clustercontroller.core.rpc.RPCCommunicator;
*/
public class DummyVdsNodeOptions {
// 0 - 4.1, 1 - 4.2-5.0.10, 2 - 5.0.11+, 3 - 6.220+, 4 - 7.24+
- public int stateCommunicationVersion = RPCCommunicator.ACTIVATE_CLUSTER_STATE_VERSION_RPC_VERSION;
+ int stateCommunicationVersion = RPCCommunicator.ACTIVATE_CLUSTER_STATE_VERSION_RPC_VERSION;
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventLogTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventLogTest.java
index 1dfe1249ed0..8888ab2d7d0 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventLogTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventLogTest.java
@@ -3,7 +3,6 @@ package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.state.Node;
import com.yahoo.vdslib.state.NodeType;
-import com.yahoo.vespa.clustercontroller.utils.util.MetricReporter;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FakeTimer.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FakeTimer.java
index d2fa0b51eed..e161c4aacb7 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FakeTimer.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FakeTimer.java
@@ -13,8 +13,8 @@ import java.util.logging.Logger;
*/
public class FakeTimer implements Timer {
private static Logger log = Logger.getLogger(FakeTimer.class.getName());
- // Don't start at zero. Clock users may initialize a 'last run' entry with 0, and we want first time to always look like a timeout
- long currentTime = (long)30 * 365 * 24 * 60 * 60 * 1000;
+ // Don't start at zero. Clock users may initialize a 'last run' entry with 0, and we want first time to always look like a timeout
+ private long currentTime = (long) 30 * 365 * 24 * 60 * 60 * 1000;
public synchronized long getCurrentTimeInMillis() {
return currentTime;
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 5ecc33ae964..ae64bee6bbf 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
@@ -34,14 +34,17 @@ import org.junit.rules.TestRule;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -52,20 +55,20 @@ import java.util.stream.Collectors;
public abstract class FleetControllerTest implements Waiter {
private static Logger log = Logger.getLogger(FleetControllerTest.class.getName());
- protected static final int DEFAULT_NODE_COUNT = 10;
+ private static final int DEFAULT_NODE_COUNT = 10;
- protected Supervisor supervisor;
+ Supervisor supervisor;
protected FakeTimer timer = new FakeTimer();
- protected boolean usingFakeTimer = false;
+ boolean usingFakeTimer = false;
protected Slobrok slobrok;
protected FleetControllerOptions options;
- protected ZooKeeperTestServer zooKeeperServer;
+ ZooKeeperTestServer zooKeeperServer;
protected FleetController fleetController;
protected List<DummyVdsNode> nodes = new ArrayList<>();
- protected String testName;
+ private String testName;
- public final static int timeoutS;
- public final static int timeoutMS;
+ final static int timeoutS;
+ final static int timeoutMS;
private final Waiter waiter = new Waiter.Impl(new DataRetriever() {
@Override
public Object getMonitor() { return timer; }
@@ -83,7 +86,7 @@ public abstract class FleetControllerTest implements Waiter {
timeoutMS = timeoutS * 1000;
}
- class BackOff implements BackOffPolicy {
+ static class BackOff implements BackOffPolicy {
private int counter = 0;
public void reset() { counter = 0; }
public double get() { ++counter; return 0.01; }
@@ -131,7 +134,7 @@ public abstract class FleetControllerTest implements Waiter {
return opts;
}
- protected void setUpSystem(boolean useFakeTimer, FleetControllerOptions options) throws Exception {
+ void setUpSystem(boolean useFakeTimer, FleetControllerOptions options) throws Exception {
log.log(LogLevel.DEBUG, "Setting up system");
slobrok = new Slobrok();
this.options = options;
@@ -145,7 +148,7 @@ public abstract class FleetControllerTest implements Waiter {
this.usingFakeTimer = useFakeTimer;
}
- protected FleetController createFleetController(boolean useFakeTimer, FleetControllerOptions options, boolean startThread, StatusPageServerInterface status) throws Exception {
+ FleetController createFleetController(boolean useFakeTimer, FleetControllerOptions options, boolean startThread, StatusPageServerInterface status) throws Exception {
Timer timer = useFakeTimer ? this.timer : new RealTimer();
MetricUpdater metricUpdater = new MetricUpdater(new NoMetricReporter(), options.fleetControllerIndex);
EventLog log = new EventLog(timer, metricUpdater);
@@ -197,13 +200,14 @@ public abstract class FleetControllerTest implements Waiter {
}
}
- protected void stopFleetController() throws Exception {
+ void stopFleetController() throws Exception {
if (fleetController != null) {
fleetController.shutdown();
fleetController = null;
}
}
- protected void startFleetController() throws Exception {
+
+ void startFleetController() throws Exception {
if (fleetController == null) {
fleetController = createFleetController(usingFakeTimer, options, true, null);
} else {
@@ -224,7 +228,7 @@ public abstract class FleetControllerTest implements Waiter {
setUpVdsNodes(useFakeTimer, options, startDisconnected, nodeIndexes);
}
protected void setUpVdsNodes(boolean useFakeTimer, DummyVdsNodeOptions options, boolean startDisconnected, Set<Integer> nodeIndexes) throws Exception {
- String connectionSpecs[] = new String[1];
+ String[] connectionSpecs = new String[1];
connectionSpecs[0] = "tcp/localhost:" + slobrok.port();
for (int nodeIndex : nodeIndexes) {
nodes.add(new DummyVdsNode(useFakeTimer ? timer : new RealTimer(), options, connectionSpecs, this.options.clusterName, true, nodeIndex));
@@ -241,7 +245,7 @@ public abstract class FleetControllerTest implements Waiter {
* the returned list is twice as large as configuredNodes.
*/
protected List<DummyVdsNode> setUpVdsNodes(boolean useFakeTimer, DummyVdsNodeOptions options, boolean startDisconnected, List<ConfiguredNode> configuredNodes) throws Exception {
- String connectionSpecs[] = new String[1];
+ String[] connectionSpecs = new String[1];
connectionSpecs[0] = "tcp/localhost:" + slobrok.port();
nodes = new ArrayList<>();
final boolean distributor = true;
@@ -254,15 +258,15 @@ public abstract class FleetControllerTest implements Waiter {
return nodes;
}
- protected static Set<Integer> asIntSet(Integer... idx) {
- return Arrays.asList(idx).stream().collect(Collectors.toSet());
+ static Set<Integer> asIntSet(Integer... idx) {
+ return new HashSet<>(Arrays.asList(idx));
}
- protected static Set<ConfiguredNode> asConfiguredNodes(Set<Integer> indices) {
+ static Set<ConfiguredNode> asConfiguredNodes(Set<Integer> indices) {
return indices.stream().map(idx -> new ConfiguredNode(idx, false)).collect(Collectors.toSet());
}
- protected void waitForStateExcludingNodeSubset(String expectedState, Set<Integer> excludedNodes) throws Exception {
+ void waitForStateExcludingNodeSubset(String expectedState, Set<Integer> excludedNodes) throws Exception {
// Due to the implementation details of the test base, this.waitForState() will always
// wait until all nodes added in the test have received the latest cluster state. Since we
// want to entirely ignore node #6, it won't get a cluster state at all and the test will
@@ -286,7 +290,7 @@ public abstract class FleetControllerTest implements Waiter {
subsetWaiter.waitForState(expectedState);
}
- protected static Map<NodeType, Integer> transitionTimes(int milliseconds) {
+ static Map<NodeType, Integer> transitionTimes(int milliseconds) {
Map<NodeType, Integer> maxTransitionTime = new TreeMap<>();
maxTransitionTime.put(NodeType.DISTRIBUTOR, milliseconds);
maxTransitionTime.put(NodeType.STORAGE, milliseconds);
@@ -330,23 +334,11 @@ public abstract class FleetControllerTest implements Waiter {
public ClusterState waitForInitProgressPassed(Node n, double progress) { return waiter.waitForInitProgressPassed(n, progress); }
public ClusterState waitForClusterStateIncludingNodesWithMinUsedBits(int bitcount, int nodecount) { return waiter.waitForClusterStateIncludingNodesWithMinUsedBits(bitcount, nodecount); }
- protected void waitForNodeStateReported(int nodeIndex, NodeState state, int ms) {
- long timeoutAtTime = System.currentTimeMillis() + ms;
- while (true) {
- Node node = nodes.get(nodeIndex).getNode();
- NodeState ns = fleetController.getReportedNodeState(node);
- if ((ns == null && state == null) || (ns != null && state != null && ns.equals(state))) break;
- if (System.currentTimeMillis() > timeoutAtTime) {
- throw new IllegalStateException("Failed to find " + node + " in nodestate " + state + " before timeout of " + ms + " milliseconds.");
- }
- }
- }
-
public void wait(WaitCondition c, WaitTask wt, int timeoutMS) {
waiter.wait(c, wt, timeoutMS);
}
- public void waitForCompleteCycle() {
+ void waitForCompleteCycle() {
fleetController.waitForCompleteCycle(timeoutMS);
}
@@ -354,7 +346,7 @@ public abstract class FleetControllerTest implements Waiter {
verifyNodeEvents(n, exp, null);
}
- private class ExpectLine {
+ private static class ExpectLine {
Pattern regex;
int matchedCount = 0;
int minCount = 1;
@@ -398,7 +390,7 @@ public abstract class FleetControllerTest implements Waiter {
* <li>The rest of the line is a regular expression.
* </ul>
*/
- protected void verifyNodeEvents(Node n, String exp, String ignoreRegex) {
+ private void verifyNodeEvents(Node n, String exp, String ignoreRegex) {
Pattern ignorePattern = (ignoreRegex == null ? null : Pattern.compile(ignoreRegex));
List<NodeEvent> events = fleetController.getNodeEvents(n);
String[] expectLines = exp.split("\n");
@@ -475,64 +467,13 @@ public abstract class FleetControllerTest implements Waiter {
}
}
- protected String generateHostInfo(double averagePutLatency, long operationCount) {
- return ("{\n" +
- " \"metrics\":\n" +
- " {\n" +
- " \"snapshot\":\n" +
- " {\n" +
- " \"from\":1335527020,\n" +
- " \"to\":1335527320\n" +
- " },\n" +
- " \"values\":\n" +
- " [\n" +
- " {\n" +
- " \"name\":\"vds.filestor.disk_0.allthreads.put.sum.latency\",\n" +
- " \"values\":\n" +
- " {\n" +
- " \"average\":" + averagePutLatency + ",\n" +
- " \"rate\":123.00000\n" +
- " }\n" +
- " },\n" +
- " {\n" +
- " \"name\":\"vds.filestor.disk_0.allthreads.operations\",\n" +
- " \"values\":\n" +
- " {\n" +
- " \"count\":" + operationCount + ",\n" +
- " \"rate\":3.266666\n" +
- " }\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- "}\n");
- }
-
- protected String readFile(String filename) throws IOException {
- FileInputStream stream = new FileInputStream(new File(filename));
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- try {
- byte [] buf = new byte[4096];
- while (true) {
- int read = stream.read(buf);
- if (read<=0) {
- break;
- }
- output.write(buf, 0, read);
- }
- output.close();
- return output.toString();
- } finally {
- stream.close();
- }
- }
-
public static Set<ConfiguredNode> toNodes(Integer ... indexes) {
- return Arrays.asList(indexes).stream()
+ return Arrays.stream(indexes)
.map(i -> new ConfiguredNode(i, false))
.collect(Collectors.toSet());
}
- protected void setWantedState(DummyVdsNode node, State state, String reason) {
+ void setWantedState(DummyVdsNode node, State state, String reason) {
if (supervisor == null) {
supervisor = new Supervisor(new Transport());
}
@@ -544,10 +485,10 @@ public abstract class FleetControllerTest implements Waiter {
req.parameters().add(new StringValue(ns.serialize()));
connection.invokeSync(req, timeoutS);
if (req.isError()) {
- assertTrue("Failed to invoke setNodeState(): " + req.errorCode() + ": " + req.errorMessage(), false);
+ fail("Failed to invoke setNodeState(): " + req.errorCode() + ": " + req.errorMessage());
}
if (!req.checkReturnTypes("s")) {
- assertTrue("Failed to invoke setNodeState(): Invalid return types.", false);
+ fail("Failed to invoke setNodeState(): Invalid return types.");
}
}
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 4805257ea7a..10d7bc94ae0 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
@@ -1,12 +1,9 @@
// Copyright 2017 Yahoo Holdings. 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.state.NodeType;
import org.junit.Test;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.stream.Collectors;
+import java.util.HashSet;
import static org.junit.Assert.assertFalse;
@@ -20,8 +17,7 @@ public class GroupAutoTakedownLiveConfigTest extends FleetControllerTest {
{
FleetControllerOptions options = defaultOptions("mycluster");
options.setStorageDistribution(DistributionBuilder.forHierarchicCluster(groupBuilder));
- options.nodes = DistributionBuilder.buildConfiguredNodes(groupBuilder.totalNodeCount())
- .stream().collect(Collectors.toSet());
+ options.nodes = new HashSet<>(DistributionBuilder.buildConfiguredNodes(groupBuilder.totalNodeCount()));
options.minNodeRatioPerGroup = minNodeRatio;
options.maxTransitionTime = transitionTimes(0);
return options;
@@ -40,8 +36,7 @@ public class GroupAutoTakedownLiveConfigTest extends FleetControllerTest {
private void reconfigureWithDistribution(DistributionBuilder.GroupBuilder groupBuilder) {
FleetControllerOptions newOptions = this.options.clone();
- newOptions.nodes = DistributionBuilder.buildConfiguredNodes(groupBuilder.totalNodeCount())
- .stream().collect(Collectors.toSet());
+ newOptions.nodes = new HashSet<>(DistributionBuilder.buildConfiguredNodes(groupBuilder.totalNodeCount()));
newOptions.storageDistribution = DistributionBuilder.forHierarchicCluster(groupBuilder);
updateConfigLive(newOptions);
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownTest.java
index 41c5922c932..7ab920f384b 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownTest.java
@@ -21,12 +21,8 @@ import java.util.Set;
import static org.hamcrest.core.AllOf.allOf;
import static org.hamcrest.core.IsCollectionContaining.hasItem;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class GroupAutoTakedownTest {
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculatorTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculatorTest.java
index cef3e39937d..07bd18c3667 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculatorTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculatorTest.java
@@ -22,10 +22,7 @@ public class GroupAvailabilityCalculatorTest {
}
}
- private static GroupAvailabilityCalculator calcForFlatCluster(
- final int nodeCount,
- final double minNodeRatioPerGroup)
- {
+ private static GroupAvailabilityCalculator calcForFlatCluster(int nodeCount, double minNodeRatioPerGroup) {
return GroupAvailabilityCalculator.builder()
.withDistribution(DistributionBuilder.forFlatCluster(nodeCount))
.withMinNodeRatioPerGroup(minNodeRatioPerGroup)
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/LeafGroupsTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/LeafGroupsTest.java
index 47d2913b253..6302af5ebc9 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/LeafGroupsTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/LeafGroupsTest.java
@@ -7,7 +7,7 @@ import org.junit.Test;
import java.util.List;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertThat;
public class LeafGroupsTest {
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MaintenanceWhenPendingGlobalMergesTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MaintenanceWhenPendingGlobalMergesTest.java
index 294c57d520c..6619495fdd4 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MaintenanceWhenPendingGlobalMergesTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MaintenanceWhenPendingGlobalMergesTest.java
@@ -5,7 +5,7 @@ import com.yahoo.document.FixedBucketSpaces;
import com.yahoo.vdslib.state.ClusterState;
import org.junit.Test;
-import java.util.*;
+import java.util.Arrays;
import static com.yahoo.vespa.clustercontroller.core.NodeStateReason.MAY_HAVE_MERGES_PENDING;
import static com.yahoo.vespa.clustercontroller.core.NodeStateReason.NODE_TOO_UNSTABLE;
@@ -42,7 +42,7 @@ public class MaintenanceWhenPendingGlobalMergesTest {
private static class AnnotatedClusterStateBuilder extends AnnotatedClusterState.Builder {
- public static AnnotatedClusterStateBuilder ofState(String stateStr) {
+ static AnnotatedClusterStateBuilder ofState(String stateStr) {
return (AnnotatedClusterStateBuilder) new AnnotatedClusterStateBuilder().clusterState(stateStr);
}
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 821e98800d3..f919bd867c6 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
@@ -18,10 +18,10 @@ import org.junit.Test;
import org.junit.rules.TestRule;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
+import java.util.stream.Stream;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertEquals;
@@ -33,8 +33,8 @@ public class MasterElectionTest extends FleetControllerTest {
private static Logger log = Logger.getLogger(MasterElectionTest.class.getName());
- protected Supervisor supervisor;
- protected List<FleetController> fleetControllers = new ArrayList<>();
+ private Supervisor supervisor;
+ private List<FleetController> fleetControllers = new ArrayList<>();
@Rule
public TestRule cleanupZookeeperLogsOnSuccess = new CleanupZookeeperLogsOnSuccess();
@@ -60,9 +60,8 @@ public class MasterElectionTest extends FleetControllerTest {
}
}
- public FleetControllerOptions adjustConfig(FleetControllerOptions o,
- int fleetControllerIndex, int fleetControllerCount) throws Exception
- {
+ private FleetControllerOptions adjustConfig(FleetControllerOptions o,
+ int fleetControllerIndex, int fleetControllerCount) {
FleetControllerOptions options = o.clone();
options.zooKeeperSessionTimeout = defaultZkSessionTimeoutInMillis();
options.zooKeeperServerAddress = zooKeeperServer.getAddress();
@@ -73,7 +72,7 @@ public class MasterElectionTest extends FleetControllerTest {
return options;
}
- protected void waitForZookeeperDisconnected() throws TimeoutException {
+ private void waitForZookeeperDisconnected() throws TimeoutException {
long maxTime = System.currentTimeMillis() + timeoutMS;
for(FleetController f : fleetControllers) {
while (true) {
@@ -86,11 +85,11 @@ public class MasterElectionTest extends FleetControllerTest {
waitForCompleteCycles();
}
- protected void waitForCompleteCycle(int findex) {
+ private void waitForCompleteCycle(int findex) {
fleetControllers.get(findex).waitForCompleteCycle(timeoutMS);
}
- protected void waitForCompleteCycles() {
+ private void waitForCompleteCycles() {
for (int i = 0; i < fleetControllers.size(); ++i) {
waitForCompleteCycle(i);
}
@@ -137,7 +136,7 @@ public class MasterElectionTest extends FleetControllerTest {
// 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);
- assertEquals("Fleet controller " + i, false, fleetControllers.get(i).isMaster());
+ assertFalse("Fleet controller " + i, fleetControllers.get(i).isMaster());
}
log.log(LogLevel.INFO, "STARTING FLEET CONTROLLER 2");
@@ -162,11 +161,11 @@ public class MasterElectionTest extends FleetControllerTest {
// 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);
- assertEquals(false, fleetControllers.get(i).isMaster());
+ assertFalse(fleetControllers.get(i).isMaster());
}
}
- protected void waitForMaster(int master) {
+ private void waitForMaster(int master) {
log.log(LogLevel.INFO, "Entering waitForMaster");
boolean isOnlyMaster = false;
for (int i=0; i < FleetControllerTest.timeoutMS; i+=100) {
@@ -207,11 +206,11 @@ public class MasterElectionTest extends FleetControllerTest {
this.lastState = initialState;
}
- public static StrictlyIncreasingVersionChecker bootstrappedWith(ClusterState initialState) {
+ static StrictlyIncreasingVersionChecker bootstrappedWith(ClusterState initialState) {
return new StrictlyIncreasingVersionChecker(initialState);
}
- public void updateAndVerify(ClusterState currentState) {
+ void updateAndVerify(ClusterState currentState) {
final ClusterState last = lastState;
lastState = currentState;
if (currentState.getVersion() <= last.getVersion()) {
@@ -234,16 +233,16 @@ public class MasterElectionTest extends FleetControllerTest {
fleetController = fleetControllers.get(0); // Required to prevent waitForStableSystem from NPE'ing
waitForStableSystem();
waitForMaster(0);
- Arrays.asList(0, 1, 2, 3, 4).stream().forEach(this::waitForCompleteCycle);
+ Stream.of(0, 1, 2, 3, 4).forEach(this::waitForCompleteCycle);
StrictlyIncreasingVersionChecker checker = StrictlyIncreasingVersionChecker.bootstrappedWith(
fleetControllers.get(0).getClusterState());
fleetControllers.get(0).shutdown();
waitForMaster(1);
- Arrays.asList(1, 2, 3, 4).stream().forEach(this::waitForCompleteCycle);
+ Stream.of(1, 2, 3, 4).forEach(this::waitForCompleteCycle);
checker.updateAndVerify(fleetControllers.get(1).getClusterState());
fleetControllers.get(1).shutdown();
waitForMaster(2); // Still a quorum available
- Arrays.asList(2, 3, 4).stream().forEach(this::waitForCompleteCycle);
+ Stream.of(2, 3, 4).forEach(this::waitForCompleteCycle);
checker.updateAndVerify(fleetControllers.get(2).getClusterState());
}
@@ -287,7 +286,7 @@ public class MasterElectionTest extends FleetControllerTest {
// Noone can be master if server is unavailable
log.log(LogLevel.INFO, "Checking master status");
for (int i=0; i<fleetControllers.size(); ++i) {
- assertEquals("Index " + i, false, fleetControllers.get(i).isMaster());
+ assertFalse("Index " + i, fleetControllers.get(i).isMaster());
}
zooKeeperServer = new ZooKeeperTestServer();
@@ -372,7 +371,7 @@ public class MasterElectionTest extends FleetControllerTest {
for (int retry = 0; retry < FleetControllerTest.timeoutS * 10; ++retry) {
req = new Request("getMaster");
connections.get(nodeIndex).invokeSync(req, FleetControllerTest.timeoutS);
- assertEquals(req.errorMessage(), false, req.isError());
+ assertFalse(req.errorMessage(), req.isError());
if (req.returnValues().get(0).asInt32() == 0 &&
req.returnValues().get(1).asString().equals("All 3 nodes agree that 0 is current master.")) {
break;
@@ -390,7 +389,7 @@ public class MasterElectionTest extends FleetControllerTest {
// 5 minutes is not long enough period to wait before letting this node be master.
timer.advanceTime(300 * 1000); // 5 minutes
- int remainingNodes[] = { 1, 2 };
+ int[] remainingNodes = { 1, 2 };
waitForMasterReason(
"2 of 3 nodes agree 1 should be master, but old master cooldown period of 3600000 ms has not passed yet. To ensure it has got time to realize it is no longer master before we elect a new one, currently there is no master.",
-1, connections, remainingNodes);
@@ -409,7 +408,7 @@ public class MasterElectionTest extends FleetControllerTest {
for (int i=0; i<FleetControllerTest.timeoutS * 10; ++i) {
req = new Request("getMaster");
connections.get(1).invokeSync(req, FleetControllerTest.timeoutS);
- assertEquals(req.errorMessage(), false, req.isError());
+ assertFalse(req.errorMessage(), req.isError());
if (req.returnValues().get(0).asInt32() != -1) break;
// We may have bad timing causing node not to have realized it is master yet
}
@@ -419,7 +418,7 @@ public class MasterElectionTest extends FleetControllerTest {
for (int i=0; i<FleetControllerTest.timeoutS * 10; ++i) {
req = new Request("getMaster");
connections.get(2).invokeSync(req, FleetControllerTest.timeoutS);
- assertEquals(req.errorMessage(), false, req.isError());
+ assertFalse(req.errorMessage(), req.isError());
if (req.returnValues().get(0).asInt32() != -1) break;
}
assertEquals(req.toString(), 1, req.returnValues().get(0).asInt32());
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NoZooKeeperTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NoZooKeeperTest.java
index dff33d7a6fc..1b4837757c5 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NoZooKeeperTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NoZooKeeperTest.java
@@ -2,7 +2,7 @@
package com.yahoo.vespa.clustercontroller.core;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
public class NoZooKeeperTest extends FleetControllerTest {
@@ -15,7 +15,7 @@ public class NoZooKeeperTest extends FleetControllerTest {
setUpVdsNodes(true, new DummyVdsNodeOptions());
waitForStableSystem();
- assertEquals(true, nodes.get(0).isDistributor());
+ assertTrue(nodes.get(0).isDistributor());
nodes.get(0).disconnect();
waitForState("version:\\d+ distributor:10 .0.s:d storage:10");
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeSlobrokConfigurationMembershipTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeSlobrokConfigurationMembershipTest.java
index 9003e369b59..f9bb93c7bb5 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeSlobrokConfigurationMembershipTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeSlobrokConfigurationMembershipTest.java
@@ -2,14 +2,10 @@
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.distribution.ConfiguredNode;
-import com.yahoo.vespa.clustercontroller.core.testutils.Waiter;
import org.junit.Test;
-import java.util.Arrays;
-import java.util.List;
import java.util.Set;
import java.util.TreeSet;
-import java.util.stream.Collectors;
import static org.junit.Assert.assertTrue;
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java
index fc466664e56..303376e7a5e 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java
@@ -41,8 +41,8 @@ public class NodeStateChangeCheckerTest {
private static final Node nodeStorage = new Node(NodeType.STORAGE, 1);
private static final NodeState UP_NODE_STATE = new NodeState(NodeType.STORAGE, State.UP);
- public static final NodeState MAINTENANCE_NODE_STATE = createNodeState(State.MAINTENANCE, "Orchestrator");
- public static final NodeState DOWN_NODE_STATE = createNodeState(State.DOWN, "RetireEarlyExpirer");
+ private static final NodeState MAINTENANCE_NODE_STATE = createNodeState(State.MAINTENANCE, "Orchestrator");
+ private static final NodeState DOWN_NODE_STATE = createNodeState(State.DOWN, "RetireEarlyExpirer");
private static NodeState createNodeState(State state, String description) {
return new NodeState(NodeType.STORAGE, state).setDescription(description);
@@ -129,7 +129,7 @@ public class NodeStateChangeCheckerTest {
nodeDistributor, defaultAllUpClusterState(), SetUnitStateRequest.Condition.FORCE,
UP_NODE_STATE, newState);
assertTrue(result.settingWantedStateIsAllowed());
- assertTrue(!result.wantedStateAlreadySet());
+ assertFalse(result.wantedStateAlreadySet());
}
@Test
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 214ccfa1c5b..532919f05da 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
@@ -25,7 +25,6 @@ import com.yahoo.vespa.config.content.StorDistributionConfig;
import org.junit.Test;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -34,6 +33,7 @@ import java.util.logging.Logger;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -43,7 +43,7 @@ public class RpcServerTest extends FleetControllerTest {
public static Logger log = Logger.getLogger(RpcServerTest.class.getName());
- protected Supervisor supervisor;
+ private Supervisor supervisor;
public void tearDown() throws Exception {
if (supervisor != null) {
@@ -56,7 +56,7 @@ public class RpcServerTest extends FleetControllerTest {
public void testRebinding() throws Exception {
startingTest("RpcServerTest::testRebinding");
Slobrok slobrok = new Slobrok();
- String slobrokConnectionSpecs[] = new String[1];
+ String[] slobrokConnectionSpecs = new String[1];
slobrokConnectionSpecs[0] = "tcp/localhost:" + slobrok.port();
RpcServer server = new RpcServer(timer, new Object(), "mycluster", 0, new BackOff());
server.setSlobrokConnectionSpecs(slobrokConnectionSpecs, 0);
@@ -470,7 +470,7 @@ public class RpcServerTest extends FleetControllerTest {
}
}
- public StorDistributionConfig getDistConfig(Set<Integer> nodes) {
+ 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();
@@ -490,7 +490,7 @@ public class RpcServerTest extends FleetControllerTest {
public void testSetNodeState() throws Exception {
startingTest("RpcServerTest::testSetNodeState");
FleetControllerOptions options = defaultOptions("mycluster");
- Set<Integer> nodeIndexes = new TreeSet<>(Arrays.asList(new Integer[]{4, 6, 9, 10, 14, 16, 21, 22, 23, 25}));
+ Set<Integer> nodeIndexes = new TreeSet<>(List.of(4, 6, 9, 10, 14, 16, 21, 22, 23, 25));
options.setStorageDistribution(new Distribution(getDistConfig(nodeIndexes)));
setUpFleetController(true, options);
setUpVdsNodes(true, new DummyVdsNodeOptions(), false, nodeIndexes);
@@ -598,7 +598,7 @@ public class RpcServerTest extends FleetControllerTest {
setUpVdsNodes(true, new DummyVdsNodeOptions());
waitForStableSystem();
- assertEquals(true, nodes.get(0).isDistributor());
+ assertTrue(nodes.get(0).isDistributor());
nodes.get(0).disconnect();
waitForState("version:\\d+ distributor:10 .0.s:d storage:10");
@@ -613,8 +613,8 @@ public class RpcServerTest extends FleetControllerTest {
connection.invokeSync(req, timeoutS);
assertEquals(req.errorMessage(), ErrorCode.NONE, req.errorCode());
assertTrue(req.toString(), req.checkReturnTypes("SS"));
- String slobrok[] = req.returnValues().get(0).asStringArray().clone();
- String rpc[] = req.returnValues().get(1).asStringArray().clone();
+ String[] slobrok = req.returnValues().get(0).asStringArray().clone();
+ String[] rpc = req.returnValues().get(1).asStringArray().clone();
assertEquals(20, slobrok.length);
assertEquals(20, rpc.length);
@@ -622,13 +622,13 @@ public class RpcServerTest extends FleetControllerTest {
// Verify that we can connect to all addresses returned.
for (int i=0; i<20; ++i) {
if (slobrok[i].equals("storage/cluster.mycluster/distributor/0")) {
- if (j < 10 && !"".equals(rpc[i])) {
+ if (i < 10 && !"".equals(rpc[i])) {
continue;
}
assertEquals(slobrok[i], "", rpc[i]);
continue;
}
- assertTrue(slobrok[i], !rpc[i].equals(""));
+ assertNotEquals("", rpc[i]);
Request req2 = new Request("getnodestate2");
req2.parameters().add(new StringValue("unknown"));
Target connection2 = supervisor.connect(new Spec(rpc[i]));
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcVersionAutoDowngradeTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcVersionAutoDowngradeTest.java
index b76f1fc20bf..e7c9f3b179a 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcVersionAutoDowngradeTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcVersionAutoDowngradeTest.java
@@ -4,7 +4,6 @@ package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.distribution.ConfiguredNode;
import com.yahoo.vdslib.state.NodeState;
import com.yahoo.vdslib.state.State;
-import com.yahoo.vespa.clustercontroller.core.testutils.StateWaiter;
import org.junit.Test;
import java.util.ArrayList;
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandlerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandlerTest.java
index 7ef6d298885..68926b4d10d 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandlerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandlerTest.java
@@ -27,14 +27,14 @@ import static org.junit.Assert.assertTrue;
public class StateChangeHandlerTest {
private static final Logger log = Logger.getLogger(StateChangeHandlerTest.class.getName());
- private class Config {
+ private static class Config {
int nodeCount = 3;
int stableStateTime = 1000 * 60000;
int maxSlobrokDisconnectPeriod = 60000;
int maxPrematureCrashes = 3;
}
- private class TestNodeStateOrHostInfoChangeHandler implements NodeStateOrHostInfoChangeHandler {
+ private static class TestNodeStateOrHostInfoChangeHandler implements NodeStateOrHostInfoChangeHandler {
LinkedList<String> events = new LinkedList<>();
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeTest.java
index ca246b3549f..016cce9580e 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeTest.java
@@ -1,9 +1,14 @@
// Copyright 2017 Yahoo Holdings. 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.*;
+import com.yahoo.jrt.Supervisor;
+import com.yahoo.jrt.Transport;
import com.yahoo.vdslib.distribution.ConfiguredNode;
-import com.yahoo.vdslib.state.*;
+import com.yahoo.vdslib.state.ClusterState;
+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.clustercontroller.core.database.DatabaseHandler;
import com.yahoo.vespa.clustercontroller.core.database.ZooKeeperDatabaseFactory;
import com.yahoo.vespa.clustercontroller.core.testutils.StateWaiter;
@@ -18,7 +23,10 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.time.Duration;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.logging.Logger;
public class StateChangeTest extends FleetControllerTest {
@@ -83,7 +91,6 @@ public class StateChangeTest extends FleetControllerTest {
}
assertEquals(correct, actual);
-
}
private static List<ConfiguredNode> createNodes(int count) {
@@ -184,7 +191,7 @@ public class StateChangeTest extends FleetControllerTest {
ctrl.tick();
String desc = ctrl.getReportedNodeState(new Node(NodeType.DISTRIBUTOR, 0)).getDescription();
- assertTrue(desc, desc.indexOf("Closed at other end") != -1);
+ assertTrue(desc, desc.contains("Closed at other end"));
assertEquals("version:4 distributor:10 .0.s:d storage:10", ctrl.getSystemState().toString());
@@ -201,7 +208,7 @@ public class StateChangeTest extends FleetControllerTest {
assert(!ctrl.getReportedNodeState(new Node(NodeType.DISTRIBUTOR, 0)).hasDescription());
desc = ctrl.getReportedNodeState(new Node(NodeType.STORAGE, 0)).getDescription();
- assertTrue(desc, desc.indexOf("Closed at other end") != -1);
+ assertTrue(desc, desc.contains("Closed at other end"));
timer.advanceTime(options.maxTransitionTime.get(NodeType.STORAGE) + 1);
@@ -210,7 +217,7 @@ public class StateChangeTest extends FleetControllerTest {
assertEquals("version:6 distributor:10 .0.t:12345678 storage:10 .0.s:d", ctrl.getSystemState().toString());
desc = ctrl.getReportedNodeState(new Node(NodeType.STORAGE, 0)).getDescription();
- assertTrue(desc, desc.indexOf("Closed at other end") != -1);
+ assertTrue(desc, desc.contains("Closed at other end"));
timer.advanceTime(1000);
@@ -249,7 +256,7 @@ public class StateChangeTest extends FleetControllerTest {
assertEquals(1, ctrl.getCluster().getNodeInfo(new Node(NodeType.STORAGE, 0)).getPrematureCrashCount());
}
- public void tick(int timeMs) throws Exception {
+ private void tick(int timeMs) throws Exception {
timer.advanceTime(timeMs);
ctrl.tick();
}
@@ -272,8 +279,8 @@ public class StateChangeTest extends FleetControllerTest {
ctrl.tick();
String desc = ctrl.getReportedNodeState(new Node(NodeType.DISTRIBUTOR, 0)).getDescription();
- assertTrue(desc, desc.indexOf("Received signal 15 (SIGTERM - Termination signal)") != -1
- || desc.indexOf("controlled shutdown") != -1);
+ assertTrue(desc, desc.contains("Received signal 15 (SIGTERM - Termination signal)")
+ || desc.contains("controlled shutdown"));
tick(1000);
@@ -286,15 +293,15 @@ public class StateChangeTest extends FleetControllerTest {
assert(!ctrl.getReportedNodeState(new Node(NodeType.DISTRIBUTOR, 0)).hasDescription());
desc = ctrl.getReportedNodeState(new Node(NodeType.STORAGE, 0)).getDescription();
- assertTrue(desc, desc.indexOf("Received signal 15 (SIGTERM - Termination signal)") != -1
- || desc.indexOf("controlled shutdown") != -1);
+ assertTrue(desc, desc.contains("Received signal 15 (SIGTERM - Termination signal)")
+ || desc.contains("controlled shutdown"));
tick(options.maxTransitionTime.get(NodeType.STORAGE) + 1);
assertEquals("version:6 distributor:10 storage:10 .0.s:d", ctrl.getSystemState().toString());
desc = ctrl.getReportedNodeState(new Node(NodeType.STORAGE, 0)).getDescription();
- assertTrue(desc, desc.indexOf("Received signal 15 (SIGTERM - Termination signal)") != -1
- || desc.indexOf("controlled shutdown") != -1);
+ assertTrue(desc, desc.contains("Received signal 15 (SIGTERM - Termination signal)")
+ || desc.contains("controlled shutdown"));
communicator.setNodeState(new Node(NodeType.STORAGE, 0), State.UP, "");
@@ -381,7 +388,7 @@ public class StateChangeTest extends FleetControllerTest {
assertEquals("version:4 distributor:10 storage:10 .6.s:m", ctrl.getSystemState().toString());
NodeState ns = ctrl.getReportedNodeState(new Node(NodeType.STORAGE, 6));
- assertTrue(ns.toString(), ns.getDescription().indexOf("Connection error: Closed at other end") != -1);
+ assertTrue(ns.toString(), ns.getDescription().contains("Connection error: Closed at other end"));
tick(1000);
@@ -441,7 +448,7 @@ public class StateChangeTest extends FleetControllerTest {
assertEquals("version:4 distributor:10 storage:10 .6.s:m", ctrl.getSystemState().toString());
NodeState ns = ctrl.getReportedNodeState(new Node(NodeType.STORAGE, 6));
- assertTrue(ns.toString(), ns.getDescription().indexOf("Connection error: Closed at other end") != -1);
+ assertTrue(ns.toString(), ns.getDescription().contains("Connection error: Closed at other end"));
tick(1000);
@@ -926,7 +933,7 @@ public class StateChangeTest extends FleetControllerTest {
* Class for testing states of all nodes. Will fail in constructor with
* debug message on non-expected results.
*/
- abstract class StateMessageChecker {
+ abstract static class StateMessageChecker {
StateMessageChecker(final List<DummyVdsNode> nodes) {
for (final DummyVdsNode node : nodes) {
final List<ClusterState> states = node.getSystemStatesReceived();
@@ -992,8 +999,8 @@ public class StateChangeTest extends FleetControllerTest {
setUpVdsNodes(true, new DummyVdsNodeOptions(), true);
- for (int i=0; i<nodes.size(); ++i) {
- nodes.get(i).connect();
+ for (DummyVdsNode node : nodes) {
+ node.connect();
}
// Marking one node as 'initializing' improves testing of state later on.
nodes.get(3).setNodeState(State.INITIALIZING);
@@ -1088,7 +1095,7 @@ public class StateChangeTest extends FleetControllerTest {
assertEquals("version:6 bits:17 distributor:10 storage:10", ctrl.getSystemState().toString());
}
- private void setMinUsedBitsForAllNodes(int bits) throws Exception {
+ private void setMinUsedBitsForAllNodes(int bits) {
for (int i = 0; i < 10; ++i) {
communicator.setNodeState(new Node(NodeType.STORAGE, i), new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(bits), "");
}
@@ -1106,7 +1113,7 @@ public class StateChangeTest extends FleetControllerTest {
fleetController.addSystemStateListener(waiter);
// Simulate netsplit. Take node down without node booting
- assertEquals(true, nodes.get(0).isDistributor());
+ assertTrue(nodes.get(0).isDistributor());
nodes.get(0).disconnectImmediately();
waiter.waitForState("version:\\d+ distributor:10 .0.s:d storage:10", timeoutMS);
@@ -1133,13 +1140,13 @@ public class StateChangeTest extends FleetControllerTest {
} else {
for (ConfiguredNode i : options.nodes) {
Node nodeId = new Node(NodeType.STORAGE, i.index());
- assertTrue(nodeId.toString(), lastState.getNodeState(nodeId).getStartTimestamp() == 0);
+ assertEquals(nodeId.toString(), 0, lastState.getNodeState(nodeId).getStartTimestamp());
}
}
for (ConfiguredNode i : options.nodes) {
Node nodeId = new Node(NodeType.DISTRIBUTOR, i.index());
- assertTrue(nodeId.toString(), lastState.getNodeState(nodeId).getStartTimestamp() == 0);
+ assertEquals(nodeId.toString(), 0, lastState.getNodeState(nodeId).getStartTimestamp());
}
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateGatherTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateGatherTest.java
index 007bda04f4e..398c1c16473 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateGatherTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateGatherTest.java
@@ -13,7 +13,7 @@ public class StateGatherTest extends FleetControllerTest {
public static Logger log = Logger.getLogger(StateGatherTest.class.getName());
- public String getGetNodeStateReplyCounts(DummyVdsNode node) {
+ private String getGetNodeStateReplyCounts(DummyVdsNode node) {
StringBuilder sb = new StringBuilder();
sb.append("timedout ").append(node.timedOutStateReplies)
.append(", outdated ").append(node.outdatedStateReplies)
@@ -33,7 +33,7 @@ public class StateGatherTest extends FleetControllerTest {
options.nodeStateRequestTimeoutEarliestPercentage = 80;
options.nodeStateRequestTimeoutLatestPercentage = 80;
setUpFleetController(true, options);
- String connectionSpecs[] = new String[1];
+ String[] connectionSpecs = new String[1];
connectionSpecs[0] = "tcp/localhost:" + slobrok.port();
DummyVdsNodeOptions dummyOptions = new DummyVdsNodeOptions();
DummyVdsNode dnode = new DummyVdsNode(timer, dummyOptions, connectionSpecs, this.options.clusterName, true, 0);
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateVersionTrackerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateVersionTrackerTest.java
index 95b699d4de4..83bdbfa0213 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateVersionTrackerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateVersionTrackerTest.java
@@ -9,9 +9,7 @@ import com.yahoo.vdslib.state.State;
import com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo;
import org.junit.Test;
-import java.text.ParseException;
import java.util.Arrays;
-import java.util.Optional;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.Is.is;
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StatusPagesTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StatusPagesTest.java
index fc18a1b0b8b..f761538cf1e 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StatusPagesTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StatusPagesTest.java
@@ -19,8 +19,8 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
import java.net.Socket;
+import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -225,7 +225,6 @@ public class StatusPagesTest extends FleetControllerTest {
assertTrue(content, content.contains("REPORTED"));
assertTrue(content, content.contains("Altered node state in cluster state from"));
//System.err.println(sb.toString());
-
}
@Test
@@ -283,7 +282,7 @@ public class StatusPagesTest extends FleetControllerTest {
private static class DummyRequestHandler implements StatusPageServer.RequestHandler {
private String returnData;
- public DummyRequestHandler(String returnData) {
+ DummyRequestHandler(String returnData) {
this.returnData = returnData;
}
@@ -301,11 +300,7 @@ public class StatusPagesTest extends FleetControllerTest {
if (handler == null) {
return null;
}
- try {
- return handler.handle(httpRequest).getOutputStream().toString("UTF-8");
- } catch (UnsupportedEncodingException e) {
- return "<ERROR>";
- }
+ return handler.handle(httpRequest).getOutputStream().toString(StandardCharsets.UTF_8);
}
@Test
@@ -322,7 +317,7 @@ public class StatusPagesTest extends FleetControllerTest {
assertNull(invokeHandler(router, "/blarg"));
}
- public String[] getResponseParts(String response) {
+ private String[] getResponseParts(String response) {
int offset = response.indexOf("\r\n\r\n");
if (offset == -1) {
throw new IllegalStateException("No HTTP header delimiter found");
@@ -333,18 +328,6 @@ public class StatusPagesTest extends FleetControllerTest {
};
}
- private String getHeaderValue(String header, String name) {
- int offset = header.indexOf(name + ": ");
- if (offset == -1) {
- throw new IllegalStateException("No HTTP header found for " + name);
- }
- int end = header.indexOf("\r\n", offset);
- if (end == -1) {
- throw new IllegalStateException("No EOL found for " + name);
- }
- return header.substring(offset + name.length() + 2, end);
- }
-
@Test
public void testStateServing() throws Exception {
startingTest("StatusPagesTest::testStateServing()");
@@ -369,7 +352,7 @@ public class StatusPagesTest extends FleetControllerTest {
"}";
assertEquals(expected, body);
// Check that it actually parses
- JSONObject o = new JSONObject(expected);
+ new JSONObject(expected);
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SystemStateBroadcasterTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SystemStateBroadcasterTest.java
index f99df6a25b2..182194fcc5a 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SystemStateBroadcasterTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SystemStateBroadcasterTest.java
@@ -1,7 +1,10 @@
// Copyright 2018 Yahoo Holdings. 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.state.*;
+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.clustercontroller.core.database.DatabaseHandler;
import com.yahoo.vespa.clustercontroller.core.listeners.NodeAddedOrRemovedListener;
import com.yahoo.vespa.clustercontroller.core.listeners.NodeStateOrHostInfoChangeHandler;
@@ -11,7 +14,6 @@ import org.mockito.ArgumentCaptor;
import java.util.stream.Stream;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
@@ -143,7 +145,7 @@ public class SystemStateBroadcasterTest {
}
private static class MockSetClusterStateRequest extends SetClusterStateRequest {
- public MockSetClusterStateRequest(NodeInfo nodeInfo, int clusterStateVersion) {
+ MockSetClusterStateRequest(NodeInfo nodeInfo, int clusterStateVersion) {
super(nodeInfo, clusterStateVersion);
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperTestServer.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperTestServer.java
index 72b89dad85d..34c8fafa702 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperTestServer.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperTestServer.java
@@ -20,7 +20,7 @@ public class ZooKeeperTestServer {
private static final String DIR_PREFIX = "test_fltctrl_zk";
private static final String DIR_POSTFIX = "sdir";
- public ZooKeeperTestServer() throws IOException {
+ ZooKeeperTestServer() throws IOException {
this(0);
}
@@ -42,15 +42,15 @@ public class ZooKeeperTestServer {
}
}
- public static ZooKeeperTestServer createWithFixedPort(int port) throws IOException {
+ static ZooKeeperTestServer createWithFixedPort(int port) throws IOException {
return new ZooKeeperTestServer(port);
}
- public int getPort() {
+ private int getPort() {
return factory.getLocalPort();
}
- public String getAddress() {
+ String getAddress() {
return HostName.getLocalhost() + ":" + getPort();
}
@@ -64,7 +64,7 @@ public class ZooKeeperTestServer {
factory.shutdown();
}
- public void delete(File f) {
+ private void delete(File f) {
if (f.isDirectory()) {
for (File file : f.listFiles()) {
delete(file);
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/HostInfoTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/HostInfoTest.java
index b96f5282971..8804e9a9c96 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/HostInfoTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/HostInfoTest.java
@@ -28,7 +28,7 @@ public class HostInfoTest {
}
@Test
- public void testEmptyJson() throws IOException {
+ public void testEmptyJson() {
HostInfo hostInfo = HostInfo.createHostInfo("{}");
assertThat(hostInfo.getVtag().getVersionOrNull(), is(nullValue()));
assertThat(hostInfo.getDistributor().getStorageNodes().size(), is(0));
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/ClusterEventWithDescription.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/ClusterEventWithDescription.java
index e91627e8479..f45120a2b71 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/ClusterEventWithDescription.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/ClusterEventWithDescription.java
@@ -2,7 +2,6 @@
package com.yahoo.vespa.clustercontroller.core.matchers;
import com.yahoo.vespa.clustercontroller.core.ClusterEvent;
-import com.yahoo.vespa.clustercontroller.core.NodeEvent;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.mockito.ArgumentMatcher;
@@ -10,7 +9,7 @@ import org.mockito.ArgumentMatcher;
public class ClusterEventWithDescription extends ArgumentMatcher<ClusterEvent> {
private final String expected;
- public ClusterEventWithDescription(String expected) {
+ private ClusterEventWithDescription(String expected) {
this.expected = expected;
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/EventForNode.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/EventForNode.java
index 7b806982313..6c8610db3ac 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/EventForNode.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/EventForNode.java
@@ -10,7 +10,7 @@ import org.mockito.ArgumentMatcher;
public class EventForNode extends ArgumentMatcher<NodeEvent> {
private final Node expected;
- EventForNode(Node expected) {
+ private EventForNode(Node expected) {
this.expected = expected;
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/EventTimeIs.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/EventTimeIs.java
index 2ffdfbca687..c35f3f95a5b 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/EventTimeIs.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/EventTimeIs.java
@@ -9,7 +9,7 @@ import org.mockito.ArgumentMatcher;
public class EventTimeIs extends ArgumentMatcher<Event> {
private final long expected;
- public EventTimeIs(long expected) {
+ private EventTimeIs(long expected) {
this.expected = expected;
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/EventTypeIs.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/EventTypeIs.java
index e54abfc99b0..cbb6dc47364 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/EventTypeIs.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/EventTypeIs.java
@@ -8,7 +8,7 @@ import org.mockito.ArgumentMatcher;
public class EventTypeIs extends ArgumentMatcher<NodeEvent> {
private final NodeEvent.Type expected;
- public EventTypeIs(NodeEvent.Type expected) {
+ private EventTypeIs(NodeEvent.Type expected) {
this.expected = expected;
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/HasStateReasonForNode.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/HasStateReasonForNode.java
index bbedba4114e..11166ae6ed1 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/HasStateReasonForNode.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/HasStateReasonForNode.java
@@ -13,7 +13,7 @@ public class HasStateReasonForNode extends ArgumentMatcher<Map<Node, NodeStateRe
private final Node node;
private final NodeStateReason expected;
- public HasStateReasonForNode(Node node, NodeStateReason expected) {
+ private HasStateReasonForNode(Node node, NodeStateReason expected) {
this.node = node;
this.expected = expected;
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/NodeEventForBucketSpace.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/NodeEventForBucketSpace.java
index d13f91609f4..8e7f8b27c6a 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/NodeEventForBucketSpace.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/NodeEventForBucketSpace.java
@@ -11,7 +11,7 @@ import java.util.Optional;
public class NodeEventForBucketSpace extends ArgumentMatcher<NodeEvent> {
private final Optional<String> bucketSpace;
- public NodeEventForBucketSpace(Optional<String> bucketSpace) {
+ private NodeEventForBucketSpace(Optional<String> bucketSpace) {
this.bucketSpace = bucketSpace;
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/NodeEventWithDescription.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/NodeEventWithDescription.java
index 38d3d28ab62..00f043695da 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/NodeEventWithDescription.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/NodeEventWithDescription.java
@@ -9,7 +9,7 @@ import org.mockito.ArgumentMatcher;
public class NodeEventWithDescription extends ArgumentMatcher<NodeEvent> {
private final String expected;
- public NodeEventWithDescription(String expected) {
+ private NodeEventWithDescription(String expected) {
this.expected = expected;
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterControllerMock.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterControllerMock.java
index 472301e1dfc..a37b3abbd88 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterControllerMock.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterControllerMock.java
@@ -11,13 +11,13 @@ import com.yahoo.vespa.clustercontroller.core.listeners.NodeStateOrHostInfoChang
public class ClusterControllerMock implements RemoteClusterControllerTaskScheduler {
public RemoteClusterControllerTask.Context context = new RemoteClusterControllerTask.Context();
- public int fleetControllerIndex;
- public Integer fleetControllerMaster;
- public StringBuilder events = new StringBuilder();
+ private int fleetControllerIndex;
+ Integer fleetControllerMaster;
+ private StringBuilder events = new StringBuilder();
- public ClusterControllerMock(ContentCluster cluster, ClusterState state,
- ClusterStateBundle publishedClusterStateBundle,
- int fcIndex, Integer fcMaster) {
+ ClusterControllerMock(ContentCluster cluster, ClusterState state,
+ ClusterStateBundle publishedClusterStateBundle,
+ int fcIndex, Integer fcMaster) {
this.fleetControllerIndex = fcIndex;
this.fleetControllerMaster = fcMaster;
context.cluster = cluster;
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java
index 6a2c14ae028..4ec5893c1e7 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java
@@ -9,6 +9,7 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
public class NotMasterTest extends StateRestApiTest {
@@ -29,39 +30,39 @@ public class NotMasterTest extends StateRestApiTest {
// Recursive cluster list does not work
try{
restAPI.getState(new StateRequest("", 1));
- assertTrue(false);
+ fail();
} catch (UnknownMasterException e) {
assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
}
// Other requests does not work either
try{
restAPI.getState(new StateRequest("music", 0));
- assertTrue(false);
+ fail();
} catch (UnknownMasterException e) {
assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
}
try{
restAPI.getState(new StateRequest("music/storage", 0));
- assertTrue(false);
+ fail();
} catch (UnknownMasterException e) {
assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
}
try{
restAPI.getState(new StateRequest("music/storage/1", 0));
- assertTrue(false);
+ fail();
} catch (UnknownMasterException e) {
assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
}
try{
restAPI.getState(new StateRequest("music/storage/1/0", 0));
- assertTrue(false);
+ fail();
} catch (UnknownMasterException e) {
assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
}
try{
restAPI.setUnitState(new SetNodeStateTest.SetUnitStateRequestImpl("music/storage/1")
.setNewState("user", "down", "test"));
- assertTrue(false);
+ fail();
} catch (UnknownMasterException e) {
assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
}
@@ -85,53 +86,53 @@ public class NotMasterTest extends StateRestApiTest {
// Recursive cluster list does not work
try{
restAPI.getState(new StateRequest("", 1));
- assertTrue(false);
+ fail();
} catch (OtherMasterException e) {
assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
- assertTrue(e.getHost().equals("otherhost"));
- assertTrue(e.getPort() == getDefaults().vespaWebServicePort());
+ assertEquals("otherhost", e.getHost());
+ assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
// Other requests does not work either
try{
restAPI.getState(new StateRequest("music", 0));
- assertTrue(false);
+ fail();
} catch (OtherMasterException e) {
assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
- assertTrue(e.getHost().equals("otherhost"));
- assertTrue(e.getPort() == getDefaults().vespaWebServicePort());
+ assertEquals("otherhost", e.getHost());
+ assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
try{
restAPI.getState(new StateRequest("music/storage", 0));
- assertTrue(false);
+ fail();
} catch (OtherMasterException e) {
assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
- assertTrue(e.getHost().equals("otherhost"));
- assertTrue(e.getPort() == getDefaults().vespaWebServicePort());
+ assertEquals("otherhost", e.getHost());
+ assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
try{
restAPI.getState(new StateRequest("music/storage/1", 0));
- assertTrue(false);
+ fail();
} catch (OtherMasterException e) {
assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
- assertTrue(e.getHost().equals("otherhost"));
- assertTrue(e.getPort() == getDefaults().vespaWebServicePort());
+ assertEquals("otherhost", e.getHost());
+ assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
try{
restAPI.getState(new StateRequest("music/storage/1/0", 0));
- assertTrue(false);
+ fail();
} catch (OtherMasterException e) {
assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
- assertTrue(e.getHost().equals("otherhost"));
- assertTrue(e.getPort() == getDefaults().vespaWebServicePort());
+ assertEquals("otherhost", e.getHost());
+ assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
try{
restAPI.setUnitState(new SetNodeStateTest.SetUnitStateRequestImpl("music/storage/1")
.setNewState("user", "down", "test"));
- assertTrue(false);
+ fail();
} catch (OtherMasterException e) {
assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
- assertTrue(e.getHost().equals("otherhost"));
- assertTrue(e.getPort() == getDefaults().vespaWebServicePort());
+ assertEquals("otherhost", e.getHost());
+ assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java
index f76cfd13af1..78c5f3380be 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java
@@ -5,12 +5,13 @@ import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InternalFailu
import org.junit.Test;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
public class RequestTest {
@Test
public void testGetResultBeforeCompletion() {
- Request<String> r = new Request<String>(Request.MasterState.MUST_BE_MASTER) {
+ Request<String> r = new Request<>(Request.MasterState.MUST_BE_MASTER) {
@Override
public String calculateResult(Context context) {
return "foo";
@@ -18,18 +19,18 @@ public class RequestTest {
};
try{
r.getResult();
- assertTrue(false);
+ fail();
} catch (InternalFailure e) {
} catch (Exception e) {
- assertTrue(false);
+ fail();
}
r.notifyCompleted();
try{
r.getResult();
- assertTrue(false);
+ fail();
} catch (InternalFailure e) {
} catch (Exception e) {
- assertTrue(false);
+ fail();
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java
index 6cf4b7989e7..6882b083ec9 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java
@@ -32,6 +32,7 @@ import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Mockito.mock;
@@ -49,21 +50,21 @@ public class SetNodeStateTest extends StateRestApiTest {
private TimeBudget timeBudget = TimeBudget.fromNow(Clock.systemUTC(), Duration.ofSeconds(10));
private boolean probe = false;
- public SetUnitStateRequestImpl(String req) {
+ SetUnitStateRequestImpl(String req) {
super(req, 0);
}
- public SetUnitStateRequestImpl setCondition(Condition condition) {
+ SetUnitStateRequestImpl setCondition(Condition condition) {
this.condition = condition;
return this;
}
- public SetUnitStateRequestImpl setResponseWait(ResponseWait responseWait) {
+ SetUnitStateRequestImpl setResponseWait(ResponseWait responseWait) {
this.responseWait = responseWait;
return this;
}
- public SetUnitStateRequestImpl setNewState(
+ SetUnitStateRequestImpl setNewState(
final String type,
final String state,
final String reason) {
@@ -246,7 +247,7 @@ public class SetNodeStateTest extends StateRestApiTest {
try{
restAPI.setUnitState(new SetUnitStateRequestImpl(
"").setNewState("user", "down", "testing"));
- assertTrue(false);
+ fail();
} catch (OperationNotSupportedForUnitException e) {
assertTrue(e.getMessage(), e.getMessage().contains(wrongUnitMessage));
}
@@ -256,7 +257,7 @@ public class SetNodeStateTest extends StateRestApiTest {
try{
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor").setNewState("user", "down", "testing"));
- assertTrue(false);
+ fail();
} catch (OperationNotSupportedForUnitException e) {
assertTrue(e.getMessage(), e.getMessage().contains(wrongUnitMessage));
}
@@ -266,7 +267,7 @@ public class SetNodeStateTest extends StateRestApiTest {
try{
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/storage/1/0").setNewState("user", "down", "testing"));
- assertTrue(false);
+ fail();
} catch (OperationNotSupportedForUnitException e) {
assertTrue(e.getMessage(), e.getMessage().contains(wrongUnitMessage));
}
@@ -278,37 +279,37 @@ public class SetNodeStateTest extends StateRestApiTest {
try{
restAPI.setUnitState(new SetUnitStateRequestImpl(
"foo").setNewState("user", "down", "testing"));
- assertTrue(false);
+ fail();
} catch (MissingUnitException e) {
}
try{
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/content").setNewState("user", "down", "testing"));
- assertTrue(false);
+ fail();
} catch (MissingUnitException e) {
}
try{
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/storage/bah").setNewState("user", "down", "testing"));
- assertTrue(false);
+ fail();
} catch (MissingUnitException e) {
}
try{
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/storage/10").setNewState("user", "down", "testing"));
- assertTrue(false);
+ fail();
} catch (MissingUnitException e) {
}
try{
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/storage/1/0/1").setNewState("user", "down", "testing"));
- assertTrue(false);
+ fail();
} catch (MissingUnitException e) {
}
try{
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/storage/1/bar").setNewState("user", "down", "testing"));
- assertTrue(false);
+ fail();
} catch (MissingUnitException e) {
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/StateRestApiTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/StateRestApiTest.java
index 5160ecad8b3..faebbf8755d 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/StateRestApiTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/StateRestApiTest.java
@@ -15,17 +15,17 @@ import java.util.*;
// TODO: Author
public abstract class StateRestApiTest {
- protected ClusterControllerMock books;
- protected ClusterControllerMock music;
- protected StateRestAPI restAPI;
- protected JsonWriter jsonWriter = new JsonWriter();
- protected Map<Integer, ClusterControllerStateRestAPI.Socket> ccSockets;
+ private ClusterControllerMock books;
+ ClusterControllerMock music;
+ StateRestAPI restAPI;
+ JsonWriter jsonWriter = new JsonWriter();
+ Map<Integer, ClusterControllerStateRestAPI.Socket> ccSockets;
public static class StateRequest implements UnitStateRequest {
private String[] path;
private int recursive;
- public StateRequest(String req, int recursive) {
+ StateRequest(String req, int recursive) {
path = req.isEmpty() ? new String[0] : req.split("/");
this.recursive = recursive;
}
@@ -83,7 +83,7 @@ public abstract class StateRestApiTest {
}, ccSockets);
}
- protected void initializeCluster(ContentCluster cluster, Collection<ConfiguredNode> nodes) {
+ private void initializeCluster(ContentCluster cluster, Collection<ConfiguredNode> nodes) {
for (ConfiguredNode configuredNode : nodes) {
for (NodeType type : NodeType.getTypes()) {
NodeState reported = new NodeState(type, State.UP);
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 9eb98f4f045..ac4e96c8c92 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
@@ -6,7 +6,16 @@ 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.clustercontroller.core.*;
+import com.yahoo.vespa.clustercontroller.core.ActivateClusterStateVersionRequest;
+import com.yahoo.vespa.clustercontroller.core.ClusterFixture;
+import com.yahoo.vespa.clustercontroller.core.ClusterStateBundle;
+import com.yahoo.vespa.clustercontroller.core.ClusterStateBundleUtil;
+import com.yahoo.vespa.clustercontroller.core.Communicator;
+import com.yahoo.vespa.clustercontroller.core.FakeTimer;
+import com.yahoo.vespa.clustercontroller.core.FleetControllerOptions;
+import com.yahoo.vespa.clustercontroller.core.NodeInfo;
+import com.yahoo.vespa.clustercontroller.core.SetClusterStateRequest;
+import com.yahoo.vespa.clustercontroller.core.Timer;
import org.junit.Test;
import org.mockito.Mockito;
@@ -20,22 +29,24 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyDouble;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class RPCCommunicatorTest {
- public static final int NODE_STATE_REQUEST_TIMEOUT_INTERVAL_MAX_MS = 10000;
- public static final int NODE_STATE_REQUEST_TIMEOUT_INTERVAL_START_PERCENTAGE = 80;
- public static final int NODE_STATE_REQUEST_TIMEOUT_INTERVAL_STOP_PERCENTAGE = 95;
- public static final int INDEX = 0;
- public static final int TEST_ITERATIONS = 500;
- public static final int ROUNDTRIP_LATENCY_SECONDS = 2000;
+ private static final int NODE_STATE_REQUEST_TIMEOUT_INTERVAL_MAX_MS = 10000;
+ private static final int NODE_STATE_REQUEST_TIMEOUT_INTERVAL_START_PERCENTAGE = 80;
+ private static final int NODE_STATE_REQUEST_TIMEOUT_INTERVAL_STOP_PERCENTAGE = 95;
+ private static final int INDEX = 0;
+ private static final int TEST_ITERATIONS = 500;
+ private static final int ROUNDTRIP_LATENCY_SECONDS = 2000;
@Test
- public void testGenerateNodeStateRequestTimeoutMs() throws Exception {
+ public void testGenerateNodeStateRequestTimeoutMs() {
final RPCCommunicator communicator = new RPCCommunicator(
RPCCommunicator.createRealSupervisor(),
null /* Timer */,
@@ -62,7 +73,7 @@ public class RPCCommunicatorTest {
}
@Test
- public void testGenerateNodeStateRequestTimeoutMsWithUpdates() throws Exception {
+ public void testGenerateNodeStateRequestTimeoutMsWithUpdates() {
final RPCCommunicator communicator = new RPCCommunicator(RPCCommunicator.createRealSupervisor(), null /* Timer */, INDEX, 1, 1, 100, 0);
FleetControllerOptions fleetControllerOptions = new FleetControllerOptions(null /*clustername*/);
fleetControllerOptions.nodeStateRequestTimeoutEarliestPercentage = 100;
@@ -74,7 +85,7 @@ public class RPCCommunicatorTest {
}
@Test
- public void testRoundtripLatency() throws Exception {
+ public void testRoundtripLatency() {
final Timer timer = new FakeTimer();
final RPCCommunicator communicator = new RPCCommunicator(
RPCCommunicator.createRealSupervisor(),
@@ -94,9 +105,9 @@ public class RPCCommunicatorTest {
when(nodeInfo.getReportedState()).thenReturn(new NodeState(NodeType.DISTRIBUTOR, State.UP));
communicator.getNodeState(nodeInfo, null);
Mockito.verify(target).invokeAsync(
- (Request)any(),
+ any(),
eq(ROUNDTRIP_LATENCY_SECONDS + NODE_STATE_REQUEST_TIMEOUT_INTERVAL_MAX_MS/1000.0),
- (RequestWaiter)any());
+ any());
}
private static class Fixture<RequestType> {
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/WaitCondition.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/WaitCondition.java
index 9734156b13f..c24424d3bab 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/WaitCondition.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/WaitCondition.java
@@ -29,7 +29,7 @@ public interface WaitCondition {
abstract class StateWait implements WaitCondition {
private final Object monitor;
protected ClusterState currentState;
- protected ClusterState convergedState;
+ ClusterState convergedState;
private final SystemStateListener listener = new SystemStateListener() {
@Override
public void handleNewPublishedState(ClusterStateBundle state) {
@@ -48,14 +48,14 @@ public interface WaitCondition {
}
};
- public StateWait(FleetController fc, Object monitor) {
+ protected StateWait(FleetController fc, Object monitor) {
this.monitor = monitor;
synchronized (this.monitor) {
fc.addSystemStateListener(listener);
}
}
- public ClusterState getCurrentState() {
+ ClusterState getCurrentState() {
synchronized (monitor) {
return currentState;
}
@@ -70,22 +70,22 @@ public interface WaitCondition {
private boolean checkAllSpaces = false;
private Set<String> checkSpaceSubset = Collections.emptySet();
- public RegexStateMatcher(String regex, FleetController fc, Object monitor) {
+ RegexStateMatcher(String regex, FleetController fc, Object monitor) {
super(fc, monitor);
pattern = Pattern.compile(regex);
}
- public RegexStateMatcher includeNotifyingNodes(Collection<DummyVdsNode> nodes) {
+ RegexStateMatcher includeNotifyingNodes(Collection<DummyVdsNode> nodes) {
nodesToCheck = nodes;
return this;
}
- public RegexStateMatcher checkAllSpaces(boolean checkAllSpaces) {
+ RegexStateMatcher checkAllSpaces(boolean checkAllSpaces) {
this.checkAllSpaces = checkAllSpaces;
return this;
}
- public RegexStateMatcher checkSpaceSubset(Set<String> spaces) {
+ RegexStateMatcher checkSpaceSubset(Set<String> spaces) {
this.checkSpaceSubset = spaces;
return this;
}
@@ -163,11 +163,11 @@ public interface WaitCondition {
}
}
- public class InitProgressPassedMatcher extends StateWait {
+ class InitProgressPassedMatcher extends StateWait {
private final Node node;
private final double minProgress;
- public InitProgressPassedMatcher(Node n, double minProgress, FleetController fc, Object monitor) {
+ InitProgressPassedMatcher(Node n, double minProgress, FleetController fc, Object monitor) {
super(fc, monitor);
this.node = n;
this.minProgress = minProgress;
@@ -195,7 +195,7 @@ public interface WaitCondition {
private final int bitCount;
private final int nodeCount;
- public MinUsedBitsMatcher(int bitCount, int nodeCount, FleetController fc, Object monitor) {
+ MinUsedBitsMatcher(int bitCount, int nodeCount, FleetController fc, Object monitor) {
super(fc, monitor);
this.bitCount = bitCount;
this.nodeCount = nodeCount;
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/WaitTask.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/WaitTask.java
index 247f13d7cdb..92b06081645 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/WaitTask.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/WaitTask.java
@@ -6,18 +6,18 @@ import com.yahoo.vespa.clustercontroller.core.NodeInfo;
/** A wait task is something that is performed once in a while while waiting for something. */
public abstract class WaitTask {
- public static final int defaultTaskFrequencyMillis = 1;
+ static final int defaultTaskFrequencyMillis = 1;
public abstract boolean performWaitTask();
- public int getWaitTaskFrequencyInMillis() {
+ int getWaitTaskFrequencyInMillis() {
return defaultTaskFrequencyMillis;
}
public static class StateResender extends WaitTask {
public final FleetController fleetController;
- public StateResender(FleetController fc) {
+ StateResender(FleetController fc) {
fleetController = fc;
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/Waiter.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/Waiter.java
index fb49b1cbf47..deef3157eed 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/Waiter.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/Waiter.java
@@ -56,7 +56,7 @@ public interface Waiter {
return swc.getCurrentState();
}
- public ClusterState waitForState(String state) throws Exception {
+ public ClusterState waitForState(String state) {
return waitForState(state, data.getTimeoutMS());
}
public ClusterState waitForStateInAllSpaces(String state) {
@@ -68,10 +68,10 @@ public interface Waiter {
public ClusterState waitForState(String state, int timeoutMS) {
return waitForState(state, timeoutMS, false, Collections.emptySet());
}
- public ClusterState waitForStableSystem() throws Exception {
+ public ClusterState waitForStableSystem() {
return waitForStableSystem(data.getDummyNodes().size() / 2);
}
- public ClusterState waitForStableSystem(int nodeCount) throws Exception {
+ public ClusterState waitForStableSystem(int nodeCount) {
WaitCondition.StateWait swc = new WaitCondition.RegexStateMatcher("version:\\d+ distributor:"+nodeCount+" storage:"+nodeCount, data.getFleetController(), data.getMonitor()).includeNotifyingNodes(data.getDummyNodes());
wait(swc, new WaitTask.StateResender(data.getFleetController()), data.getTimeoutMS());
return swc.getCurrentState();