summaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2020-11-11 19:31:49 +0100
committerJon Marius Venstad <venstad@gmail.com>2020-11-12 09:54:46 +0100
commit9792ecf734a417bed4f514359e014253fdaa8730 (patch)
tree38065851e8913b1ab6fe531a01cf6ace61e9483e /controller-api
parent24c35e915b8ed2c5afddd345225832058b5faa96 (diff)
Wire reindexing status through controller and application v4
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ApplicationReindexing.java145
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java10
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java7
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/Policy.java4
4 files changed, 163 insertions, 3 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ApplicationReindexing.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ApplicationReindexing.java
new file mode 100644
index 00000000000..8d002640156
--- /dev/null
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ApplicationReindexing.java
@@ -0,0 +1,145 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.hosted.controller.api.integration.configserver;
+
+import java.time.Instant;
+import java.util.Map;
+import java.util.Objects;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Reindexing status for a single Vespa application.
+ *
+ * @author jonmv
+ */
+public class ApplicationReindexing {
+
+ private final boolean enabled;
+ private final Status common;
+ private final Map<String, Cluster> clusters;
+
+ public ApplicationReindexing(boolean enabled, Status common, Map<String, Cluster> clusters) {
+ this.enabled = enabled;
+ this.common = requireNonNull(common);
+ this.clusters = Map.copyOf(clusters);
+ }
+
+ public boolean enabled() {
+ return enabled;
+ }
+
+ public Status common() {
+ return common;
+ }
+
+ public Map<String, Cluster> clusters() {
+ return clusters;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ApplicationReindexing that = (ApplicationReindexing) o;
+ return enabled == that.enabled &&
+ common.equals(that.common) &&
+ clusters.equals(that.clusters);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(enabled, common, clusters);
+ }
+
+ @Override
+ public String toString() {
+ return "ApplicationReindexing{" +
+ "enabled=" + enabled +
+ ", common=" + common +
+ ", clusters=" + clusters +
+ '}';
+ }
+
+
+ public static class Cluster {
+
+ private final Status common;
+ private final Map<String, Long> pending;
+ private final Map<String, Status> ready;
+
+ public Cluster(Status common, Map<String, Long> pending, Map<String, Status> ready) {
+ this.common = requireNonNull(common);
+ this.pending = Map.copyOf(pending);
+ this.ready = Map.copyOf(ready);
+ }
+
+ public Status common() {
+ return common;
+ }
+
+ public Map<String, Long> pending() {
+ return pending;
+ }
+
+ public Map<String, Status> ready() {
+ return ready;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Cluster cluster = (Cluster) o;
+ return common.equals(cluster.common) &&
+ pending.equals(cluster.pending) &&
+ ready.equals(cluster.ready);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(common, pending, ready);
+ }
+
+ @Override
+ public String toString() {
+ return "Cluster{" +
+ "common=" + common +
+ ", pending=" + pending +
+ ", ready=" + ready +
+ '}';
+ }
+
+ }
+
+
+ public static class Status {
+
+ private final Instant readyAt;
+
+ public Status(Instant readyAt) {
+ this.readyAt = requireNonNull(readyAt);
+ }
+
+ public Instant readyAt() { return readyAt; }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Status status = (Status) o;
+ return readyAt.equals(status.readyAt);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(readyAt);
+ }
+
+ @Override
+ public String toString() {
+ return "ready at " + readyAt;
+ }
+
+ }
+
+}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java
index d1db863c2d9..e9e39e1f449 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java
@@ -25,7 +25,7 @@ import java.util.Optional;
/**
* The API controllers use when communicating with config servers.
*
- * @author Oyvind Grønnesby
+ * @author Øyvind Grønnesby
*/
public interface ConfigServer {
@@ -35,6 +35,14 @@ public interface ConfigServer {
PreparedApplication deploy(DeploymentData deployment);
+ void reindex(DeploymentId deployment, List<String> clusterNames, List<String> documentTypes);
+
+ ApplicationReindexing getReindexing(DeploymentId deployment);
+
+ void disableReindexing(DeploymentId deployment);
+
+ void enableReindexing(DeploymentId deployment);
+
void restart(DeploymentId deployment, RestartFilter restartFilter);
void deactivate(DeploymentId deployment) throws NotFoundException;
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java
index 9efd216b9f1..ee52da2a233 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java
@@ -154,6 +154,13 @@ enum PathGroup {
"/application/v4/tenant/{tenant}/application/{application}/environment/test/region/{region}/instance/{ignored}/restart",
"/application/v4/tenant/{tenant}/application/{application}/environment/staging/region/{region}/instance/{ignored}/restart"),
+ /** Path used to manipulate reindexing status. */
+ reindexing(Matcher.tenant,
+ Matcher.application,
+ PathPrefix.api,
+ "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/{environment}/region/{region}/reindex",
+ "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/{environment}/region/{region}/reindexing"),
+
/** Paths used for development deployments. */
developmentDeployment(Matcher.tenant,
Matcher.application,
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/Policy.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/Policy.java
index c1d00b995aa..4191dbd767d 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/Policy.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/Policy.java
@@ -76,7 +76,7 @@ enum Policy {
/** Read access to application information and settings. */
applicationRead(Privilege.grant(Action.read)
- .on(PathGroup.application, PathGroup.applicationInfo)
+ .on(PathGroup.application, PathGroup.applicationInfo, PathGroup.reindexing)
.in(SystemName.all())),
/** Read access to application information and settings. */
@@ -91,7 +91,7 @@ enum Policy {
/** Full access to application information and settings. */
applicationOperations(Privilege.grant(Action.write())
- .on(PathGroup.applicationInfo, PathGroup.productionRestart)
+ .on(PathGroup.applicationInfo, PathGroup.productionRestart, PathGroup.reindexing)
.in(SystemName.all())),
/** Access to create and delete developer and deploy keys under a tenant. */