aboutsummaryrefslogtreecommitdiffstats
path: root/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/DummyBackend.java
blob: f3af57559c5b6ab0a89faebd2a2135a459d4378b (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
34
35
36
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.utils.staterestapi;

import java.util.LinkedHashMap;
import java.util.Map;

public class DummyBackend {
    public static class Cluster {
        public final String id;
        public final Map<String, Node> nodes = new LinkedHashMap<>();

        public Cluster(String id) { this.id = id; }
        public Cluster addNode(Node n) { nodes.put(n.id, n); n.clusterId = id; return this; }
    }
    public static class Node {
        public String clusterId;
        public final String id;
        public int docCount = 0;
        public String state = "up";
        public String reason = "";
        public final String group = "mygroup";

        public Node(String id) { this.id = id; }

        public Node setDocCount(int count) { docCount = count; return this; }
        public Node setState(String state) { this.state = state; return this; }
    }
    private final Map<String, Cluster> clusters = new LinkedHashMap<>();

    public Map<String, Cluster> getClusters() { return clusters; }

    public DummyBackend addCluster(Cluster c) {
        clusters.put(c.id, c);
        return this;
    }
}