summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorandreer <andreer@verizonmedia.com>2019-08-16 10:45:34 +0200
committerandreer <andreer@verizonmedia.com>2019-08-16 10:45:34 +0200
commit46f70d0a5d670b3b4cf9322c60f6eb1ae6bb919f (patch)
treed678989c0bf93a5a9c3ce02953556353de5fd89e /controller-server
parent9c302b224567a20337f1280890640d8beccc6bf2 (diff)
receive zone in wildcard and target methods
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Endpoint.java28
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/RoutingPolicy.java2
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/EndpointTest.java30
3 files changed, 27 insertions, 33 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Endpoint.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Endpoint.java
index 622eb1bde97..f11e7f8d28c 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Endpoint.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Endpoint.java
@@ -234,11 +234,12 @@ public class Endpoint {
}
/** Sets the cluster target for this */
- public EndpointBuilder target(ClusterSpec.Id cluster) {
+ public EndpointBuilder target(ClusterSpec.Id cluster, ZoneId zone) {
if (endpointId != null || wildcard) {
throw new IllegalArgumentException("Cannot set multiple target types");
}
this.cluster = cluster;
+ this.zone = zone;
return this;
}
@@ -246,14 +247,12 @@ public class Endpoint {
public EndpointBuilder named(EndpointId endpointId) {
if (cluster != null || wildcard) {
throw new IllegalArgumentException("Cannot set multiple target types");
- } else if (zone != null) {
- throw new IllegalArgumentException("Cannot set zone for rotation target");
}
this.endpointId = endpointId;
return this;
}
- /** Sets the wildcard target for this */
+ /** Sets the global wildcard target for this */
public EndpointBuilder wildcard() {
if (endpointId != null || cluster != null) {
throw new IllegalArgumentException("Cannot set multiple target types");
@@ -262,6 +261,16 @@ public class Endpoint {
return this;
}
+ /** Sets the zone wildcard target for this */
+ public EndpointBuilder wildcard(ZoneId zone) {
+ if(endpointId != null || cluster != null) {
+ throw new IllegalArgumentException("Cannot set multiple target types");
+ }
+ this.zone = zone;
+ this.wildcard = true;
+ return this;
+ }
+
/** Sets the port of this */
public EndpointBuilder on(Port port) {
this.port = port;
@@ -280,16 +289,6 @@ public class Endpoint {
return this;
}
- public EndpointBuilder zone(ZoneId zone) {
- if (endpointId != null) {
- throw new IllegalArgumentException("Cannot set zone for endpoint target");
- } else if (this.zone != null) {
- throw new IllegalArgumentException("Cannot set multiple zones");
- }
- this.zone = zone;
- return this;
- }
-
/** Sets the system that owns this */
public Endpoint in(SystemName system) {
String name;
@@ -299,7 +298,6 @@ public class Endpoint {
name = endpointId.id();
} else if (cluster != null) {
name = cluster.value();
- if(zone == null) throw new IllegalArgumentException("Must set zone for cluster target");
} else {
throw new IllegalArgumentException("Must set either cluster, rotation or wildcard target");
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/RoutingPolicy.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/RoutingPolicy.java
index 8ff860cc37d..a86bbaa317e 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/RoutingPolicy.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/RoutingPolicy.java
@@ -71,7 +71,7 @@ public class RoutingPolicy {
/** Returns the endpoint of this */
public Endpoint endpointIn(SystemName system) {
- return Endpoint.of(owner).target(cluster).zone(zone).on(Port.tls()).directRouting().in(system);
+ return Endpoint.of(owner).target(cluster, zone).on(Port.tls()).directRouting().in(system);
}
/** Returns rotation endpoints of this */
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/EndpointTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/EndpointTest.java
index 99701470dc1..fa41f5a6ac3 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/EndpointTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/EndpointTest.java
@@ -117,39 +117,39 @@ public class EndpointTest {
Map<String, Endpoint> tests = Map.of(
// Legacy endpoint (always contains environment)
"http://a1.t1.us-north-1.prod.vespa.yahooapis.com:4080/",
- Endpoint.of(app1).target(cluster).zone(prodZone).on(Port.plain(4080)).legacy().in(SystemName.main),
+ Endpoint.of(app1).target(cluster, prodZone).on(Port.plain(4080)).legacy().in(SystemName.main),
// Secure legacy endpoint
"https://a1--t1.us-north-1.prod.vespa.yahooapis.com:4443/",
- Endpoint.of(app1).target(cluster).zone(prodZone).on(Port.tls(4443)).legacy().in(SystemName.main),
+ Endpoint.of(app1).target(cluster, prodZone).on(Port.tls(4443)).legacy().in(SystemName.main),
// Prod endpoint in main
"https://a1--t1.us-north-1.vespa.oath.cloud:4443/",
- Endpoint.of(app1).target(cluster).zone(prodZone).on(Port.tls(4443)).in(SystemName.main),
+ Endpoint.of(app1).target(cluster, prodZone).on(Port.tls(4443)).in(SystemName.main),
// Prod endpoint in CD
"https://cd--a1--t1.us-north-1.vespa.oath.cloud:4443/",
- Endpoint.of(app1).target(cluster).zone(prodZone).on(Port.tls(4443)).in(SystemName.cd),
+ Endpoint.of(app1).target(cluster, prodZone).on(Port.tls(4443)).in(SystemName.cd),
// Test endpoint in main
"https://a1--t1.us-north-2.test.vespa.oath.cloud:4443/",
- Endpoint.of(app1).target(cluster).zone(testZone).on(Port.tls(4443)).in(SystemName.main),
+ Endpoint.of(app1).target(cluster, testZone).on(Port.tls(4443)).in(SystemName.main),
// Non-default cluster in main
"https://c1--a1--t1.us-north-1.vespa.oath.cloud/",
- Endpoint.of(app1).target(ClusterSpec.Id.from("c1")).zone(prodZone).on(Port.tls()).in(SystemName.main),
+ Endpoint.of(app1).target(ClusterSpec.Id.from("c1"), prodZone).on(Port.tls()).in(SystemName.main),
// Non-default instance in main
"https://i2--a2--t2.us-north-1.vespa.oath.cloud:4443/",
- Endpoint.of(app2).target(cluster).zone(prodZone).on(Port.tls(4443)).in(SystemName.main),
+ Endpoint.of(app2).target(cluster, prodZone).on(Port.tls(4443)).in(SystemName.main),
// Non-default cluster in public
"https://c1.a1.t1.us-north-1.public.vespa.oath.cloud/",
- Endpoint.of(app1).target(ClusterSpec.Id.from("c1")).zone(prodZone).on(Port.tls()).directRouting().in(SystemName.Public),
+ Endpoint.of(app1).target(ClusterSpec.Id.from("c1"), prodZone).on(Port.tls()).directRouting().in(SystemName.Public),
// Non-default cluster and instance in public
"https://c2.i2.a2.t2.us-north-1.public.vespa.oath.cloud/",
- Endpoint.of(app2).target(ClusterSpec.Id.from("c2")).zone(prodZone).on(Port.tls()).directRouting().in(SystemName.Public)
+ Endpoint.of(app2).target(ClusterSpec.Id.from("c2"), prodZone).on(Port.tls()).directRouting().in(SystemName.Public)
);
tests.forEach((expected, endpoint) -> assertEquals(expected, endpoint.url().toString()));
}
@@ -180,8 +180,7 @@ public class EndpointTest {
// Default cluster in zone
"https://a1.t1.us-north-1.public.vespa.oath.cloud/",
Endpoint.of(app1)
- .target(defaultCluster)
- .zone(prodZone)
+ .target(defaultCluster, prodZone)
.directRouting()
.on(Port.tls())
.in(SystemName.Public),
@@ -189,8 +188,7 @@ public class EndpointTest {
// Wildcard to match other clusters in zone
"https://*.a1.t1.us-north-1.public.vespa.oath.cloud/",
Endpoint.of(app1)
- .wildcard()
- .zone(prodZone)
+ .wildcard(prodZone)
.directRouting()
.on(Port.tls())
.in(SystemName.Public),
@@ -198,8 +196,7 @@ public class EndpointTest {
// Default cluster in test zone
"https://a1.t1.us-north-2.test.public.vespa.oath.cloud/",
Endpoint.of(app1)
- .target(defaultCluster)
- .zone(testZone)
+ .target(defaultCluster, testZone)
.directRouting()
.on(Port.tls())
.in(SystemName.Public),
@@ -207,8 +204,7 @@ public class EndpointTest {
// Wildcard to match other clusters in test zone
"https://*.a1.t1.us-north-2.test.public.vespa.oath.cloud/",
Endpoint.of(app1)
- .wildcard()
- .zone(testZone)
+ .wildcard(testZone)
.directRouting()
.on(Port.tls())
.in(SystemName.Public)