diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-09-10 16:47:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-10 16:47:24 +0200 |
commit | fda7503c125fd5a304cb2bb7d3d4e705f97987b5 (patch) | |
tree | d658b275d27393a1e94b3a65bd249c9560690a1f | |
parent | 9aa1fd9329c9bf0fd47c893483c761381bbe383f (diff) | |
parent | 1d3740fda0b4bcbe4d36176aa6188e153d57c3dc (diff) |
Merge pull request #24000 from vespa-engine/balder/propagate-target-active-docs
Balder/propagate target active docs
51 files changed, 220 insertions, 189 deletions
diff --git a/container-core/abi-spec.json b/container-core/abi-spec.json index 9c14c03ba21..6e4fc74fdc6 100644 --- a/container-core/abi-spec.json +++ b/container-core/abi-spec.json @@ -207,7 +207,7 @@ "public void merge(com.yahoo.container.handler.Coverage)", "public long getDocs()", "public long getActive()", - "public long getSoonActive()", + "public long getTargetActive()", "public boolean isDegraded()", "public boolean isDegradedByMatchPhase()", "public boolean isDegradedByTimeout()", @@ -225,7 +225,7 @@ "fields": [ "protected long docs", "protected long active", - "protected long soonActive", + "protected long targetActive", "protected int degradedReason", "protected int nodes", "protected int resultSets", diff --git a/container-core/src/main/java/com/yahoo/container/handler/Coverage.java b/container-core/src/main/java/com/yahoo/container/handler/Coverage.java index 6b510aadd3f..3f8d085af9e 100644 --- a/container-core/src/main/java/com/yahoo/container/handler/Coverage.java +++ b/container-core/src/main/java/com/yahoo/container/handler/Coverage.java @@ -1,9 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.container.handler; - -import com.yahoo.api.annotations.Beta; - /** * The coverage report for a result set. * @@ -14,7 +11,7 @@ public class Coverage { protected long docs; protected long active; - protected long soonActive; + protected long targetActive; protected int degradedReason; protected int nodes; private int nodesTried; @@ -55,7 +52,7 @@ public class Coverage { this.nodes = nodes; this.nodesTried = nodes; this.active = active; - this.soonActive = active; + this.targetActive = active; this.degradedReason = 0; this.resultSets = resultSets; this.fullReason = fullReason; @@ -69,7 +66,7 @@ public class Coverage { nodes += other.getNodes(); nodesTried += other.nodesTried; active += other.getActive(); - soonActive += other.getSoonActive(); + targetActive += other.getTargetActive(); degradedReason |= other.degradedReason; resultSets += other.getResultSets(); fullResultSets += other.getFullResultSets(); @@ -104,10 +101,8 @@ public class Coverage { /** * Returns the total number of documents that will be searchable once redistribution has settled. - * Still in beta, semantics not finalized yet. */ - @Beta - public long getSoonActive() { return soonActive; } + public long getTargetActive() { return targetActive; } public boolean isDegraded() { return (degradedReason != 0) || isDegradedByNonIdealState(); } public boolean isDegradedByMatchPhase() { return (degradedReason & DEGRADED_BY_MATCH_PHASE) != 0; } @@ -117,16 +112,11 @@ public class Coverage { /** Returns whether the search had full coverage or not */ public boolean getFull() { - switch (fullReason) { - case EXPLICITLY_FULL: - return true; - case EXPLICITLY_INCOMPLETE: - return false; - case DOCUMENT_COUNT: - return docs == active; - default: - throw new IllegalStateException("Implementation out of sync. Please report this as a bug."); - } + return switch (fullReason) { + case EXPLICITLY_FULL: yield true; + case EXPLICITLY_INCOMPLETE: yield false; + case DOCUMENT_COUNT: yield docs == active; + }; } /** Returns the number of search instances which participated successfully in the search. */ @@ -184,7 +174,7 @@ public class Coverage { int degradation = com.yahoo.container.logging.Coverage.toDegradation(isDegradedByMatchPhase(), isDegradedByTimeout(), isDegradedByAdapativeTimeout()); - return new com.yahoo.container.logging.Coverage(getDocs(), getActive(), getSoonActive(), degradation); + return new com.yahoo.container.logging.Coverage(getDocs(), getActive(), getTargetActive(), degradation); } } diff --git a/container-core/src/main/java/com/yahoo/container/logging/Coverage.java b/container-core/src/main/java/com/yahoo/container/logging/Coverage.java index bf0cb2d524b..98d685393dc 100644 --- a/container-core/src/main/java/com/yahoo/container/logging/Coverage.java +++ b/container-core/src/main/java/com/yahoo/container/logging/Coverage.java @@ -7,15 +7,15 @@ package com.yahoo.container.logging; public class Coverage { private final long docs; private final long active; - private final long soonActive; + private final long targetActive; private final int degradedReason; private final static int DEGRADED_BY_MATCH_PHASE = 1; private final static int DEGRADED_BY_TIMEOUT = 2; private final static int DEGRADED_BY_ADAPTIVE_TIMEOUT = 4; - public Coverage(long docs, long active, long soonActive, int degradedReason) { + public Coverage(long docs, long active, long targetActive, int degradedReason) { this.docs = docs; this.active = active; - this.soonActive = soonActive; + this.targetActive = targetActive; this.degradedReason = degradedReason; } @@ -41,7 +41,7 @@ public class Coverage { return v; } - public long getSoonActive() { return soonActive; } + public long getTargetActive() { return targetActive; } public boolean isDegraded() { return (degradedReason != 0) || isDegradedByNonIdealState(); } public boolean isDegradedByMatchPhase() { return (degradedReason & DEGRADED_BY_MATCH_PHASE) != 0; } diff --git a/container-search/abi-spec.json b/container-search/abi-spec.json index 87fdfb1379a..93e8ce16b6f 100644 --- a/container-search/abi-spec.json +++ b/container-search/abi-spec.json @@ -7485,7 +7485,7 @@ "public void <init>(long, long)", "public void <init>(long, long, int)", "public void <init>(long, long, int, int)", - "public com.yahoo.search.result.Coverage setSoonActive(long)", + "public com.yahoo.search.result.Coverage setTargetActive(long)", "public com.yahoo.search.result.Coverage setDegradedReason(int)", "public com.yahoo.search.result.Coverage setNodesTried(int)", "public bridge synthetic com.yahoo.container.handler.Coverage setNodesTried(int)" diff --git a/container-search/src/main/java/com/yahoo/prelude/Pong.java b/container-search/src/main/java/com/yahoo/prelude/Pong.java index ecd6e302ccc..0d2a2de1da0 100644 --- a/container-search/src/main/java/com/yahoo/prelude/Pong.java +++ b/container-search/src/main/java/com/yahoo/prelude/Pong.java @@ -4,9 +4,7 @@ package com.yahoo.prelude; import com.yahoo.search.result.ErrorMessage; import com.yahoo.search.statistics.ElapsedTime; -import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * An answer from Ping. @@ -16,42 +14,47 @@ import java.util.stream.Collectors; public class Pong { private final ElapsedTime elapsed = new ElapsedTime(); - private final Optional<Long> activeDocuments; + private final Long activeDocuments; + private final Long targetActiveDocuments; private final boolean isBlockingWrites; - private final Optional<ErrorMessage> error; + private final ErrorMessage error; public Pong() { - this(Optional.empty(), false, Optional.empty()); + this(null, null, false, null); } public Pong(ErrorMessage error) { - this(Optional.empty(), false, Optional.of(error)); + this(null, null, false, error); } - public Pong(long activeDocuments) { - this(Optional.of(activeDocuments), false, Optional.empty()); + public Pong(long activeDocuments, long targetActiveDocuments) { + this(activeDocuments, targetActiveDocuments, false, null); } - public Pong(long activeDocuments, boolean isBlockingWrites) { - this(Optional.of(activeDocuments), isBlockingWrites, Optional.empty()); + public Pong(long activeDocuments, long targetActiveDocuments, boolean isBlockingWrites) { + this(activeDocuments, targetActiveDocuments, isBlockingWrites, null); } - private Pong(Optional<Long> activeDocuments, boolean isBlockingWrites, Optional<ErrorMessage> error) { + private Pong(Long activeDocuments, Long targetActiveDocuments, boolean isBlockingWrites, ErrorMessage error) { this.activeDocuments = activeDocuments; + this.targetActiveDocuments = targetActiveDocuments; this.isBlockingWrites = isBlockingWrites; this.error = error; } - public Optional<ErrorMessage> error() { return error; } + public Optional<ErrorMessage> error() { return Optional.ofNullable(error); } /** Returns the number of active documents in the backend responding in this Pong, if available */ - public Optional<Long> activeDocuments() { return activeDocuments; } + public Optional<Long> activeDocuments() { return Optional.ofNullable(activeDocuments); } + + /** Returns the number of target active documents in the backend responding in this Pong, if available */ + public Optional<Long> targetActiveDocuments() { return Optional.ofNullable(targetActiveDocuments); } /** Returns true if the pinged node is currently blocking write operations due to being full */ public boolean isBlockingWrites() { return isBlockingWrites; } /** Returns whether there is an error or not */ - public boolean badResponse() { return error.isPresent(); } + public boolean badResponse() { return error != null; } public ElapsedTime getElapsedTime() { return elapsed; } @@ -59,10 +62,11 @@ public class Pong { @Override public String toString() { StringBuilder m = new StringBuilder("Ping result"); - activeDocuments.ifPresent(docCount -> m.append(" active docs: ").append(docCount)); + activeDocuments().ifPresent(docCount -> m.append(" active docs: ").append(docCount)); + targetActiveDocuments().ifPresent(docCount -> m.append(" target active docs: ").append(docCount)); if (isBlockingWrites) m.append(" blocking writes: true"); - error.ifPresent(e -> m.append(" error: ").append(error)); + error().ifPresent(e -> m.append(" error: ").append(error)); return m.toString(); } diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/InterleavedSearchInvoker.java b/container-search/src/main/java/com/yahoo/search/dispatch/InterleavedSearchInvoker.java index 99a2bc34a14..8c92e8b0270 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/InterleavedSearchInvoker.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/InterleavedSearchInvoker.java @@ -54,7 +54,7 @@ public class InterleavedSearchInvoker extends SearchInvoker implements ResponseM private long answeredDocs = 0; private long answeredActiveDocs = 0; - private long answeredSoonActiveDocs = 0; + private long answeredTargetActiveDocs = 0; private int askedNodes = 0; private int answeredNodes = 0; private int answeredNodesParticipated = 0; @@ -268,7 +268,7 @@ public class InterleavedSearchInvoker extends SearchInvoker implements ResponseM private void collectCoverage(Coverage source) { answeredDocs += source.getDocs(); answeredActiveDocs += source.getActive(); - answeredSoonActiveDocs += source.getSoonActive(); + answeredTargetActiveDocs += source.getTargetActive(); answeredNodesParticipated += source.getNodes(); answeredNodes++; degradedByMatchPhase |= source.isDegradedByMatchPhase(); @@ -280,7 +280,7 @@ public class InterleavedSearchInvoker extends SearchInvoker implements ResponseM Coverage coverage = new Coverage(answeredDocs, answeredActiveDocs, answeredNodesParticipated, 1); coverage.setNodesTried(askedNodes); - coverage.setSoonActive(answeredSoonActiveDocs); + coverage.setTargetActive(answeredTargetActiveDocs); int degradedReason = 0; if (timedOut) { degradedReason |= (adaptiveTimeoutCalculated ? DEGRADED_BY_ADAPTIVE_TIMEOUT : DEGRADED_BY_TIMEOUT); @@ -300,14 +300,14 @@ public class InterleavedSearchInvoker extends SearchInvoker implements ResponseM if (adaptiveTimeoutCalculated && answeredNodesParticipated > 0) { answeredActiveDocs += (notAnswered * answeredActiveDocs / answeredNodesParticipated); - answeredSoonActiveDocs += (notAnswered * answeredSoonActiveDocs / answeredNodesParticipated); + answeredTargetActiveDocs += (notAnswered * answeredTargetActiveDocs / answeredNodesParticipated); } else { if (askedNodes > answeredNodesParticipated) { int searchableCopies = (int) searchCluster.dispatchConfig().searchableCopies(); int missingNodes = notAnswered - (searchableCopies - 1); if (answeredNodesParticipated > 0) { answeredActiveDocs += (missingNodes * answeredActiveDocs / answeredNodesParticipated); - answeredSoonActiveDocs += (missingNodes * answeredSoonActiveDocs / answeredNodesParticipated); + answeredTargetActiveDocs += (missingNodes * answeredTargetActiveDocs / answeredNodesParticipated); timedOut = true; } } diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/ProtobufSerialization.java b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/ProtobufSerialization.java index 09a101e3bff..de4f4f45eed 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/ProtobufSerialization.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/ProtobufSerialization.java @@ -263,7 +263,7 @@ public class ProtobufSerialization { private static Coverage convertToCoverage(SearchProtocol.SearchReply protobuf) { var coverage = new Coverage(protobuf.getCoverageDocs(), protobuf.getActiveDocs(), 1); - coverage.setNodesTried(1).setSoonActive(protobuf.getSoonActiveDocs()); + coverage.setNodesTried(1).setTargetActive(protobuf.getTargetActiveDocs()); int degradedReason = 0; if (protobuf.getDegradedByMatchPhase()) @@ -280,7 +280,7 @@ public class ProtobufSerialization { var coverage = result.getCoverage(false); if (coverage != null) { - builder.setCoverageDocs(coverage.getDocs()).setActiveDocs(coverage.getActive()).setSoonActiveDocs(coverage.getSoonActive()) + builder.setCoverageDocs(coverage.getDocs()).setActiveDocs(coverage.getActive()).setTargetActiveDocs(coverage.getTargetActive()) .setDegradedBySoftTimeout(coverage.isDegradedByTimeout()).setDegradedByMatchPhase(coverage.isDegradedByMatchPhase()); } diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcPing.java b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcPing.java index 8e99f4948ce..44f0af2aca1 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcPing.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcPing.java @@ -81,7 +81,7 @@ public class RpcPing implements Pinger, Client.ResponseReceiver { } else if (!reply.getOnline()) { return new Pong(ErrorMessage.createBackendCommunicationError("Node id " + node.key() + " reports being offline")); } else { - return new Pong(reply.getActiveDocs(), reply.getIsBlockingWrites()); + return new Pong(reply.getActiveDocs(), reply.getTargetActiveDocs(), reply.getIsBlockingWrites()); } } diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Group.java b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Group.java index d30abd1d047..cf161638104 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Group.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Group.java @@ -26,6 +26,7 @@ public class Group { private final AtomicBoolean hasSufficientCoverage = new AtomicBoolean(true); private final AtomicBoolean hasFullCoverage = new AtomicBoolean(true); private final AtomicLong activeDocuments = new AtomicLong(0); + private final AtomicLong targetActiveDocuments = new AtomicLong(0); private final AtomicBoolean isBlockingWrites = new AtomicBoolean(false); private final AtomicBoolean isBalanced = new AtomicBoolean(true); @@ -68,6 +69,8 @@ public class Group { public void aggregateNodeValues() { long activeDocs = nodes.stream().filter(node -> node.isWorking() == Boolean.TRUE).mapToLong(Node::getActiveDocuments).sum(); activeDocuments.set(activeDocs); + long targetActiveDocs = nodes.stream().filter(node -> node.isWorking() == Boolean.TRUE).mapToLong(Node::getTargetActiveDocuments).sum(); + targetActiveDocuments.set(targetActiveDocs); isBlockingWrites.set(nodes.stream().anyMatch(Node::isBlockingWrites)); int numWorkingNodes = workingNodes(); if (numWorkingNodes > 0) { @@ -90,6 +93,9 @@ public class Group { /** Returns the active documents on this group. If unknown, 0 is returned. */ long activeDocuments() { return activeDocuments.get(); } + /** Returns the target active documents on this group. If unknown, 0 is returned. */ + long targetActiveDocuments() { return targetActiveDocuments.get(); } + /** Returns whether any node in this group is currently blocking write operations */ public boolean isBlockingWrites() { return isBlockingWrites.get(); } @@ -99,7 +105,7 @@ public class Group { /** Returns whether this group has too few documents per node to expect it to be balanced */ public boolean isSparse() { if (nodes.isEmpty()) return false; - return activeDocuments.get() / nodes.size() < minDocsPerNodeToRequireLowSkew; + return activeDocuments() / nodes.size() < minDocsPerNodeToRequireLowSkew; } public boolean fullCoverageStatusChanged(boolean hasFullCoverageNow) { diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java index 0dce3d84273..d9c0198a472 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java @@ -21,6 +21,7 @@ public class Node { private final AtomicBoolean statusIsKnown = new AtomicBoolean(false); private final AtomicBoolean working = new AtomicBoolean(true); private final AtomicLong activeDocuments = new AtomicLong(0); + private final AtomicLong targetActiveDocuments = new AtomicLong(0); private final AtomicLong pingSequence = new AtomicLong(0); private final AtomicLong lastPong = new AtomicLong(0); private final AtomicBoolean isBlockingWrites = new AtomicBoolean(false); @@ -62,6 +63,7 @@ public class Node { this.working.lazySet(working); if ( ! working ) { activeDocuments.set(0); + targetActiveDocuments.set(0); } } @@ -71,10 +73,12 @@ public class Node { } /** Updates the active documents on this node */ - public void setActiveDocuments(long activeDocuments) { this.activeDocuments.set(activeDocuments); } + public void setActiveDocuments(long documents) { this.activeDocuments.set(documents); } + public void setTargetActiveDocuments(long documents) { this.targetActiveDocuments.set(documents); } /** Returns the active documents on this node. If unknown, 0 is returned. */ long getActiveDocuments() { return activeDocuments.get(); } + long getTargetActiveDocuments() { return targetActiveDocuments.get(); } public void setBlockingWrites(boolean isBlockingWrites) { this.isBlockingWrites.set(isBlockingWrites); } @@ -86,8 +90,7 @@ public class Node { @Override public boolean equals(Object o) { if (o == this) return true; - if ( ! (o instanceof Node)) return false; - Node other = (Node)o; + if ( ! (o instanceof Node other)) return false; if ( ! Objects.equals(this.hostname, other.hostname)) return false; if ( ! Objects.equals(this.key, other.key)) return false; if ( ! Objects.equals(this.pathIndex, other.pathIndex)) return false; @@ -100,7 +103,7 @@ public class Node { public String toString() { return "search node key = " + key + " hostname = "+ hostname + " path = " + pathIndex + " in group " + group + " statusIsKnown = " + statusIsKnown.get() + " working = " + working.get() + - " activeDocs = " + activeDocuments.get(); + " activeDocs = " + getActiveDocuments() + " targetActiveDocs = " + getTargetActiveDocuments(); } } diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java index f8c4627473d..82d3d98d9ef 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java @@ -339,6 +339,7 @@ public class SearchCluster implements NodeManager<Node> { } else { if (pong.activeDocuments().isPresent()) { node.setActiveDocuments(pong.activeDocuments().get()); + node.setTargetActiveDocuments(pong.targetActiveDocuments().get()); node.setBlockingWrites(pong.isBlockingWrites()); } clusterMonitor.responded(node); diff --git a/container-search/src/main/java/com/yahoo/search/result/Coverage.java b/container-search/src/main/java/com/yahoo/search/result/Coverage.java index aa561f58d7a..390c6ec4435 100644 --- a/container-search/src/main/java/com/yahoo/search/result/Coverage.java +++ b/container-search/src/main/java/com/yahoo/search/result/Coverage.java @@ -1,8 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.result; -import com.yahoo.api.annotations.Beta; - /** * The coverage report for a result set. * @@ -26,11 +24,10 @@ public class Coverage extends com.yahoo.container.handler.Coverage { /** * Will set number of documents present in ideal state * - * @param soonActive number of documents active in ideal state + * @param targetActive number of documents active in ideal state * @return self for chaining */ - @Beta - public Coverage setSoonActive(long soonActive) { this.soonActive = soonActive; return this; } + public Coverage setTargetActive(long targetActive) { this.targetActive = targetActive; return this; } /** * Will set the reasons for degraded coverage as reported by vespa backend. diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java index 1293975deb5..a88046197e0 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java @@ -436,9 +436,9 @@ public class InterleavedSearchInvokerTest { }; } - private static Coverage createCoverage(int docs, int activeDocs, int soonActiveDocs, int nodes, int nodesTried, int degradedReason) { + private static Coverage createCoverage(int docs, int activeDocs, int targetActiveDocs, int nodes, int nodesTried, int degradedReason) { Coverage coverage = new Coverage(docs, activeDocs, nodes); - coverage.setSoonActive(soonActiveDocs); + coverage.setTargetActive(targetActiveDocs); coverage.setNodesTried(nodesTried); coverage.setDegradedReason(degradedReason); return coverage; diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java index 473b24af19f..6c46b2a492f 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java @@ -124,7 +124,7 @@ public class SearchClusterTest { int docs = numDocs.get(); pongHandler.handle ((docs < 0) ? new Pong(ErrorMessage.createBackendCommunicationError("Negative numDocs = " + docs)) - : new Pong(docs)); + : new Pong(docs, docs)); pingCount.incrementAndGet(); } } diff --git a/container-search/src/test/java/com/yahoo/search/result/test/CoverageTestCase.java b/container-search/src/test/java/com/yahoo/search/result/test/CoverageTestCase.java index c0b0a90b682..f59a7a94f0a 100644 --- a/container-search/src/test/java/com/yahoo/search/result/test/CoverageTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/result/test/CoverageTestCase.java @@ -74,7 +74,7 @@ public class CoverageTestCase { com.yahoo.container.logging.Coverage lc = c.toLoggingCoverage(); assertEquals(lc.getDocs(), c.getDocs()); assertEquals(lc.getActive(), c.getActive()); - assertEquals(lc.getSoonActive(), c.getSoonActive()); + assertEquals(lc.getTargetActive(), c.getTargetActive()); assertEquals(lc.getResultPercentage(), c.getResultPercentage()); assertEquals(lc.isDegraded(), c.isDegraded()); assertEquals(lc.isDegradedByNonIdealState(), c.isDegradedByNonIdealState()); diff --git a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp index a9a75a1fc7a..45ec3824c11 100644 --- a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp +++ b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp @@ -2,6 +2,7 @@ #include <vespa/searchcore/proton/attribute/imported_attributes_repo.h> #include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/searchcore/proton/common/hw_info.h> #include <vespa/searchcore/proton/feedoperation/operations.h> #include <vespa/searchcore/proton/initializer/task_runner.h> diff --git a/searchcore/src/tests/proton/documentdb/documentbucketmover/bucketmover_common.cpp b/searchcore/src/tests/proton/documentdb/documentbucketmover/bucketmover_common.cpp index 42e85f2909f..1d8585666b8 100644 --- a/searchcore/src/tests/proton/documentdb/documentbucketmover/bucketmover_common.cpp +++ b/searchcore/src/tests/proton/documentdb/documentbucketmover/bucketmover_common.cpp @@ -2,6 +2,7 @@ #include "bucketmover_common.h" #include <vespa/searchcore/proton/documentmetastore/documentmetastore.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/vespalib/testkit/test_macros.h> using vespalib::IDestructorCallback; @@ -58,8 +59,7 @@ void MySubDb::insertDocs(const UserDocuments &docs_) { for (const auto & entry : docs_) { const auto & bucketDocs = entry.second; - for (size_t i = 0; i < bucketDocs.getDocs().size(); ++i) { - const auto & testDoc = bucketDocs.getDocs()[i]; + for (const auto & testDoc : bucketDocs.getDocs()) { _metaStore.put(testDoc.getGid(), testDoc.getBucket(), testDoc.getTimestamp(), testDoc.getDocSize(), testDoc.getLid(), 0u); _realRetriever->_docs.push_back(testDoc.getDoc()); diff --git a/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp b/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp index 2db34e45140..84ce40589a3 100644 --- a/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp @@ -4,6 +4,7 @@ #include <vespa/searchcore/proton/server/bucketmovejob.h> #include <vespa/searchcore/proton/server/executor_thread_service.h> #include <vespa/searchcore/proton/server/document_db_maintenance_config.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/persistence/dummyimpl/dummy_bucket_executor.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/vespalib/util/lambdatask.h> diff --git a/searchcore/src/tests/proton/documentdb/documentbucketmover/documentmover_test.cpp b/searchcore/src/tests/proton/documentdb/documentbucketmover/documentmover_test.cpp index 8d0d11295cd..b65beb5d231 100644 --- a/searchcore/src/tests/proton/documentdb/documentbucketmover/documentmover_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentbucketmover/documentmover_test.cpp @@ -3,6 +3,7 @@ #include "bucketmover_common.h" #include <vespa/searchcore/proton/server/documentbucketmover.h> #include <vespa/searchcore/proton/common/pendinglidtracker.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/vespalib/gtest/gtest.h> #include <vespa/log/log.h> @@ -18,7 +19,7 @@ struct MySubDbTwoBuckets : public MySubDb std::shared_ptr<bucketdb::BucketDBOwner> bucketDB, uint32_t subDbId, SubDbType subDbType) - : MySubDb(builder.getRepo(), bucketDB, subDbId, subDbType) + : MySubDb(builder.getRepo(), std::move(bucketDB), subDbId, subDbType) { builder.createDocs(1, 1, 6); builder.createDocs(2, 6, 9); diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index f9518cb1b5e..e89d5eef078 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -12,6 +12,7 @@ #include <vespa/eval/eval/tensor_spec.h> #include <vespa/eval/eval/value.h> #include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/searchcore/proton/test/bucketfactory.h> #include <vespa/searchcore/proton/common/feedtoken.h> #include <vespa/searchcore/proton/feedoperation/moveoperation.h> diff --git a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp index f5ac3cd8c13..c62226ad363 100644 --- a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp +++ b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp @@ -4,6 +4,7 @@ #include <vespa/persistence/spi/bucket_limits.h> #include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h> #include <vespa/searchcore/proton/bucketdb/checksumaggregators.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/searchcore/proton/bucketdb/i_bucket_create_listener.h> #include <vespa/searchcore/proton/common/hw_info.h> #include <vespa/searchcore/proton/documentmetastore/documentmetastore.h> diff --git a/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp b/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp index 07fd4ac6fc3..48ff1dac93a 100644 --- a/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp +++ b/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp @@ -65,17 +65,17 @@ struct DBConfigFixture { return schema; } - RankingConstants::SP buildRankingConstants() + static RankingConstants::SP buildRankingConstants() { return std::make_shared<RankingConstants>(); } - RankingExpressions::SP buildRankingExpressions() + static RankingExpressions::SP buildRankingExpressions() { return std::make_shared<RankingExpressions>(); } - OnnxModels::SP buildOnnxModels() + static OnnxModels::SP buildOnnxModels() { return std::make_shared<OnnxModels>(); } @@ -96,8 +96,8 @@ struct DBConfigFixture { std::make_shared<AttributesConfig>(_attributesBuilder), std::make_shared<SummaryConfig>(_summaryBuilder), std::make_shared<JuniperrcConfig>(_juniperrcBuilder), - documentTypes, - repo, + std::move(documentTypes), + std::move(repo), std::make_shared<ImportedFieldsConfig>(_importedFieldsBuilder), std::make_shared<TuneFileDocumentDB>(), buildSchema(), @@ -121,7 +121,7 @@ struct ConfigFixture { int64_t _generation; std::shared_ptr<ProtonConfigSnapshot> _cachedConfigSnapshot; - ConfigFixture(const std::string & id) + explicit ConfigFixture(const std::string & id) : _configId(id), _protonBuilder(), _documenttypesBuilder(), @@ -135,7 +135,7 @@ struct ConfigFixture { addDocType("_alwaysthere_", "default"); } - ~ConfigFixture() { } + ~ConfigFixture(); DBConfigFixture *addDocType(const std::string & name, const std::string& bucket_space) { DocumenttypesConfigBuilder::Documenttype dt; @@ -191,13 +191,13 @@ struct ConfigFixture { } BootstrapConfig::SP getBootstrapConfig(int64_t generation) const { - return BootstrapConfig::SP(new BootstrapConfig(generation, - BootstrapConfig::DocumenttypesConfigSP(new DocumenttypesConfig(_documenttypesBuilder)), - std::shared_ptr<const DocumentTypeRepo>(new DocumentTypeRepo(_documenttypesBuilder)), - BootstrapConfig::ProtonConfigSP(new ProtonConfig(_protonBuilder)), - std::make_shared<FiledistributorrpcConfig>(), - std::make_shared<BucketspacesConfig>(_bucketspacesBuilder), - std::make_shared<TuneFileDocumentDB>(), HwInfo())); + return std::make_shared<BootstrapConfig>(generation, + std::make_shared<DocumenttypesConfig>(_documenttypesBuilder), + std::make_shared<DocumentTypeRepo>(_documenttypesBuilder), + std::make_shared<ProtonConfig>(_protonBuilder), + std::make_shared<FiledistributorrpcConfig>(), + std::make_shared<BucketspacesConfig>(_bucketspacesBuilder), + std::make_shared<TuneFileDocumentDB>(), HwInfo()); } std::shared_ptr<ProtonConfigSnapshot> getConfigSnapshot() @@ -226,6 +226,8 @@ struct ConfigFixture { }; +ConfigFixture::~ConfigFixture() = default; + struct MyProtonConfigurerOwner; struct MyDocumentDBConfigOwner : public DocumentDBConfigOwner @@ -242,9 +244,9 @@ struct MyDocumentDBConfigOwner : public DocumentDBConfigOwner _owner(owner) { } - ~MyDocumentDBConfigOwner() { } + ~MyDocumentDBConfigOwner() override; - void reconfigure(const DocumentDBConfig::SP & config) override; + void reconfigure(DocumentDBConfig::SP config) override; document::BucketSpace getBucketSpace() const override { return _bucket_space; } }; @@ -256,13 +258,16 @@ struct MyLog : _log() { } + ~MyLog(); - void appendLog(vespalib::string logEntry) + void appendLog(const vespalib::string & logEntry) { _log.emplace_back(logEntry); } }; +MyLog::~MyLog() = default; + struct MyProtonConfigurerOwner : public IProtonConfigurerOwner, public MyLog { @@ -276,7 +281,7 @@ struct MyProtonConfigurerOwner : public IProtonConfigurerOwner, _dbs() { } - ~MyProtonConfigurerOwner() { } + ~MyProtonConfigurerOwner() override; std::shared_ptr<DocumentDBConfigOwner> addDocumentDB(const DocTypeName &docTypeName, document::BucketSpace bucketSpace, @@ -294,7 +299,7 @@ struct MyProtonConfigurerOwner : public IProtonConfigurerOwner, _dbs.insert(std::make_pair(docTypeName, db)); std::ostringstream os; os << "add db " << docTypeName.getName() << " " << documentDBConfig->getGeneration(); - _log.push_back(os.str()); + _log.emplace_back(os.str()); return db; } void removeDocumentDB(const DocTypeName &docTypeName) override { @@ -302,34 +307,37 @@ struct MyProtonConfigurerOwner : public IProtonConfigurerOwner, _dbs.erase(docTypeName); std::ostringstream os; os << "remove db " << docTypeName.getName(); - _log.push_back(os.str()); + _log.emplace_back(os.str()); } void applyConfig(const std::shared_ptr<BootstrapConfig> &bootstrapConfig) override { std::ostringstream os; os << "apply config " << bootstrapConfig->getGeneration(); - _log.push_back(os.str()); + _log.emplace_back(os.str()); } - void reconfigureDocumentDB(const vespalib::string &name, const DocumentDBConfig::SP &config) + void reconfigureDocumentDB(const vespalib::string &name, const DocumentDBConfig & config) { std::ostringstream os; - os << "reconf db " << name << " " << config->getGeneration(); - _log.push_back(os.str()); + os << "reconf db " << name << " " << config.getGeneration(); + _log.emplace_back(os.str()); } void sync() { _executor.sync(); } }; +MyProtonConfigurerOwner::~MyProtonConfigurerOwner() = default; +MyDocumentDBConfigOwner::~MyDocumentDBConfigOwner() = default; + void -MyDocumentDBConfigOwner::reconfigure(const DocumentDBConfig::SP & config) +MyDocumentDBConfigOwner::reconfigure(DocumentDBConfig::SP config) { - _owner.reconfigureDocumentDB(_name, config); + _owner.reconfigureDocumentDB(_name, *config); } struct MyProtonDiskLayout : public IProtonDiskLayout { MyLog &_log; - MyProtonDiskLayout(MyLog &myLog) + explicit MyProtonDiskLayout(MyLog &myLog) : _log(myLog) { } diff --git a/searchcore/src/tests/proton/server/feedstates_test.cpp b/searchcore/src/tests/proton/server/feedstates_test.cpp index e01d90f5eed..faffb8fe1de 100644 --- a/searchcore/src/tests/proton/server/feedstates_test.cpp +++ b/searchcore/src/tests/proton/server/feedstates_test.cpp @@ -10,13 +10,14 @@ #include <vespa/searchcore/proton/server/memoryconfigstore.h> #include <vespa/searchcore/proton/server/replay_throttling_policy.h> #include <vespa/searchcore/proton/feedoperation/removeoperation.h> +#include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/searchcore/proton/test/dummy_feed_view.h> #include <vespa/searchlib/common/serialnum.h> #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/util/foreground_thread_executor.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/buffer.h> -#include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h> #include <vespa/log/log.h> LOG_SETUP("feedstates_test"); @@ -56,7 +57,7 @@ struct MyReplayConfig : IReplayConfig { struct MyIncSerialNum : IIncSerialNum { SerialNum _serial_num; - MyIncSerialNum(SerialNum serial_num) + explicit MyIncSerialNum(SerialNum serial_num) : _serial_num(serial_num) { } diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_explorer.cpp b/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_explorer.cpp index 9d28d88ba4a..74c30e5340a 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_explorer.cpp +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_explorer.cpp @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "bucket_db_explorer.h" - #include <vespa/vespalib/data/slime/cursor.h> #include <vespa/vespalib/stllike/asciistream.h> diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_explorer.h b/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_explorer.h index 71448e6fad1..922ca9f1ad2 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_explorer.h +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_explorer.h @@ -16,7 +16,7 @@ private: bucketdb::Guard _bucketDb; public: - BucketDBExplorer(bucketdb::Guard bucketDb); + explicit BucketDBExplorer(bucketdb::Guard bucketDb); ~BucketDBExplorer() override; void get_state(const vespalib::slime::Inserter &inserter, bool full) const override; diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_owner.h b/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_owner.h index 2ad13576601..fbb31967c5a 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_owner.h +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_owner.h @@ -34,6 +34,7 @@ public: Guard takeGuard() { return Guard(&_bucketDB, _mutex); } + size_t getNumActiveDocs() const { return _bucketDB.getNumActiveDocs(); } private: BucketDB _bucketDB; std::mutex _mutex; diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h index 286c1e3aa45..2672a98f5a0 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h @@ -39,6 +39,8 @@ private: } public: BucketDB(); + BucketDB(const BucketDB &) = delete; + BucketDB & operator=(const BucketDB &) = delete; ~BucketDB(); const BucketState & add(const GlobalId &gid, @@ -81,8 +83,6 @@ public: // Must be called if buckets state aquired with getBucketStatePtr has been modified. void restoreIntegrity(); bool validateIntegrity() const; - }; } - diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.h b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.h index 2a423eaa213..f4cd23ef712 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.h +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.h @@ -2,13 +2,14 @@ #pragma once -#include "bucket_db_owner.h" #include "ibucketdbhandler.h" #include "ibucketdbhandlerinitializer.h" #include "bucket_create_notifier.h" namespace proton::bucketdb { +class BucketDBOwner; + /** * The BucketDBHandler class handles operations on a bucket db. */ @@ -34,10 +35,9 @@ private: BucketCreateNotifier _bucketCreateNotifier; public: - BucketDBHandler(BucketDBOwner &bucketDB); - ~BucketDBHandler(); + explicit BucketDBHandler(BucketDBOwner &bucketDB); + ~BucketDBHandler() override; - void setBucketDB(BucketDBOwner &bucketDB); void addDocumentMetaStore(IDocumentMetaStore *dms, search::SerialNum flushedSerialNum) override; void handleSplit(search::SerialNum serialNum, const BucketId &source, const BucketId &target1, const BucketId &target2) override; diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp index efc41d2de03..bade54a2adc 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp @@ -19,7 +19,7 @@ DocumentMetaStoreInitializer:: DocumentMetaStoreInitializer(const vespalib::string baseDir, const vespalib::string &subDbName, const vespalib::string &docTypeName, - DocumentMetaStore::SP dms) + std::shared_ptr<DocumentMetaStore> dms) : _baseDir(baseDir), _subDbName(subDbName), _docTypeName(docTypeName), diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.h index 811c3087b3b..fe370489d7e 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.h @@ -2,12 +2,11 @@ #pragma once -#include "documentmetastore.h" -#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/searchcore/proton/initializer/initializer_task.h> #include <vespa/searchcommon/common/growstrategy.h> #include <vespa/vespalib/stllike/string.h> +namespace proton { class DocumentMetaStore; } namespace proton::documentmetastore { /* @@ -16,10 +15,10 @@ namespace proton::documentmetastore { */ class DocumentMetaStoreInitializer : public initializer::InitializerTask { - vespalib::string _baseDir; - vespalib::string _subDbName; - vespalib::string _docTypeName; - DocumentMetaStore::SP _dms; + vespalib::string _baseDir; + vespalib::string _subDbName; + vespalib::string _docTypeName; + std::shared_ptr<DocumentMetaStore> _dms; public: using SP = std::shared_ptr<DocumentMetaStoreInitializer>; @@ -28,7 +27,7 @@ public: DocumentMetaStoreInitializer(const vespalib::string baseDir, const vespalib::string &subDbName, const vespalib::string &docTypeName, - DocumentMetaStore::SP dms); + std::shared_ptr<DocumentMetaStore> dms); void run() override; }; diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp index 6dc1b2b354e..26ab2d10671 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp @@ -277,7 +277,7 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl SearchReply::Coverage & coverage = reply->coverage; coverage.setActive(numActiveLids); //TODO this should be calculated with ClusterState calculator. - coverage.setSoonActive(numActiveLids); + coverage.setTargetActive(numActiveLids); coverage.setCovered(covered); if (wasLimited) { coverage.degradeMatchPhase(); diff --git a/searchcore/src/vespa/searchcore/proton/server/document_db_config_owner.h b/searchcore/src/vespa/searchcore/proton/server/document_db_config_owner.h index cfdcea24e4c..37741886def 100644 --- a/searchcore/src/vespa/searchcore/proton/server/document_db_config_owner.h +++ b/searchcore/src/vespa/searchcore/proton/server/document_db_config_owner.h @@ -18,7 +18,7 @@ class DocumentDBConfigOwner : public IDocumentDBConfigOwner std::shared_ptr<DocumentDBDirectoryHolder> _holder; public: DocumentDBConfigOwner(); - virtual ~DocumentDBConfigOwner(); + ~DocumentDBConfigOwner() override; std::shared_ptr<DocumentDBDirectoryHolder> getDocumentDBDirectoryHolder(); }; diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 51c02c818b2..2ae7e38cf4a 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -30,6 +30,7 @@ #include <vespa/searchcore/proton/persistenceengine/commit_and_wait_document_retriever.h> #include <vespa/searchcore/proton/reference/document_db_reference_resolver.h> #include <vespa/searchcore/proton/reference/i_document_db_reference_registry.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/searchlib/attribute/configconverter.h> #include <vespa/searchlib/engine/docsumreply.h> #include <vespa/searchlib/engine/searchreply.h> @@ -119,10 +120,10 @@ public: template<typename T> void -forceCommitAndWait(std::shared_ptr<IFeedView> feedView, SerialNum serialNum, T keepAlive) { +forceCommitAndWait(IFeedView & feedView, SerialNum serialNum, T keepAlive) { vespalib::Gate gate; using Keep = vespalib::KeepAlive<std::pair<T, std::shared_ptr<IDestructorCallback>>>; - feedView->forceCommit(CommitParam(serialNum), + feedView.forceCommit(CommitParam(serialNum), std::make_shared<Keep>(std::make_pair(std::move(keepAlive), std::make_shared<GateCallback>(gate)))); gate.await(); } @@ -157,7 +158,7 @@ DocumentDB::create(const vespalib::string &baseDir, new DocumentDB(baseDir, std::move(currentSnapshot), tlsSpec, queryLimiter, docTypeName, bucketSpace, protonCfg, owner, shared_service, tlsWriterFactory, metricsWireService, fileHeaderContext, std::move(attribute_interlock), - std::move(config_store), initializeThreads, hwInfo)); + std::move(config_store), std::move(initializeThreads), hwInfo)); } DocumentDB::DocumentDB(const vespalib::string &baseDir, DocumentDBConfig::SP configSnapshot, @@ -268,11 +269,11 @@ DocumentDB::registerReference() } void -DocumentDB::setActiveConfig(const DocumentDBConfig::SP &config, int64_t generation) { +DocumentDB::setActiveConfig(DocumentDBConfig::SP config, int64_t generation) { lock_guard guard(_configMutex); registerReference(); - _activeConfigSnapshot = config; assert(generation >= config->getGeneration()); + _activeConfigSnapshot = std::move(config); if (_activeConfigSnapshotGeneration < generation) { _activeConfigSnapshotGeneration = generation; } @@ -342,7 +343,8 @@ DocumentDB::initFinish(DocumentDBConfig::SP configSnapshot) syncFeedView(); // Check that feed view has been activated. assert(_feedView.get()); - setActiveConfig(configSnapshot, configSnapshot->getGeneration()); + int64_t generation = configSnapshot->getGeneration(); + setActiveConfig(std::move(configSnapshot), generation); startTransactionLogReplay(); } @@ -351,7 +353,7 @@ void DocumentDB::newConfigSnapshot(DocumentDBConfig::SP snapshot) { // Called by executor thread - _pendingConfigSnapshot.set(snapshot); + _pendingConfigSnapshot.set(std::move(snapshot)); { lock_guard guard(_configMutex); if ( ! _activeConfigSnapshot) { @@ -428,7 +430,7 @@ DocumentDB::applySubDBConfig(const DocumentDBConfig &newConfigSnapshot, auto oldRepo = _activeConfigSnapshot->getDocumentTypeRepoSP(); auto oldDocType = oldRepo->getDocumentType(_docTypeName.getName()); assert(oldDocType != nullptr); - auto newRepo = newConfigSnapshot.getDocumentTypeRepoSP(); + const auto & newRepo = newConfigSnapshot.getDocumentTypeRepoSP(); auto newDocType = newRepo->getDocumentType(_docTypeName.getName()); assert(newDocType != nullptr); DocumentDBReferenceResolver resolver(*registry, *newDocType, newConfigSnapshot.getImportedFieldsConfig(), *oldDocType, @@ -487,7 +489,7 @@ DocumentDB::applyConfig(DocumentDBConfig::SP configSnapshot, SerialNum serialNum } { bool elidedConfigSave = equalReplayConfig && tlsReplayDone; - forceCommitAndWait(_feedView.get(), elidedConfigSave ? serialNum : serialNum - 1, std::move(commit_result)); + forceCommitAndWait(*_feedView.get(), elidedConfigSave ? serialNum : serialNum - 1, std::move(commit_result)); } if (params.shouldMaintenanceControllerChange()) { _maintenanceController.killJobs(); @@ -619,13 +621,13 @@ DocumentDB::getNumDocs() const } } -size_t +std::pair<size_t, size_t> DocumentDB::getNumActiveDocs() const { if (_state.get_load_done()) { - return _subDBs.getReadySubDB()->getNumActiveDocs(); + return { _subDBs.getReadySubDB()->getNumActiveDocs(), _subDBs.getBucketDB().getNumActiveDocs() }; } else { - return 0u; + return {0u, 0u}; } } @@ -805,9 +807,9 @@ DocumentDB::setIndexSchema(const DocumentDBConfig &configSnapshot, SerialNum ser } void -DocumentDB::reconfigure(const DocumentDBConfig::SP & snapshot) +DocumentDB::reconfigure(DocumentDBConfig::SP snapshot) { - masterExecute([this, snapshot]() { newConfigSnapshot(snapshot); }); + masterExecute([this, snapshot=std::move(snapshot)]() mutable { newConfigSnapshot(std::move(snapshot)); }); // Wait for config to be applied, or for document db close std::unique_lock<std::mutex> guard(_configMutex); while ((_activeConfigSnapshotGeneration < snapshot->getGeneration()) && !_state.getClosed()) { @@ -1010,7 +1012,7 @@ DocumentDB::notifyClusterStateChanged(const std::shared_ptr<IBucketStateCalculat IFeedView::SP feedView(_feedView.get()); if (feedView) { // Try downcast to avoid polluting API - CombiningFeedView *cfv = dynamic_cast<CombiningFeedView *>(feedView.get()); + auto *cfv = dynamic_cast<CombiningFeedView *>(feedView.get()); if (cfv != nullptr) cfv->setCalculator(newCalc); } diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.h b/searchcore/src/vespa/searchcore/proton/server/documentdb.h index 96944ba25e7..9d7e98e0db4 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.h @@ -126,7 +126,7 @@ private: DocumentDBMetricsUpdater _metricsUpdater; void registerReference(); - void setActiveConfig(const DocumentDBConfigSP &config, int64_t generation); + void setActiveConfig(DocumentDBConfigSP config, int64_t generation); DocumentDBConfigSP getActiveConfig() const; void internalInit(); void initManagers(); @@ -297,11 +297,12 @@ public: size_t getNumDocs() const; /** - * Returns the number of documents that are active for search in this database. + * Returns the number of documents that are active for search in this database, + * and the number of documents that will be active once ideal state is reached. * - * @return The active-document count. + * @return The active and target-active document count. */ - size_t getNumActiveDocs() const; + std::pair<size_t, size_t> getNumActiveDocs() const; /** * Returns the base directory that this document database uses when @@ -370,7 +371,7 @@ public: void replayConfig(SerialNum serialNum) override; const DocTypeName & getDocTypeName() const { return _docTypeName; } void newConfigSnapshot(DocumentDBConfigSP snapshot); - void reconfigure(const DocumentDBConfigSP & snapshot) override; + void reconfigure(DocumentDBConfigSP snapshot) override; int64_t getActiveGeneration() const; /* * Implements IDocumentSubDBOwner diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp index 1cd27783a39..945570c5b3b 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp @@ -8,6 +8,7 @@ #include "searchabledocsubdb.h" #include <vespa/searchcore/proton/persistenceengine/commit_and_wait_document_retriever.h> #include <vespa/searchcore/proton/metrics/documentdb_tagged_metrics.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/vespalib/util/lambdatask.h> #include <vespa/vespalib/util/threadstackexecutor.h> diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h index f5654fb661d..8c1e670454c 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h @@ -118,6 +118,7 @@ public: const_iterator end() const { return _subDBs.end(); } bucketdb::BucketDBOwner &getBucketDB() { return *_bucketDB; } + const bucketdb::BucketDBOwner &getBucketDB() const { return *_bucketDB; } bucketdb::IBucketDBHandler &getBucketDBHandler() { return *_bucketDBHandler; diff --git a/searchcore/src/vespa/searchcore/proton/server/i_document_db_config_owner.h b/searchcore/src/vespa/searchcore/proton/server/i_document_db_config_owner.h index 7e1dda917f8..c22b02c968e 100644 --- a/searchcore/src/vespa/searchcore/proton/server/i_document_db_config_owner.h +++ b/searchcore/src/vespa/searchcore/proton/server/i_document_db_config_owner.h @@ -16,9 +16,9 @@ class DocumentDBConfig; class IDocumentDBConfigOwner { public: - virtual ~IDocumentDBConfigOwner() { } + virtual ~IDocumentDBConfigOwner() = default; virtual document::BucketSpace getBucketSpace() const = 0; - virtual void reconfigure(const std::shared_ptr<DocumentDBConfig> & config) = 0; + virtual void reconfigure(std::shared_ptr<DocumentDBConfig> config) = 0; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/i_proton_configurer_owner.h b/searchcore/src/vespa/searchcore/proton/server/i_proton_configurer_owner.h index 704b54dc566..432a5c30d03 100644 --- a/searchcore/src/vespa/searchcore/proton/server/i_proton_configurer_owner.h +++ b/searchcore/src/vespa/searchcore/proton/server/i_proton_configurer_owner.h @@ -18,7 +18,7 @@ class IProtonConfigurerOwner { public: using InitializeThreads = std::shared_ptr<vespalib::ThreadExecutor>; - virtual ~IProtonConfigurerOwner() { } + virtual ~IProtonConfigurerOwner() = default; virtual std::shared_ptr<DocumentDBConfigOwner> addDocumentDB(const DocTypeName &docTypeName, document::BucketSpace bucketSpace, const vespalib::string &configId, diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp index c4b30d50dbd..51e131d5548 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp @@ -115,11 +115,10 @@ setFS4Compression(const ProtonConfig & proton) DiskMemUsageSampler::Config diskMemUsageSamplerConfig(const ProtonConfig &proton, const HwInfo &hwInfo) { - return DiskMemUsageSampler::Config( - proton.writefilter.memorylimit, - proton.writefilter.disklimit, - vespalib::from_s(proton.writefilter.sampleinterval), - hwInfo); + return { proton.writefilter.memorylimit, + proton.writefilter.disklimit, + vespalib::from_s(proton.writefilter.sampleinterval), + hwInfo }; } uint32_t @@ -135,7 +134,7 @@ computeRpcTransportThreads(const ProtonConfig & cfg, const HwInfo::Cpu &cpuInfo) struct MetricsUpdateHook : metrics::UpdateHook { Proton &self; - MetricsUpdateHook(Proton &s) + explicit MetricsUpdateHook(Proton &s) : metrics::UpdateHook("proton-hook"), self(s) {} @@ -427,14 +426,14 @@ Proton::addDocumentDB(const DocTypeName &docTypeName, "Did not find document type '%s' in the document manager. " "Skipping creating document database for this type", docTypeName.toString().c_str()); - return std::shared_ptr<DocumentDBConfigOwner>(); + return {}; } } catch (const document::DocumentTypeNotFoundException & e) { LOG(warning, "Did not find document type '%s' in the document manager. " "Skipping creating document database for this type", docTypeName.toString().c_str()); - return std::shared_ptr<DocumentDBConfigOwner>(); + return {}; } } @@ -537,14 +536,17 @@ size_t Proton::getNumDocs() const return numDocs; } -size_t Proton::getNumActiveDocs() const +std::pair<size_t, size_t> +Proton::getNumActiveDocs() const { - size_t numDocs(0); + size_t activeDocs(0), targetActiveDocs(0); std::shared_lock<std::shared_mutex> guard(_mutex); for (const auto &kv : _documentDBMap) { - numDocs += kv.second->getNumActiveDocs(); + const auto & docs = kv.second->getNumActiveDocs(); + activeDocs += docs.first; + targetActiveDocs += docs.second; } - return numDocs; + return {activeDocs, targetActiveDocs}; } search::engine::SearchServer & @@ -725,8 +727,16 @@ Proton::ping(std::unique_ptr<MonitorRequest>, MonitorClient &) BootstrapConfig::SP configSnapshot = getActiveConfigSnapshot(); const ProtonConfig &protonConfig = configSnapshot->getProtonConfig(); ret.distribution_key = protonConfig.distributionkey; - ret.timestamp = (_matchEngine->isOnline()) ? 42 : 0; - ret.activeDocs = (_matchEngine->isOnline()) ? getNumActiveDocs() : 0; + if (_matchEngine->isOnline()) { + ret.timestamp = 42; + auto [active, targetActive] = getNumActiveDocs(); + ret.activeDocs = active; + ret.targetActiveDocs = targetActive; + } else { + ret.timestamp = 0; + ret.activeDocs = 0; + ret.targetActiveDocs = 0; // TODO vekterli hmm... or target anyway ... + } ret.is_blocking_writes = !_diskMemUsageSampler->writeFilter().acceptWriteOperation(); return reply; } diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.h b/searchcore/src/vespa/searchcore/proton/server/proton.h index 6e154159ecc..4c4bf87ee8e 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.h +++ b/searchcore/src/vespa/searchcore/proton/server/proton.h @@ -24,7 +24,6 @@ #include <vespa/vespalib/net/http/json_get_handler.h> #include <vespa/vespalib/net/http/json_handler_repo.h> #include <vespa/vespalib/net/http/state_explorer.h> -#include <vespa/vespalib/util/varholder.h> #include <vespa/vespalib/util/cpu_usage.h> #include <mutex> #include <shared_mutex> @@ -198,7 +197,8 @@ public: int64_t getConfigGeneration(); size_t getNumDocs() const; - size_t getNumActiveDocs() const; + // Active (searchable), and targetActive that will be searchable when idealstate is reached + std::pair<size_t, size_t> getNumActiveDocs() const; search::engine::SearchServer &get_search_server(); search::engine::DocsumServer &get_docsum_server(); diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp index 2c891927fa3..4877d8a7cfa 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp @@ -61,7 +61,7 @@ ProtonConfigurer::ProtonConfigurer(vespalib::ThreadExecutor &executor, class ProtonConfigurer::ReconfigureTask : public vespalib::Executor::Task { public: - ReconfigureTask(ProtonConfigurer & configurer) + explicit ReconfigureTask(ProtonConfigurer & configurer) : _configurer(configurer), _retainGuard(configurer._pendingReconfigureTasks) {} @@ -169,7 +169,7 @@ ProtonConfigurer::applyConfig(std::shared_ptr<ProtonConfigSnapshot> configSnapsh size_t gen = bootstrapConfig->getGeneration(); _componentConfig.addConfig({"proton", gen}); std::lock_guard<std::mutex> guard(_mutex); - _activeConfigSnapshot = configSnapshot; + _activeConfigSnapshot = std::move(configSnapshot); } void @@ -177,7 +177,7 @@ ProtonConfigurer::configureDocumentDB(const ProtonConfigSnapshot &configSnapshot const DocTypeName &docTypeName, document::BucketSpace bucketSpace, const vespalib::string &configId, - const InitializeThreads &initializeThreads) + InitializeThreads initializeThreads) { // called by proton executor thread const auto &bootstrapConfig = configSnapshot.getBootstrapConfig(); @@ -187,7 +187,7 @@ ProtonConfigurer::configureDocumentDB(const ProtonConfigSnapshot &configSnapshot const auto &documentDBConfig = cfgitr->second; auto dbitr(_documentDBs.find(docTypeName)); if (dbitr == _documentDBs.end()) { - auto newdb = _owner.addDocumentDB(docTypeName, bucketSpace, configId, bootstrapConfig, documentDBConfig, initializeThreads); + auto newdb = _owner.addDocumentDB(docTypeName, bucketSpace, configId, bootstrapConfig, documentDBConfig, std::move(initializeThreads)); if (newdb) { auto insres = _documentDBs.insert(std::make_pair(docTypeName, std::make_pair(newdb, newdb->getDocumentDBDirectoryHolder()))); assert(insres.second); @@ -251,7 +251,10 @@ ProtonConfigurer::applyInitialConfig(InitializeThreads initializeThreads) assert(!_executor.isCurrentThread()); std::promise<void> promise; auto future = promise.get_future(); - _executor.execute(makeLambdaTask([this, initializeThreads, &promise]() { applyConfig(getPendingConfigSnapshot(), initializeThreads, true); promise.set_value(); })); + _executor.execute(makeLambdaTask([this, executor=std::move(initializeThreads), &promise]() mutable { + applyConfig(getPendingConfigSnapshot(), std::move(executor), true); + promise.set_value(); + })); future.wait(); } diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_configurer.h b/searchcore/src/vespa/searchcore/proton/server/proton_configurer.h index 0ccf1b1a348..e9affb91d44 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton_configurer.h +++ b/searchcore/src/vespa/searchcore/proton/server/proton_configurer.h @@ -46,7 +46,7 @@ class ProtonConfigurer : public IProtonConfigurer InitializeThreads initializeThreads, bool initialConfig); void configureDocumentDB(const ProtonConfigSnapshot &configSnapshot, const DocTypeName &docTypeName, document::BucketSpace bucketSpace, - const vespalib::string &configId, const InitializeThreads &initializeThreads); + const vespalib::string &configId, InitializeThreads initializeThreads); void pruneDocumentDBs(const ProtonConfigSnapshot &configSnapshot); void pruneInitialDocumentDBDirs(const ProtonConfigSnapshot &configSnapshot); @@ -63,7 +63,7 @@ public: std::shared_ptr<ProtonConfigSnapshot> getActiveConfigSnapshot() const; - virtual void reconfigure(std::shared_ptr<ProtonConfigSnapshot> configSnapshot) override; + void reconfigure(std::shared_ptr<ProtonConfigSnapshot> configSnapshot) override; void applyInitialConfig(InitializeThreads initializeThreads); vespalib::SimpleComponentConfigProducer &getComponentConfig() { return _componentConfig; } diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h index 315587dd5ed..d264a625e96 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h @@ -19,7 +19,6 @@ #include <vespa/searchcore/proton/matching/ranking_assets_repo.h> #include <vespa/searchcorespi/index/iindexmanager.h> #include <vespa/vespalib/util/blockingthreadstackexecutor.h> -#include <vespa/vespalib/util/varholder.h> namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h index 178ed73aef5..cb1f1ed07bb 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h @@ -5,7 +5,6 @@ #include "storeonlyfeedview.h" #include "summaryadapter.h" #include "tlssyncer.h" -#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/searchcore/proton/common/doctypename.h> #include <vespa/searchcore/proton/common/subdbtype.h> #include <vespa/searchcore/proton/docsummary/summarymanager.h> @@ -48,7 +47,7 @@ public: _tlSyncer(tlSyncer) { } - virtual ~DocSubDB() { } + ~DocSubDB() override = default; void close() override { } }; @@ -68,7 +67,7 @@ public: StoreOnlySubDBFileHeaderContext(const search::common::FileHeaderContext & parentFileHeaderContext, const DocTypeName &docTypeName, const vespalib::string &baseDir); - ~StoreOnlySubDBFileHeaderContext(); + ~StoreOnlySubDBFileHeaderContext() override; void addTags(vespalib::GenericHeader &header, const vespalib::string &name) const override; }; diff --git a/searchlib/src/protobuf/search_protocol.proto b/searchlib/src/protobuf/search_protocol.proto index 3cf2f01a7a8..1be68abad04 100644 --- a/searchlib/src/protobuf/search_protocol.proto +++ b/searchlib/src/protobuf/search_protocol.proto @@ -46,7 +46,7 @@ message SearchReply { int64 total_hit_count = 1; int64 coverage_docs = 2; int64 active_docs = 3; - int64 soon_active_docs = 4; + int64 target_active_docs = 4; bool degraded_by_match_phase = 5; bool degraded_by_soft_timeout = 6; repeated Hit hits = 7; @@ -104,4 +104,5 @@ message MonitorReply { int64 active_docs = 2; int32 distribution_key = 3; bool is_blocking_writes = 4; + int64 target_active_docs = 5; } diff --git a/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp b/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp index 3091d167399..bd40a4566cd 100644 --- a/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp +++ b/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp @@ -246,10 +246,10 @@ TEST_F(SearchReplyTest, require_that_active_docs_is_converted) { EXPECT_EQ(proto.active_docs(), 200000); } -TEST_F(SearchReplyTest, require_that_soon_active_docs_is_converted) { - reply.coverage.setSoonActive(250000); +TEST_F(SearchReplyTest, require_that_target_active_docs_is_converted) { + reply.coverage.setTargetActive(250000); convert(); - EXPECT_EQ(proto.soon_active_docs(), 250000); + EXPECT_EQ(proto.target_active_docs(), 250000); } TEST_F(SearchReplyTest, require_that_degraded_by_match_phase_is_converted) { @@ -594,6 +594,11 @@ TEST_F(MonitorReplyTest, require_that_active_docs_is_converted) { convert(); EXPECT_EQ(proto.active_docs(), 12345); } +TEST_F(MonitorReplyTest, require_that_target_active_docs_is_converted) { + reply.targetActiveDocs = 12345; + convert(); + EXPECT_EQ(proto.target_active_docs(), 12345); +} TEST_F(MonitorReplyTest, require_that_distribution_key_is_converted) { reply.distribution_key = 7; diff --git a/searchlib/src/vespa/searchlib/engine/monitorreply.cpp b/searchlib/src/vespa/searchlib/engine/monitorreply.cpp index 44a00638661..139c377a626 100644 --- a/searchlib/src/vespa/searchlib/engine/monitorreply.cpp +++ b/searchlib/src/vespa/searchlib/engine/monitorreply.cpp @@ -6,6 +6,7 @@ namespace search::engine { MonitorReply::MonitorReply() : activeDocs(0), + targetActiveDocs(0), distribution_key(-1), timestamp(), is_blocking_writes(false) diff --git a/searchlib/src/vespa/searchlib/engine/monitorreply.h b/searchlib/src/vespa/searchlib/engine/monitorreply.h index 52948e9f963..7e0af9be63a 100644 --- a/searchlib/src/vespa/searchlib/engine/monitorreply.h +++ b/searchlib/src/vespa/searchlib/engine/monitorreply.h @@ -9,6 +9,7 @@ namespace search::engine { struct MonitorReply { uint64_t activeDocs; + uint64_t targetActiveDocs; int32_t distribution_key; uint32_t timestamp; bool is_blocking_writes; diff --git a/searchlib/src/vespa/searchlib/engine/proto_converter.cpp b/searchlib/src/vespa/searchlib/engine/proto_converter.cpp index 8d06dcc10e6..842ced502c6 100644 --- a/searchlib/src/vespa/searchlib/engine/proto_converter.cpp +++ b/searchlib/src/vespa/searchlib/engine/proto_converter.cpp @@ -101,7 +101,7 @@ ProtoConverter::search_reply_to_proto(const SearchReply &reply, ProtoSearchReply proto.set_total_hit_count(reply.totalHitCount); proto.set_coverage_docs(reply.coverage.getCovered()); proto.set_active_docs(reply.coverage.getActive()); - proto.set_soon_active_docs(reply.coverage.getSoonActive()); + proto.set_target_active_docs(reply.coverage.getTargetActive()); proto.set_degraded_by_match_phase(reply.coverage.wasDegradedByMatchPhase()); proto.set_degraded_by_soft_timeout(reply.coverage.wasDegradedByTimeout()); bool has_sort_data = ! reply.sortIndex.empty(); @@ -228,6 +228,7 @@ ProtoConverter::monitor_reply_to_proto(const MonitorReply &reply, ProtoMonitorRe { proto.set_online(reply.timestamp != 0); proto.set_active_docs(reply.activeDocs); + proto.set_target_active_docs(reply.targetActiveDocs); proto.set_distribution_key(reply.distribution_key); proto.set_is_blocking_writes(reply.is_blocking_writes); } diff --git a/searchlib/src/vespa/searchlib/engine/searchreply.h b/searchlib/src/vespa/searchlib/engine/searchreply.h index 25418a698c2..fc64566acf1 100644 --- a/searchlib/src/vespa/searchlib/engine/searchreply.h +++ b/searchlib/src/vespa/searchlib/engine/searchreply.h @@ -28,38 +28,30 @@ public: class Coverage { public: Coverage() noexcept : Coverage(0) { } - Coverage(uint64_t active) noexcept : Coverage(active, active) { } + explicit Coverage(uint64_t active) noexcept : Coverage(active, active) { } Coverage(uint64_t active, uint64_t covered) noexcept - : _covered(covered), _active(active), _soonActive(active), - _degradeReason(0), _nodesQueried(1), _nodesReplied(1) + : _covered(covered), _active(active), _targetActive(active), + _degradeReason(0) { } uint64_t getCovered() const { return _covered; } uint64_t getActive() const { return _active; } - uint64_t getSoonActive() const { return _soonActive; } - uint32_t getDegradeReason() const { return _degradeReason; } - uint16_t getNodesQueried() const { return _nodesQueried; } - uint16_t getNodesReplied() const { return _nodesReplied; } + uint64_t getTargetActive() const { return _targetActive; } + bool wasDegradedByMatchPhase() const { return ((_degradeReason & MATCH_PHASE) != 0); } bool wasDegradedByTimeout() const { return ((_degradeReason & TIMEOUT) != 0); } Coverage & setCovered(uint64_t v) { _covered = v; return *this; } Coverage & setActive(uint64_t v) { _active = v; return *this; } - Coverage & setSoonActive(uint64_t v) { _soonActive = v; return *this; } - Coverage & setDegradeReason(uint32_t v) { _degradeReason = v; return *this; } - Coverage & setNodesQueried(uint16_t v) { _nodesQueried = v; return *this; } - Coverage & setNodesReplied(uint16_t v) { _nodesReplied = v; return *this; } + Coverage & setTargetActive(uint64_t v) { _targetActive = v; return *this; } Coverage & degradeMatchPhase() { _degradeReason |= MATCH_PHASE; return *this; } Coverage & degradeTimeout() { _degradeReason |= TIMEOUT; return *this; } - Coverage & degradeAdaptiveTimeout() { _degradeReason |= ADAPTIVE_TIMEOUT; return *this; } - enum DegradeReason {MATCH_PHASE=0x01, TIMEOUT=0x02, ADAPTIVE_TIMEOUT=0x04}; + enum DegradeReason {MATCH_PHASE=0x01, TIMEOUT=0x02}; private: uint64_t _covered; uint64_t _active; - uint64_t _soonActive; + uint64_t _targetActive; uint32_t _degradeReason; - uint16_t _nodesQueried; - uint16_t _nodesReplied; }; private: diff --git a/vespalib/src/vespa/vespalib/util/varholder.h b/vespalib/src/vespa/vespalib/util/varholder.h index c9bd9f1641a..db8109fca70 100644 --- a/vespalib/src/vespa/vespalib/util/varholder.h +++ b/vespalib/src/vespa/vespalib/util/varholder.h @@ -18,12 +18,12 @@ public: VarHolder & operator = (const VarHolder &) = delete; ~VarHolder(); - void set(const T &v) { + void set(T v) { T old; { std::lock_guard guard(_lock); - old = _v; - _v = v; + old = std::move(_v); + _v = std::move(v); } } |