aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValerij Fredriksen <valerijf@yahooinc.com>2023-03-29 12:09:51 +0200
committerValerij Fredriksen <valerijf@yahooinc.com>2023-03-29 12:16:09 +0200
commit4b57fc3f8936eb026b5231e79f8680bd30420bab (patch)
treee89bb3a39d46433f2281c26a1722255ada39363e
parentacc09c0650ea2458ba68e62fa1fc4b4ce93e6482 (diff)
Add method to get a zone by ID
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneRegistry.java4
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneRegistryMock.java9
2 files changed, 13 insertions, 0 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneRegistry.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneRegistry.java
index 4956dd475de..6cdb197b307 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneRegistry.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneRegistry.java
@@ -23,6 +23,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.deployment.RunId;
import java.net.URI;
import java.time.Duration;
import java.util.List;
+import java.util.NoSuchElementException;
import java.util.Optional;
/**
@@ -50,6 +51,9 @@ public interface ZoneRegistry {
/** Returns the default region for the given environment, if one is configured */
Optional<RegionName> getDefaultRegion(Environment environment);
+ /** Throws {@link NoSuchElementException} if there is no such zone (in the system). */
+ ZoneApi get(ZoneId zoneId);
+
/** Returns the URI for the config server VIP in the given zone */
URI getConfigServerVipUri(ZoneId zoneId);
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneRegistryMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneRegistryMock.java
index e59c677d0fa..8b279adc4fa 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneRegistryMock.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneRegistryMock.java
@@ -32,6 +32,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
@@ -299,6 +300,14 @@ public class ZoneRegistryMock extends AbstractComponent implements ZoneRegistry
}
@Override
+ public ZoneApi get(ZoneId zoneId) {
+ return zones.stream()
+ .filter(zone -> zone.getId().equals(zoneId))
+ .findFirst()
+ .orElseThrow(() -> new NoSuchElementException("No zone with id '" + zoneId + "'"));
+ }
+
+ @Override
public URI getMonitoringSystemUri(DeploymentId deploymentId) {
return URI.create("http://monitoring-system.test/?environment=" + deploymentId.zoneId().environment().value() + "&region="
+ deploymentId.zoneId().region().value() + "&application=" + deploymentId.applicationId().toShortString());