diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2017-12-08 15:37:22 +0100 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2017-12-08 15:37:22 +0100 |
commit | b8de1c1581ee0c67780a91fd89c4879c86526440 (patch) | |
tree | 70090a789b714da346b7d922f3486232280adb83 | |
parent | ecc30dbc982a14afd44bb56bc1d08ba115fa7477 (diff) |
Replaced Zone with ZoneId two places where only that part was used
5 files changed, 32 insertions, 36 deletions
diff --git a/config-application-package/src/main/java/com/yahoo/config/model/application/provider/FilesApplicationPackage.java b/config-application-package/src/main/java/com/yahoo/config/model/application/provider/FilesApplicationPackage.java index 97322fc1c55..330692abb1e 100644 --- a/config-application-package/src/main/java/com/yahoo/config/model/application/provider/FilesApplicationPackage.java +++ b/config-application-package/src/main/java/com/yahoo/config/model/application/provider/FilesApplicationPackage.java @@ -15,6 +15,7 @@ import com.yahoo.config.application.api.ApplicationFile; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.provision.Version; import com.yahoo.config.provision.Zone; +import com.yahoo.config.provision.ZoneId; import com.yahoo.path.Path; import com.yahoo.io.HexDump; import com.yahoo.io.IOUtils; @@ -649,7 +650,7 @@ public class FilesApplicationPackage implements ApplicationPackage { return searchDefinitionContents(); } - private void preprocessXML(File destination, File inputXml, Zone zone) throws ParserConfigurationException, TransformerException, SAXException, IOException { + private void preprocessXML(File destination, File inputXml, ZoneId zone) throws ParserConfigurationException, TransformerException, SAXException, IOException { Document document = new XmlPreProcessor(appDir, inputXml, zone.environment(), zone.region()).run(); Transformer transformer = TransformerFactory.newInstance().newTransformer(); try (FileOutputStream outputStream = new FileOutputStream(destination)) { @@ -658,7 +659,7 @@ public class FilesApplicationPackage implements ApplicationPackage { } @Override - public ApplicationPackage preprocess(Zone zone, RuleConfigDeriver ignored, DeployLogger logger) throws IOException, TransformerException, ParserConfigurationException, SAXException { + public ApplicationPackage preprocess(ZoneId zone, RuleConfigDeriver ignored, DeployLogger logger) throws IOException, TransformerException, ParserConfigurationException, SAXException { IOUtils.recursiveDeleteDir(preprocessedDir); IOUtils.copyDirectory(appDir, preprocessedDir, -1, (dir, name) -> ! name.equals(".preprocessed") && ! name.equals(SERVICES) && diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java b/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java index c1a786194a2..480d4d05451 100644 --- a/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java +++ b/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java @@ -4,6 +4,7 @@ package com.yahoo.config.application.api; import com.yahoo.config.provision.AllocatedHosts; import com.yahoo.config.provision.Version; import com.yahoo.config.provision.Zone; +import com.yahoo.config.provision.ZoneId; import com.yahoo.path.Path; import com.yahoo.io.IOUtils; import com.yahoo.io.reader.NamedReader; @@ -255,13 +256,13 @@ public interface ApplicationPackage { * application package. This is the entry point for the multi environment application package support. This method * will not mutate the existing application package. * - * @param zone A valid {@link Zone} instance, used to decide which parts of services to keep and remove + * @param zone A valid {@link ZoneId} instance, used to decide which parts of services to keep and remove * @param ruleConfigDeriver ignored * @param logger A {@link DeployLogger} to add output that will be returned to the user * * @return A new application package instance pointing to a new location */ - default ApplicationPackage preprocess(Zone zone, RuleConfigDeriver ruleConfigDeriver, DeployLogger logger) throws IOException, TransformerException, ParserConfigurationException, SAXException { + default ApplicationPackage preprocess(ZoneId zone, RuleConfigDeriver ruleConfigDeriver, DeployLogger logger) throws IOException, TransformerException, ParserConfigurationException, SAXException { throw new UnsupportedOperationException("This application package does not support preprocessing"); } diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/Zone.java b/config-provisioning/src/main/java/com/yahoo/config/provision/Zone.java index 56bbd82c761..b69795a4f95 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/Zone.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/Zone.java @@ -8,7 +8,7 @@ import com.yahoo.cloud.config.ConfigserverConfig; import java.util.Optional; /** - * The zone (environment + region) of this runtime. + * The zone (environment + region) of this runtime, and some other information. * An injected instance of this will return the correct current environment and region. * Components can use this to obtain information about which zone they are running in. * @@ -29,12 +29,12 @@ public class Zone extends ZoneId { nodeFlavors); } - /** Create from environment and region */ + /** Create from environment and region. Use for testing. */ public Zone(Environment environment, RegionName region) { this(SystemName.defaultSystem(), environment, region); } - /** Create from system, environment and region */ + /** Create from system, environment and region. Use for testing. */ public Zone(SystemName systemName, Environment environment, RegionName region) { this(systemName, environment, region, new FlavorDefaults("default"), null); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentJobs.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentJobs.java index 47b2cb94d12..27e94588626 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentJobs.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentJobs.java @@ -19,7 +19,6 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -161,28 +160,30 @@ public class DeploymentJobs { /** Job types that exist in the build system */ public enum JobType { - - component ("component" ), - systemTest ("system-test" , zone("test" , "us-east-1" ), zone(SystemName.cd, "test" , "cd-us-central-1")), - stagingTest ("staging-test" , zone("staging", "us-east-3" ), zone(SystemName.cd, "staging", "cd-us-central-1")), - productionCorpUsEast1 ("production-corp-us-east-1" , zone("prod" , "corp-us-east-1")), - productionUsEast3 ("production-us-east-3" , zone("prod" , "us-east-3" )), - productionUsWest1 ("production-us-west-1" , zone("prod" , "us-west-1" )), - productionUsCentral1 ("production-us-central-1" , zone("prod" , "us-central-1" )), - productionApNortheast1 ("production-ap-northeast-1" , zone("prod" , "ap-northeast-1")), - productionApNortheast2 ("production-ap-northeast-2" , zone("prod" , "ap-northeast-2")), - productionApSoutheast1 ("production-ap-southeast-1" , zone("prod" , "ap-southeast-1")), - productionEuWest1 ("production-eu-west-1" , zone("prod" , "eu-west-1" )), - productionCdUsCentral1 ("production-cd-us-central-1", zone(SystemName.cd, "prod", "cd-us-central-1")), - productionCdUsCentral2 ("production-cd-us-central-2", zone(SystemName.cd, "prod", "cd-us-central-2")); +// | enum name ------------| job name ------------------| Zone in main system ---------------------------------------| Zone in CD system ------------------------------------------- + component ("component" , null , null ), + systemTest ("system-test" , ZoneId.from("test" , "us-east-1") , ZoneId.from("test" , "cd-us-central-1")), + stagingTest ("staging-test" , ZoneId.from("staging", "us-east-3") , ZoneId.from("staging", "cd-us-central-1")), + productionCorpUsEast1 ("production-corp-us-east-1" , ZoneId.from("prod" , "corp-us-east-1") , null ), + productionUsEast3 ("production-us-east-3" , ZoneId.from("prod" , "us-east-3") , null ), + productionUsWest1 ("production-us-west-1" , ZoneId.from("prod" , "us-west-1") , null ), + productionUsCentral1 ("production-us-central-1" , ZoneId.from("prod" , "us-central-1") , null ), + productionApNortheast1 ("production-ap-northeast-1" , ZoneId.from("prod" , "ap-northeast-1") , null ), + productionApNortheast2 ("production-ap-northeast-2" , ZoneId.from("prod" , "ap-northeast-2") , null ), + productionApSoutheast1 ("production-ap-southeast-1" , ZoneId.from("prod" , "ap-southeast-1") , null ), + productionEuWest1 ("production-eu-west-1" , ZoneId.from("prod" , "eu-west-1") , null ), + productionCdUsCentral1 ("production-cd-us-central-1", null , ZoneId.from("prod" , "cd-us-central-1")), + productionCdUsCentral2 ("production-cd-us-central-2", null , ZoneId.from("prod" , "cd-us-central-2")); private final String jobName; private final ImmutableMap<SystemName, ZoneId> zones; - JobType(String jobName, Zone... zones) { + JobType(String jobName, ZoneId mainZone, ZoneId cdZone) { this.jobName = jobName; - this.zones = ImmutableMap.copyOf(Stream.of(zones).collect(Collectors.toMap(zone -> zone.system(), - zone -> zone))); + ImmutableMap.Builder<SystemName, ZoneId> builder = ImmutableMap.builder(); + if (mainZone != null) builder.put(SystemName.main, mainZone); + if (cdZone != null) builder.put(SystemName.cd, cdZone); + this.zones = builder.build(); } public String jobName() { return jobName; } @@ -229,16 +230,9 @@ public class DeploymentJobs { case test: return Optional.of(systemTest); case staging: return Optional.of(stagingTest); } - return from(system, new Zone(environment, region)); - } - - private static Zone zone(SystemName system, String environment, String region) { - return new Zone(system, Environment.from(environment), RegionName.from(region)); + return from(system, new ZoneId(environment, region)); } - private static Zone zone(String environment, String region) { - return new Zone(Environment.from(environment), RegionName.from(region)); - } } /** A job report. This class is immutable. */ diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ZoneRegistryMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ZoneRegistryMock.java index e2475ef6c87..55d71cc43bb 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ZoneRegistryMock.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ZoneRegistryMock.java @@ -32,9 +32,9 @@ public class ZoneRegistryMock extends AbstractComponent implements ZoneRegistry @Inject public ZoneRegistryMock() { - this.zones.add(new Zone(SystemName.main, Environment.from("prod"), RegionName.from("corp-us-east-1"))); - this.zones.add(new Zone(SystemName.main, Environment.from("prod"), RegionName.from("us-east-3"))); - this.zones.add(new Zone(SystemName.main, Environment.from("prod"), RegionName.from("us-west-1"))); + this.zones.add(new ZoneId(Environment.from("prod"), RegionName.from("corp-us-east-1"))); + this.zones.add(new ZoneId(Environment.from("prod"), RegionName.from("us-east-3"))); + this.zones.add(new ZoneId(Environment.from("prod"), RegionName.from("us-west-1"))); } public ZoneRegistryMock setDeploymentTimeToLive(ZoneId zone, Duration duration) { |