aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2021-02-21 21:09:10 +0100
committerHarald Musum <musum@verizonmedia.com>2021-02-21 21:09:10 +0100
commit6593cc7ab591eda2c2637a964371dbc8b50f0c9d (patch)
tree2b4fca15e8b452c08d79493bfcc8d2d145055027
parente4d417a2a1423aaab5d0b1b00369fb4fbe7757b3 (diff)
Mincor cleanup, no functional changs
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/AnnotatedClusterState.java4
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterEvent.java6
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterInfo.java5
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStateDeriver.java4
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStateView.java19
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregator.java15
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsChangeTracker.java11
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/Communicator.java4
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentCluster.java9
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStats.java4
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/EventLog.java19
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/FleetController.java3
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/FleetControllerOptions.java2
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculator.java6
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/MasterElectionHandler.java8
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeInfo.java8
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeChecker.java4
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ResourceUsageStats.java5
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandler.java27
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/StateVersionTracker.java4
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/LegacyNodePageRequestHandler.java5
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/NodeHealthRequestHandler.java26
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/RunDataExtractor.java6
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/StatusHandler.java11
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterFixture.java12
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregatorTest.java4
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterHtmlRendrerTest.java4
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyCommunicator.java8
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyVdsNode.java42
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventLogTest.java6
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FakeTimer.java14
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java8
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SlobrokTest.java4
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandlerTest.java8
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateGatherTest.java6
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterControllerMock.java7
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ServiceTest.java3
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java7
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/StateRestApiTest.java7
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequestTest.java16
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/LogFormatter.java7
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/StateWaiter.java36
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/WaitCondition.java5
44 files changed, 174 insertions, 247 deletions
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/AnnotatedClusterState.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/AnnotatedClusterState.java
index aad94f78aef..89af1ec9764 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/AnnotatedClusterState.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/AnnotatedClusterState.java
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.state.ClusterState;
@@ -15,7 +15,7 @@ public class AnnotatedClusterState implements Cloneable {
public static class Builder {
private ClusterState clusterState = ClusterState.emptyState();
private Optional<ClusterStateReason> clusterReason = Optional.empty();
- private Map<Node, NodeStateReason> nodeStateReasons = new HashMap<>();
+ private final Map<Node, NodeStateReason> nodeStateReasons = new HashMap<>();
public Builder clusterState(String stateStr) {
clusterState = ClusterState.stateFromString(stateStr);
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterEvent.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterEvent.java
index 64413062860..b681b4d8b76 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterEvent.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterEvent.java
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
public class ClusterEvent implements Event{
@@ -8,9 +8,9 @@ public class ClusterEvent implements Event{
MASTER_ELECTION
}
- private String description;
+ private final String description;
private long timeMs = 0;
- private Type type;
+ private final Type type;
public ClusterEvent(Type type, String description, long timeMs) {
this.type = type;
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterInfo.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterInfo.java
index 450ef468122..57b2998679a 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterInfo.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterInfo.java
@@ -1,10 +1,9 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.distribution.ConfiguredNode;
import com.yahoo.vdslib.distribution.Distribution;
import com.yahoo.vdslib.state.Node;
-import com.yahoo.vdslib.state.NodeType;
import java.util.Collection;
import java.util.Collections;
@@ -38,8 +37,6 @@ public class ClusterInfo {
/** Returns non-null iff index is a configured nodes (except perhaps in tests). */
StorageNodeInfo getStorageNodeInfo(int index) { return storageNodeInfo.get(index); }
- NodeInfo getNodeInfo(NodeType type, int index) { return getNodeInfo(new Node(type, index)); }
-
/** Returns information about the given node id, or null if this node does not exist */
public NodeInfo getNodeInfo(Node node) { return allNodeInfo.get(node); }
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStateDeriver.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStateDeriver.java
index aea6db7c2f6..a3941ddc1c2 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStateDeriver.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStateDeriver.java
@@ -1,8 +1,6 @@
-// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
-import com.yahoo.vdslib.state.ClusterState;
-
/**
* Bucket-space aware transformation factory to "derive" new cluster states from an
* existing state.
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStateView.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStateView.java
index eefa7dfb322..f8774b87b2a 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStateView.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStateView.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.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
-import java.util.logging.Level;
import com.yahoo.vdslib.state.ClusterState;
import com.yahoo.vdslib.state.Node;
import com.yahoo.vdslib.state.NodeState;
@@ -12,8 +11,8 @@ import com.yahoo.vespa.clustercontroller.core.hostinfo.StorageNodeStatsBridge;
import java.text.ParseException;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -26,7 +25,7 @@ import java.util.logging.Logger;
*/
public class ClusterStateView {
- private static Logger log = Logger.getLogger(ClusterStateView.class.getName());
+ private static final Logger log = Logger.getLogger(ClusterStateView.class.getName());
private final ClusterState clusterState;
private final ClusterStatsAggregator statsAggregator;
@@ -70,18 +69,6 @@ public class ClusterStateView {
return nodesBeingUp;
}
- /**
- * Creates a new ClusterStateView which is set up with the same static view of the cluster state
- * (i.e. the ClusterState is a clone of this instance's ClusterState), while transient and dynamic
- * parts are cleared.
- */
- public ClusterStateView cloneForNewState() {
- ClusterState clonedClusterState = clusterState.clone();
- return new ClusterStateView(
- clonedClusterState,
- createNewAggregator(clonedClusterState));
- }
-
public ClusterState getClusterState() { return clusterState; }
public void handleUpdatedHostInfo(NodeInfo node, HostInfo hostInfo) {
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregator.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregator.java
index 2a9ca13b3ee..ad7ec71c808 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregator.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregator.java
@@ -1,9 +1,10 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
-import com.yahoo.document.FixedBucketSpaces;
-
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
/**
* Class that stores content cluster stats (with bucket space stats per node) for
@@ -27,7 +28,6 @@ import java.util.*;
public class ClusterStatsAggregator {
private final Set<Integer> distributors;
- private final Set<Integer> storageNodes;
private final Set<Integer> nonUpdatedDistributors;
// Maps the distributor node index to a map of content node index to the
@@ -41,7 +41,6 @@ public class ClusterStatsAggregator {
ClusterStatsAggregator(Set<Integer> distributors, Set<Integer> storageNodes) {
this.distributors = distributors;
- this.storageNodes = storageNodes;
nonUpdatedDistributors = new HashSet<>(distributors);
aggregatedStats = new ContentClusterStats(storageNodes);
}
@@ -66,8 +65,8 @@ public class ClusterStatsAggregator {
ContentNodeStats result = new ContentNodeStats(distributorIndex);
ContentClusterStats distributorStats = distributorToStats.get(distributorIndex);
if (distributorStats != null) {
- for (Iterator<ContentNodeStats> itr = distributorStats.iterator(); itr.hasNext(); ) {
- result.add(itr.next());
+ for (ContentNodeStats distributorStat : distributorStats) {
+ result.add(distributorStat);
}
}
return result;
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsChangeTracker.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsChangeTracker.java
index 68f19c721d9..3b9de562ea6 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsChangeTracker.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsChangeTracker.java
@@ -1,10 +1,9 @@
-// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.document.FixedBucketSpaces;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
/**
@@ -32,8 +31,8 @@ public class ClusterStatsChangeTracker {
public void syncAggregatedStats() {
prevMayHaveMergesPending = new HashMap<>();
- for (Iterator<ContentNodeStats> itr = aggregatedStats.getStats().iterator(); itr.hasNext(); ) {
- int nodeIndex = itr.next().getNodeIndex();
+ for (ContentNodeStats contentNodeStats : aggregatedStats.getStats()) {
+ int nodeIndex = contentNodeStats.getNodeIndex();
prevMayHaveMergesPending.put(nodeIndex, mayHaveMergesPendingInGlobalSpace(nodeIndex));
}
}
@@ -48,8 +47,8 @@ public class ClusterStatsChangeTracker {
if (!aggregatedStats.hasUpdatesFromAllDistributors()) {
return false;
}
- for (Iterator<ContentNodeStats> itr = aggregatedStats.getStats().iterator(); itr.hasNext(); ) {
- int nodeIndex = itr.next().getNodeIndex();
+ for (ContentNodeStats contentNodeStats : aggregatedStats.getStats()) {
+ int nodeIndex = contentNodeStats.getNodeIndex();
boolean currValue = mayHaveMergesPendingInGlobalSpace(nodeIndex);
Boolean prevValue = prevMayHaveMergesPendingInGlobalSpace(nodeIndex);
if (prevValue != null) {
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/Communicator.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/Communicator.java
index 900eee54cd3..e2a84804dfc 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/Communicator.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/Communicator.java
@@ -1,8 +1,6 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
-import com.yahoo.vdslib.state.ClusterState;
-
/**
* Remote interface between the fleet controller and controlled nodes.
*/
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 1b78833480c..501f51e620a 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
@@ -1,9 +1,5 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-/**
- * @class VdsCluster
- *
- * Represents a VDS cluster.
- */
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.distribution.ConfiguredNode;
@@ -241,4 +237,5 @@ public class ContentCluster {
public boolean hasConfiguredNode(int index) {
return clusterInfo.hasConfiguredNode(index);
}
+
}
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStats.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStats.java
index 8bbbb20bef4..f26bc90c1c0 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStats.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStats.java
@@ -1,4 +1,4 @@
-// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vespa.clustercontroller.core.hostinfo.StorageNode;
@@ -10,7 +10,7 @@ import java.util.*;
*/
public class ContentNodeStats {
- private int nodeIndex;
+ private final int nodeIndex;
private Map<String, BucketSpaceStats> bucketSpaces = new HashMap<>();
public static class BucketSpaceStats {
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/EventLog.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/EventLog.java
index 367771ff87a..f6a90124b1e 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/EventLog.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/EventLog.java
@@ -1,11 +1,16 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
-import java.util.logging.Level;
import com.yahoo.vdslib.state.Node;
-import com.yahoo.vespa.clustercontroller.utils.util.MetricReporter;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.TreeMap;
+import java.util.logging.Level;
import java.util.logging.Logger;
public class EventLog implements EventLogInterface {
@@ -15,12 +20,12 @@ public class EventLog implements EventLogInterface {
private final Timer timer;
private final LinkedList<Event> eventLog = new LinkedList<>();
private final Map<Node, LinkedList<NodeEvent>> nodeLog = new TreeMap<>();
- private MetricUpdater metricUpdater; // may be null
+ private final MetricUpdater metricUpdater; // may be null
private long eventsSeen = 0;
- private long startTime;
+ private final long startTime;
private int maxSize = 1024;
private int maxNodeSize = 1024;
- private long recentTimePeriod = 7 * 24 * 60 * 60 * 1000; // millisecs - 1 week
+ private final long recentTimePeriod = 7 * 24 * 60 * 60 * 1000; // millisecs - 1 week
/** Note: metricReporter may be null. */
public EventLog(Timer timer, MetricUpdater metricUpdater) {
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/FleetController.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/FleetController.java
index 83efb5d8ded..d40460bfc8a 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/FleetController.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/FleetController.java
@@ -103,8 +103,6 @@ public class FleetController implements NodeStateOrHostInfoChangeHandler, NodeAd
private final RunDataExtractor dataExtractor = new RunDataExtractor() {
@Override
- public com.yahoo.vdslib.state.ClusterState getLatestClusterState() { return stateVersionTracker.getVersionedClusterState(); }
- @Override
public FleetControllerOptions getOptions() { return options; }
@Override
public long getConfigGeneration() { return configGeneration; }
@@ -277,7 +275,6 @@ public class FleetController implements NodeStateOrHostInfoChangeHandler, NodeAd
}
}
- public int getHttpPort() { return statusPageServer.getPort(); }
public int getRpcPort() { return rpcServer.getPort(); }
public void shutdown() throws InterruptedException, java.io.IOException {
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/FleetControllerOptions.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/FleetControllerOptions.java
index e63531229d6..528a9d79a7b 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/FleetControllerOptions.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/FleetControllerOptions.java
@@ -1,4 +1,4 @@
-// Copyright Verizone Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.jrt.slobrok.api.BackOffPolicy;
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculator.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculator.java
index 0afad4a0efe..3ad2d25a455 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculator.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculator.java
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.distribution.ConfiguredNode;
@@ -21,7 +21,7 @@ class GroupAvailabilityCalculator {
private final Distribution distribution;
private final double minNodeRatioPerGroup;
private final int safeMaintenanceGroupThreshold;
- private List<Integer> nodesSafelySetToMaintenance;
+ private final List<Integer> nodesSafelySetToMaintenance;
private GroupAvailabilityCalculator(Distribution distribution,
double minNodeRatioPerGroup,
@@ -37,7 +37,7 @@ class GroupAvailabilityCalculator {
private Distribution distribution;
private double minNodeRatioPerGroup = 1.0;
private int safeMaintenanceGroupThreshold = 2;
- private List<Integer> nodesSafelySetToMaintenance = new ArrayList<>();
+ private final List<Integer> nodesSafelySetToMaintenance = new ArrayList<>();
Builder withDistribution(Distribution distribution) {
this.distribution = distribution;
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/MasterElectionHandler.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/MasterElectionHandler.java
index 7b026dd6a74..5f391b7b8e7 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/MasterElectionHandler.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/MasterElectionHandler.java
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import java.util.logging.Level;
@@ -12,11 +12,11 @@ import java.util.logging.Logger;
*/
public class MasterElectionHandler implements MasterInterface {
- private static Logger log = Logger.getLogger(MasterElectionHandler.class.getName());
+ private static final Logger log = Logger.getLogger(MasterElectionHandler.class.getName());
private final Object monitor;
private final Timer timer;
- private int index;
+ private final int index;
private int totalCount;
private Integer masterCandidate; // The lowest indexed node in zookeeper
private int nextInLineCount; // Our position in line of the nodes in zookeeper
@@ -56,7 +56,7 @@ public class MasterElectionHandler implements MasterInterface {
@Override
public boolean isMaster() {
Integer master = getMaster();
- return (master == null ? false : master == index);
+ return (master != null && master == index);
}
@Override
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeInfo.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeInfo.java
index 652c3039430..12c3de64e0b 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeInfo.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeInfo.java
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.collections.Pair;
@@ -25,11 +25,11 @@ abstract public class NodeInfo implements Comparable<NodeInfo> {
public static Logger log = Logger.getLogger(NodeInfo.class.getName());
private final ContentCluster cluster;
- private Node node;
+ private final Node node;
private String rpcAddress;
/** If set to a timestamp, we haven't seen this node in slobrok since then. If not set, it is currently in slobrok. */
private Long lastSeenInSlobrok;
- private List<Pair<GetNodeStateRequest, Long>> pendingNodeStateRequests = new LinkedList<>();
+ private final List<Pair<GetNodeStateRequest, Long>> pendingNodeStateRequests = new LinkedList<>();
private NodeState reportedState;
private NodeState wantedState;
@@ -78,7 +78,7 @@ abstract public class NodeInfo implements Comparable<NodeInfo> {
private int version;
// Mapping of cluster state version -> cluster state bundle instance
- private TreeMap<Integer, ClusterStateBundle> clusterStateVersionBundleSent = new TreeMap<>();
+ private final TreeMap<Integer, ClusterStateBundle> clusterStateVersionBundleSent = new TreeMap<>();
private ClusterStateBundle clusterStateVersionBundleAcknowledged;
private int clusterStateVersionActivationSent = -1;
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeChecker.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeChecker.java
index 864771a1206..ca3169ede6f 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeChecker.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeChecker.java
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.lang.MutableBoolean;
@@ -164,7 +164,7 @@ public class NodeStateChangeChecker {
Optional<Metrics.Value> bucketsMetric;
bucketsMetric = hostInfo.getMetrics().getValueAt(BUCKETS_METRIC_NAME, BUCKETS_METRIC_DIMENSIONS);
- if (!bucketsMetric.isPresent() || bucketsMetric.get().getLast() == null) {
+ if (bucketsMetric.isEmpty() || bucketsMetric.get().getLast() == null) {
return Result.createDisallowed("Missing last value of the " + BUCKETS_METRIC_NAME +
" metric for storage node " + nodeInfo.getNodeIndex());
}
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ResourceUsageStats.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ResourceUsageStats.java
index aef5b1be468..a2b3c3a0415 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ResourceUsageStats.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ResourceUsageStats.java
@@ -74,9 +74,8 @@ public class ResourceUsageStats {
}
private static int calculateNodesAboveLimit(Optional<ClusterStateBundle.FeedBlock> feedBlock) {
- if (!feedBlock.isPresent()) {
- return 0;
- }
+ if (feedBlock.isEmpty()) return 0;
+
var exhaustions = feedBlock.get().getConcreteExhaustions();
return (int) exhaustions.stream().map(resource -> resource.node).distinct().count();
}
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandler.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandler.java
index cb6bacf97a6..f519b6619f7 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandler.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandler.java
@@ -1,14 +1,21 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.jrt.Spec;
-import java.util.logging.Level;
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.listeners.NodeStateOrHostInfoChangeHandler;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -21,7 +28,7 @@ import java.util.logging.Logger;
*/
public class StateChangeHandler {
- private static Logger log = Logger.getLogger(StateChangeHandler.class.getName());
+ private static final Logger log = Logger.getLogger(StateChangeHandler.class.getName());
private final Timer timer;
private final EventLogInterface eventLog;
@@ -32,7 +39,7 @@ public class StateChangeHandler {
private int maxInitProgressTime = 5000;
private int maxPrematureCrashes = 4;
private long stableStateTimePeriod = 60 * 60 * 1000;
- private Map<Integer, String> hostnames = new HashMap<>();
+ private final Map<Integer, String> hostnames = new HashMap<>();
private int maxSlobrokDisconnectGracePeriod = 1000;
private static final boolean disableUnstableNodes = true;
@@ -265,10 +272,6 @@ public class StateChangeHandler {
hostnames.remove(node.getNodeIndex());
}
- Map<Integer, String> getHostnames() {
- return Collections.unmodifiableMap(hostnames);
- }
-
// TODO too many hidden behavior dependencies between this and the actually
// generated cluster state. Still a bit of a mine field...
// TODO remove all node state mutation from this function entirely in favor of ClusterStateGenerator!
@@ -489,9 +492,7 @@ public class StateChangeHandler {
timeNow - node.getUpStableStateTime(), node.getPrematureCrashCount() + 1),
NodeEvent.Type.CURRENT,
timeNow), isMaster);
- if (handlePrematureCrash(node, nodeListener)) {
- return true;
- }
+ return handlePrematureCrash(node, nodeListener);
}
}
return false;
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/StateVersionTracker.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/StateVersionTracker.java
index 12338a5bafa..3c9b457e477 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/StateVersionTracker.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/StateVersionTracker.java
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.state.ClusterState;
@@ -32,7 +32,7 @@ public class StateVersionTracker {
private ClusterStateBundle currentClusterState = latestCandidateState;
private ClusterStateView clusterStateView;
- private ClusterStatsChangeTracker clusterStatsChangeTracker;
+ private final ClusterStatsChangeTracker clusterStatsChangeTracker;
private final LinkedList<ClusterStateHistoryEntry> clusterStateHistory = new LinkedList<>();
private int maxHistoryEntryCount = 50;
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/LegacyNodePageRequestHandler.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/LegacyNodePageRequestHandler.java
index 256730f066a..55d6bd3c43c 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/LegacyNodePageRequestHandler.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/LegacyNodePageRequestHandler.java
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core.status;
import com.yahoo.vdslib.state.Node;
@@ -36,7 +36,7 @@ public class LegacyNodePageRequestHandler implements StatusPageServer.RequestHan
TimeZone tz = TimeZone.getTimeZone("UTC");
long currentTime = timer.getCurrentTimeInMillis();
NodeType nodeType = NodeType.get(m.group(1));
- int index = Integer.valueOf(m.group(2));
+ int index = Integer.parseInt(m.group(2));
Node node = new Node(nodeType, index);
StatusPageResponse response = new StatusPageResponse();
@@ -58,4 +58,5 @@ public class LegacyNodePageRequestHandler implements StatusPageServer.RequestHan
response.writeContent(content.toString());
return response;
}
+
}
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/NodeHealthRequestHandler.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/NodeHealthRequestHandler.java
index a5047b7c106..0c16ef96a57 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/NodeHealthRequestHandler.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/NodeHealthRequestHandler.java
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core.status;
import com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse;
@@ -18,21 +18,17 @@ public class NodeHealthRequestHandler implements StatusPageServer.RequestHandler
@Override
public StatusPageResponse handle(StatusPageServer.HttpRequest request) {
StatusPageResponse response = new StatusPageResponse();
- StringBuilder content = new StringBuilder();
response.setContentType("application/json");
- content.append(
- "{\n" +
- " \"status\" : {\n" +
- " \"code\" : \"up\"\n" +
- " },\n" +
- " \"config\" : {\n" +
- " \"component\" : {\n" +
- " \"generation\" : " + data.getConfigGeneration() + "\n" +
- " }\n" +
- " }\n" +
- "}"
- );
- response.writeContent(content.toString());
+ response.writeContent("{\n" +
+ " \"status\" : {\n" +
+ " \"code\" : \"up\"\n" +
+ " },\n" +
+ " \"config\" : {\n" +
+ " \"component\" : {\n" +
+ " \"generation\" : " + data.getConfigGeneration() + "\n" +
+ " }\n" +
+ " }\n" +
+ "}");
return response;
}
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/RunDataExtractor.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/RunDataExtractor.java
index d7df3565062..0ce184aa7b6 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/RunDataExtractor.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/RunDataExtractor.java
@@ -1,16 +1,14 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core.status;
-import com.yahoo.vdslib.state.ClusterState;
-import com.yahoo.vespa.clustercontroller.core.FleetControllerOptions;
import com.yahoo.vespa.clustercontroller.core.ContentCluster;
+import com.yahoo.vespa.clustercontroller.core.FleetControllerOptions;
/**
* @author Haakon Humberset
*/
public interface RunDataExtractor {
- ClusterState getLatestClusterState();
FleetControllerOptions getOptions();
long getConfigGeneration();
ContentCluster getCluster();
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/StatusHandler.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/StatusHandler.java
index ac9634478fa..dd62c88ea6c 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/StatusHandler.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/status/StatusHandler.java
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core.status;
import com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse;
@@ -10,6 +10,7 @@ import com.yahoo.vespa.clustercontroller.utils.communication.http.HttpResult;
import java.io.IOException;
import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.logging.Logger;
import java.util.regex.Matcher;
@@ -40,7 +41,7 @@ public class StatusHandler implements HttpRequestHandler {
@Override
public void shutdown() throws InterruptedException, IOException {}
@Override
- public void setPort(int port) throws IOException, InterruptedException {}
+ public void setPort(int port) {}
@Override
public StatusPageServer.HttpRequest getCurrentHttpRequest() {
synchronized (answerMonitor) {
@@ -73,8 +74,8 @@ public class StatusHandler implements HttpRequestHandler {
}
- private static Pattern clusterListRequest = Pattern.compile("^/clustercontroller-status/v1/?$");
- private static Pattern statusRequest = Pattern.compile("^/clustercontroller-status/v1/([^/]+)(/.*)?$");
+ private static final Pattern clusterListRequest = Pattern.compile("^/clustercontroller-status/v1/?$");
+ private static final Pattern statusRequest = Pattern.compile("^/clustercontroller-status/v1/([^/]+)(/.*)?$");
private final ClusterStatusPageServerSet statusClusters;
public StatusHandler(ClusterStatusPageServerSet set) {
@@ -117,7 +118,7 @@ public class StatusHandler implements HttpRequestHandler {
if (response.getContentType() != null) {
result.addHeader("Content-Type", response.getContentType());
}
- result.setContent(new String(response.getOutputStream().toByteArray()));
+ result.setContent(response.getOutputStream().toString(StandardCharsets.UTF_8));
return result;
}
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 35cfd82f367..5975f1248bb 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
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.distribution.ConfiguredNode;
@@ -21,6 +21,7 @@ import java.util.TreeMap;
import static org.mockito.Mockito.mock;
public class ClusterFixture {
+
public final ContentCluster cluster;
public final Distribution distribution;
public final FakeTimer timer;
@@ -131,22 +132,19 @@ public class ClusterFixture {
return this;
}
- ClusterFixture disableAutoClusterTakedown() {
+ void disableAutoClusterTakedown() {
setMinNodesUp(0, 0, 0.0, 0.0);
- return this;
}
- ClusterFixture setMinNodesUp(int minDistNodes, int minStorNodes, double minDistRatio, double minStorRatio) {
+ void setMinNodesUp(int minDistNodes, int minStorNodes, double minDistRatio, double minStorRatio) {
params.minStorageNodesUp(minStorNodes)
.minDistributorNodesUp(minDistNodes)
.minRatioOfStorageNodesUp(minStorRatio)
.minRatioOfDistributorNodesUp(minDistRatio);
- return this;
}
- ClusterFixture setMinNodeRatioPerGroup(double upRatio) {
+ void setMinNodeRatioPerGroup(double upRatio) {
params.minNodeRatioPerGroup(upRatio);
- return this;
}
public ClusterFixture assignDummyRpcAddresses() {
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 9a295e95fff..f5a59b0a246 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
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.google.common.collect.Sets;
@@ -16,7 +16,7 @@ import static org.junit.Assert.assertTrue;
public class ClusterStatsAggregatorTest {
private static class Fixture {
- private ClusterStatsAggregator aggregator;
+ private final ClusterStatsAggregator aggregator;
Fixture(Set<Integer> distributorNodes,
Set<Integer> contentNodes) {
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 3042e323879..e8f13b9f741 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
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.google.common.collect.Sets;
@@ -20,7 +20,7 @@ import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
public class ContentClusterHtmlRendrerTest {
- private VdsClusterHtmlRenderer renderer = new VdsClusterHtmlRenderer();
+ private final VdsClusterHtmlRenderer renderer = new VdsClusterHtmlRenderer();
private final static int slobrokGeneration = 34;
private final static String clusterName = "clustername";
private final TreeMap<Integer, NodeInfo> storageNodeInfoByIndex = new TreeMap<>();
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 5d5daa25e30..b322c62967a 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
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.collections.Pair;
@@ -16,9 +16,9 @@ import java.util.TreeMap;
public class DummyCommunicator implements Communicator, NodeLookup {
List<Node> newNodes;
- private Timer timer;
+ private final Timer timer;
private boolean shouldDeferDistributorClusterStateAcks = false;
- private List<Pair<Waiter<SetClusterStateRequest>, DummySetClusterStateRequest>> deferredClusterStateAcks = new ArrayList<>();
+ private final List<Pair<Waiter<SetClusterStateRequest>, DummySetClusterStateRequest>> deferredClusterStateAcks = new ArrayList<>();
void setShouldDeferDistributorClusterStateAcks(boolean shouldDeferDistributorClusterStateAcks) {
this.shouldDeferDistributorClusterStateAcks = shouldDeferDistributorClusterStateAcks;
@@ -55,7 +55,7 @@ public class DummyCommunicator implements Communicator, NodeLookup {
}
- private Map<Node, DummyGetNodeStateRequest> getNodeStateRequests = new TreeMap<>();
+ private final Map<Node, DummyGetNodeStateRequest> getNodeStateRequests = new TreeMap<>();
DummyCommunicator(List<Node> nodeList, Timer timer) {
this.newNodes = nodeList;
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 0cf84cfe54c..8a25f9a9e76 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,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.jrt.Acceptor;
@@ -38,21 +38,21 @@ public class DummyVdsNode {
public static Logger log = Logger.getLogger(DummyVdsNode.class.getName());
- private String[] slobrokConnectionSpecs;
- private String clusterName;
- private NodeType type;
- private int index;
+ private final String[] slobrokConnectionSpecs;
+ private final String clusterName;
+ private final NodeType type;
+ private final int index;
private NodeState nodeState;
private String hostInfo = "{}";
private Supervisor supervisor;
private Acceptor acceptor;
private Register register;
- private int stateCommunicationVersion;
+ private final int stateCommunicationVersion;
private boolean negotiatedHandle = false;
private final Timer timer;
private boolean failSetSystemStateRequests = false;
private boolean resetTimestampOnReconnect = false;
- private Map<Node, Long> highestStartTimestamps = new TreeMap<Node, Long>();
+ private final Map<Node, Long> highestStartTimestamps = new TreeMap<Node, Long>();
int timedOutStateReplies = 0;
int outdatedStateReplies = 0;
int immediateStateReplies = 0;
@@ -79,10 +79,10 @@ public class DummyVdsNode {
* History of received cluster states.
* Any access to this list or to its members must be synchronized on the timer variable.
*/
- private List<ClusterStateBundle> clusterStateBundles = new LinkedList<>();
+ private final List<ClusterStateBundle> clusterStateBundles = new LinkedList<>();
private int activatedClusterStateVersion = 0;
- private Thread messageResponder = new Thread() {
+ private final Thread messageResponder = new Thread() {
public void run() {
log.log(Level.FINE, "Dummy node " + DummyVdsNode.this.toString() + ": starting message reponder thread");
while (true) {
@@ -113,7 +113,7 @@ public class DummyVdsNode {
}
};
- public DummyVdsNode(Timer timer, DummyVdsNodeOptions options, String slobrokConnectionSpecs[], String clusterName, boolean distributor, int index) throws Exception {
+ public DummyVdsNode(Timer timer, DummyVdsNodeOptions options, String[] slobrokConnectionSpecs, String clusterName, boolean distributor, int index) throws Exception {
this.timer = timer;
this.slobrokConnectionSpecs = slobrokConnectionSpecs;
this.clusterName = clusterName;
@@ -129,7 +129,7 @@ public class DummyVdsNode {
public void shutdown() {
messageResponder.interrupt();
- try{ messageResponder.join(); } catch (InterruptedException e) {}
+ try{ messageResponder.join(); } catch (InterruptedException e) { /* ignore */ }
disconnect();
}
@@ -183,7 +183,7 @@ public class DummyVdsNode {
newState.setDescription("controlled shutdown");
setNodeState(newState);
// Sleep a bit in hopes of answer being written before shutting down socket
- try{ Thread.sleep(100); } catch (InterruptedException e) {}
+ try{ Thread.sleep(100); } catch (InterruptedException e) { /* ignore */ }
}
if (supervisor == null) return;
register.shutdown();
@@ -214,9 +214,7 @@ public class DummyVdsNode {
throw new RuntimeException("Timed out waiting for state version " + version + " in " + this);
Thread.sleep(10);
}
- }
- catch (InterruptedException e) {
- }
+ } catch (InterruptedException e) { /* ignore */ }
}
/** Returns the latest system state version received, or empty if none are received yet. */
@@ -229,12 +227,6 @@ public class DummyVdsNode {
}
}
- public int getActivatedClusterStateVersion() {
- synchronized (timer) {
- return activatedClusterStateVersion;
- }
- }
-
public boolean hasPendingGetNodeStateRequest() {
synchronized (timer) {
return !waitingRequests.isEmpty();
@@ -254,8 +246,7 @@ public class DummyVdsNode {
try{
log.log(Level.FINE, "Dummy node " + this + " waiting " + (endTime - startTime) + " ms for pending request.");
timer.wait(endTime - startTime);
- } catch (InterruptedException e) {
- }
+ } catch (InterruptedException e) { /* ignore */ }
log.log(Level.FINE, "Dummy node " + this + " woke up to recheck.");
}
startTime = System.currentTimeMillis();
@@ -474,11 +465,6 @@ public class DummyVdsNode {
}
}
- public long getStartTimestamp(Node n) {
- Long ts = highestStartTimestamps.get(n);
- return (ts == null ? 0 : ts);
- }
-
private void updateStartTimestamps(ClusterState state) {
for(int i=0; i<2; ++i) {
NodeType nodeType = (i == 0 ? NodeType.DISTRIBUTOR : NodeType.STORAGE);
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 1ec3091dc2a..290c58f6453 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
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.state.Node;
@@ -17,8 +17,8 @@ import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class EventLogTest {
- private MetricUpdater metricUpdater = mock(MetricUpdater.class);
- private NodeEvent nodeEvent = mock(NodeEvent.class);
+ private final MetricUpdater metricUpdater = mock(MetricUpdater.class);
+ private final NodeEvent nodeEvent = mock(NodeEvent.class);
private EventLog eventLog;
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 bda24b826fd..3f9ebaf319c 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
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import java.util.logging.Level;
@@ -12,7 +12,13 @@ import java.util.logging.Logger;
* Used to fake timing for unit test purposes.
*/
public class FakeTimer implements Timer {
- private static Logger log = Logger.getLogger(FakeTimer.class.getName());
+
+ private static final Logger log = Logger.getLogger(FakeTimer.class.getName());
+
+ static {
+ LogFormatter.initializeLogging();
+ }
+
// 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;
@@ -27,8 +33,4 @@ public class FakeTimer implements Timer {
notifyAll();
}
- static {
- LogFormatter.initializeLogging();
- }
-
}
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 c42a54b3528..608d7d6aee3 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
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.jrt.Request;
@@ -82,7 +82,7 @@ public class MasterElectionTest extends FleetControllerTest {
for (FleetController f : fleetControllers) {
while (f.hasZookeeperConnection()) {
timer.advanceTime(1000);
- try { Thread.sleep(1); } catch (InterruptedException e) {}
+ try { Thread.sleep(1); } catch (InterruptedException e) { /* ignore */ }
if (System.currentTimeMillis() > maxTime)
throw new TimeoutException("Failed to notice zookeeper down within timeout of " + timeoutMS + " ms");
}
@@ -194,7 +194,7 @@ public class MasterElectionTest extends FleetControllerTest {
}
}
// Have to wait to get zookeeper communication chance to happen.
- try{ Thread.sleep(100); } catch (InterruptedException e) {}
+ try{ Thread.sleep(100); } catch (InterruptedException e) { /* ignore */ }
}
if (!isOnlyMaster) {
@@ -348,7 +348,7 @@ public class MasterElectionTest extends FleetControllerTest {
}
}
if (allOk) return;
- try{ Thread.sleep(100); } catch (InterruptedException e) {}
+ try{ Thread.sleep(100); } catch (InterruptedException e) { /* ignore */ }
}
throw new IllegalStateException("Did not get master reason '" + reason
+ "' within timeout of " + timeoutMS + " ms");
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 d3cf4ba1bea..5ca6c6f2289 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
@@ -501,7 +501,7 @@ public class RpcServerTest extends FleetControllerTest {
assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
assertTrue(req.toString(), req.checkReturnTypes("s"));
- ClusterState state = waitForState("version:\\d+ distributor:26 .* storage:26 .* .14.s:r.* .16.s:m .*");
+ waitForState("version:\\d+ distributor:26 .* storage:26 .* .14.s:r.* .16.s:m .*");
nodes.get(5 * 2 + 1).disconnect();
waitForCompleteCycle();
timer.advanceTime(100000000);
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SlobrokTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SlobrokTest.java
index a77e267c85b..4c8bcbbe58b 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SlobrokTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/SlobrokTest.java
@@ -58,7 +58,7 @@ public class SlobrokTest extends FleetControllerTest {
waitForCompleteCycle();
try{
Thread.sleep(10);
- } catch (InterruptedException e) {}
+ } catch (InterruptedException e) { /* ignore */ }
}
assertClusterAvailable();
}
@@ -87,7 +87,7 @@ public class SlobrokTest extends FleetControllerTest {
// Give system a little time to possible faultily removing node not in slobrok
timer.advanceTime(1000);
- try{ Thread.sleep(10); } catch (InterruptedException e) {}
+ try{ Thread.sleep(10); } catch (InterruptedException e) { /* ignore */ }
assertEquals(version, fleetController.getSystemState().getVersion());
log.log(Level.INFO, "JUMPING TIME. NODE SHOULD BE MARKED DOWN");
// At this point the fleetcontroller might not have noticed that the node is out of slobrok yet.
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 68926b4d10d..2ee0357419f 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
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vdslib.distribution.ConfiguredNode;
@@ -62,9 +62,9 @@ public class StateChangeHandlerTest {
}
}
- private FakeTimer clock = new FakeTimer();
- private TestEventLog eventLog = new TestEventLog();
- private Set<ConfiguredNode> configuredNodes = new TreeSet<>();
+ private final FakeTimer clock = new FakeTimer();
+ private final TestEventLog eventLog = new TestEventLog();
+ private final Set<ConfiguredNode> configuredNodes = new TreeSet<>();
private Config config;
private ContentCluster cluster;
private StateChangeHandler nodeStateChangeHandler;
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 7e2d8d09e1b..516f2efabb2 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
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;
import java.util.logging.Level;
@@ -65,7 +65,7 @@ public class StateGatherTest extends FleetControllerTest {
throw new TimeoutException("Did not get to have one timed out within timeout of " + timeoutMS + " ms"
+ ", " + getGetNodeStateReplyCounts(dnode) + ", " + getGetNodeStateReplyCounts(snode));
}
- try{ timer.wait(1); } catch (InterruptedException e) {}
+ try{ timer.wait(1); } catch (InterruptedException e) { /* ignore */ }
}
}
}
@@ -74,7 +74,7 @@ public class StateGatherTest extends FleetControllerTest {
long timeout = System.currentTimeMillis() + timeoutMS;
while (dnode.getPendingNodeStateCount() != 1 || snode.getPendingNodeStateCount() != 1) {
if (System.currentTimeMillis() > timeout) throw new TimeoutException("Did not get to have one pending within timeout of " + timeoutMS + " ms");
- try{ Thread.sleep(1); } catch (InterruptedException e) {}
+ try{ Thread.sleep(1); } catch (InterruptedException e) { /* ignore */ }
}
}
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 a37b3abbd88..3a859d5a27a 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
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core.restapiv2;
import com.yahoo.vdslib.state.ClusterState;
@@ -11,9 +11,9 @@ import com.yahoo.vespa.clustercontroller.core.listeners.NodeStateOrHostInfoChang
public class ClusterControllerMock implements RemoteClusterControllerTaskScheduler {
public RemoteClusterControllerTask.Context context = new RemoteClusterControllerTask.Context();
- private int fleetControllerIndex;
+ private final int fleetControllerIndex;
Integer fleetControllerMaster;
- private StringBuilder events = new StringBuilder();
+ private final StringBuilder events = new StringBuilder();
ClusterControllerMock(ContentCluster cluster, ClusterState state,
ClusterStateBundle publishedClusterStateBundle,
@@ -84,4 +84,5 @@ public class ClusterControllerMock implements RemoteClusterControllerTaskSchedul
task.doRemoteFleetControllerTask(context);
task.notifyCompleted();
}
+
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ServiceTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ServiceTest.java
index ba321d702b1..57105e0eb5b 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ServiceTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ServiceTest.java
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core.restapiv2;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse;
@@ -6,7 +6,6 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
-// TODO: Author?
public class ServiceTest extends StateRestApiTest {
@Test
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 5bb7897b8e7..03fdb15971f 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
@@ -48,11 +48,10 @@ public class SetNodeStateTest extends StateRestApiTest {
public ExpectedException expectedException = ExpectedException.none();
public static class SetUnitStateRequestImpl extends StateRequest implements SetUnitStateRequest {
- private Map<String, UnitState> newStates = new LinkedHashMap<>();
+ private final Map<String, UnitState> newStates = new LinkedHashMap<>();
private Condition condition = Condition.FORCE;
private ResponseWait responseWait = ResponseWait.WAIT_UNTIL_CLUSTER_ACKED;
- private TimeBudget timeBudget = TimeBudget.fromNow(Clock.systemUTC(), Duration.ofSeconds(10));
- private boolean probe = false;
+ private final TimeBudget timeBudget = TimeBudget.fromNow(Clock.systemUTC(), Duration.ofSeconds(10));
SetUnitStateRequestImpl(String req) {
super(req, 0);
@@ -108,7 +107,7 @@ public class SetNodeStateTest extends StateRestApiTest {
@Override
public boolean isProbe() {
- return probe;
+ return false;
}
}
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 4d079ec782f..5b5b0036ac9 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
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core.restapiv2;
import com.yahoo.vdslib.distribution.ConfiguredNode;
@@ -27,7 +27,6 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.stream.Collectors;
-// TODO: Author
public abstract class StateRestApiTest {
private ClusterControllerMock books;
@@ -37,8 +36,8 @@ public abstract class StateRestApiTest {
Map<Integer, ClusterControllerStateRestAPI.Socket> ccSockets;
public static class StateRequest implements UnitStateRequest {
- private String[] path;
- private int recursive;
+ private final String[] path;
+ private final int recursive;
StateRequest(String req, int recursive) {
path = req.isEmpty() ? new String[0] : req.split("/");
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequestTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequestTest.java
index 62ae9758faf..8c6ef1d70d8 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequestTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequestTest.java
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core.restapiv2.requests;
@@ -31,14 +31,14 @@ import static org.mockito.Mockito.when;
public class SetNodeStateRequestTest {
private static final String REASON = "operator";
- private ContentCluster cluster = mock(ContentCluster.class);
- private SetUnitStateRequest.Condition condition = SetUnitStateRequest.Condition.SAFE;
- private Map<String, UnitState> newStates = new HashMap<>();
- private UnitState unitState = mock(UnitState.class);
+ private final ContentCluster cluster = mock(ContentCluster.class);
+ private final SetUnitStateRequest.Condition condition = SetUnitStateRequest.Condition.SAFE;
+ private final Map<String, UnitState> newStates = new HashMap<>();
+ private final UnitState unitState = mock(UnitState.class);
private final int NODE_INDEX = 2;
- private Node storageNode = new Node(NodeType.STORAGE, NODE_INDEX);
- private NodeStateOrHostInfoChangeHandler stateListener = mock(NodeStateOrHostInfoChangeHandler.class);
- private ClusterState currentClusterState = mock(ClusterState.class);
+ private final Node storageNode = new Node(NodeType.STORAGE, NODE_INDEX);
+ private final NodeStateOrHostInfoChangeHandler stateListener = mock(NodeStateOrHostInfoChangeHandler.class);
+ private final ClusterState currentClusterState = mock(ClusterState.class);
private boolean probe = false;
@Before
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/LogFormatter.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/LogFormatter.java
index aa6ac0f3fcc..3bf5ddf6509 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/LogFormatter.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/LogFormatter.java
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core.testutils;
import java.io.File;
@@ -9,13 +9,15 @@ import java.util.logging.LogManager;
import java.util.logging.LogRecord;
public class LogFormatter extends Formatter {
+
+ private static boolean initialized = false;
+
@Override
public String format(LogRecord record) {
return record.getMillis() + " " + record.getLevel() + " "
+ record.getLoggerName().substring(record.getLoggerName().lastIndexOf('.') + 1) + " " + record.getMessage() + "\n";
}
- private static boolean initialized = false;
public synchronized static void initializeLogging() {
if (initialized) return;
initialized = true;
@@ -31,4 +33,5 @@ public class LogFormatter extends Formatter {
t.printStackTrace();
}
}
+
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/StateWaiter.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/StateWaiter.java
index eb0ca6cff15..f8f89bc4a04 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/StateWaiter.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/testutils/StateWaiter.java
@@ -1,8 +1,7 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core.testutils;
import com.yahoo.vdslib.state.ClusterState;
-import com.yahoo.vdslib.state.Node;
import com.yahoo.vespa.clustercontroller.core.ClusterStateBundle;
import com.yahoo.vespa.clustercontroller.core.FakeTimer;
import com.yahoo.vespa.clustercontroller.core.listeners.SystemStateListener;
@@ -17,7 +16,6 @@ import java.util.regex.Pattern;
public class StateWaiter implements SystemStateListener {
private final FakeTimer timer;
protected ClusterState current;
- private int stateUpdates = -1;
public StateWaiter(FakeTimer timer) {
this.timer = timer;
@@ -27,8 +25,6 @@ public class StateWaiter implements SystemStateListener {
public void handleNewPublishedState(ClusterStateBundle state) {
synchronized(timer) {
current = state.getBaselineClusterState();
-
- ++stateUpdates;
timer.notifyAll();
}
}
@@ -55,8 +51,6 @@ public class StateWaiter implements SystemStateListener {
handleNewPublishedState(states);
}
- public int getStateUpdates() { return Math.max(0, stateUpdates); }
-
public ClusterState getCurrentSystemState() {
synchronized(timer) {
return current;
@@ -106,33 +100,5 @@ public class StateWaiter implements SystemStateListener {
}
}
}
- public void clear() {
- synchronized(timer) {
- current = null;
- }
- }
- public void waitForInitProgressPassed(Node node, double minProgress, int timeoutMS) {
- long startTime = System.currentTimeMillis();
- long endTime = startTime + timeoutMS;
- while (true) {
- ClusterState currentClusterState;
- synchronized(timer) {
- currentClusterState = current;
- if (currentClusterState != null) {
- if (currentClusterState.getNodeState(node).getInitProgress() >= minProgress) {
- return;
- }
- }
- try{
- timer.wait(endTime - startTime);
- } catch (InterruptedException e) {
- }
- }
- startTime = System.currentTimeMillis();
- if (startTime >= endTime) {
- throw new IllegalStateException("Timeout. Did not get to " + minProgress + " init progress on node " + node + " within timeout of " + timeoutMS + " ms. Current init progress is " + currentClusterState.getNodeState(node).getInitProgress());
- }
- }
- }
}
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 c24424d3bab..356aa32dda5 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
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core.testutils;
import com.yahoo.vdslib.state.ClusterState;
@@ -19,7 +19,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
-* @author <a href="mailto:humbe@yahoo-inc.com">Haakon Humberset</a>
+* @author Haakon Humberset
*/
public interface WaitCondition {
@@ -222,4 +222,5 @@ public interface WaitCondition {
@Override
public String toString() { return "MinUsedBitsMatcher(" + bitCount + ", " + nodeCount + ")"; }
}
+
}