diff options
author | Jon Marius Venstad <jonmv@users.noreply.github.com> | 2018-01-02 15:57:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-02 15:57:26 +0100 |
commit | 0f34ad1955e9193461e5c669df3600ae4ca71c6b (patch) | |
tree | 35545093828437f6d7704b4b6c3646a39ff50a00 /config-provisioning/src | |
parent | 9967338b1a3514830e92924d868046ee2cfc97db (diff) |
Revert "Revert "Jvenstad/zone cleanup 4""
Diffstat (limited to 'config-provisioning/src')
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/Zone.java | 25 | ||||
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/ZoneId.java | 70 |
2 files changed, 12 insertions, 83 deletions
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 26c20d56d63..fbbdb1df635 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 @@ -20,7 +20,8 @@ public class Zone { private final SystemName systemName; private final FlavorDefaults flavorDefaults; private final Optional<NodeFlavors> nodeFlavors; - private final ZoneId id; + private final Environment environment; + private final RegionName region; @Inject public Zone(ConfigserverConfig configserverConfig, NodeFlavors nodeFlavors) { @@ -46,25 +47,21 @@ public class Zone { RegionName region, FlavorDefaults flavorDefaults, NodeFlavors nodeFlavors) { - this.id = ZoneId.from(environment, region); + this.environment = environment; + this.region = region; this.flavorDefaults = flavorDefaults; this.systemName = systemName; this.nodeFlavors = Optional.ofNullable(nodeFlavors); } - /** Returns the id of this */ - public ZoneId id() { - return id; - } - /** Returns the current environment */ public Environment environment() { - return id.environment(); + return environment; } /** Returns the current region */ public RegionName region() { - return id.region(); + return region; } /** Returns the current system */ @@ -83,19 +80,21 @@ public class Zone { @Override public String toString() { - return id.toString(); + return "zone " + environment + "." + region; } @Override public boolean equals(Object o) { if (this == o) return true; - if ( ! (o instanceof Zone)) return false; - return Objects.equals(id, ((Zone) o).id); + if (!(o instanceof Zone)) return false; + Zone zone = (Zone) o; + return environment == zone.environment && + Objects.equals(region, zone.region); } @Override public int hashCode() { - return id.hashCode(); + return Objects.hash(environment, region); } private static class FlavorDefaults { diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/ZoneId.java b/config-provisioning/src/main/java/com/yahoo/config/provision/ZoneId.java deleted file mode 100644 index d51a8d5e0c9..00000000000 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/ZoneId.java +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.config.provision; - -import java.util.Objects; - -/** - * Unique identifier for a Zone; use when referencing them. - * - * Serialised form is 'environment.region'. - * - * @author jvenstad - */ -public class ZoneId { - // TODO: Replace usages of zone + region with usages of this. - - private final Environment environment; - private final RegionName region; - - private ZoneId(Environment environment, RegionName region) { - this.environment = Objects.requireNonNull(environment); - this.region = Objects.requireNonNull(region); - } - - public static ZoneId from(Environment environment, RegionName region) { - return new ZoneId(environment, region); - } - - public static ZoneId from(String environment, String region) { - return from(Environment.from(environment), RegionName.from(region)); - } - /** Create from a serialised ZoneId. Inverse of {@code ZoneId.value()}. */ - public static ZoneId from(String value) { - String[] parts = value.split("\\."); - return from(parts[0], parts[1]); - } - - public Environment environment() { - return environment; - } - - public RegionName region() { - return region; - } - - /** Returns the serialised value of this. Inverse of {@code ZoneId.from(String value)}. */ - public String value() { - return environment + "." + region; - } - - @Override - public String toString() { - return "zone " + value(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if ( ! (o instanceof ZoneId)) return false; - ZoneId id = (ZoneId) o; - return environment == id.environment && - Objects.equals(region, id.region); - } - - @Override - public int hashCode() { - return Objects.hash(environment, region); - } - -} - |