aboutsummaryrefslogtreecommitdiffstats
path: root/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/NodeRepository.java
blob: ac1f8ec059ff80e177afda08ba60b836ecbe603a (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.admin.configserver.noderepository;

import com.yahoo.vespa.hosted.node.admin.wireguard.WireguardPeer;

import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * @author stiankri
 */
public interface NodeRepository {

    void addNodes(List<AddNode> nodes);

    List<NodeSpec> getNodes(String baseHostName);

    default NodeSpec getNode(String hostName) {
        return getOptionalNode(hostName).orElseThrow(() -> new NoSuchNodeException(hostName + " not found in node-repo"));
    }

    Optional<NodeSpec> getOptionalNode(String hostName);

    Map<String, Acl> getAcls(String hostname);

    List<WireguardPeer> getExclavePeers();

    List<WireguardPeer> getConfigserverPeers();

    void updateNodeAttributes(String hostName, NodeAttributes nodeAttributes);

    void setNodeState(String hostName, NodeState nodeState);

    default void reboot(String hostname) {
        throw new UnsupportedOperationException("Rebooting not supported in " + getClass().getName());
    }
}