Search in sources :

Example 1 with RegionName

use of com.yahoo.config.provision.RegionName in project vespa by vespa-engine.

the class OverrideProcessor method getParentContext.

private Context getParentContext(Element parent, Context context) {
    Optional<Environment> environment = context.environment;
    RegionName region = context.region;
    if (!environment.isPresent()) {
        environment = getEnvironment(parent);
    }
    if (region.isDefault()) {
        region = getRegion(parent);
    }
    return Context.create(environment, region);
}
Also used : RegionName(com.yahoo.config.provision.RegionName) Environment(com.yahoo.config.provision.Environment)

Example 2 with RegionName

use of com.yahoo.config.provision.RegionName in project vespa by vespa-engine.

the class OverrideProcessor method getNumberOfOverrides.

private int getNumberOfOverrides(Element child, Context context) {
    int currentMatch = 0;
    Optional<Environment> elementEnvironment = hasEnvironment(child) ? getEnvironment(child) : context.environment;
    RegionName elementRegion = hasRegion(child) ? getRegion(child) : context.region;
    if (elementEnvironment.isPresent() && elementEnvironment.get().equals(environment))
        currentMatch++;
    if (!elementRegion.isDefault() && elementRegion.equals(region))
        currentMatch++;
    return currentMatch;
}
Also used : RegionName(com.yahoo.config.provision.RegionName) Environment(com.yahoo.config.provision.Environment)

Example 3 with RegionName

use of com.yahoo.config.provision.RegionName in project vespa by vespa-engine.

the class OverrideProcessor method checkConsistentInheritance.

/**
 * Ensures that environment and region does not change from something non-default to something else.
 */
private void checkConsistentInheritance(List<Element> children, Context context) {
    for (Element child : children) {
        Optional<Environment> env = getEnvironment(child);
        RegionName reg = getRegion(child);
        if (env.isPresent() && context.environment.isPresent() && !env.equals(context.environment)) {
            throw new IllegalArgumentException("Environment in child (" + env.get() + ") differs from that inherited from parent (" + context.environment + ") at " + child);
        }
        if (!reg.isDefault() && !context.region.isDefault() && !reg.equals(context.region)) {
            throw new IllegalArgumentException("Region in child (" + reg + ") differs from that inherited from parent (" + context.region + ") at " + child);
        }
    }
}
Also used : RegionName(com.yahoo.config.provision.RegionName) Element(org.w3c.dom.Element) Environment(com.yahoo.config.provision.Environment)

Example 4 with RegionName

use of com.yahoo.config.provision.RegionName in project vespa by vespa-engine.

the class DeploymentSpec method main.

/**
 * This may be invoked by a continuous build
 */
public static void main(String[] args) {
    if (args.length != 2 && args.length != 3) {
        System.err.println("Usage: DeploymentSpec [file] [environment] [region]?" + "Returns 0 if the specified zone matches the deployment spec, 1 otherwise");
        System.exit(1);
    }
    try (BufferedReader reader = new BufferedReader(new FileReader(args[0]))) {
        DeploymentSpec spec = DeploymentSpec.fromXml(reader);
        Environment environment = Environment.from(args[1]);
        Optional<RegionName> region = args.length == 3 ? Optional.of(RegionName.from(args[2])) : Optional.empty();
        if (spec.includes(environment, region))
            System.exit(0);
        else
            System.exit(1);
    } catch (Exception e) {
        System.err.println("Exception checking deployment spec: " + toMessageString(e));
        System.exit(1);
    }
}
Also used : RegionName(com.yahoo.config.provision.RegionName) BufferedReader(java.io.BufferedReader) Environment(com.yahoo.config.provision.Environment) FileReader(java.io.FileReader)

Example 5 with RegionName

use of com.yahoo.config.provision.RegionName in project vespa by vespa-engine.

the class ConfigserverCluster method setContainerCluster.

public void setContainerCluster(ContainerCluster containerCluster) {
    this.containerCluster = containerCluster;
    // If we are in a config server cluster the correct zone is propagated through cloud config options,
    // not through config to deployment options (see StandaloneContainerApplication.scala),
    // so we need to propagate the zone options into the container from here
    Environment environment = options.environment().isPresent() ? Environment.from(options.environment().get()) : Environment.defaultEnvironment();
    RegionName region = options.region().isPresent() ? RegionName.from(options.region().get()) : RegionName.defaultName();
    SystemName system = options.system().isPresent() ? SystemName.from(options.system().get()) : SystemName.defaultSystem();
    containerCluster.setZone(new Zone(system, environment, region));
}
Also used : RegionName(com.yahoo.config.provision.RegionName) Zone(com.yahoo.config.provision.Zone) Environment(com.yahoo.config.provision.Environment) SystemName(com.yahoo.config.provision.SystemName)

Aggregations

RegionName (com.yahoo.config.provision.RegionName)7 Environment (com.yahoo.config.provision.Environment)5 Zone (com.yahoo.config.provision.Zone)2 LbServicesConfig (com.yahoo.cloud.config.LbServicesConfig)1 SystemName (com.yahoo.config.provision.SystemName)1 TenantName (com.yahoo.config.provision.TenantName)1 Cursor (com.yahoo.slime.Cursor)1 Slime (com.yahoo.slime.Slime)1 SlimeJsonResponse (com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1 Element (org.w3c.dom.Element)1