diff options
8 files changed, 32 insertions, 23 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 index 869fe9d04b5..305cd4c802e 100644 --- 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 @@ -103,18 +103,20 @@ public class ApplicationReindexing { private final State state; private final String message; private final Double progress; + private final Double speed; - public Status(Instant readyAt, Instant startedAt, Instant endedAt, State state, String message, Double progress) { + public Status(Instant readyAt, Instant startedAt, Instant endedAt, State state, String message, Double progress, Double speed) { this.readyAt = readyAt; this.startedAt = startedAt; this.endedAt = endedAt; this.state = state; this.message = message; this.progress = progress; + this.speed = speed; } public Status(Instant readyAt) { - this(readyAt, null, null, null, null, null); + this(readyAt, null, null, null, null, null, 1.0); } public Optional<Instant> readyAt() { return Optional.ofNullable(readyAt); } @@ -123,23 +125,19 @@ public class ApplicationReindexing { public Optional<State> state() { return Optional.ofNullable(state); } public Optional<String> message() { return Optional.ofNullable(message); } public Optional<Double> progress() { return Optional.ofNullable(progress); } + public Optional<Double> speed() { return Optional.ofNullable(speed); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Status status = (Status) o; - return Objects.equals(readyAt, status.readyAt) && - Objects.equals(startedAt, status.startedAt) && - Objects.equals(endedAt, status.endedAt) && - state == status.state && - Objects.equals(message, status.message) && - Objects.equals(progress, status.progress); + return Objects.equals(readyAt, status.readyAt) && Objects.equals(startedAt, status.startedAt) && Objects.equals(endedAt, status.endedAt) && state == status.state && Objects.equals(message, status.message) && Objects.equals(progress, status.progress) && Objects.equals(speed, status.speed); } @Override public int hashCode() { - return Objects.hash(readyAt, startedAt, endedAt, state, message, progress); + return Objects.hash(readyAt, startedAt, endedAt, state, message, progress, speed); } @Override @@ -150,7 +148,8 @@ public class ApplicationReindexing { ", endedAt=" + endedAt + ", state=" + state + ", message='" + message + '\'' + - ", progress='" + progress + '\'' + + ", progress=" + progress + + ", speed=" + speed + '}'; } 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 7f9b693f413..b9b7881745a 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 @@ -36,7 +36,7 @@ public interface ConfigServer { PreparedApplication deploy(DeploymentData deployment); - void reindex(DeploymentId deployment, List<String> clusterNames, List<String> documentTypes, boolean indexedOnly); + void reindex(DeploymentId deployment, List<String> clusterNames, List<String> documentTypes, boolean indexedOnly, Double speed); ApplicationReindexing getReindexing(DeploymentId deployment); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java index 49939f4bfd2..e7e7101aff7 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java @@ -178,8 +178,8 @@ public class ApplicationController { * if no documents types are given, reindexing is triggered for all given clusters; otherwise * reindexing is triggered for the cartesian product of the given clusters and document types. */ - public void reindex(ApplicationId id, ZoneId zoneId, List<String> clusterNames, List<String> documentTypes, boolean indexedOnly) { - configServer.reindex(new DeploymentId(id, zoneId), clusterNames, documentTypes, indexedOnly); + public void reindex(ApplicationId id, ZoneId zoneId, List<String> clusterNames, List<String> documentTypes, boolean indexedOnly, Double speed) { + configServer.reindex(new DeploymentId(id, zoneId), clusterNames, documentTypes, indexedOnly, speed); } /** Returns the reindexing status for the given application in the given zone. */ diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ReindexingTriggerer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ReindexingTriggerer.java index 34b1ea34227..1ee13bbd0c0 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ReindexingTriggerer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ReindexingTriggerer.java @@ -32,6 +32,7 @@ import java.util.logging.Logger; public class ReindexingTriggerer extends ControllerMaintainer { static final Duration reindexingPeriod = Duration.ofDays(91); // 13 weeks — four times a year. + static final double speed = 0.2; // Careful reindexing, as this is supposed to be a background operation. private static final Logger log = Logger.getLogger(ReindexingTriggerer.class.getName()); @@ -49,7 +50,7 @@ public class ReindexingTriggerer extends ControllerMaintainer { for (Deployment deployment : deployments) if ( inWindowOfOpportunity(now, id, deployment.zone()) && reindexingIsReady(controller().applications().applicationReindexing(id, deployment.zone()), now)) - controller().applications().reindex(id, deployment.zone(), List.of(), List.of(), true); + controller().applications().reindex(id, deployment.zone(), List.of(), List.of(), true, speed); }); return 1.0; } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java index 8af26f564a6..73a80a0a94a 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java @@ -139,6 +139,7 @@ import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.OptionalLong; import java.util.Scanner; @@ -1839,10 +1840,14 @@ public class ApplicationApiHandler extends AuditLoggingRequestHandler { .filter(type -> ! type.isBlank()) .collect(toUnmodifiableList()); - controller.applications().reindex(id, zone, clusterNames, documentTypes, request.getBooleanProperty("indexedOnly")); + Double speed = request.hasProperty("speed") ? Double.parseDouble(request.getProperty("speed")) : null; + boolean indexedOnly = request.getBooleanProperty("indexedOnly"); + controller.applications().reindex(id, zone, clusterNames, documentTypes, indexedOnly, speed); return new MessageResponse("Requested reindexing of " + id + " in " + zone + - (clusterNames.isEmpty() ? "" : ", on clusters " + String.join(", ", clusterNames) + - (documentTypes.isEmpty() ? "" : ", for types " + String.join(", ", documentTypes)))); + (clusterNames.isEmpty() ? "" : ", on clusters " + String.join(", ", clusterNames)) + + (documentTypes.isEmpty() ? "" : ", for types " + String.join(", ", documentTypes)) + + (indexedOnly ? ", for indexed types" : "") + + (speed != null ? ", with speed " + speed : "")); } /** Gets reindexing status of an application in a zone. */ @@ -1888,6 +1893,7 @@ public class ApplicationApiHandler extends AuditLoggingRequestHandler { status.state().map(ApplicationApiHandler::toString).ifPresent(state -> statusObject.setString("state", state)); status.message().ifPresent(message -> statusObject.setString("message", message)); status.progress().ifPresent(progress -> statusObject.setDouble("progress", progress)); + status.speed().ifPresent(speed -> statusObject.setDouble("speed", speed)); } private static String toString(ApplicationReindexing.State state) { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java index aa53d09be04..e0ce1c060bc 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java @@ -438,7 +438,7 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer } @Override - public void reindex(DeploymentId deployment, List<String> clusterNames, List<String> documentTypes, boolean indexedOnly) { } + public void reindex(DeploymentId deployment, List<String> clusterNames, List<String> documentTypes, boolean indexedOnly, Double speed) { } @Override public ApplicationReindexing getReindexing(DeploymentId deployment) { @@ -450,7 +450,8 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer Instant.ofEpochMilli(567), ApplicationReindexing.State.FAILED, "(#`д´)ノ", - 0.1))))); + 0.1, + 1.0))))); } @Override diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ReindexingTriggererTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ReindexingTriggererTest.java index 8b5a12c8879..76cc9f5773a 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ReindexingTriggererTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ReindexingTriggererTest.java @@ -69,7 +69,7 @@ public class ReindexingTriggererTest { Map.of("cluster", new Cluster(Map.of(), Map.of("type", - new Status(then, then, null, null, null, null))))); + new Status(then, then, null, null, null, null, 1.0))))); assertFalse("Should not be ready when reindexing is already running", reindexingIsReady(reindexing, now)); @@ -77,7 +77,7 @@ public class ReindexingTriggererTest { Map.of("cluster", new Cluster(Map.of("type", 123L), Map.of("type", - new Status(then, then, now, null, null, null))))); + new Status(then, then, now, null, null, null, 1.0))))); assertTrue("Should be ready when reindexing is no longer running", reindexingIsReady(reindexing, now)); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java index b6aa2313ab3..8eaa190e9fa 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java @@ -597,8 +597,10 @@ public class ApplicationApiTest extends ControllerContainerTest { // POST a 'reindex application' command tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/instance/instance1/environment/prod/region/us-central-1/reindex", POST) + .properties(Map.of("indexedOnly", "true", + "speed", "10")) .userIdentity(USER_ID), - "{\"message\":\"Requested reindexing of tenant1.application1.instance1 in prod.us-central-1\"}"); + "{\"message\":\"Requested reindexing of tenant1.application1.instance1 in prod.us-central-1, for indexed types, with speed 10.0\"}"); // POST a 'reindex application' command with cluster filter tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/instance/instance1/environment/prod/region/us-central-1/reindex", POST) @@ -626,7 +628,7 @@ public class ApplicationApiTest extends ControllerContainerTest { // GET to get reindexing status tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/instance/instance1/environment/prod/region/us-central-1/reindexing", GET) .userIdentity(USER_ID), - "{\"enabled\":true,\"clusters\":[{\"name\":\"cluster\",\"pending\":[{\"type\":\"type\",\"requiredGeneration\":100}],\"ready\":[{\"type\":\"type\",\"readyAtMillis\":345,\"startedAtMillis\":456,\"endedAtMillis\":567,\"state\":\"failed\",\"message\":\"(#`д´)ノ\",\"progress\":0.1}]}]}"); + "{\"enabled\":true,\"clusters\":[{\"name\":\"cluster\",\"pending\":[{\"type\":\"type\",\"requiredGeneration\":100}],\"ready\":[{\"type\":\"type\",\"readyAtMillis\":345,\"startedAtMillis\":456,\"endedAtMillis\":567,\"state\":\"failed\",\"message\":\"(#`д´)ノ\",\"progress\":0.1,\"speed\":1.0}]}]}"); // POST to request a service dump tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/instance/instance1/environment/prod/region/us-central-1/node/host-tenant1:application1:instance1-prod.us-central-1/service-dump", POST) |