summaryrefslogtreecommitdiffstats
path: root/hosted-zone-api/src/main/java/ai/vespa/cloud/SystemInfo.java
blob: 2ace2e7872b8ed68b69856596ae5fbe664f95ef4 (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 Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.cloud;

import java.util.Objects;

/**
 * Provides information about the system in which this container is running.
 * This is available and can be injected when running in a cloud environment.
 *
 * @author bratseth
 */
public class SystemInfo {

    private final ApplicationId application;
    private final Zone zone;
    private final Cloud cloud;
    private final Cluster cluster;
    private final Node node;

    // TODO: Remove on Vespa 9
    @Deprecated(forRemoval = true)
    public SystemInfo(ApplicationId application, Zone zone, Cluster cluster, Node node) {
        this(application, zone, new Cloud(""), cluster, node);
    }

    public SystemInfo(ApplicationId application, Zone zone, Cloud cloud, Cluster cluster, Node node) {
        this.application = Objects.requireNonNull(application, "Application cannot be null");
        this.zone = Objects.requireNonNull(zone, "Zone cannot be null");
        this.cloud = Objects.requireNonNull(cloud, "Cloud cannot be null");
        this.cluster = Objects.requireNonNull(cluster, "Cluster cannot be null");
        this.node = Objects.requireNonNull(node, "Node cannot be null");
    }

    /** Returns the application this is running as a part of */
    public ApplicationId application() { return application; }

    /** Returns the zone this is running in */
    public Zone zone() { return zone; }

    /** Returns the cloud provider this is running in */
    public Cloud cloud() {
        return cloud;
    }

    /**
     *  Returns the cluster this is part of
     * @deprecated This will shortly be removed as it breaks the intention of SystemInfo
     *             Use clusterName() as replacement for cluster().id().
     *             If you need cluster size or node indices you should have Cluster injected directly.
     */
    @Deprecated(forRemoval = true)
    public Cluster cluster() { return cluster; }

    /** Returns the name of the cluster it is running in */
    public String clusterName() { return cluster.id(); }

    /** Returns the node this is running on */
    public Node node() { return node; }

}