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);
}
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;
}
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);
}
}
}
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);
}
}
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));
}
Aggregations