aboutsummaryrefslogtreecommitdiffstats
path: root/config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java
blob: 44bd7ec3708ad59d59fa6511a859f91e70074c86 (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.provision;

/**
 * The possible types of nodes in the node repository
 * 
 * @author bratseth
 */
public enum NodeType {

    /** A node to be assigned to a tenant to run application workloads */
    tenant(null, "Tenant node"),

    /** A host of a set of (Docker) tenant nodes */
    host(tenant, "Tenant docker host"),

    /** Nodes running the shared proxy layer */
    proxy(null, "Proxy node"),

    /** A host of a (Docker) proxy node */
    proxyhost(proxy, "Proxy docker host"),

    /** A config server */
    config(null, "Config server"),

    /** A host of a (Docker) config server node */
    confighost(config, "Config docker host"),

    /** A controller */
    controller(null, "Controller"),

    /** A host of a (Docker) controller node */
    controllerhost(controller, "Controller host");

    private final NodeType childNodeType;
    private final String description;

    NodeType(NodeType childNodeType, String description) {
        this.childNodeType = childNodeType;
        this.description = description;
    }

    public boolean isDockerHost() {
        return childNodeType != null;
    }

    public String description() {
        return description;
    }

    /**
     * @return {@link NodeType} of the node(s) that run on this host
     * @throws IllegalStateException if this type is not a host
     */
    public NodeType childNodeType() {
        if (! isDockerHost())
            throw new IllegalStateException(this + " has no children");

        return childNodeType;
    }
}