Remove unused executor, log if we get InterruptedException
@@ -9,14 +9,12 @@ import com.yahoo.prelude.Pong;
import com.yahoo.search.cluster.ClusterMonitor;
import com.yahoo.search.dispatch.MockSearchCluster;
import com.yahoo.search.result.ErrorMessage;
-import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
-import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@@ -32,20 +30,6 @@ public class SearchClusterTest {
static class State {
- class MyExecutor implements Executor {
- private final List<Runnable> list = new ArrayList<>();
- @Override
- public void execute(@NotNull Runnable command) {
- list.add(command);
- }
- void run() {
- for (Runnable runnable : list) {
- runnable.run();
- }
- list.clear();
- }
- }
-
final String clusterId;
final int nodesPerGroup;
final VipStatus vipStatus;
@@ -57,22 +41,22 @@ public class SearchClusterTest {
this(clusterId, nodesPergroup, Arrays.asList(nodeNames));
}
- State(String clusterId, int nodesPergroup, List<String> nodeNames) {
+ State(String clusterId, int nodesPerGroup, List<String> nodeNames) {
this.clusterId = clusterId;
- this.nodesPerGroup = nodesPergroup;
+ this.nodesPerGroup = nodesPerGroup;
vipStatus = new VipStatus(new QrSearchersConfig.Builder().searchcluster(new QrSearchersConfig.Searchcluster.Builder().name(clusterId)).build(), new ClustersStatus());
numDocsPerNode = new ArrayList<>(nodeNames.size());
pingCounts = new ArrayList<>(nodeNames.size());
List<Node> nodes = new ArrayList<>(nodeNames.size());
for (String name : nodeNames) {
- int key = nodes.size() % nodesPergroup;
- int group = nodes.size() / nodesPergroup;
+ int key = nodes.size() % nodesPerGroup;
+ int group = nodes.size() / nodesPerGroup;
nodes.add(new Node(key, name, group));
numDocsPerNode.add(new AtomicInteger(1));
pingCounts.add(new AtomicInteger(0));
}
- searchCluster = new SearchCluster(clusterId, MockSearchCluster.createDispatchConfig(nodes), nodes.size() / nodesPergroup, vipStatus);
+ searchCluster = new SearchCluster(clusterId, MockSearchCluster.createDispatchConfig(nodes), nodes.size() / nodesPerGroup, vipStatus);
}
void startMonitoring() {
@@ -108,7 +92,9 @@ public class SearchClusterTest {
boolean completed = executor.awaitTermination(120, TimeUnit.SECONDS);
if ( ! completed )
throw new IllegalStateException("Ping thread timed out");
- } catch (InterruptedException e) {}
+ } catch (InterruptedException e) {
+ System.out.println("Ping thread interrupted");
+ }
}
}
@@ -125,7 +111,7 @@ public class SearchClusterTest {
this.pingCount = pingCount;
}
@Override
- public Pong call() throws Exception {
+ public Pong call() {
int docs = numDocs.get();
pingCount.incrementAndGet();
return (docs < 0)
@@ -260,6 +246,7 @@ public class SearchClusterTest {
test.waitOneFullPingRound();
assertFalse(test.vipStatus.isInRotation());
}
+
@Test
public void requireThatVipStatusDownRequireAllNodesDown() {
verifyThatVipStatusDownRequireAllNodesDown(1,2);
@@ -297,6 +284,7 @@ public class SearchClusterTest {
test.waitOneFullPingRound();
assertTrue(test.vipStatus.isInRotation());
}
+
@Test
public void requireThatVipStatusUpRequireOnlyOneOnlineNode() {
verifyThatVipStatusUpRequireOnlyOneOnlineNode(1, 2);
