aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTester.java
blob: 35d990be412f353f43c920d4bc7bf43d899729d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.dispatch.searchcluster;

public class SearchClusterTester {

    private final SearchCluster cluster;

    public SearchClusterTester(int groups, int nodesPerGroup) {
        cluster = new MockSearchCluster("1", groups, nodesPerGroup);
    }

    public SearchCluster cluster() { return cluster; }

    public void pingIterationCompleted() {
        cluster.pingIterationCompleted();
    }

    public Group group(int id) {
        return cluster.group(id);
    }

    public void setWorking(int group, int node, boolean working) {
        cluster.group(group).nodes().get(node).setWorking(working);
    }

    public void setDocsPerNode(int docs, int groupId) {
        for (Node node : cluster.group(groupId).nodes()) {
            node.setWorking(true);
            node.setActiveDocuments(docs);
        }
    }

}