diff options
author | Bjørn Christian Seime <bjorncs@oath.com> | 2018-01-18 17:30:17 +0100 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@oath.com> | 2018-01-18 17:30:17 +0100 |
commit | 8fe47f607aa9b9608757873fb283c5623a2b7b15 (patch) | |
tree | a85269e5209458a1ee4578daa502533f796ac8cb /controller-api | |
parent | b2abdfe88851ab4a8127bb171dce6505243f44a8 (diff) |
Add Routing Status API to Zone v2
Diffstat (limited to 'controller-api')
5 files changed, 159 insertions, 0 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/routing/status/StatusReply.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/routing/status/StatusReply.java new file mode 100644 index 00000000000..c1ca68adfbd --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/routing/status/StatusReply.java @@ -0,0 +1,31 @@ +// Copyright 2018 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.routing.status; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus; + +/** + * @author bjorncs + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class StatusReply { + + public final RotationStatus status; + public final long lastUpdate; + public final String cause; + public final String agent; + + @JsonCreator + public StatusReply(@JsonProperty("status") RotationStatus status, + @JsonProperty("lastUpdate") long lastUpdate, + @JsonProperty("cause") String cause, + @JsonProperty("agent") String agent) { + this.status = status; + this.lastUpdate = lastUpdate; + this.cause = cause; + this.agent = agent; + } + +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/routing/status/ZoneStatus.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/routing/status/ZoneStatus.java new file mode 100644 index 00000000000..aea5f6d928d --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/routing/status/ZoneStatus.java @@ -0,0 +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.integration.routing.status; + +/** + * @author bjorncs + */ +public enum ZoneStatus { + OUT, IN +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/routing/status/ZoneStatusReply.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/routing/status/ZoneStatusReply.java new file mode 100644 index 00000000000..d2e94e73b39 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/routing/status/ZoneStatusReply.java @@ -0,0 +1,21 @@ +// 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.routing.status; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * @author bjorncs + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ZoneStatusReply { + + public final ZoneStatus status; + + @JsonCreator + public ZoneStatusReply(@JsonProperty("status") ZoneStatus status) { + this.status = status; + } + +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/routing/status/package-info.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/routing/status/package-info.java new file mode 100644 index 00000000000..0b6117d516f --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/routing/status/package-info.java @@ -0,0 +1,8 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +/** + * @author bjorncs + */ +@ExportPackage +package com.yahoo.vespa.hosted.controller.api.integration.routing.status; + +import com.yahoo.osgi.annotation.ExportPackage;
\ No newline at end of file diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v2/ZoneApiV2.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v2/ZoneApiV2.java index 248d8d3ee28..02371529583 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v2/ZoneApiV2.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v2/ZoneApiV2.java @@ -11,6 +11,9 @@ import com.yahoo.vespa.hosted.controller.api.integration.noderepository.Maintena import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList; import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode; import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeState; +import com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus; +import com.yahoo.vespa.hosted.controller.api.integration.routing.status.StatusReply; +import com.yahoo.vespa.hosted.controller.api.integration.routing.status.ZoneStatusReply; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -25,6 +28,7 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.Collection; +import java.util.List; import java.util.Set; /** @@ -208,4 +212,90 @@ public interface ZoneApiV2 { void resumeApplication(@PathParam("environmentId") EnvironmentId environmentId, @PathParam("regionId") RegionId regionId, @PathParam("application") String applicationIdString); + + /** + * Get names of all rotations with the status OUT + * + * @return List of rotation names. + */ + @GET + @Produces(MediaType.APPLICATION_JSON) + @Path("/{environmentId}/{regionId}/routing/v1/status") + List<String> listRotations(@PathParam("environmentId") EnvironmentId environmentId, + @PathParam("regionId") RegionId regionId); + + /** + * Get the status of a rotation + * + * @param rotation The name of a rotation. + * @return The current status of the rotation, wrapped into a {@link StatusReply} object. The value is {@link + * RotationStatus#IN} for any rotation that has not been explicitly set to {@link RotationStatus#OUT} using {@link + * #setRotationStatus(EnvironmentId, RegionId, String, StatusReply)}. + */ + @GET + @Path("/{environmentId}/{regionId}/routing/v1/status/{rotation}") + @Produces(MediaType.APPLICATION_JSON) + StatusReply getRotationStatus(@PathParam("environmentId") EnvironmentId environmentId, + @PathParam("regionId") RegionId regionId, + @PathParam("rotation") String rotation); + + /** + * Set or modify rotation status according to payload + * + * @param rotation The rotation (endpoint) to modify + * @param payload The name/status/agent/reason to set + * @return The updated status of the rotation wrapped into a {@link StatusReply} object. + */ + @PUT + @Path("/{environmentId}/{regionId}/routing/v1/status/{rotation}") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + StatusReply setRotationStatus(@PathParam("environmentId") EnvironmentId environmentId, + @PathParam("regionId") RegionId regionId, + @PathParam("rotation") String rotation, + StatusReply payload); + + /** + * Set the status of a rotation to IN + * + * @param rotation The name of a rotation. + * @return The updated status of the rotation wrapped into a {@link StatusReply} object. + */ + @DELETE + @Path("/{environmentId}/{regionId}/routing/v1/status/{rotation}") + @Produces(MediaType.APPLICATION_JSON) + @Deprecated + StatusReply unsetRotation(@PathParam("environmentId") EnvironmentId environmentId, + @PathParam("regionId") RegionId regionId, + @PathParam("rotation") String rotation); + + /** + * Set the status of the zone to OUT + * @return The updated status of the zone wrapped into a {@link ZoneStatusReply} object. + */ + @PUT + @Path("/{environmentId}/{regionId}/routing/v1/status/zone") + @Produces(MediaType.APPLICATION_JSON) + ZoneStatusReply setZoneRotationInactive(@PathParam("environmentId") EnvironmentId environmentId, + @PathParam("regionId") RegionId regionId); + + /** + * Clears the status of the zone. The routing check will fall back to check individual rotations. + * @return The updated status of the zone wrapped into a {@link ZoneStatusReply} object. + */ + @DELETE + @Path("/{environmentId}/{regionId}/routing/v1/status/zone") + @Produces(MediaType.APPLICATION_JSON) + ZoneStatusReply unsetZoneRotationInactive(@PathParam("environmentId") EnvironmentId environmentId, + @PathParam("regionId") RegionId regionId); + + /** + * Get the status of the zone + * @return The status of the zone wrapped into a {@link ZoneStatusReply} object. + */ + @GET + @Path("/{environmentId}/{regionId}/routing/v1/status/zone") + @Produces(MediaType.APPLICATION_JSON) + ZoneStatusReply getZoneRotationStatus(@PathParam("environmentId") EnvironmentId environmentId, + @PathParam("regionId") RegionId regionId); } |