From 8070bd0d1a0cd0eda908cc32fc2506d247ec2f67 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 23 Sep 2019 16:18:40 +0200 Subject: Revert "Revert "Balder/remove tld from config model rebased"" --- .../com/yahoo/prelude/cluster/ClusterSearcher.java | 35 +++++----------------- .../prelude/cluster/ClusterSearcherTestCase.java | 27 ----------------- 2 files changed, 8 insertions(+), 54 deletions(-) (limited to 'container-search/src') 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 22af77020eb..1f621eb926c 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 @@ -23,7 +23,6 @@ import com.yahoo.search.dispatch.Dispatcher; 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.vespa.config.search.DispatchConfig; import com.yahoo.vespa.streamingvisitors.VdsStreamingSearcher; import org.apache.commons.lang.StringUtils; @@ -107,17 +106,9 @@ public class ClusterSearcher extends Searcher { vipStatus.addToRotation(searcher.getName()); } else { Dispatcher dispatcher = Dispatcher.create(id.stringValue(), dispatchConfig, clusterInfoConfig.nodeCount(), vipStatus, metric); - for (int dispatcherIndex = 0; dispatcherIndex < searchClusterConfig.dispatcher().size(); dispatcherIndex++) { - try { - if ( ! isRemote(searchClusterConfig.dispatcher(dispatcherIndex).host())) { - FastSearcher searcher = searchDispatch(searchClusterIndex, fs4ResourcePool.getServerId(), docSumParams, - documentDbConfig, dispatcher, dispatcherIndex); - addBackendSearcher(searcher); - } - } catch (UnknownHostException e) { - throw new RuntimeException(e); - } - } + FastSearcher searcher = searchDispatch(searchClusterIndex, fs4ResourcePool.getServerId(), docSumParams, documentDbConfig, dispatcher); + addBackendSearcher(searcher); + } if ( server == null ) { throw new IllegalStateException("ClusterSearcher should have backend."); @@ -133,26 +124,16 @@ public class ClusterSearcher extends Searcher { return null; } - /** - * Returns false if this host is local. - */ - boolean isRemote(String host) throws UnknownHostException { - return (InetAddress.getByName(host).isLoopbackAddress()) - ? false - : !host.equals(HostName.getLocalhost()); - } - - private static ClusterParams makeClusterParams(int searchclusterIndex, int dispatchIndex) { - return new ClusterParams("sc" + searchclusterIndex + ".num" + dispatchIndex); + private static ClusterParams makeClusterParams(int searchclusterIndex) { + return new ClusterParams("sc" + searchclusterIndex + ".num" + 0); } private static FastSearcher searchDispatch(int searchclusterIndex, String serverId, SummaryParameters docSumParams, DocumentdbInfoConfig documentdbInfoConfig, - Dispatcher dispatcher, - int dispatcherIndex) { - ClusterParams clusterParams = makeClusterParams(searchclusterIndex, dispatcherIndex); + Dispatcher dispatcher) { + ClusterParams clusterParams = makeClusterParams(searchclusterIndex); return new FastSearcher(serverId, dispatcher, docSumParams, clusterParams, documentdbInfoConfig); } @@ -164,7 +145,7 @@ public class ClusterSearcher extends Searcher { if (searchClusterConfig.searchdef().size() != 1) { throw new IllegalArgumentException("Search clusters in streaming search shall only contain a single searchdefinition : " + searchClusterConfig.searchdef()); } - ClusterParams clusterParams = makeClusterParams(searchclusterIndex, 0); + ClusterParams clusterParams = makeClusterParams(searchclusterIndex); VdsStreamingSearcher searcher = new VdsStreamingSearcher(); searcher.setSearchClusterConfigId(searchClusterConfig.rankprofiles().configid()); searcher.setDocumentType(searchClusterConfig.searchdef(0)); 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 c772300876b..f35d77de01a 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 @@ -21,12 +21,9 @@ import com.yahoo.search.Result; import com.yahoo.search.config.ClusterConfig; import com.yahoo.search.result.Hit; import com.yahoo.search.searchchain.Execution; -import com.yahoo.statistics.Statistics; import com.yahoo.vespa.config.search.DispatchConfig; import org.junit.Test; -import java.net.InetAddress; -import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; @@ -419,26 +416,6 @@ public class ClusterSearcherTestCase { assertResult(6, new ArrayList<>(), getResult(6, 2, extra, ex)); } - @Test - public void testLocalConnect() throws UnknownHostException { - ClusterSearcher cluster = new ClusterSearcher(new LinkedHashSet<>(Arrays.asList("dummy"))); - boolean canFindYahoo; - final String yahoo = "www.yahoo.com"; - - try { - canFindYahoo = (null != InetAddress.getByName(yahoo)); - } catch (Exception e) { - canFindYahoo = false; - } - - assertFalse(cluster.isRemote("127.0.0.1")); - assertFalse(cluster.isRemote("localhost")); - - if (canFindYahoo) { - assertTrue(cluster.isRemote(yahoo)); - } - } - @Test public void testRequireThatSearchFailsForUndefinedRankProfileWithOneDocType() { Execution execution = createExecution(Arrays.asList("type1"), false); @@ -525,10 +502,6 @@ public class ClusterSearcherTestCase { searchClusterConfig.searchdef("streaming_sd"); } qrSearchersConfig.searchcluster(searchClusterConfig); - QrSearchersConfig.Searchcluster.Dispatcher.Builder dispatcherConfig = new QrSearchersConfig.Searchcluster.Dispatcher.Builder(); - dispatcherConfig.host("localhost"); - dispatcherConfig.port(0); - searchClusterConfig.dispatcher(dispatcherConfig); ClusterConfig.Builder clusterConfig = new ClusterConfig.Builder().clusterName(clusterName); if (maxQueryTimeout != null) -- cgit v1.2.3