diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2017-08-31 12:12:14 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2017-08-31 12:55:53 +0200 |
commit | c56715fb7e7f163da95bf527d01149aaf0104e8f (patch) | |
tree | b8d75f413d159ec476c0e5b9bbcb6e2235852555 /config-model-api | |
parent | fb9402d94d80e4f27c13e84f783ce825114d872e (diff) |
Move zones() up to simplify
Diffstat (limited to 'config-model-api')
-rw-r--r-- | config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java b/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java index fc7344aa9e8..8530679e82f 100644 --- a/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java +++ b/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java @@ -15,6 +15,7 @@ import java.io.Reader; import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; @@ -76,13 +77,9 @@ public class DeploymentSpec { private void validateZones(List<Step> steps) { Set<DeclaredZone> zones = new HashSet<>(); - steps.stream().filter(step -> step instanceof DeclaredZone) - .map(DeclaredZone.class::cast) - .forEach(zone -> ensureUnique(zone, zones)); - steps.stream().filter(step -> step instanceof ParallelZones) - .map(ParallelZones.class::cast) - .flatMap(parallelZones -> parallelZones.zones().stream()) - .forEach(zone -> ensureUnique(zone, zones)); + for (Step step : steps) + for (DeclaredZone zone : step.zones()) + ensureUnique(zone, zones); } private void ensureUnique(DeclaredZone zone, Set<DeclaredZone> zones) { @@ -320,6 +317,9 @@ public class DeploymentSpec { /** Returns whether this step deploys to the given environment, and (if specified) region */ public abstract boolean deploysTo(Environment environment, Optional<RegionName> region); + /** Returns the zones deployed to in this step */ + public List<DeclaredZone> zones() { return Collections.emptyList(); } + } /** A deployment step which is to wait for some time before progressing to the next step */ @@ -370,6 +370,9 @@ public class DeploymentSpec { public boolean active() { return active; } @Override + public List<DeclaredZone> zones() { return Collections.singletonList(this); } + + @Override public boolean deploysTo(Environment environment, Optional<RegionName> region) { if (environment != this.environment) return false; if (region.isPresent() && ! region.equals(this.region)) return false; @@ -407,7 +410,7 @@ public class DeploymentSpec { this.zones = ImmutableList.copyOf(zones); } - /** The list of zones to deploy in */ + @Override public List<DeclaredZone> zones() { return this.zones; } @Override |