diff options
author | Harald Musum <musum@verizonmedia.com> | 2019-09-23 16:12:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-23 16:12:12 +0200 |
commit | 5d9cf7eab1eac805b933d07321d95524a8cb2164 (patch) | |
tree | 2980ee536afafa6126e1b783554d4e7f9e0a9cd2 /container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java | |
parent | 8affeae3e0659a7254aea22582919b85a412a8fe (diff) |
Revert "Balder/remove tld from config model rebased"
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java | 35 |
1 files changed, 27 insertions, 8 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 1f621eb926c..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 @@ -23,6 +23,7 @@ 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; @@ -106,9 +107,17 @@ public class ClusterSearcher extends Searcher { vipStatus.addToRotation(searcher.getName()); } else { Dispatcher dispatcher = Dispatcher.create(id.stringValue(), dispatchConfig, clusterInfoConfig.nodeCount(), vipStatus, metric); - FastSearcher searcher = searchDispatch(searchClusterIndex, fs4ResourcePool.getServerId(), docSumParams, documentDbConfig, dispatcher); - addBackendSearcher(searcher); - + 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); + } + } } if ( server == null ) { throw new IllegalStateException("ClusterSearcher should have backend."); @@ -124,16 +133,26 @@ public class ClusterSearcher extends Searcher { return null; } - private static ClusterParams makeClusterParams(int searchclusterIndex) { - return new ClusterParams("sc" + searchclusterIndex + ".num" + 0); + /** + * 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 FastSearcher searchDispatch(int searchclusterIndex, String serverId, SummaryParameters docSumParams, DocumentdbInfoConfig documentdbInfoConfig, - Dispatcher dispatcher) { - ClusterParams clusterParams = makeClusterParams(searchclusterIndex); + Dispatcher dispatcher, + int dispatcherIndex) { + ClusterParams clusterParams = makeClusterParams(searchclusterIndex, dispatcherIndex); return new FastSearcher(serverId, dispatcher, docSumParams, clusterParams, documentdbInfoConfig); } @@ -145,7 +164,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); + ClusterParams clusterParams = makeClusterParams(searchclusterIndex, 0); VdsStreamingSearcher searcher = new VdsStreamingSearcher(); searcher.setSearchClusterConfigId(searchClusterConfig.rankprofiles().configid()); searcher.setDocumentType(searchClusterConfig.searchdef(0)); |