aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTester.java
blob: 5e7ecb854ff7a3b32563db76dfe735984fc25c02 (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 Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.dispatch.searchcluster;

import com.yahoo.search.dispatch.MockSearchCluster;

public class SearchClusterTester {

    private final SearchCluster cluster;

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

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

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

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

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

}