summaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-10-05 12:31:26 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-10-05 12:31:26 +0200
commit0d343fa575e866e86c1e185eef959885d4dae8a0 (patch)
treeb851f2d0b78fb5a5631753bb36f411556c38d841 /container-search
parent7a0243a1e6bcbbfb672ff7933635b9ab0d607474 (diff)
Nonfunctional changes only
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/data/JsonProducer.java11
-rw-r--r--container-search/src/main/java/com/yahoo/data/XmlProducer.java11
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/cluster/ClusterMonitor.java2
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java31
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/cluster/NodeMonitor.java6
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/cluster/dispatchprototype/DispatchClusterSearcher.java141
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/cluster/package-info.java5
-rw-r--r--container-search/src/main/java/com/yahoo/search/cluster/ClusterMonitor.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java15
9 files changed, 43 insertions, 181 deletions
diff --git a/container-search/src/main/java/com/yahoo/data/JsonProducer.java b/container-search/src/main/java/com/yahoo/data/JsonProducer.java
index 488f2b4c720..b4ccc95f228 100644
--- a/container-search/src/main/java/com/yahoo/data/JsonProducer.java
+++ b/container-search/src/main/java/com/yahoo/data/JsonProducer.java
@@ -3,7 +3,7 @@ package com.yahoo.data;
/**
* Generic API for classes that contain data representable as JSON.
- **/
+ */
public interface JsonProducer {
/**
@@ -14,13 +14,14 @@ public interface JsonProducer {
* canonical format.
* @param target the StringBuilder to append to.
* @return the target passed in is also returned (to allow chaining).
- **/
- public StringBuilder writeJson(StringBuilder target);
+ */
+ StringBuilder writeJson(StringBuilder target);
/**
* Convenience method equivalent to:
* makeJson(new StringBuilder()).toString()
* @return String containing JSON representation of this object's data.
- **/
- public String toJson();
+ */
+ String toJson();
+
}
diff --git a/container-search/src/main/java/com/yahoo/data/XmlProducer.java b/container-search/src/main/java/com/yahoo/data/XmlProducer.java
index d1d65aab095..e0c93f79eb5 100644
--- a/container-search/src/main/java/com/yahoo/data/XmlProducer.java
+++ b/container-search/src/main/java/com/yahoo/data/XmlProducer.java
@@ -3,21 +3,22 @@ package com.yahoo.data;
/**
* Generic API for classes that contain data representable as XML.
- **/
+ */
public interface XmlProducer {
/**
* Append the XML representation of this object's data to a StringBuilder.
* @param target the StringBuilder to append to.
* @return the target passed in is also returned (to allow chaining).
- **/
- public StringBuilder writeXML(StringBuilder target);
+ */
+ StringBuilder writeXML(StringBuilder target);
/**
* Convenience method equivalent to:
* makeXML(new StringBuilder()).toString()
* @return String containing XML representation of this object's data.
- **/
- public String toXML();
+ */
+ String toXML();
+
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterMonitor.java b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterMonitor.java
index ff77680172d..3c3a9542127 100644
--- a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterMonitor.java
+++ b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterMonitor.java
@@ -20,6 +20,7 @@ import com.yahoo.search.result.ErrorMessage;
* @author Steinar Knutsen
*/
public class ClusterMonitor implements Runnable, Freezable {
+
// The ping thread wil start using the system, but we cannot be guaranteed that all components
// in the system is up. As a workaround for not being able to find out when the system
// is ready to be used, we wait some time before starting the ping thread
@@ -76,7 +77,6 @@ public class ClusterMonitor implements Runnable, Freezable {
boolean wasWorking = monitor.isWorking();
monitor.failed(error);
if (wasWorking && !monitor.isWorking()) {
- // was warning, see VESPA-1922
log.info("Failed monitoring node '" + node + "' due to '" + error);
nodeManager.failed(node);
}
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 46ef5a41ed5..bc740cd646f 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
@@ -116,12 +116,12 @@ public class ClusterSearcher extends Searcher {
Dispatcher dispatcher = new Dispatcher(dispatchConfig, fs4ResourcePool);
String eventName = clusterModelName + ".cache_hit_ratio";
- cacheHitRatio = new Value(eventName, manager, new Value.Parameters()
- .setNameExtension(false).setLogRaw(false).setLogMean(true));
+ cacheHitRatio = new Value(eventName, manager, new Value.Parameters().setNameExtension(false)
+ .setLogRaw(false).setLogMean(true));
maxQueryTimeout = ParameterParser.asMilliSeconds(clusterConfig.maxQueryTimeout(), DEFAULT_MAX_QUERY_TIMEOUT);
maxQueryCacheTimeout = ParameterParser.asMilliSeconds(clusterConfig.maxQueryCacheTimeout(),
- DEFAULT_MAX_QUERY_CACHE_TIMEOUT);
+ DEFAULT_MAX_QUERY_CACHE_TIMEOUT);
CacheParams cacheParams = new CacheParams(createCache(clusterConfig, clusterModelName));
SummaryParameters docSumParams = new SummaryParameters(qrsConfig
@@ -162,10 +162,10 @@ public class ClusterSearcher extends Searcher {
gotExpectedBackend |= searcher.isLocalDispatching();
}
}
- if (!gotExpectedBackend) {
+ if ( ! gotExpectedBackend) {
log.log(Level.SEVERE, "ClusterSearcher should have a local top level dispatch."
- + " The possibility to configure dispatchers explicitly will be removed"
- + " in a future release.");
+ + " The possibility to configure dispatchers explicitly will be removed"
+ + " in a future release.");
}
hasher.running = true;
monitor.freeze();
@@ -231,10 +231,8 @@ public class ClusterSearcher extends Searcher {
emulConfig, 0);
VdsStreamingSearcher searcher = (VdsStreamingSearcher) VespaBackEndSearcher
.getSearcher("com.yahoo.vespa.streamingvisitors.VdsStreamingSearcher");
- searcher.setSearchClusterConfigId(searchClusterConfig
- .rankprofiles().configid());
- searcher.setStorageClusterRouteSpec(searchClusterConfig
- .storagecluster().routespec());
+ searcher.setSearchClusterConfigId(searchClusterConfig.rankprofiles().configid());
+ searcher.setStorageClusterRouteSpec(searchClusterConfig.storagecluster().routespec());
searcher.init(docSumParams, clusterParams, cacheParams, documentdbInfoConfig);
return searcher;
}
@@ -245,9 +243,8 @@ public class ClusterSearcher extends Searcher {
this.failoverToRemote = false;
this.documentTypes = documentTypes;
monitor = new ClusterMonitor(this, new QrMonitorConfig(new QrMonitorConfig.Builder()), new VipStatus());
- cacheHitRatio = new Value(
- "com.yahoo.prelude.cluster.ClusterSearcher.ClusterSearcher().dummy",
- Statistics.nullImplementation, new Value.Parameters());
+ cacheHitRatio = new Value("com.yahoo.prelude.cluster.ClusterSearcher.ClusterSearcher().dummy",
+ Statistics.nullImplementation, new Value.Parameters());
clusterModelName = "testScenario";
fs4ResourcePool = null;
maxQueryTimeout = DEFAULT_MAX_QUERY_TIMEOUT;
@@ -268,8 +265,8 @@ public class ClusterSearcher extends Searcher {
private static CacheControl createCache(ClusterConfig config, String clusterModelName) {
log.log(Level.INFO, "Enabling cache for search cluster "
- + clusterModelName + " (size=" + config.cacheSize()
- + ", timeout=" + config.cacheTimeout() + ")");
+ + clusterModelName + " (size=" + config.cacheSize()
+ + ", timeout=" + config.cacheTimeout() + ")");
return new CacheControl(config.cacheSize(), config.cacheTimeout());
}
@@ -311,6 +308,7 @@ public class ClusterSearcher extends Searcher {
* @return null if request rank profile is ok for the requested
* doc types, a result with error message if not.
*/
+ // TODO: This should be in a separate searcher
private Result checkValidRankProfiles(Query query, Set<String> docTypes) {
String rankProfile = query.getRanking().getProfile();
Set<String> invalidInDocTypes = null;
@@ -405,8 +403,7 @@ public class ClusterSearcher extends Searcher {
int tries = 0;
do {
- // The loop is in case there are other searchers available
- // able to produce results
+ // The loop is in case there are other searchers available able to produce results
validateQueryTimeout(query);
validateQueryCache(query);
VespaBackEndSearcher searcher = hasher.select(tries++);
diff --git a/container-search/src/main/java/com/yahoo/prelude/cluster/NodeMonitor.java b/container-search/src/main/java/com/yahoo/prelude/cluster/NodeMonitor.java
index eb747b2bbee..850b362e0f5 100644
--- a/container-search/src/main/java/com/yahoo/prelude/cluster/NodeMonitor.java
+++ b/container-search/src/main/java/com/yahoo/prelude/cluster/NodeMonitor.java
@@ -18,7 +18,7 @@ import com.yahoo.search.result.ErrorMessage;
* </ul>
*
* @author bratseth
- * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @author Steinar Knutsen
*/
public class NodeMonitor {
@@ -65,8 +65,8 @@ public class NodeMonitor {
public void failed(ErrorMessage error) {
long respondedAt = System.currentTimeMillis();
- if (error.getCode() == BACKEND_COMMUNICATION_ERROR.code
- || error.getCode() == NO_ANSWER_WHEN_PINGING_NODE.code) {
+ if (error.getCode() == BACKEND_COMMUNICATION_ERROR.code
+ || error.getCode() == NO_ANSWER_WHEN_PINGING_NODE.code) {
// Only count not being able to talk to backend at all
// as errors we care about
if ((respondedAt - succeededAt) > 10000) {
diff --git a/container-search/src/main/java/com/yahoo/prelude/cluster/dispatchprototype/DispatchClusterSearcher.java b/container-search/src/main/java/com/yahoo/prelude/cluster/dispatchprototype/DispatchClusterSearcher.java
deleted file mode 100644
index dbcee3234ea..00000000000
--- a/container-search/src/main/java/com/yahoo/prelude/cluster/dispatchprototype/DispatchClusterSearcher.java
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.prelude.cluster.dispatchprototype;
-
-import com.google.common.annotations.Beta;
-import com.yahoo.cloud.config.ClusterInfoConfig;
-import com.yahoo.component.ComponentId;
-import com.yahoo.component.chain.dependencies.After;
-import com.yahoo.component.provider.ComponentRegistry;
-import com.yahoo.container.QrSearchersConfig;
-import com.yahoo.container.handler.VipStatus;
-import com.yahoo.container.search.LegacyEmulationConfig;
-import com.yahoo.prelude.cluster.ClusterSearcher;
-import com.yahoo.prelude.cluster.QrMonitorConfig;
-import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig;
-import com.yahoo.prelude.fastsearch.FS4ResourcePool;
-import com.yahoo.search.Query;
-import com.yahoo.search.Result;
-import com.yahoo.search.Searcher;
-import com.yahoo.search.config.ClusterConfig;
-import com.yahoo.search.config.dispatchprototype.SearchNodesConfig;
-import com.yahoo.search.searchchain.Execution;
-import com.yahoo.statistics.Statistics;
-import com.yahoo.vespa.config.search.DispatchConfig;
-
-import static com.yahoo.container.QrSearchersConfig.Searchcluster;
-
-/**
- * This class modifies ClusterSearcher behavior to talk directly to search nodes instead of dispatchers.
- *
- * This means that queries are sent to a single search node only. Obviously, this will not give correct
- * results - it is just a single step towards eliminating top-level dispatch as a separate process.
- *
- * @author bakksjo
- */
-// 2016-08-16 (bratseth): We should probably just remove this now. It was a prototype that never went anywhere
-@Beta
-@After("*")
-public class DispatchClusterSearcher extends Searcher {
- private final ClusterSearcher clusterSearcher;
-
- public DispatchClusterSearcher(
- final ComponentId id,
- final SearchNodesConfig searchNodesConfig,
- final QrSearchersConfig qrsConfig,
- final ClusterConfig clusterConfig,
- final DocumentdbInfoConfig documentDbConfig,
- final LegacyEmulationConfig emulationConfig,
- final QrMonitorConfig monitorConfig,
- final DispatchConfig dispatchConfig,
- final ClusterInfoConfig clusterInfoConfig,
- final Statistics manager,
- final FS4ResourcePool listeners,
- final ComponentRegistry<ClusterSearcher> otherClusterSearchers,
- final VipStatus vipStatus) {
-
- clusterSearcher = new ClusterSearcher(
- id,
- makeQrSearchersConfigWithSearchNodesInsteadOfDispatcherNodes(
- qrsConfig,
- searchNodesConfig,
- clusterConfig.clusterName()),
- clusterConfig,
- documentDbConfig,
- emulationConfig,
- monitorConfig,
- dispatchConfig,
- clusterInfoConfig,
- manager,
- listeners,
- vipStatus);
-
- // Prevent the ClusterSearcher(s) implicitly set up by the model from warning that it can't contact
- // the c++ TLD when we disable it in the system test.
- otherClusterSearchers.allComponents().stream()
- .forEach(ClusterSearcher::deconstruct);
- }
-
-
- @Override
- public Result search(Query query, Execution execution) {
- return clusterSearcher.search(query, execution);
- }
-
- @Override
- public void fill(Result result, String summaryClass, Execution execution) {
- clusterSearcher.fill(result, summaryClass, execution);
- }
-
- private static QrSearchersConfig makeQrSearchersConfigWithSearchNodesInsteadOfDispatcherNodes(
- final QrSearchersConfig qrsConfig,
- final SearchNodesConfig searchNodesConfig,
- final String clusterName) {
- final QrSearchersConfig.Builder qrSearchersConfigBuilder = new QrSearchersConfig.Builder();
- copyEverythingExceptSearchclusters(qrsConfig, qrSearchersConfigBuilder);
-
- // We only "copy" (with modifications) a single Searchcluster.
- final Searchcluster originalSearchcluster = getSearchclusterByName(qrsConfig, clusterName);
- final Searchcluster.Builder searchclusterBuilder = new Searchcluster.Builder();
- copyEverythingExceptDispatchers(originalSearchcluster, searchclusterBuilder);
- // Here comes the trick: Substitute search nodes for dispatchers.
- for (final SearchNodesConfig.Search_node searchNodeConfig : searchNodesConfig.search_node()) {
- searchclusterBuilder.dispatcher(
- new Searchcluster.Dispatcher.Builder()
- .host(searchNodeConfig.host())
- .port(searchNodeConfig.port()));
- }
- qrSearchersConfigBuilder.searchcluster(searchclusterBuilder);
-
- return new QrSearchersConfig(qrSearchersConfigBuilder);
- }
-
- private static void copyEverythingExceptSearchclusters(
- final QrSearchersConfig source,
- final QrSearchersConfig.Builder destination) {
- destination.tag(new QrSearchersConfig.Tag.Builder(source.tag()));
- destination.com(new QrSearchersConfig.Com.Builder(source.com()));
- destination.customizedsearchers(new QrSearchersConfig.Customizedsearchers.Builder(source.customizedsearchers()));
- for (final QrSearchersConfig.External external : source.external()) {
- destination.external(new QrSearchersConfig.External.Builder(external));
- }
- }
-
- private static Searchcluster getSearchclusterByName(final QrSearchersConfig qrsConfig, final String clusterName) {
- return qrsConfig.searchcluster().stream()
- .filter(cluster -> clusterName.equals(cluster.name()))
- .findAny()
- .orElseThrow(() -> new IllegalStateException("No cluster found with name " + clusterName));
- }
-
- private static void copyEverythingExceptDispatchers(
- final Searchcluster source,
- final Searchcluster.Builder destination) {
- destination
- .name(source.name())
- .searchdef(source.searchdef())
- .rankprofiles(new Searchcluster.Rankprofiles.Builder(source.rankprofiles()))
- .indexingmode(source.indexingmode())
- // Deliberately excluding storagecluster here because it's not relevant.
- .rowbits(source.rowbits());
- }
-}
diff --git a/container-search/src/main/java/com/yahoo/prelude/cluster/package-info.java b/container-search/src/main/java/com/yahoo/prelude/cluster/package-info.java
index e4dbfbb3a1b..26ba438bb68 100644
--- a/container-search/src/main/java/com/yahoo/prelude/cluster/package-info.java
+++ b/container-search/src/main/java/com/yahoo/prelude/cluster/package-info.java
@@ -1,4 +1,9 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+/**
+ * Cluster monitoring for content clusters queried over fnet.
+ * Others (e.g HTTP connections and content clusters queried over RPC)
+ * should use com.yahoo.search.cluster
+ */
@ExportPackage
package com.yahoo.prelude.cluster;
diff --git a/container-search/src/main/java/com/yahoo/search/cluster/ClusterMonitor.java b/container-search/src/main/java/com/yahoo/search/cluster/ClusterMonitor.java
index 520903f2210..0916e3f4f9a 100644
--- a/container-search/src/main/java/com/yahoo/search/cluster/ClusterMonitor.java
+++ b/container-search/src/main/java/com/yahoo/search/cluster/ClusterMonitor.java
@@ -20,7 +20,7 @@ import java.util.logging.Logger;
* The monitor uses an internal thread for node monitoring.
* All <i>public</i> methods of this class are multithread safe.
*
- * @author bratseth
+ * @author bratseth
*/
public class ClusterMonitor<T> {
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 aa5726bd52c..56bd3fc57b3 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
@@ -64,7 +64,7 @@ import java.util.logging.Logger;
/**
* Handles search request.
*
- * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @author Steinar Knutsen
*/
public class SearchHandler extends LoggingRequestHandler {
@@ -377,7 +377,10 @@ public class SearchHandler extends LoggingRequestHandler {
/**
* For internal use only
+ *
+ * @deprecated remove on Vespa 7
*/
+ @Deprecated
public Renderer<Result> getRendererCopy(ComponentSpecification spec) { // TODO: Deprecate this
Renderer<Result> renderer = rendererRegistry.getRenderer(spec);
return perRenderingCopy(renderer);
@@ -508,14 +511,10 @@ public class SearchHandler extends LoggingRequestHandler {
ElapsedTime elapsedTime = result.getElapsedTime();
long now = System.currentTimeMillis();
if (elapsedTime.firstFill() != 0) {
- query.trace("Query time " + query + ": "
- + (elapsedTime.firstFill() - elapsedTime.first()) + " ms", false, 3);
-
- query.trace("Summary fetch time " + query + ": "
- + (now - elapsedTime.firstFill()) + " ms", false, 3);
+ query.trace("Query time " + query + ": " + (elapsedTime.firstFill() - elapsedTime.first()) + " ms", false, 3);
+ query.trace("Summary fetch time " + query + ": " + (now - elapsedTime.firstFill()) + " ms", false, 3);
} else {
- query.trace("Total search time " + query + ": "
- + (now - elapsedTime.first()) + " ms", false, 3);
+ query.trace("Total search time " + query + ": " + (now - elapsedTime.first()) + " ms", false, 3);
}
}