From 7f56c30703f5319f5368653f6313a8f12f07b3cb Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Fri, 15 Mar 2019 18:14:17 +0100 Subject: Revert "Protobuf over jrt support in search" --- .../prelude/fastsearch/FS4InvokerFactory.java | 46 +++++++++++++++------- .../yahoo/prelude/fastsearch/FS4SearchInvoker.java | 36 +++++++++++++---- .../com/yahoo/prelude/fastsearch/FastSearcher.java | 11 ++++-- .../prelude/fastsearch/VespaBackEndSearcher.java | 2 +- .../java/com/yahoo/prelude/query/Highlight.java | 8 ++-- 5 files changed, 70 insertions(+), 33 deletions(-) (limited to 'container-search/src/main/java/com/yahoo/prelude') 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 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 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 empty if some node in the * list is invalid and the remaining coverage is not sufficient */ - @Override - public Optional createSearchInvoker(VespaBackEndSearcher searcher, Query query, OptionalInt groupId, List nodes, - boolean acceptIncompleteCoverage) { + public Optional getSearchInvoker(Query query, OptionalInt groupId, List nodes, boolean acceptIncompleteCoverage) { List invokers = new ArrayList<>(nodes.size()); Set 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 nodes, Set 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 empty if some hit is from an unknown content node */ - public Optional createFillInvoker(VespaBackEndSearcher searcher, Result result) { + public Optional getFillInvoker(Result result) { Collection requiredNodes = requiredFillNodes(result); + Query query = result.getQuery(); Map 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 { - 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 "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 invoker = dispatcher.getSearchInvoker(query, this); + Optional invoker = dispatcher.getSearchInvoker(query, fs4InvokerFactory); if (invoker.isPresent()) { return invoker.get(); } Optional 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 invoker = dispatcher.getFillInvoker(result, this); + Optional invoker = dispatcher.getFillInvoker(result, this, getDocumentDatabase(query), fs4InvokerFactory); if (invoker.isPresent()) { return invoker.get(); } Optional 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 { } } + + } -- cgit v1.2.3