summaryrefslogtreecommitdiffstats
path: root/configserver/src
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2020-11-10 11:49:39 +0100
committerGitHub <noreply@github.com>2020-11-10 11:49:39 +0100
commit4f05c4affb9290018ca00abe7ce21ecc365f1135 (patch)
treec31503aed0a6649a81c4634ab1b6cacde4af034f /configserver/src
parent8f2e03f3d79df85c2939e056cad289cf0a982b2d (diff)
parentb9175dd619335df9759ec0422f207ed689770df4 (diff)
Merge pull request #15247 from vespa-engine/jonmv/enabled-override-for-reindexing
Add "enabled" to application reindexing status, and storage
Diffstat (limited to 'configserver/src')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationCuratorDatabase.java5
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationReindexing.java33
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationCuratorDatabaseTest.java3
3 files changed, 29 insertions, 12 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationCuratorDatabase.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationCuratorDatabase.java
index 8c3c9882aa1..eb294e6a1b9 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationCuratorDatabase.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationCuratorDatabase.java
@@ -146,6 +146,7 @@ public class ApplicationCuratorDatabase {
private static class ReindexingStatusSerializer {
private static final String COMMON = "common";
+ private static final String ENABLED = "enabled";
private static final String CLUSTERS = "clusters";
private static final String PENDING = "pending";
private static final String READY = "ready";
@@ -156,6 +157,7 @@ public class ApplicationCuratorDatabase {
private static byte[] toBytes(ApplicationReindexing reindexing) {
Cursor root = new Slime().setObject();
+ root.setBool(ENABLED, reindexing.enabled());
setStatus(root.setObject(COMMON), reindexing.common());
Cursor clustersArray = root.setArray(CLUSTERS);
@@ -187,7 +189,8 @@ public class ApplicationCuratorDatabase {
private static ApplicationReindexing fromBytes(byte[] data) {
Cursor root = SlimeUtils.jsonToSlimeOrThrow(data).get();
- return new ApplicationReindexing(getStatus(root.field(COMMON)),
+ return new ApplicationReindexing(root.field(ENABLED).valid() ? root.field(ENABLED).asBool() : true,
+ getStatus(root.field(COMMON)),
SlimeUtils.entriesStream(root.field(CLUSTERS))
.collect(toUnmodifiableMap(object -> object.field(NAME).asString(),
object -> getCluster(object))));
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationReindexing.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationReindexing.java
index ed28bec0d81..ecda8cbcde9 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationReindexing.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationReindexing.java
@@ -22,29 +22,31 @@ import static java.util.stream.Collectors.toUnmodifiableMap;
*/
public class ApplicationReindexing implements Reindexing {
+ private final boolean enabled;
private final Status common;
private final Map<String, Cluster> clusters;
- public ApplicationReindexing(Status common, Map<String, Cluster> clusters) {
+ ApplicationReindexing(boolean enabled, Status common, Map<String, Cluster> clusters) {
+ this.enabled = enabled;
this.common = requireNonNull(common);
this.clusters = Map.copyOf(clusters);
}
/** Reindexing for the whole application ready now. */
public static ApplicationReindexing ready(Instant now) {
- return new ApplicationReindexing(new Status(now), Map.of());
+ return new ApplicationReindexing(true, new Status(now), Map.of());
}
/** Returns a copy of this with common reindexing for the whole application ready at the given instant. */
public ApplicationReindexing withReady(Instant readyAt) {
- return new ApplicationReindexing(new Status(readyAt), clusters);
+ return new ApplicationReindexing(enabled, new Status(readyAt), clusters);
}
/** Returns a copy of this with common reindexing for the given cluster ready at the given instant. */
public ApplicationReindexing withReady(String cluster, Instant readyAt) {
Cluster current = clusters.getOrDefault(cluster, Cluster.ready(common));
Cluster modified = new Cluster(new Status(readyAt), current.pending, current.ready);
- return new ApplicationReindexing(common, with(cluster, modified, clusters));
+ return new ApplicationReindexing(enabled, common, with(cluster, modified, clusters));
}
/** Returns a copy of this with reindexing for the given document type in the given cluster ready at the given instant. */
@@ -53,7 +55,7 @@ public class ApplicationReindexing implements Reindexing {
Cluster modified = new Cluster(current.common,
without(documentType, current.pending),
with(documentType, new Status(readyAt), current.ready));
- return new ApplicationReindexing(common, with(cluster, modified, clusters));
+ return new ApplicationReindexing(enabled, common, with(cluster, modified, clusters));
}
/** Returns a copy of this with a pending reindexing at the given generation, for the given document type. */
@@ -62,7 +64,17 @@ public class ApplicationReindexing implements Reindexing {
Cluster modified = new Cluster(current.common,
with(documentType, requirePositive(requiredGeneration), current.pending),
without(documentType, current.ready));
- return new ApplicationReindexing(common, with(cluster, modified, clusters));
+ return new ApplicationReindexing(enabled, common, with(cluster, modified, clusters));
+ }
+
+ /** Returns a copy of this with the enabled-state set to the given value. */
+ public ApplicationReindexing enabled(boolean enabled) {
+ return new ApplicationReindexing(enabled, common, clusters);
+ }
+
+ /** Returns whether reindexing should run for this application. */
+ public boolean enabled() {
+ return enabled;
}
/** The common reindexing status for the whole application. */
@@ -92,24 +104,25 @@ public class ApplicationReindexing implements Reindexing {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ApplicationReindexing that = (ApplicationReindexing) o;
- return common.equals(that.common) &&
+ return enabled == that.enabled &&
+ common.equals(that.common) &&
clusters.equals(that.clusters);
}
@Override
public int hashCode() {
- return Objects.hash(common, clusters);
+ return Objects.hash(enabled, common, clusters);
}
@Override
public String toString() {
return "ApplicationReindexing{" +
- "common=" + common +
+ "enabled=" + enabled +
+ ", common=" + common +
", clusters=" + clusters +
'}';
}
-
/** Reindexing status for a single content cluster in an application. */
public static class Cluster {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationCuratorDatabaseTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationCuratorDatabaseTest.java
index b74df3ffd9a..0c4472398c1 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationCuratorDatabaseTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationCuratorDatabaseTest.java
@@ -29,7 +29,8 @@ public class ApplicationCuratorDatabaseTest {
.withPending("two", "b", 20)
.withReady("two", Instant.ofEpochMilli(2 << 10))
.withReady("one", "a", Instant.ofEpochMilli(1))
- .withReady("two", "c", Instant.ofEpochMilli(3));
+ .withReady("two", "c", Instant.ofEpochMilli(3))
+ .enabled(false);
db.writeReindexingStatus(id, reindexing);
assertEquals(reindexing, db.readReindexingStatus(id).orElseThrow());