Search in sources :

Example 1 with ParallelZones

use of com.yahoo.config.application.api.DeploymentSpec.ParallelZones in project vespa by vespa-engine.

the class DeploymentSpecXmlReader method read.

/**
 * Reads a deployment spec from XML
 */
public DeploymentSpec read(String xmlForm) {
    List<Step> steps = new ArrayList<>();
    Optional<String> globalServiceId = Optional.empty();
    Element root = XML.getDocument(xmlForm).getDocumentElement();
    if (validate)
        validateTagOrder(root);
    for (Element environmentTag : XML.getChildren(root)) {
        if (!isEnvironmentName(environmentTag.getTagName()))
            continue;
        Environment environment = Environment.from(environmentTag.getTagName());
        if (environment == Environment.prod) {
            for (Element stepTag : XML.getChildren(environmentTag)) {
                Optional<AthenzService> athenzService = stringAttribute("athenz-service", environmentTag).map(AthenzService::from);
                if (stepTag.getTagName().equals("delay")) {
                    steps.add(new Delay(Duration.ofSeconds(longAttribute("hours", stepTag) * 60 * 60 + longAttribute("minutes", stepTag) * 60 + longAttribute("seconds", stepTag))));
                } else if (stepTag.getTagName().equals("parallel")) {
                    List<DeclaredZone> zones = new ArrayList<>();
                    for (Element regionTag : XML.getChildren(stepTag)) {
                        zones.add(readDeclaredZone(environment, athenzService, regionTag));
                    }
                    steps.add(new ParallelZones(zones));
                } else {
                    // a region: deploy step
                    steps.add(readDeclaredZone(environment, athenzService, stepTag));
                }
            }
        } else {
            steps.add(new DeclaredZone(environment));
        }
        if (environment == Environment.prod)
            globalServiceId = readGlobalServiceId(environmentTag);
        else if (readGlobalServiceId(environmentTag).isPresent())
            throw new IllegalArgumentException("Attribute 'global-service-id' is only valid on 'prod' tag.");
    }
    Optional<AthenzDomain> athenzDomain = stringAttribute("athenz-domain", root).map(AthenzDomain::from);
    Optional<AthenzService> athenzService = stringAttribute("athenz-service", root).map(AthenzService::from);
    return new DeploymentSpec(globalServiceId, readUpgradePolicy(root), readChangeBlockers(root), steps, xmlForm, athenzDomain, athenzService);
}
Also used : AthenzService(com.yahoo.config.provision.AthenzService) AthenzDomain(com.yahoo.config.provision.AthenzDomain) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) Step(com.yahoo.config.application.api.DeploymentSpec.Step) DeclaredZone(com.yahoo.config.application.api.DeploymentSpec.DeclaredZone) Delay(com.yahoo.config.application.api.DeploymentSpec.Delay) ParallelZones(com.yahoo.config.application.api.DeploymentSpec.ParallelZones) DeploymentSpec(com.yahoo.config.application.api.DeploymentSpec) Environment(com.yahoo.config.provision.Environment) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

DeploymentSpec (com.yahoo.config.application.api.DeploymentSpec)1 DeclaredZone (com.yahoo.config.application.api.DeploymentSpec.DeclaredZone)1 Delay (com.yahoo.config.application.api.DeploymentSpec.Delay)1 ParallelZones (com.yahoo.config.application.api.DeploymentSpec.ParallelZones)1 Step (com.yahoo.config.application.api.DeploymentSpec.Step)1 AthenzDomain (com.yahoo.config.provision.AthenzDomain)1 AthenzService (com.yahoo.config.provision.AthenzService)1 Environment (com.yahoo.config.provision.Environment)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Element (org.w3c.dom.Element)1