public abstract class HTTPClientSearcher extends HTTPSearcher
getQueryMap(com.yahoo.search.Query)
and handleResponse(java.io.InputStream, long, com.yahoo.search.Query)
to create the http request and handle the response, respectively.
This class automatically adds a meta hit containing latency and other meta information about the obtained HTTP data using createRequestMeta(). The fields available in the hit are:
HTTPSearcher.SearcherHttpClient, HTTPSearcher.ThrowingCertificateStore
Modifier and Type | Field and Description |
---|---|
protected static Logger |
log |
(package private) static com.yahoo.processing.request.CompoundName |
REQUEST_META_CARRIER |
certificateProxy, IP_ADDRESS_UNKNOWN, LOG_CONNECT_TIMEOUT_PREFIX, LOG_HEADER_PREFIX, LOG_HITCOUNT, LOG_HOST, LOG_IP_ADDRESS, LOG_LATENCY_CONNECT, LOG_LATENCY_FINISH, LOG_LATENCY_START, LOG_PATH, LOG_PORT, LOG_PROXY_HOST, LOG_PROXY_PORT, LOG_PROXY_TYPE, LOG_QUERY_PARAM_PREFIX, LOG_READ_TIMEOUT_PREFIX, LOG_RESPONSE_HEADER_PREFIX, LOG_SCHEME, LOG_STATUS, LOG_URI, useCertificate, YCA_HTTP_HEADER
Constructor and Description |
---|
HTTPClientSearcher(com.yahoo.component.ComponentId id,
List<Connection> connections,
HTTPParameters parameters,
com.yahoo.statistics.Statistics statistics) |
HTTPClientSearcher(com.yahoo.component.ComponentId id,
List<Connection> connections,
HTTPParameters parameters,
com.yahoo.statistics.Statistics statistics,
com.yahoo.jdisc.http.CertificateStore certificateStore)
Creates a client searcher
|
HTTPClientSearcher(com.yahoo.component.ComponentId id,
List<Connection> connections,
String path,
com.yahoo.statistics.Statistics statistics)
Creates a client searcher
|
HTTPClientSearcher(com.yahoo.component.ComponentId id,
List<Connection> connections,
String path,
com.yahoo.statistics.Statistics statistics,
com.yahoo.jdisc.http.CertificateStore certificateStore) |
Modifier and Type | Method and Description |
---|---|
private Hit |
doHttpRequest(Query query,
Connection connection) |
void |
fill(Result result,
String summaryClass,
Execution execution,
Connection connection)
Do nothing on fill in client searchers
|
abstract Map<String,String> |
getCacheKey(Query q)
numHits and offset should not be part of the cache key as cache supports
partial read/write that is only one cache entry is maintained per query
irrespective of the offset and numhits.
|
Map<String,String> |
getQueryMap(Query query)
Adds all key-values starting by "service." + getClientName() in query.properties().
|
protected String |
getServiceName()
Override this to return the name of the service this is a client of.
|
Query |
handleResponse(org.apache.http.HttpEntity entity,
Query query)
Unmarshals the response and adds the resulting data to the given query.
|
Query |
handleResponse(InputStream inputStream,
long contentLength,
Query query)
Convenience hook for unmarshalling the response and adding the information to the query.
|
Result |
robustSearch(Query query,
Execution execution,
Connection connection)
Overridden to avoid interfering with errors from nested searchers, which is inappropriate for a client
|
Result |
search(Query query,
Execution execution,
Connection connection)
Implements a search towards the connection chosen by the cluster searcher for this query
|
Result |
search(Query query,
Execution execution,
ErrorMessage error)
Overrides to pass the query on to the next searcher
|
protected boolean |
shouldRetry(Query query,
Result result)
Never retry individual queries to clients for now
|
checkPing, cleanupHttpEntity, createClient, createMalformedUrlError, createRequest, createRequest, createRequestMeta, getConnectionManager, getEntity, getEntity, getParameters, getPath, getPingPath, getPingURI, getRequestEntity, getRequestHeaders, getResponse, getResponse, getResponse, getResponse, getURI, getURI, logResponseLatency, ping, shutdownConnectionManagers
deconstruct, failed, fill, getFirstConnection, getHasher, getMonitor, log, ping, search, timedOut, working
ping
ensureFilled, getLogger, process, toString
getAnnotatedDependencies, getDefaultAnnotatedDependencies, getDependencies, initDependencies
clone, compareTo, getClassName, getId, getIdString, hasInitializedId, initId, isDeconstructable, setIsDeconstructable
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
pingIterationCompleted
static final com.yahoo.processing.request.CompoundName REQUEST_META_CARRIER
protected static final Logger log
public HTTPClientSearcher(com.yahoo.component.ComponentId id, List<Connection> connections, String path, com.yahoo.statistics.Statistics statistics)
id
- the id of this instanceconnections
- the connections this will load balance and fail over betweenpath
- the path portion of the url to be usedpublic HTTPClientSearcher(com.yahoo.component.ComponentId id, List<Connection> connections, String path, com.yahoo.statistics.Statistics statistics, com.yahoo.jdisc.http.CertificateStore certificateStore)
public HTTPClientSearcher(com.yahoo.component.ComponentId id, List<Connection> connections, HTTPParameters parameters, com.yahoo.statistics.Statistics statistics)
public HTTPClientSearcher(com.yahoo.component.ComponentId id, List<Connection> connections, HTTPParameters parameters, com.yahoo.statistics.Statistics statistics, com.yahoo.jdisc.http.CertificateStore certificateStore)
id
- the id of this instanceconnections
- the connections this will load balance and fail over betweenparameters
- the parameters to use when making http callscertificateStore
- the certificate store to use to pass certificates in requestspublic Result robustSearch(Query query, Execution execution, Connection connection)
robustSearch
in class ClusterSearcher<Connection>
public Result search(Query query, Execution execution, Connection connection)
search
in class ClusterSearcher<Connection>
private Hit doHttpRequest(Query query, Connection connection)
public Result search(Query query, Execution execution, ErrorMessage error)
search
in class ClusterSearcher<Connection>
public void fill(Result result, String summaryClass, Execution execution, Connection connection)
fill
in class ClusterSearcher<Connection>
public Query handleResponse(InputStream inputStream, long contentLength, Query query) throws IOException
handleResponse(entity,query)
in any subclass.
This default implementation throws an exception.inputStream
- the stream containing the data from the http servicecontentLength
- the length of the content in the stream in bytes, or a negative number if not knownquery
- the current query, to which information from the stream should be addedIOException
public Query handleResponse(org.apache.http.HttpEntity entity, Query query) throws IOException
return handleResponse(entity.getContent(), entity.getContentLength(), query);
(and does some detailed query tracing).query
- the current query, to which information from the stream should be addedIOException
protected boolean shouldRetry(Query query, Result result)
shouldRetry
in class ClusterSearcher<Connection>
public abstract Map<String,String> getCacheKey(Query q)
public Map<String,String> getQueryMap(Query query)
getServiceName()
is not overridden.getQueryMap
in class HTTPSearcher
protected String getServiceName()
Copyright © 2018. All rights reserved.