summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/prelude
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-03-15 18:14:17 +0100
committerGitHub <noreply@github.com>2019-03-15 18:14:17 +0100
commit7f56c30703f5319f5368653f6313a8f12f07b3cb (patch)
tree394c9717eee127c407e3d3222169bab4a420228e /container-search/src/main/java/com/yahoo/prelude
parent156743b84071f04114bc4479a3bcc3ca10b2f7e5 (diff)
Revert "Protobuf over jrt support in search"
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude')
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4InvokerFactory.java46
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4SearchInvoker.java36
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java11
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java2
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/query/Highlight.java8
5 files changed, 70 insertions, 33 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4InvokerFactory.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4InvokerFactory.java
index 66088faed79..5700e316493 100644
--- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4InvokerFactory.java
+++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4InvokerFactory.java
@@ -8,10 +8,12 @@ import com.yahoo.search.Result;
import com.yahoo.search.dispatch.FillInvoker;
import com.yahoo.search.dispatch.InterleavedFillInvoker;
import com.yahoo.search.dispatch.InterleavedSearchInvoker;
-import com.yahoo.search.dispatch.InvokerFactory;
+import com.yahoo.search.dispatch.SearchErrorInvoker;
import com.yahoo.search.dispatch.SearchInvoker;
import com.yahoo.search.dispatch.searchcluster.Node;
import com.yahoo.search.dispatch.searchcluster.SearchCluster;
+import com.yahoo.search.result.Coverage;
+import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.result.Hit;
import java.util.ArrayList;
@@ -31,13 +33,15 @@ import java.util.Set;
*
* @author ollivir
*/
-public class FS4InvokerFactory extends InvokerFactory {
+public class FS4InvokerFactory {
private final FS4ResourcePool fs4ResourcePool;
+ private final VespaBackEndSearcher searcher;
private final SearchCluster searchCluster;
private final ImmutableMap<Integer, Node> nodesByKey;
- public FS4InvokerFactory(FS4ResourcePool fs4ResourcePool, SearchCluster searchCluster) {
+ public FS4InvokerFactory(FS4ResourcePool fs4ResourcePool, SearchCluster searchCluster, VespaBackEndSearcher searcher) {
this.fs4ResourcePool = fs4ResourcePool;
+ this.searcher = searcher;
this.searchCluster = searchCluster;
ImmutableMap.Builder<Integer, Node> builder = ImmutableMap.builder();
@@ -45,7 +49,7 @@ public class FS4InvokerFactory extends InvokerFactory {
this.nodesByKey = builder.build();
}
- public SearchInvoker createSearchInvoker(VespaBackEndSearcher searcher, Query query, Node node) {
+ public SearchInvoker getSearchInvoker(Query query, Node node) {
Backend backend = fs4ResourcePool.getBackend(node.hostname(), node.fs4port());
return new FS4SearchInvoker(searcher, query, backend.openChannel(), Optional.of(node));
}
@@ -53,8 +57,6 @@ public class FS4InvokerFactory extends InvokerFactory {
/**
* Create a {@link SearchInvoker} for a list of content nodes.
*
- * @param searcher
- * the searcher processing the query
* @param query
* the search query being processed
* @param groupId
@@ -68,9 +70,7 @@ public class FS4InvokerFactory extends InvokerFactory {
* @return Optional containing the SearchInvoker or <i>empty</i> if some node in the
* list is invalid and the remaining coverage is not sufficient
*/
- @Override
- public Optional<SearchInvoker> createSearchInvoker(VespaBackEndSearcher searcher, Query query, OptionalInt groupId, List<Node> nodes,
- boolean acceptIncompleteCoverage) {
+ public Optional<SearchInvoker> getSearchInvoker(Query query, OptionalInt groupId, List<Node> nodes, boolean acceptIncompleteCoverage) {
List<SearchInvoker> invokers = new ArrayList<>(nodes.size());
Set<Integer> failed = null;
for (Node node : nodes) {
@@ -114,27 +114,44 @@ public class FS4InvokerFactory extends InvokerFactory {
}
}
- public FillInvoker createFillInvoker(VespaBackEndSearcher searcher, Result result, Node node) {
- return new FS4FillInvoker(searcher, result.getQuery(), fs4ResourcePool, node.hostname(), node.fs4port());
+ private SearchInvoker createCoverageErrorInvoker(List<Node> nodes, Set<Integer> failed) {
+ StringBuilder down = new StringBuilder("Connection failure on nodes with distribution-keys: ");
+ int count = 0;
+ for (Node node : nodes) {
+ if (failed.contains(node.key())) {
+ if (count > 0) {
+ down.append(", ");
+ }
+ count++;
+ down.append(node.key());
+ }
+ }
+ Coverage coverage = new Coverage(0, 0, 0);
+ coverage.setNodesTried(count);
+ return new SearchErrorInvoker(ErrorMessage.createBackendCommunicationError(down.toString()), coverage);
+ }
+
+ public FillInvoker getFillInvoker(Query query, Node node) {
+ return new FS4FillInvoker(searcher, query, fs4ResourcePool, node.hostname(), node.fs4port());
}
/**
* Create a {@link FillInvoker} for a the hits in a {@link Result}.
*
- * @param searcher the searcher processing the query
* @param result the Result containing hits that need to be filled
* @return Optional containing the FillInvoker or <i>empty</i> if some hit is from an unknown content node
*/
- public Optional<FillInvoker> createFillInvoker(VespaBackEndSearcher searcher, Result result) {
+ public Optional<FillInvoker> getFillInvoker(Result result) {
Collection<Integer> requiredNodes = requiredFillNodes(result);
+ Query query = result.getQuery();
Map<Integer, FillInvoker> invokers = new HashMap<>();
for (Integer distKey : requiredNodes) {
Node node = nodesByKey.get(distKey);
if (node == null) {
return Optional.empty();
}
- invokers.put(distKey, createFillInvoker(searcher, result, node));
+ invokers.put(distKey, getFillInvoker(query, node));
}
if (invokers.size() == 1) {
@@ -155,5 +172,4 @@ public class FS4InvokerFactory extends InvokerFactory {
}
return requiredNodes;
}
-
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4SearchInvoker.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4SearchInvoker.java
index 24653db5671..d2910ba3fbc 100644
--- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4SearchInvoker.java
+++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4SearchInvoker.java
@@ -12,11 +12,13 @@ import com.yahoo.search.Result;
import com.yahoo.search.dispatch.ResponseMonitor;
import com.yahoo.search.dispatch.SearchInvoker;
import com.yahoo.search.dispatch.searchcluster.Node;
+import com.yahoo.search.result.Coverage;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.searchchain.Execution;
import java.io.IOException;
import java.util.Optional;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -25,7 +27,6 @@ import java.util.logging.Logger;
* @author ollivir
*/
public class FS4SearchInvoker extends SearchInvoker implements ResponseMonitor<FS4Channel> {
- private static final Logger log = Logger.getLogger(FS4SearchInvoker.class.getName());
private final VespaBackEndSearcher searcher;
private FS4Channel channel;
@@ -45,7 +46,8 @@ public class FS4SearchInvoker extends SearchInvoker implements ResponseMonitor<F
@Override
protected void sendSearchRequest(Query query, QueryPacket queryPacket) throws IOException {
- log.finest("sending query packet");
+ if (isLoggingFine())
+ getLogger().finest("sending query packet");
if (queryPacket == null) {
// query changed for subchannel
@@ -75,28 +77,30 @@ public class FS4SearchInvoker extends SearchInvoker implements ResponseMonitor<F
@Override
protected Result getSearchResult(Execution execution) throws IOException {
if (pendingSearchError != null) {
- return errorResult(query, pendingSearchError);
+ return errorResult(pendingSearchError);
}
BasicPacket[] basicPackets;
try {
basicPackets = channel.receivePackets(query.getTimeLeft(), 1);
} catch (ChannelTimeoutException e) {
- return errorResult(query, ErrorMessage.createTimeout("Timeout while waiting for " + getName()));
+ return errorResult(ErrorMessage.createTimeout("Timeout while waiting for " + getName()));
} catch (InvalidChannelException e) {
- return errorResult(query, ErrorMessage.createBackendCommunicationError("Invalid channel for " + getName()));
+ return errorResult(ErrorMessage.createBackendCommunicationError("Invalid channel for " + getName()));
}
if (basicPackets.length == 0) {
- return errorResult(query, ErrorMessage.createBackendCommunicationError(getName() + " got no packets back"));
+ return errorResult(ErrorMessage.createBackendCommunicationError(getName() + " got no packets back"));
}
- log.finest(() -> "got packets " + basicPackets.length + " packets");
+ if (isLoggingFine())
+ getLogger().finest("got packets " + basicPackets.length + " packets");
basicPackets[0].ensureInstanceOf(QueryResultPacket.class, getName());
QueryResultPacket resultPacket = (QueryResultPacket) basicPackets[0];
- log.finest(() -> "got query packet. " + "docsumClass=" + query.getPresentation().getSummary());
+ if (isLoggingFine())
+ getLogger().finest("got query packet. " + "docsumClass=" + query.getPresentation().getSummary());
if (query.getPresentation().getSummary() == null)
query.getPresentation().setSummary(searcher.getDefaultDocsumClass());
@@ -110,6 +114,14 @@ public class FS4SearchInvoker extends SearchInvoker implements ResponseMonitor<F
return result;
}
+ private Result errorResult(ErrorMessage errorMessage) {
+ Result error = new Result(query, errorMessage);
+ Coverage errorCoverage = new Coverage(0, 0, 0);
+ errorCoverage.setNodesTried(1);
+ error.setCoverage(errorCoverage);
+ return error;
+ }
+
@Override
public void release() {
if (channel != null) {
@@ -122,6 +134,14 @@ public class FS4SearchInvoker extends SearchInvoker implements ResponseMonitor<F
return searcher.getName();
}
+ private Logger getLogger() {
+ return searcher.getLogger();
+ }
+
+ private boolean isLoggingFine() {
+ return getLogger().isLoggable(Level.FINE);
+ }
+
@Override
public void responseAvailable(FS4Channel from) {
responseAvailable();
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java
index 68f8bd9d9ea..ac02b5f8e5e 100644
--- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java
@@ -54,6 +54,8 @@ public class FastSearcher extends VespaBackEndSearcher {
private final Backend dispatchBackend;
+ private final FS4InvokerFactory fs4InvokerFactory;
+
/**
* Creates a Fastsearcher.
*
@@ -75,6 +77,7 @@ public class FastSearcher extends VespaBackEndSearcher {
init(fs4ResourcePool.getServerId(), docSumParams, clusterParams, documentdbInfoConfig);
this.dispatchBackend = dispatchBackend;
this.dispatcher = dispatcher;
+ this.fs4InvokerFactory = new FS4InvokerFactory(fs4ResourcePool, dispatcher.searchCluster(), this);
}
/**
@@ -206,14 +209,14 @@ public class FastSearcher extends VespaBackEndSearcher {
* on the same host.
*/
private SearchInvoker getSearchInvoker(Query query) {
- Optional<SearchInvoker> invoker = dispatcher.getSearchInvoker(query, this);
+ Optional<SearchInvoker> invoker = dispatcher.getSearchInvoker(query, fs4InvokerFactory);
if (invoker.isPresent()) {
return invoker.get();
}
Optional<Node> direct = getDirectNode(query);
if(direct.isPresent()) {
- return dispatcher.getFS4InvokerFactory().createSearchInvoker(this, query, direct.get());
+ return fs4InvokerFactory.getSearchInvoker(query, direct.get());
}
return new FS4SearchInvoker(this, query, dispatchBackend.openChannel(), Optional.empty());
}
@@ -225,14 +228,14 @@ public class FastSearcher extends VespaBackEndSearcher {
*/
private FillInvoker getFillInvoker(Result result) {
Query query = result.getQuery();
- Optional<FillInvoker> invoker = dispatcher.getFillInvoker(result, this);
+ Optional<FillInvoker> invoker = dispatcher.getFillInvoker(result, this, getDocumentDatabase(query), fs4InvokerFactory);
if (invoker.isPresent()) {
return invoker.get();
}
Optional<Node> direct = getDirectNode(query);
if (direct.isPresent()) {
- return dispatcher.getFS4InvokerFactory().createFillInvoker(this, result, direct.get());
+ return fs4InvokerFactory.getFillInvoker(query, direct.get());
}
return new FS4FillInvoker(this, query, dispatchBackend);
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java
index dccda0bf733..bee1fab5686 100644
--- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java
@@ -122,7 +122,7 @@ public abstract class VespaBackEndSearcher extends PingableSearcher {
public String getServerId() { return serverId; }
- public DocumentDatabase getDocumentDatabase(Query query) {
+ protected DocumentDatabase getDocumentDatabase(Query query) {
if (query.getModel().getRestrict().size() == 1) {
String docTypeName = (String)query.getModel().getRestrict().toArray()[0];
DocumentDatabase db = documentDbs.get(docTypeName);
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/Highlight.java b/container-search/src/main/java/com/yahoo/prelude/query/Highlight.java
index 44691b04b84..81c68ccc2b9 100644
--- a/container-search/src/main/java/com/yahoo/prelude/query/Highlight.java
+++ b/container-search/src/main/java/com/yahoo/prelude/query/Highlight.java
@@ -1,11 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.query;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import static com.yahoo.language.LinguisticsCase.toLowerCase;
@@ -135,6 +131,8 @@ public class Highlight implements Cloneable {
}
}
+
+
}