summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-09-21 17:39:42 +0200
committerGitHub <noreply@github.com>2019-09-21 17:39:42 +0200
commit5944399213e87c5416b50297fd5dd87a63554992 (patch)
tree32ade303573e811e79b26ead964c000539daf229
parentff63348305a64c60c4225285c28a1f1c28754b57 (diff)
parentf0358c83a4684f62b3608aa59715319a74a58f59 (diff)
Merge pull request #10757 from vespa-engine/bratseth/cleanup-prelude-cluster
Remove unused classes and unused metric cache_hit_ratio
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java59
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/cluster/MonitorConfiguration.java51
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/cluster/NodeMonitor.java116
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java2
-rw-r--r--statistics/src/main/java/com/yahoo/statistics/Value.java5
5 files changed, 10 insertions, 223 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
index 37d8e316302..22af77020eb 100644
--- a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
@@ -24,7 +24,6 @@ import com.yahoo.search.query.ParameterParser;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.statistics.Statistics;
-import com.yahoo.statistics.Value;
import com.yahoo.vespa.config.search.DispatchConfig;
import com.yahoo.vespa.streamingvisitors.VdsStreamingSearcher;
import org.apache.commons.lang.StringUtils;
@@ -53,8 +52,6 @@ import static com.yahoo.container.QrSearchersConfig.Searchcluster.Indexingmode.S
@After("*")
public class ClusterSearcher extends Searcher {
- private final Value cacheHitRatio;
-
private final String clusterModelName;
// The set of document types contained in this search cluster
@@ -71,16 +68,12 @@ public class ClusterSearcher extends Searcher {
private VespaBackEndSearcher server = null;
- /**
- * Creates a new ClusterSearcher.
- */
public ClusterSearcher(ComponentId id,
QrSearchersConfig qrsConfig,
ClusterConfig clusterConfig,
DocumentdbInfoConfig documentDbConfig,
DispatchConfig dispatchConfig,
ClusterInfoConfig clusterInfoConfig,
- Statistics manager,
Metric metric,
FS4ResourcePool fs4ResourcePool,
VipStatus vipStatus) {
@@ -91,10 +84,6 @@ public class ClusterSearcher extends Searcher {
QrSearchersConfig.Searchcluster searchClusterConfig = getSearchClusterConfigFromClusterName(qrsConfig, clusterModelName);
documentTypes = new LinkedHashSet<>();
- String eventName = clusterModelName + ".cache_hit_ratio";
- cacheHitRatio = new Value(eventName, manager, new Value.Parameters().setNameExtension(false)
- .setLogRaw(false).setLogMean(true));
-
maxQueryTimeout = ParameterParser.asMilliSeconds(clusterConfig.maxQueryTimeout(), DEFAULT_MAX_QUERY_TIMEOUT);
maxQueryCacheTimeout = ParameterParser.asMilliSeconds(clusterConfig.maxQueryCacheTimeout(), DEFAULT_MAX_QUERY_CACHE_TIMEOUT);
@@ -162,8 +151,7 @@ public class ClusterSearcher extends Searcher {
SummaryParameters docSumParams,
DocumentdbInfoConfig documentdbInfoConfig,
Dispatcher dispatcher,
- int dispatcherIndex)
- {
+ int dispatcherIndex) {
ClusterParams clusterParams = makeClusterParams(searchclusterIndex, dispatcherIndex);
return new FastSearcher(serverId, dispatcher, docSumParams, clusterParams, documentdbInfoConfig);
}
@@ -172,8 +160,7 @@ public class ClusterSearcher extends Searcher {
int searchclusterIndex,
QrSearchersConfig.Searchcluster searchClusterConfig,
SummaryParameters docSumParams,
- DocumentdbInfoConfig documentdbInfoConfig)
- {
+ DocumentdbInfoConfig documentdbInfoConfig) {
if (searchClusterConfig.searchdef().size() != 1) {
throw new IllegalArgumentException("Search clusters in streaming search shall only contain a single searchdefinition : " + searchClusterConfig.searchdef());
}
@@ -189,8 +176,6 @@ public class ClusterSearcher extends Searcher {
/** Do not use, for internal testing purposes only. **/
ClusterSearcher(Set<String> documentTypes) {
this.documentTypes = documentTypes;
- cacheHitRatio = new Value("com.yahoo.prelude.cluster.ClusterSearcher.ClusterSearcher().dummy",
- Statistics.nullImplementation, new Value.Parameters());
clusterModelName = "testScenario";
maxQueryTimeout = DEFAULT_MAX_QUERY_TIMEOUT;
maxQueryCacheTimeout = DEFAULT_MAX_QUERY_CACHE_TIMEOUT;
@@ -270,7 +255,7 @@ public class ClusterSearcher extends Searcher {
VespaBackEndSearcher searcher = server;
if (searcher != null) {
if (query.getTimeLeft() > 0) {
- doFill(searcher, result, summaryClass, execution);
+ searcher.fill(result, summaryClass, execution);
} else {
if (result.hits().getErrorHit() == null) {
result.hits().addError(ErrorMessage.createTimeout("No time left to get summaries, query timeout was " + query.getTimeout() + " ms"));
@@ -283,23 +268,6 @@ public class ClusterSearcher extends Searcher {
}
}
- private void doFill(Searcher searcher, Result result, String summaryClass, Execution execution) {
- searcher.fill(result, summaryClass, execution);
- updateCacheHitRatio(result, result.getQuery());
- }
-
- private void updateCacheHitRatio(Result result, Query query) {
- // result.isCached() looks at the contained hits, so if there are no
- // hits, the result will be treated as cached, even though the backend was queried.
- if (result.hits().getError() == null && result.hits().getConcreteSize() > 0) {
- if (result.isCached()) {
- cacheHit();
- } else if (!query.getNoCache()) {
- cacheMiss();
- }
- }
- }
-
@Override
public Result search(Query query, Execution execution) {
validateQueryTimeout(query);
@@ -337,9 +305,8 @@ public class ClusterSearcher extends Searcher {
}
private Result doSearch(Searcher searcher, Query query, Execution execution) {
- Result result;
if (documentTypes.size() > 1) {
- result = searchMultipleDocumentTypes(searcher, query, execution);
+ return searchMultipleDocumentTypes(searcher, query, execution);
} else {
String docType = documentTypes.iterator().next();
@@ -349,20 +316,15 @@ public class ClusterSearcher extends Searcher {
}
query.getModel().setRestrict(docType);
- result = searcher.search(query, execution);
+ return searcher.search(query, execution);
}
- updateCacheHitRatio(result, query);
- return result;
}
-
private Result searchMultipleDocumentTypes(Searcher searcher, Query query, Execution execution) {
Set<String> docTypes = resolveDocumentTypes(query, execution.context().getIndexFacts());
Result invalidRankProfile = checkValidRankProfiles(query, docTypes);
- if (invalidRankProfile != null) {
- return invalidRankProfile;
- }
+ if (invalidRankProfile != null) return invalidRankProfile;
List<Query> queries = createQueries(query, docTypes);
if (queries.size() == 1) {
@@ -427,14 +389,7 @@ public class ClusterSearcher extends Searcher {
return retval;
}
- private void cacheHit() {
- cacheHitRatio.put(1.0);
- }
-
- private void cacheMiss() {
- cacheHitRatio.put(0.0);
- }
-
@Override
public void deconstruct() { }
+
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/cluster/MonitorConfiguration.java b/container-search/src/main/java/com/yahoo/prelude/cluster/MonitorConfiguration.java
deleted file mode 100644
index cd354b8451a..00000000000
--- a/container-search/src/main/java/com/yahoo/prelude/cluster/MonitorConfiguration.java
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.prelude.cluster;
-
-/**
- * The configuration of a cluster monitor instance
- *
- * @author bratseth
- * @author Steinar Knutsen
- */
-public class MonitorConfiguration {
-
- /**
- * The interval in ms between consecutive checks of the monitored nodes
- */
- private final long checkInterval = 100;
-
- /**
- * The number of milliseconds to attempt to complete a request before giving
- * up
- */
- private long requestTimeout = 2700;
-
- public MonitorConfiguration(final QrMonitorConfig config) {
- requestTimeout = config.requesttimeout();
- }
-
- /**
- * Returns the interval between each ping of idle or failing nodes Default
- * is 1000ms
- */
- public long getCheckInterval() {
- return checkInterval;
- }
-
- /**
- * Sets the number of milliseconds to attempt to service a request (at
- * different nodes) before giving up.
- */
- public void setRequestTimeout(final long timeout) {
- requestTimeout = timeout;
- }
-
- /**
- * Returns the number of milliseconds to attempt to service a request (at
- * different nodes) before giving up. Default is 2700 ms.
- */
- public long getRequestTimeout() {
- return requestTimeout;
- }
-
-}
diff --git a/container-search/src/main/java/com/yahoo/prelude/cluster/NodeMonitor.java b/container-search/src/main/java/com/yahoo/prelude/cluster/NodeMonitor.java
deleted file mode 100644
index 894b9ebd8ce..00000000000
--- a/container-search/src/main/java/com/yahoo/prelude/cluster/NodeMonitor.java
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.prelude.cluster;
-
-import static com.yahoo.container.protect.Error.BACKEND_COMMUNICATION_ERROR;
-import static com.yahoo.container.protect.Error.NO_ANSWER_WHEN_PINGING_NODE;
-
-import java.util.logging.Logger;
-
-import com.yahoo.prelude.fastsearch.VespaBackEndSearcher;
-import com.yahoo.search.result.ErrorMessage;
-
-/**
- * A node monitor is responsible for maintaining the state of a monitored node.
- * It has the following properties:
- * <ul>
- * <li>A node is taken out of operation if it gives no response in 10 s</li>
- * <li>A node is put back in operation when it responds correctly again</li>
- * <li>A node is initially considered not in operation until we have some data from it</li>
- * </ul>
- *
- * @author bratseth
- * @author Steinar Knutsen
- */
-public class NodeMonitor {
-
- protected static Logger log = Logger.getLogger(NodeMonitor.class.getName());
-
- /** The object representing the monitored node */
- private final VespaBackEndSearcher node;
-
- private boolean isWorking = true;
-
- /** The last time this node responded successfully */
- private long succeededAt = 0;
-
- /** Whether it is assumed the node has documents available to serve */
- private boolean searchNodesOnline = false;
-
- /**
- * Creates a new node monitor for a node
- */
- public NodeMonitor(final VespaBackEndSearcher node) {
- this.node = node;
- }
-
- /**
- * Returns whether this node is currently in a state suitable for receiving
- * traffic. As far as we know, that is
- */
- public boolean isWorking() {
- return isWorking;
- }
-
- // Whether or not dispatch has ever responded successfully
- private boolean statusIsKnown = false;
-
- public VespaBackEndSearcher getNode() {
- return node;
- }
-
- /**
- * Called when this node fails.
- *
- * @param error a container which should contain a short description
- */
- public void failed(ErrorMessage error) {
- long respondedAt = System.currentTimeMillis();
- statusIsKnown = true;
-
- if (error.getCode() == NO_ANSWER_WHEN_PINGING_NODE.code) {
- // Only count not being able to talk to backend at all
- // as errors we care about
- if ((respondedAt - succeededAt) > 10000) {
- this.searchNodesOnline = false;
- setWorking(false, "Not working for 10 s: " + error.toString());
- }
- } else if (error.getCode() == BACKEND_COMMUNICATION_ERROR.code) {
- this.searchNodesOnline = false;
- setWorking(false, "Backend communication error: " + error.toString());
- } else {
- succeededAt = respondedAt;
- }
- }
-
- /**
- * Called when a response is received from this node.
- */
- public void responded(boolean searchNodesOnline) {
- succeededAt = System.currentTimeMillis();
- statusIsKnown = true;
-
- this.searchNodesOnline = searchNodesOnline;
- if (! isWorking)
- setWorking(true, "Responds correctly");
- }
-
- /** Changes the state of this node if required */
- private void setWorking(boolean working, String explanation) {
- if (isWorking == working) return; // Old news
-
- if (statusIsKnown) {
- if (working)
- log.info("Putting " + node + " in service: " + explanation);
- else
- log.info("Taking " + node + " out of service: " + explanation);
- }
-
- isWorking = working;
- }
-
- boolean searchNodesOnline() { return searchNodesOnline; }
-
- /** Returns true if we have had enough time to determine the status of this node since creating the monitor */
- boolean statusIsKnown() { return statusIsKnown; }
-
-}
diff --git a/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java
index 3e6e88c72c1..c772300876b 100644
--- a/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java
@@ -47,6 +47,7 @@ import static org.junit.Assert.assertTrue;
* @author bratseth
*/
public class ClusterSearcherTestCase {
+
private static final double DELTA = 0.0000000000000001;
@Test
@@ -544,7 +545,6 @@ public class ClusterSearcherTestCase {
documentDbConfig.build(),
new DispatchConfig.Builder().build(),
createClusterInfoConfig(),
- Statistics.nullImplementation,
new MockMetric(),
new FS4ResourcePool(new QrConfig.Builder().build()),
vipStatus);
diff --git a/statistics/src/main/java/com/yahoo/statistics/Value.java b/statistics/src/main/java/com/yahoo/statistics/Value.java
index b1e08300d69..e9cacdebbd5 100644
--- a/statistics/src/main/java/com/yahoo/statistics/Value.java
+++ b/statistics/src/main/java/com/yahoo/statistics/Value.java
@@ -1,7 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.statistics;
-
import java.util.HashMap;
import java.util.List;
import java.util.logging.Logger;
@@ -12,14 +11,14 @@ import com.yahoo.log.LogLevel;
import com.yahoo.log.event.Event;
import com.yahoo.statistics.SampleSet.Sampling;
-
/**
* A statistical variable, typically representing a sampling of an
* arbitrarily changing parameter.
*
- * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @author Steinar Knutsen
*/
public class Value extends Handle {
+
// For accumulated values, SampleSet instances are mem barriers between {n
// sampling threads} and {logging thread}.