All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yahoo.config.model.provision.Host Maven / Gradle / Ivy

There is a newer version: 8.441.21
Show newest version
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.model.provision;

import com.yahoo.component.Version;
import com.yahoo.config.provision.Flavor;

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

/**
 * A hostname with zero or more aliases. This is immutable.
 *
 * @author hmusum
 */
public class Host {

    private final String hostname;
    private final List aliases;
    private final Optional flavor;
    private final Optional version;

    public Host(String hostname) {
        this(hostname, List.of(), Optional.empty());
    }

    public Host(String hostname, List hostAliases) {
        this(hostname, hostAliases, Optional.empty());
    }

    public Host(String hostname, List hostAliases, Optional flavor) {
        this(hostname, hostAliases, flavor, Optional.empty());
    }

    public Host(String hostname, List hostAliases, Optional flavor, Optional version) {
        this.hostname = hostname;
        this.aliases = List.copyOf(hostAliases);
        this.flavor = flavor;
        this.version = version;
    }

    public String hostname() { return hostname; }

    /** Returns an immutable list of the aliases of this node, which may be empty but never null */
    public List aliases() { return aliases; }

    public Optional flavor() { return flavor; }

    /** The current Vespa version running on this host, or empty if not known */
    public Optional version() { return version; }

    @Override
    public String toString() {
        return hostname + (!aliases.isEmpty() ? " (aliases: " + aliases + ")" : "" ) +
               (flavor.map(value -> " (flavor: " + value + ")").orElse(""));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy