aboutsummaryrefslogtreecommitdiffstats
path: root/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/RealConfigServerClients.java
blob: 4311a31816a6fab5440289554fd3ef6f2553ad94 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.admin.configserver;

import com.yahoo.vespa.flags.FlagRepository;
import com.yahoo.vespa.hosted.node.admin.configserver.cores.Cores;
import com.yahoo.vespa.hosted.node.admin.configserver.cores.CoresImpl;
import com.yahoo.vespa.hosted.node.admin.configserver.flags.RealFlagRepository;
import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeRepository;
import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.RealNodeRepository;
import com.yahoo.vespa.hosted.node.admin.configserver.orchestrator.Orchestrator;
import com.yahoo.vespa.hosted.node.admin.configserver.orchestrator.OrchestratorImpl;
import com.yahoo.vespa.hosted.node.admin.configserver.state.State;
import com.yahoo.vespa.hosted.node.admin.configserver.state.StateImpl;

/**
 * {@link ConfigServerClients} using the default implementation for the various clients,
 * and backed by a {@link ConfigServerApi}.
 *
 * @author freva
 */
public class RealConfigServerClients implements ConfigServerClients {
    private final ConfigServerApi configServerApi;
    private final NodeRepository nodeRepository;
    private final Orchestrator orchestrator;
    private final State state;
    private final RealFlagRepository flagRepository;
    private final Cores cores;

    /**
     * @param configServerApi the backend API to use - will be closed at {@link #stop()}.
     */
    public RealConfigServerClients(ConfigServerApi configServerApi) {
        this.configServerApi = configServerApi;
        nodeRepository = new RealNodeRepository(configServerApi);
        orchestrator = new OrchestratorImpl(configServerApi);
        state = new StateImpl(configServerApi);
        flagRepository = new RealFlagRepository(configServerApi);
        cores = new CoresImpl(configServerApi);
    }

    @Override
    public NodeRepository nodeRepository() {
        return nodeRepository;
    }

    @Override
    public Orchestrator orchestrator() {
        return orchestrator;
    }

    @Override
    public State state() {
        return state;
    }

    @Override
    public FlagRepository flagRepository() {
        return flagRepository;
    }

    @Override
    public Cores cores() {
        return cores;
    }

    @Override
    public void stop() {
        configServerApi.close();
    }
}