aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2018-01-02 13:58:54 +0100
committerGitHub <noreply@github.com>2018-01-02 13:58:54 +0100
commitc71969101b26dd4e29e5bef4c507550ebb47a9d9 (patch)
tree8f27590a3063bc592b85dc5d269e89491def2524 /controller-api
parente77379005bccd3d5009b1484038183a05856b4cd (diff)
Revert "Jvenstad/zone cleanup 4"
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/DeploymentId.java2
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MetricsService.java2
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneFilter.java22
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneFilterMock.java72
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneId.java73
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneList.java34
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneRegistry.java6
-rw-r--r--controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/identifiers/IdentifierTest.java4
8 files changed, 9 insertions, 206 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/DeploymentId.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/DeploymentId.java
index 04dd91670c1..f1c584c7a3c 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/DeploymentId.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/DeploymentId.java
@@ -1,7 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.identifiers;
-import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
+import com.yahoo.config.provision.ZoneId;
import java.util.Objects;
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MetricsService.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MetricsService.java
index 20e9710f092..d3e1b881bbd 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MetricsService.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MetricsService.java
@@ -2,7 +2,7 @@
package com.yahoo.vespa.hosted.controller.api.integration;
import com.yahoo.config.provision.ApplicationId;
-import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
+import com.yahoo.config.provision.ZoneId;
import java.util.Map;
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneFilter.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneFilter.java
deleted file mode 100644
index f718b86ca40..00000000000
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneFilter.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.yahoo.vespa.hosted.controller.api.integration.zone;
-
-/**
- * A ZoneId list which can be filtered in various ways; elements can be accessed after at least one filter.
- *
- * The methods here return instances of {@link ZoneList}, which extends ZoneFilter, but with accessors and additional filters.
- * This forces the developer to consider which of the filters in this class to apply, prior to processing any zones.
- *
- * @author jvenstad
- */
-public interface ZoneFilter {
-
- /** Negates the next filter. */
- ZoneFilter not();
-
- /** All zones from the initial pool. */
- ZoneList all();
-
- /** Zones where which are managed by the controller. */
- ZoneList controllerManaged();
-
-}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneFilterMock.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneFilterMock.java
deleted file mode 100644
index e68bf0ccc24..00000000000
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneFilterMock.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.yahoo.vespa.hosted.controller.api.integration.zone;
-
-import com.yahoo.config.provision.Environment;
-import com.yahoo.config.provision.RegionName;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-
-/**
- * A Zones.List implementation which assumes all zones are controllerManaged.
- *
- * @author jvenstad
- */
-public class ZoneFilterMock implements ZoneList {
-
- private final java.util.List<ZoneId> zones;
- private final boolean negate;
-
- private ZoneFilterMock(java.util.List<ZoneId> zones, boolean negate) {
- this.negate = negate;
- this.zones = zones;
- }
-
- public static ZoneFilter from(Collection<ZoneId> zones) {
- return new ZoneFilterMock(new ArrayList<>(zones), false);
- }
-
- @Override
- public ZoneList not() {
- return new ZoneFilterMock(zones, ! negate);
- }
-
- @Override
- public ZoneList all() {
- return filter(zoneId -> true);
- }
-
- @Override
- public ZoneList controllerManaged() {
- return all();
- }
-
- @Override
- public ZoneList in(Environment environment) {
- return filter(zoneId -> zoneId.environment() == environment);
- }
-
- @Override
- public ZoneList in(RegionName region) {
- return filter(zoneId -> zoneId.region().equals(region));
- }
-
- @Override
- public ZoneList zones(ZoneId... zones) {
- return filter(zoneId -> new HashSet<>(Arrays.asList(zones)).contains(zoneId));
- }
-
- @Override
- public java.util.List<ZoneId> ids() {
- return Collections.unmodifiableList(zones);
- }
-
- private ZoneFilterMock filter(Predicate<ZoneId> condition) {
- return new ZoneFilterMock(zones.stream().filter(negate ? condition.negate() : condition).collect(Collectors.toList()), false);
- }
-
-}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneId.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneId.java
deleted file mode 100644
index 21ac7a654b8..00000000000
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneId.java
+++ /dev/null
@@ -1,73 +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.vespa.hosted.controller.api.integration.zone;
-
-import com.yahoo.config.provision.Environment;
-import com.yahoo.config.provision.RegionName;
-
-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 environment + 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);
- }
-
-}
-
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneList.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneList.java
deleted file mode 100644
index cd263769864..00000000000
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneList.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.yahoo.vespa.hosted.controller.api.integration.zone;
-
-import com.yahoo.config.provision.Environment;
-import com.yahoo.config.provision.RegionName;
-
-import java.util.List;
-
-/**
- * Provides filters for and access to a list of ZoneIds.
- *
- * This is typically offered after an initial filter from {@link ZoneFilter} has been applied.
- * This forces the developer to consider which zones to process.
- *
- * @author jvenstad
- */
-public interface ZoneList extends ZoneFilter {
-
- /** Negates the next filter. */
- @Override
- ZoneList not();
-
- /** Zones in the given environment. */
- ZoneList in(Environment environment);
-
- /** Zones in the given region. */
- ZoneList in(RegionName region);
-
- /** Only the given zones — combine with not() for best effect! */
- ZoneList zones(ZoneId... zones);
-
- /** Returns the id of all zones in this list as — you guessed it — a list. */
- List<ZoneId> ids();
-
-}
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 03207d86983..af7c464b8d7 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
@@ -1,9 +1,11 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.zone;
+import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.Environment;
import com.yahoo.config.provision.RegionName;
import com.yahoo.config.provision.SystemName;
+import com.yahoo.config.provision.ZoneId;
import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
import java.net.URI;
@@ -22,7 +24,7 @@ public interface ZoneRegistry {
boolean hasZone(ZoneId zoneId);
/** Returns a list containing the id of all zones in this registry. */
- ZoneFilter zones();
+ List<ZoneId> zones();
/** Returns the default region for the given environment, if one is configured. */
Optional<RegionName> getDefaultRegion(Environment environment);
@@ -37,7 +39,7 @@ public interface ZoneRegistry {
/** Returns a list with all known config servers in the given zone, with a secure connection URL. */
List<URI> getConfigServerSecureUris(ZoneId zoneId);
- /** Returns a URL with the logs for the given deployment, if logging is configured for its zone. */
+ /** Returns a URL with the logs for the given deployment, if loggin is configured for its zone. */
Optional<URI> getLogServerUri(DeploymentId deploymentId);
/** Returns the time to live for deployments in the given zone, or empty if this is infinite. */
diff --git a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/identifiers/IdentifierTest.java b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/identifiers/IdentifierTest.java
index 0ba607a235b..aa3d1be879e 100644
--- a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/identifiers/IdentifierTest.java
+++ b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/identifiers/IdentifierTest.java
@@ -1,7 +1,9 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.identifiers;
-import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
+import com.yahoo.config.provision.Environment;
+import com.yahoo.config.provision.RegionName;
+import com.yahoo.config.provision.ZoneId;
import org.junit.Test;
import static org.junit.Assert.assertEquals;