aboutsummaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
Diffstat (limited to 'container-search')
-rw-r--r--container-search/abi-spec.json1
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/statistics/StatisticsSearcher.java47
-rw-r--r--container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java106
-rw-r--r--container-search/src/main/java/com/yahoo/search/statistics/PeakQpsSearcher.java8
-rw-r--r--container-search/src/main/java/com/yahoo/search/statistics/TimingSearcher.java2
-rw-r--r--container-search/src/test/java/com/yahoo/search/statistics/PeakQpsTestCase.java164
-rw-r--r--container-search/src/test/java/com/yahoo/search/statistics/TimingSearcherTestCase.java89
7 files changed, 50 insertions, 367 deletions
diff --git a/container-search/abi-spec.json b/container-search/abi-spec.json
index 9d3b4934aa3..183bb33b4f4 100644
--- a/container-search/abi-spec.json
+++ b/container-search/abi-spec.json
@@ -4322,6 +4322,7 @@
"public"
],
"methods": [
+ "public void <init>(com.yahoo.jdisc.Metric, com.yahoo.container.handler.threadpool.ContainerThreadPool, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.language.process.Embedder, com.yahoo.search.searchchain.ExecutionFactory)",
"public void <init>(com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric, com.yahoo.container.handler.threadpool.ContainerThreadPool, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.language.process.Embedder, com.yahoo.search.searchchain.ExecutionFactory)",
"public void <init>(com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric, com.yahoo.container.handler.threadpool.ContainerThreadPool, com.yahoo.container.logging.AccessLog, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.search.searchchain.ExecutionFactory)",
"public void <init>(com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric, java.util.concurrent.Executor, com.yahoo.container.logging.AccessLog, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.search.searchchain.ExecutionFactory)",
diff --git a/container-search/src/main/java/com/yahoo/prelude/statistics/StatisticsSearcher.java b/container-search/src/main/java/com/yahoo/prelude/statistics/StatisticsSearcher.java
index 63704788b20..1d1c446f6e1 100644
--- a/container-search/src/main/java/com/yahoo/prelude/statistics/StatisticsSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/statistics/StatisticsSearcher.java
@@ -3,7 +3,6 @@ package com.yahoo.prelude.statistics;
import com.yahoo.component.chain.dependencies.Before;
import com.yahoo.concurrent.CopyOnWriteHashMap;
-import com.yahoo.container.protect.Error;
import com.yahoo.jdisc.Metric;
import com.yahoo.jdisc.http.HttpRequest;
import com.yahoo.metrics.simple.MetricReceiver;
@@ -19,8 +18,6 @@ import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.PhaseNames;
-import com.yahoo.statistics.Counter;
-import com.yahoo.statistics.Value;
import java.util.HashMap;
import java.util.Map;
@@ -76,19 +73,7 @@ public class StatisticsSearcher extends Searcher {
private static final String RELEVANCE_AT_3_METRIC = "relevance.at_3";
private static final String RELEVANCE_AT_10_METRIC = "relevance.at_10";
- private final Counter queriesCounter; // basic counter
- private final Counter failedQueriesCounter; // basic counter
- private final Counter nullQueriesCounter; // basic counter
- private final Counter illegalQueriesCounter; // basic counter
- private final Value meanQueryLatency; // mean pr 5 min
- private final Value queryLatencyBuckets;
- private final Value maxQueryLatency; // separate to avoid name mangling
@SuppressWarnings("unused") // all the work is done by the callback
- private final Value peakQPS; // peak 1s QPS
- private final Counter emptyResultsCounter; // number of results containing no concrete hits
- private final Value hitsPerQuery; // mean number of hits per query
- private final Value totalHitsPerQuery;
-
private final PeakQpsReporter peakQpsReporter;
// Naming of enums are reflected directly in metric dimensions and should not be changed as they are public API
@@ -123,7 +108,6 @@ public class StatisticsSearcher extends Searcher {
private void flushPeakQps(long now) {
double ms = (double) (now - prevMaxQPSTime);
final double value = ((double)queriesForQPS) / (ms / 1000.0);
- peakQPS.put(value);
metric.set(PEAK_QPS_METRIC, value, metricContext);
prevMaxQPSTime = now;
queriesForQPS = 0;
@@ -135,22 +119,10 @@ public class StatisticsSearcher extends Searcher {
}
}
- public StatisticsSearcher(com.yahoo.statistics.Statistics manager, Metric metric, MetricReceiver metricReceiver) {
+ public StatisticsSearcher(Metric metric, MetricReceiver metricReceiver) {
this.peakQpsReporter = new PeakQpsReporter();
this.metric = metric;
- queriesCounter = new Counter(QUERIES_METRIC, manager, false);
- failedQueriesCounter = new Counter(FAILED_QUERIES_METRIC, manager, false);
- nullQueriesCounter = new Counter("null_queries", manager, false);
- illegalQueriesCounter = new Counter("illegal_queries", manager, false);
- meanQueryLatency = new Value(MEAN_QUERY_LATENCY_METRIC, manager, new Value.Parameters().setLogRaw(false).setLogMean(true).setNameExtension(false));
- maxQueryLatency = new Value(MAX_QUERY_LATENCY_METRIC, manager, new Value.Parameters().setLogRaw(false).setLogMax(true).setNameExtension(false));
- queryLatencyBuckets = Value.buildValue(QUERY_LATENCY_METRIC, manager, null);
- peakQPS = new Value(PEAK_QPS_METRIC, manager, new Value.Parameters().setLogRaw(false).setLogMax(true).setNameExtension(false));
- hitsPerQuery = new Value(HITS_PER_QUERY_METRIC, manager, new Value.Parameters().setLogRaw(false).setLogMean(true).setNameExtension(false));
- totalHitsPerQuery = new Value(TOTALHITS_PER_QUERY_METRIC, manager, new Value.Parameters().setLogRaw(false).setLogMean(true).setNameExtension(false));
-
- emptyResultsCounter = new Counter(EMPTY_RESULTS_METRIC, manager, false);
metricReceiver.declareGauge(QUERY_LATENCY_METRIC, Optional.empty(), new MetricSettings.Builder().histogram(true).build());
metricReceiver.declareGauge(HITS_PER_QUERY_METRIC, Optional.empty(), new MetricSettings.Builder().histogram(true).build());
metricReceiver.declareGauge(TOTALHITS_PER_QUERY_METRIC, Optional.empty(), new MetricSettings.Builder().histogram(true).build());
@@ -265,7 +237,7 @@ public class StatisticsSearcher extends Searcher {
} else {
getLogger().log(Level.WARNING,
"Apparently negative latency measure, start: " + start_ns
- + ", end: " + end_ns + ", for query: " + query.toString());
+ + ", end: " + end_ns + ", for query: " + query);
}
if (result.hits().getError() != null) {
incrErrorCount(result, metricContext);
@@ -281,16 +253,12 @@ public class StatisticsSearcher extends Searcher {
metric.add(DOCS_TOTAL_METRIC, queryCoverage.getActive(), metricContext);
}
int hitCount = result.getConcreteHitCount();
- hitsPerQuery.put(hitCount);
metric.set(HITS_PER_QUERY_METRIC, (double) hitCount, metricContext);
long totalHitCount = result.getTotalHitCount();
- totalHitsPerQuery.put(totalHitCount);
metric.set(TOTALHITS_PER_QUERY_METRIC, (double) totalHitCount, metricContext);
-
metric.set(QUERY_HIT_OFFSET_METRIC, (double) (query.getHits() + query.getOffset()), metricContext);
if (hitCount == 0) {
- emptyResultsCounter.increment();
metric.add(EMPTY_RESULTS_METRIC, 1, metricContext);
}
@@ -309,31 +277,20 @@ public class StatisticsSearcher extends Searcher {
private void addLatency(long latency_ns, Metric.Context metricContext) {
double latency = 0.000001 * latency_ns;
- //myStats.addLatency(latency);
- meanQueryLatency.put(latency);
metric.set(QUERY_LATENCY_METRIC, latency, metricContext);
metric.set(MEAN_QUERY_LATENCY_METRIC, latency, metricContext);
- maxQueryLatency.put(latency);
metric.set(MAX_QUERY_LATENCY_METRIC, latency, metricContext);
- queryLatencyBuckets.put(latency);
}
private void incrQueryCount(Metric.Context metricContext) {
- //myStats.incrQueryCnt();
- queriesCounter.increment();
metric.add(QUERIES_METRIC, 1, metricContext);
}
private void incrErrorCount(Result result, Metric.Context metricContext) {
- failedQueriesCounter.increment();
metric.add(FAILED_QUERIES_METRIC, 1, metricContext);
if (result == null) // the chain threw an exception
metric.add("error.unhandled_exception", 1, metricContext);
- else if (result.hits().getErrorHit().hasOnlyErrorCode(Error.NULL_QUERY.code))
- nullQueriesCounter.increment();
- else if (result.hits().getErrorHit().hasOnlyErrorCode(Error.ILLEGAL_QUERY.code))
- illegalQueriesCounter.increment();
}
/**
diff --git a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java
index a38dd5dc67a..52a3672e7a2 100644
--- a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java
+++ b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java
@@ -49,10 +49,7 @@ import com.yahoo.search.statistics.ElapsedTime;
import com.yahoo.slime.Inspector;
import com.yahoo.slime.ObjectTraverser;
import com.yahoo.slime.SlimeUtils;
-import com.yahoo.statistics.Callback;
-import com.yahoo.statistics.Handle;
import com.yahoo.statistics.Statistics;
-import com.yahoo.statistics.Value;
import com.yahoo.vespa.configdefinition.SpecialtokensConfig;
import com.yahoo.yolean.Exceptions;
import com.yahoo.yolean.trace.TraceNode;
@@ -93,9 +90,6 @@ public class SearchHandler extends LoggingRequestHandler {
static final String RENDERER_DIMENSION = "renderer";
private static final String JSON_CONTENT_TYPE = "application/json";
-
- private final Value searchConnections;
-
public static final String defaultSearchChainName = "default";
private static final String fallbackSearchChain = "vespa";
@@ -105,30 +99,26 @@ public class SearchHandler extends LoggingRequestHandler {
private final Optional<String> hostResponseHeaderKey;
private final String selfHostname = HostName.getLocalhost();
-
private final Embedder embedder;
-
private final ExecutionFactory executionFactory;
-
private final AtomicLong numRequestsLeftToTrace;
private final static RequestHandlerSpec REQUEST_HANDLER_SPEC = RequestHandlerSpec.builder()
.withAclMapping(SearchHandler.aclRequestMapper()).build();
- private final class MeanConnections implements Callback {
-
- @Override
- public void run(Handle h, boolean firstTime) {
- if (firstTime) {
- metric.set(SEARCH_CONNECTIONS, 0.0d, null);
- return;
- }
- Value v = (Value) h;
- metric.set(SEARCH_CONNECTIONS, v.getMean(), null);
- }
+ @Inject
+ public SearchHandler(Metric metric,
+ ContainerThreadPool threadpool,
+ CompiledQueryProfileRegistry queryProfileRegistry,
+ ContainerHttpConfig config,
+ Embedder embedder,
+ ExecutionFactory executionFactory) {
+ this(metric, threadpool.executor(), queryProfileRegistry, embedder, executionFactory,
+ config.numQueriesToTraceOnDebugAfterConstruction(),
+ config.hostResponseHeaderKey().equals("") ? Optional.empty() : Optional.of(config.hostResponseHeaderKey()));
}
- @Inject
+ @Deprecated
public SearchHandler(Statistics statistics,
Metric metric,
ContainerThreadPool threadpool,
@@ -136,7 +126,7 @@ public class SearchHandler extends LoggingRequestHandler {
ContainerHttpConfig config,
Embedder embedder,
ExecutionFactory executionFactory) {
- this(statistics, metric, threadpool.executor(), queryProfileRegistry, embedder, executionFactory,
+ this(metric, threadpool.executor(), queryProfileRegistry, embedder, executionFactory,
config.numQueriesToTraceOnDebugAfterConstruction(),
config.hostResponseHeaderKey().equals("") ? Optional.empty() : Optional.of(config.hostResponseHeaderKey()));
}
@@ -166,12 +156,7 @@ public class SearchHandler extends LoggingRequestHandler {
CompiledQueryProfileRegistry queryProfileRegistry,
ContainerHttpConfig containerHttpConfig,
ExecutionFactory executionFactory) {
- this(statistics,
- metric,
- executor,
- queryProfileRegistry,
- Embedder.throwsOnUse,
- executionFactory,
+ this(metric, executor, queryProfileRegistry, Embedder.throwsOnUse, executionFactory,
containerHttpConfig.numQueriesToTraceOnDebugAfterConstruction(),
containerHttpConfig.hostResponseHeaderKey().equals("") ?
Optional.empty() : Optional.of(containerHttpConfig.hostResponseHeaderKey()));
@@ -188,12 +173,8 @@ public class SearchHandler extends LoggingRequestHandler {
QueryProfilesConfig queryProfileConfig,
ContainerHttpConfig containerHttpConfig,
ExecutionFactory executionFactory) {
- this(statistics,
- metric,
- executor,
- QueryProfileConfigurer.createFromConfig(queryProfileConfig).compile(),
- Embedder.throwsOnUse,
- executionFactory,
+ this(metric, executor, QueryProfileConfigurer.createFromConfig(queryProfileConfig).compile(),
+ Embedder.throwsOnUse, executionFactory,
containerHttpConfig.numQueriesToTraceOnDebugAfterConstruction(),
containerHttpConfig.hostResponseHeaderKey().equals("") ?
Optional.empty() : Optional.of( containerHttpConfig.hostResponseHeaderKey()));
@@ -210,12 +191,11 @@ public class SearchHandler extends LoggingRequestHandler {
CompiledQueryProfileRegistry queryProfileRegistry,
ExecutionFactory executionFactory,
Optional<String> hostResponseHeaderKey) {
- this(statistics, metric, executor, queryProfileRegistry, Embedder.throwsOnUse,
+ this(metric, executor, queryProfileRegistry, Embedder.throwsOnUse,
executionFactory, 0, hostResponseHeaderKey);
}
- private SearchHandler(Statistics statistics,
- Metric metric,
+ private SearchHandler(Metric metric,
Executor executor,
CompiledQueryProfileRegistry queryProfileRegistry,
Embedder embedder,
@@ -230,14 +210,9 @@ public class SearchHandler extends LoggingRequestHandler {
this.maxThreads = examineExecutor(executor);
- searchConnections = new Value(SEARCH_CONNECTIONS, statistics,
- new Value.Parameters().setLogRaw(true).setLogMax(true)
- .setLogMean(true).setLogMin(true)
- .setNameExtension(true)
- .setCallback(new MeanConnections()));
-
this.hostResponseHeaderKey = hostResponseHeaderKey;
this.numRequestsLeftToTrace = new AtomicLong(numQueriesToTraceOnDebugAfterStartup);
+ metric.set(SEARCH_CONNECTIONS, 0.0d, null);
}
/** @deprecated use the other constructor */
@@ -487,13 +462,8 @@ public class SearchHandler extends LoggingRequestHandler {
query.trace("Invoking " + searchChain, false, 2);
}
- if (searchConnections != null) {
- connectionStatistics();
- } else {
- log.log(Level.WARNING,
- "searchConnections is a null reference, probably a known race condition during startup.",
- new IllegalStateException("searchConnections reference is null."));
- }
+ connectionStatistics();
+
try {
return searchAndFill(query, searchChain);
} catch (ParseException e) {
@@ -525,24 +495,24 @@ public class SearchHandler extends LoggingRequestHandler {
}
private void connectionStatistics() {
+ if (maxThreads <= 3) return;
+
int connections = requestsInFlight.intValue();
- searchConnections.put(connections);
- if (maxThreads > 3) {
- // cast to long to avoid overflows if maxThreads is at no
- // log value (maxint)
- long maxThreadsAsLong = maxThreads;
- long connectionsAsLong = connections;
- // only log when exactly crossing the limit to avoid
- // spamming the log
- if (connectionsAsLong < maxThreadsAsLong * 9L / 10L) {
- // NOP
- } else if (connectionsAsLong == maxThreadsAsLong * 9L / 10L) {
- log.log(Level.WARNING, threadConsumptionMessage(connections, maxThreads, "90"));
- } else if (connectionsAsLong == maxThreadsAsLong * 95L / 100L) {
- log.log(Level.WARNING, threadConsumptionMessage(connections, maxThreads, "95"));
- } else if (connectionsAsLong == maxThreadsAsLong) {
- log.log(Level.WARNING, threadConsumptionMessage(connections, maxThreads, "100"));
- }
+ metric.set(SEARCH_CONNECTIONS, connections, null);
+ // cast to long to avoid overflows if maxThreads is at no
+ // log value (maxint)
+ long maxThreadsAsLong = maxThreads;
+ long connectionsAsLong = connections;
+ // only log when exactly crossing the limit to avoid
+ // spamming the log
+ if (connectionsAsLong < maxThreadsAsLong * 9L / 10L) {
+ // NOP
+ } else if (connectionsAsLong == maxThreadsAsLong * 9L / 10L) {
+ log.log(Level.WARNING, threadConsumptionMessage(connections, maxThreads, "90"));
+ } else if (connectionsAsLong == maxThreadsAsLong * 95L / 100L) {
+ log.log(Level.WARNING, threadConsumptionMessage(connections, maxThreads, "95"));
+ } else if (connectionsAsLong == maxThreadsAsLong) {
+ log.log(Level.WARNING, threadConsumptionMessage(connections, maxThreads, "100"));
}
}
@@ -598,7 +568,7 @@ public class SearchHandler extends LoggingRequestHandler {
}
private void traceVespaVersion(Query query) {
- query.trace("Vespa version: " + Vtag.currentVersion.toString(), false, 4);
+ query.trace("Vespa version: " + Vtag.currentVersion, false, 4);
}
public SearchChainRegistry getSearchChainRegistry() { return executionFactory.searchChainRegistry();
diff --git a/container-search/src/main/java/com/yahoo/search/statistics/PeakQpsSearcher.java b/container-search/src/main/java/com/yahoo/search/statistics/PeakQpsSearcher.java
index e4bce05b4f2..2823a7d74e1 100644
--- a/container-search/src/main/java/com/yahoo/search/statistics/PeakQpsSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/statistics/PeakQpsSearcher.java
@@ -14,13 +14,19 @@ import com.yahoo.statistics.Handle;
import com.yahoo.statistics.Statistics;
import com.yahoo.statistics.Value;
-import java.util.*;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Deque;
+import java.util.List;
+import java.util.ListIterator;
/**
* Aggregate peak qps and expose through meta hits and/or log events.
*
* @author Steinar Knutsen
+ * @deprecated Will be removed on Vespa 8
*/
+@Deprecated
public class PeakQpsSearcher extends Searcher {
private final ThreadLocalDirectory<Deque<QueryRatePerSecond>, Long> directory;
diff --git a/container-search/src/main/java/com/yahoo/search/statistics/TimingSearcher.java b/container-search/src/main/java/com/yahoo/search/statistics/TimingSearcher.java
index 8aa68d83d88..5d036b8fa20 100644
--- a/container-search/src/main/java/com/yahoo/search/statistics/TimingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/statistics/TimingSearcher.java
@@ -19,8 +19,10 @@ import com.yahoo.statistics.Value;
* measuring time consumption a search chain.
*
* @author Steinar Knutsen
+ * @deprecated Will be removed on Vespa 8
*/
@Before("rawQuery")
+@Deprecated
public class TimingSearcher extends PingableSearcher {
private Value measurements;
diff --git a/container-search/src/test/java/com/yahoo/search/statistics/PeakQpsTestCase.java b/container-search/src/test/java/com/yahoo/search/statistics/PeakQpsTestCase.java
deleted file mode 100644
index 4bc8ee76165..00000000000
--- a/container-search/src/test/java/com/yahoo/search/statistics/PeakQpsTestCase.java
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.search.statistics;
-
-import static org.junit.Assert.*;
-
-import java.util.Deque;
-import java.util.List;
-
-import com.yahoo.statistics.Statistics;
-import org.junit.Test;
-
-import com.yahoo.component.chain.Chain;
-import com.yahoo.concurrent.LocalInstance;
-import com.yahoo.concurrent.ThreadLocalDirectory;
-import com.yahoo.search.Query;
-import com.yahoo.search.Result;
-import com.yahoo.search.Searcher;
-import com.yahoo.search.result.Hit;
-import com.yahoo.search.searchchain.Execution;
-import com.yahoo.search.statistics.PeakQpsSearcher.QueryRatePerSecond;
-
-/**
- * Check peak QPS aggregation has a chance of working.
- *
- * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
- */
-public class PeakQpsTestCase {
-
- static class Producer implements Runnable {
- private final ThreadLocalDirectory<Deque<QueryRatePerSecond>, Long> rates;
-
- Producer(ThreadLocalDirectory<Deque<QueryRatePerSecond>, Long> rates) {
- this.rates = rates;
- }
-
- @Override
- public void run() {
- LocalInstance<Deque<QueryRatePerSecond>, Long> rate = rates.getLocalInstance();
- rates.update(1L, rate);
- rates.update(2L, rate);
- rates.update(2L, rate);
- rates.update(3L, rate);
- rates.update(3L, rate);
- rates.update(3L, rate);
- rates.update(4L, rate);
- rates.update(4L, rate);
- rates.update(4L, rate);
- rates.update(4L, rate);
- }
- }
-
- static class LaterProducer implements Runnable {
- private final ThreadLocalDirectory<Deque<QueryRatePerSecond>, Long> rates;
-
- LaterProducer(ThreadLocalDirectory<Deque<QueryRatePerSecond>, Long> rates) {
- this.rates = rates;
- }
-
- @Override
- public void run() {
- LocalInstance<Deque<QueryRatePerSecond>, Long> rate = rates.getLocalInstance();
- rates.update(2L, rate);
- rates.update(2L, rate);
- rates.update(3L, rate);
- rates.update(3L, rate);
- rates.update(3L, rate);
- rates.update(5L, rate);
- rates.update(5L, rate);
- rates.update(6L, rate);
- rates.update(7L, rate);
- }
- }
-
- @Test
- public void checkBasicDataAggregation() {
- ThreadLocalDirectory<Deque<QueryRatePerSecond>, Long> directory = PeakQpsSearcher.createDirectory();
- final int threadCount = 20;
- Thread[] threads = new Thread[threadCount];
- for (int i = 0; i < threadCount; ++i) {
- Producer p = new Producer(directory);
- threads[i] = new Thread(p);
- threads[i].start();
- }
- for (Thread t : threads) {
- try {
- t.join();
- } catch (InterruptedException e) {
- // nop
- }
- }
- List<Deque<QueryRatePerSecond>> measurements = directory.fetch();
- List<QueryRatePerSecond> results = PeakQpsSearcher.merge(measurements);
- assertTrue(results.get(0).when == 1L);
- assertTrue(results.get(0).howMany == threadCount);
- assertTrue(results.get(1).when == 2L);
- assertTrue(results.get(1).howMany == threadCount * 2);
- assertTrue(results.get(2).when == 3L);
- assertTrue(results.get(2).howMany == threadCount * 3);
- assertTrue(results.get(3).when == 4L);
- assertTrue(results.get(3).howMany == threadCount * 4);
- }
-
- @Test
- public void checkMixedDataAggregation() {
- ThreadLocalDirectory<Deque<QueryRatePerSecond>, Long> directory = PeakQpsSearcher.createDirectory();
- final int firstThreads = 20;
- final int secondThreads = 20;
- final int threadCount = firstThreads + secondThreads;
- Thread[] threads = new Thread[threadCount];
- for (int i = 0; i < threadCount; ++i) {
- if (i < firstThreads) {
- Producer p = new Producer(directory);
- threads[i] = new Thread(p);
- } else {
- LaterProducer p = new LaterProducer(directory);
- threads[i] = new Thread(p);
- }
- threads[i].start();
-
- }
- for (Thread t : threads) {
- try {
- t.join();
- } catch (InterruptedException e) {
- // nop
- }
- }
- List<Deque<QueryRatePerSecond>> measurements = directory.fetch();
- List<QueryRatePerSecond> results = PeakQpsSearcher.merge(measurements);
- assertTrue(results.size() == 7);
- assertTrue(results.get(0).when == 1L);
- assertTrue(results.get(0).howMany == firstThreads);
- assertTrue(results.get(1).when == 2L);
- assertTrue(results.get(1).howMany == threadCount * 2);
- assertTrue(results.get(2).when == 3L);
- assertTrue(results.get(2).howMany == threadCount * 3);
- assertTrue(results.get(3).when == 4L);
- assertTrue(results.get(3).howMany == firstThreads * 4);
- assertTrue(results.get(4).when == 5L);
- assertTrue(results.get(4).howMany == secondThreads * 2);
- assertTrue(results.get(5).when == 6L);
- assertTrue(results.get(5).howMany == secondThreads);
- assertTrue(results.get(6).when == 7L);
- assertTrue(results.get(6).howMany == secondThreads);
- }
-
- @Test
- public void checkSearch() {
- MeasureQpsConfig config = new MeasureQpsConfig(
- new MeasureQpsConfig.Builder().outputmethod(
- MeasureQpsConfig.Outputmethod.METAHIT).queryproperty(
- "qpsprobe"));
- Searcher s = new PeakQpsSearcher(config, Statistics.nullImplementation);
- Chain<Searcher> c = new Chain<>(s);
- Execution e = new Execution(c, Execution.Context.createContextStub());
- e.search(new Query("/?query=a"));
- new Execution(c, Execution.Context.createContextStub());
- Result r = e.search(new Query("/?query=a&qpsprobe=true"));
- final Hit hit = r.hits().get(0);
- assertTrue(hit instanceof PeakQpsSearcher.QpsHit);
- assertNotNull(hit.fields().get(PeakQpsSearcher.QpsHit.MEAN_QPS));
- assertNotNull(hit.fields().get(PeakQpsSearcher.QpsHit.PEAK_QPS));
- }
-}
diff --git a/container-search/src/test/java/com/yahoo/search/statistics/TimingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/statistics/TimingSearcherTestCase.java
deleted file mode 100644
index 673d38cc2b8..00000000000
--- a/container-search/src/test/java/com/yahoo/search/statistics/TimingSearcherTestCase.java
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.search.statistics;
-
-import com.yahoo.component.ComponentId;
-import com.yahoo.prelude.Ping;
-import com.yahoo.search.Query;
-import com.yahoo.search.Result;
-import com.yahoo.search.result.Hit;
-import com.yahoo.search.searchchain.Execution;
-import com.yahoo.search.statistics.TimingSearcher.Parameters;
-import com.yahoo.statistics.Statistics;
-import com.yahoo.statistics.Value;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class TimingSearcherTestCase {
-
- public static class MockValue extends Value {
- public int putCount = 0;
-
- public MockValue() {
- super("mock", Statistics.nullImplementation, new Value.Parameters());
- }
-
- @Override
- public void put(double x) {
- putCount += 1;
- }
- }
-
- @Test
- public void testMeasurementSearchPath() {
- Parameters p = new Parameters("timingtest", TimeTracker.Activity.SEARCH);
- TimingSearcher ts = new TimingSearcher(new ComponentId("lblblbl"), p, Statistics.nullImplementation);
- MockValue v = new MockValue();
- ts.setMeasurements(v);
- Execution exec = new Execution(ts, Execution.Context.createContextStub());
- Result r = exec.search(new Query("/?query=a"));
- Hit f = new Hit("blblbl");
- f.setFillable();
- r.hits().add(f);
- exec.fill(r, "whatever");
- exec.fill(r, "lalala");
- exec.ping(new Ping());
- exec.ping(new Ping());
- exec.ping(new Ping());
- assertEquals(1, v.putCount);
- }
-
- @Test
- public void testMeasurementFillPath() {
- Parameters p = new Parameters("timingtest", TimeTracker.Activity.FILL);
- TimingSearcher ts = new TimingSearcher(new ComponentId("lblblbl"), p, Statistics.nullImplementation);
- MockValue v = new MockValue();
- ts.setMeasurements(v);
- Execution exec = new Execution(ts, Execution.Context.createContextStub());
- Result r = exec.search(new Query("/?query=a"));
- Hit f = new Hit("blblbl");
- f.setFillable();
- r.hits().add(f);
- exec.fill(r, "whatever");
- exec.fill(r, "lalala");
- exec.ping(new Ping());
- exec.ping(new Ping());
- exec.ping(new Ping());
- assertEquals(2, v.putCount);
- }
-
- @Test
- public void testMeasurementPingPath() {
- Parameters p = new Parameters("timingtest", TimeTracker.Activity.PING);
- TimingSearcher ts = new TimingSearcher(new ComponentId("lblblbl"), p, Statistics.nullImplementation);
- MockValue v = new MockValue();
- ts.setMeasurements(v);
- Execution exec = new Execution(ts, Execution.Context.createContextStub());
- Result r = exec.search(new Query("/?query=a"));
- Hit f = new Hit("blblbl");
- f.setFillable();
- r.hits().add(f);
- exec.fill(r, "whatever");
- exec.fill(r, "lalala");
- exec.ping(new Ping());
- exec.ping(new Ping());
- exec.ping(new Ping());
- assertEquals(3, v.putCount);
- }
-
-}