From a466ce2f31e4eb7bf037c66800173e2621bff5c8 Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Fri, 26 Nov 2021 13:03:57 +0100 Subject: Rename routing contexts --- .../vespa/hosted/controller/RoutingController.java | 8 ++-- .../routing/context/ExclusiveRoutingContext.java | 41 ------------------ .../context/ExclusiveZoneRoutingContext.java | 41 ++++++++++++++++++ .../routing/context/SharedRoutingContext.java | 48 ---------------------- .../routing/context/SharedZoneRoutingContext.java | 48 ++++++++++++++++++++++ 5 files changed, 93 insertions(+), 93 deletions(-) delete mode 100644 controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/context/ExclusiveRoutingContext.java create mode 100644 controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/context/ExclusiveZoneRoutingContext.java delete mode 100644 controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/context/SharedRoutingContext.java create mode 100644 controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/context/SharedZoneRoutingContext.java diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java index 1a9dc90b1b8..67f82297651 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java @@ -35,9 +35,9 @@ import com.yahoo.vespa.hosted.controller.routing.RoutingPolicies; import com.yahoo.vespa.hosted.controller.routing.context.DeploymentRoutingContext; import com.yahoo.vespa.hosted.controller.routing.context.DeploymentRoutingContext.ExclusiveDeploymentRoutingContext; import com.yahoo.vespa.hosted.controller.routing.context.DeploymentRoutingContext.SharedDeploymentRoutingContext; -import com.yahoo.vespa.hosted.controller.routing.context.ExclusiveRoutingContext; +import com.yahoo.vespa.hosted.controller.routing.context.ExclusiveZoneRoutingContext; import com.yahoo.vespa.hosted.controller.routing.context.RoutingContext; -import com.yahoo.vespa.hosted.controller.routing.context.SharedRoutingContext; +import com.yahoo.vespa.hosted.controller.routing.context.SharedZoneRoutingContext; import com.yahoo.vespa.hosted.controller.routing.rotation.RotationLock; import com.yahoo.vespa.hosted.controller.routing.rotation.RotationRepository; import com.yahoo.vespa.hosted.rotation.config.RotationsConfig; @@ -97,9 +97,9 @@ public class RoutingController { /** Create a routing context for given zone */ public RoutingContext of(ZoneId zone) { if (usesSharedRouting(zone)) { - return new SharedRoutingContext(zone, controller.serviceRegistry().configServer()); + return new SharedZoneRoutingContext(zone, controller.serviceRegistry().configServer()); } - return new ExclusiveRoutingContext(zone, routingPolicies); + return new ExclusiveZoneRoutingContext(zone, routingPolicies); } public RoutingPolicies policies() { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/context/ExclusiveRoutingContext.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/context/ExclusiveRoutingContext.java deleted file mode 100644 index e949c45f2fd..00000000000 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/context/ExclusiveRoutingContext.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.routing.context; - -import com.yahoo.config.provision.zone.RoutingMethod; -import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.routing.RoutingPolicies; -import com.yahoo.vespa.hosted.controller.routing.RoutingStatus; - -import java.util.Objects; - -/** - * An implementation of {@link RoutingContext} for a zone using {@link RoutingMethod#exclusive} routing. - * - * @author mpolden - */ -public class ExclusiveRoutingContext implements RoutingContext { - - private final RoutingPolicies policies; - private final ZoneId zone; - - public ExclusiveRoutingContext(ZoneId zone, RoutingPolicies policies) { - this.policies = Objects.requireNonNull(policies); - this.zone = Objects.requireNonNull(zone); - } - - @Override - public void setRoutingStatus(RoutingStatus.Value value, RoutingStatus.Agent agent) { - policies.setRoutingStatus(zone, value); - } - - @Override - public RoutingStatus routingStatus() { - return policies.get(zone).routingStatus(); - } - - @Override - public RoutingMethod routingMethod() { - return RoutingMethod.exclusive; - } - -} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/context/ExclusiveZoneRoutingContext.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/context/ExclusiveZoneRoutingContext.java new file mode 100644 index 00000000000..e29fb5ab404 --- /dev/null +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/context/ExclusiveZoneRoutingContext.java @@ -0,0 +1,41 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.routing.context; + +import com.yahoo.config.provision.zone.RoutingMethod; +import com.yahoo.config.provision.zone.ZoneId; +import com.yahoo.vespa.hosted.controller.routing.RoutingPolicies; +import com.yahoo.vespa.hosted.controller.routing.RoutingStatus; + +import java.util.Objects; + +/** + * An implementation of {@link RoutingContext} for a zone using {@link RoutingMethod#exclusive} routing. + * + * @author mpolden + */ +public class ExclusiveZoneRoutingContext implements RoutingContext { + + private final RoutingPolicies policies; + private final ZoneId zone; + + public ExclusiveZoneRoutingContext(ZoneId zone, RoutingPolicies policies) { + this.policies = Objects.requireNonNull(policies); + this.zone = Objects.requireNonNull(zone); + } + + @Override + public void setRoutingStatus(RoutingStatus.Value value, RoutingStatus.Agent agent) { + policies.setRoutingStatus(zone, value); + } + + @Override + public RoutingStatus routingStatus() { + return policies.get(zone).routingStatus(); + } + + @Override + public RoutingMethod routingMethod() { + return RoutingMethod.exclusive; + } + +} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/context/SharedRoutingContext.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/context/SharedRoutingContext.java deleted file mode 100644 index e38212d7f80..00000000000 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/context/SharedRoutingContext.java +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.routing.context; - -import com.yahoo.config.provision.zone.RoutingMethod; -import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServer; -import com.yahoo.vespa.hosted.controller.routing.RoutingStatus; - -import java.time.Instant; -import java.util.Objects; - -/** - * An implementation of {@link RoutingContext} for a zone, using either {@link RoutingMethod#shared} or - * {@link RoutingMethod#sharedLayer4} routing. - * - * @author mpolden - */ -public class SharedRoutingContext implements RoutingContext { - - private final ConfigServer configServer; - private final ZoneId zone; - - public SharedRoutingContext(ZoneId zone, ConfigServer configServer) { - this.configServer = Objects.requireNonNull(configServer); - this.zone = Objects.requireNonNull(zone); - } - - @Override - public void setRoutingStatus(RoutingStatus.Value value, RoutingStatus.Agent agent) { - boolean in = value == RoutingStatus.Value.in; - configServer.setGlobalRotationStatus(zone, in); - } - - @Override - public RoutingStatus routingStatus() { - boolean in = configServer.getGlobalRotationStatus(zone); - RoutingStatus.Value newValue = in ? RoutingStatus.Value.in : RoutingStatus.Value.out; - return new RoutingStatus(newValue, - RoutingStatus.Agent.operator, - Instant.EPOCH); // API does not support time of change - } - - @Override - public RoutingMethod routingMethod() { - return RoutingMethod.shared; - } - -} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/context/SharedZoneRoutingContext.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/context/SharedZoneRoutingContext.java new file mode 100644 index 00000000000..2923c8dff5c --- /dev/null +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/context/SharedZoneRoutingContext.java @@ -0,0 +1,48 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.routing.context; + +import com.yahoo.config.provision.zone.RoutingMethod; +import com.yahoo.config.provision.zone.ZoneId; +import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServer; +import com.yahoo.vespa.hosted.controller.routing.RoutingStatus; + +import java.time.Instant; +import java.util.Objects; + +/** + * An implementation of {@link RoutingContext} for a zone, using either {@link RoutingMethod#shared} or + * {@link RoutingMethod#sharedLayer4} routing. + * + * @author mpolden + */ +public class SharedZoneRoutingContext implements RoutingContext { + + private final ConfigServer configServer; + private final ZoneId zone; + + public SharedZoneRoutingContext(ZoneId zone, ConfigServer configServer) { + this.configServer = Objects.requireNonNull(configServer); + this.zone = Objects.requireNonNull(zone); + } + + @Override + public void setRoutingStatus(RoutingStatus.Value value, RoutingStatus.Agent agent) { + boolean in = value == RoutingStatus.Value.in; + configServer.setGlobalRotationStatus(zone, in); + } + + @Override + public RoutingStatus routingStatus() { + boolean in = configServer.getGlobalRotationStatus(zone); + RoutingStatus.Value newValue = in ? RoutingStatus.Value.in : RoutingStatus.Value.out; + return new RoutingStatus(newValue, + RoutingStatus.Agent.operator, + Instant.EPOCH); // API does not support time of change + } + + @Override + public RoutingMethod routingMethod() { + return RoutingMethod.shared; + } + +} -- cgit v1.2.3