aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/SystemApplication.java
blob: f264251361a3a6d4cec8cbb39bc127ed4e753a49 (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
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.application;

import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.NodeType;

import java.util.Arrays;
import java.util.List;

/**
 * This represents a system-level application in hosted Vespa. E.g. the zone-application.
 *
 * @author mpolden
 */
public enum SystemApplication {

    // Note that the enum declaration order decides the upgrade order
    configServerHost(ApplicationId.from("hosted-vespa", "configserver-host", "default"), NodeType.confighost),
    proxyHost(ApplicationId.from("hosted-vespa", "proxy-host", "default"), NodeType.proxyhost),
    configServer(ApplicationId.from("hosted-vespa", "zone-config-servers", "default"), NodeType.config),
    zone(ApplicationId.from("hosted-vespa", "routing", "default"), NodeType.proxy);

    private final ApplicationId id;
    private final NodeType nodeType;

    SystemApplication(ApplicationId id, NodeType nodeType) {
        this.id = id;
        this.nodeType = nodeType;
    }

    public ApplicationId id() {
        return id;
    }

    /** The type of nodes that will be allocated to this */
    public NodeType nodeType() {
        return nodeType;
    }

    /** Returns whether this system application has an application package */
    public boolean hasApplicationPackage() {
        return nodeType == NodeType.proxy;
    }

    /** Returns whether this system application must be upgraded in the declared order */
    public boolean upgradeInOrder() {
        return nodeType != NodeType.confighost && nodeType != NodeType.proxyhost;
    }

    /** All known system applications */
    public static List<SystemApplication> all() {
        return Arrays.asList(values());
    }

    @Override
    public String toString() {
        return String.format("system application %s of type %s", id, nodeType);
    }

}