@Deprecated public abstract class HTTPSearcher extends ClusterSearcher<Connection>
This simply provides some utility methods for working with http connections and implements ping against the service.
This searcher contains code from the Apache httpcomponents client library, licensed to the Apache Software Foundation under the Apache License, Version 2.0. Please refer to http://www.apache.org/licenses/LICENSE-2.0 for details.
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:
Modifier and Type | Class and Description |
---|---|
protected static class |
HTTPSearcher.SearcherHttpClient
Deprecated.
|
protected static class |
HTTPSearcher.ThrowingCertificateStore
Deprecated.
|
Modifier and Type | Field and Description |
---|---|
protected org.apache.http.HttpHost |
certificateProxy
Deprecated.
The (optional) certificate server proxy
|
static String |
IP_ADDRESS_UNKNOWN
Deprecated.
|
protected Logger |
log
Deprecated.
|
static String |
LOG_CONNECT_TIMEOUT_PREFIX
Deprecated.
|
static String |
LOG_HEADER_PREFIX
Deprecated.
|
static String |
LOG_HITCOUNT
Deprecated.
|
static String |
LOG_HOST
Deprecated.
|
static String |
LOG_IP_ADDRESS
Deprecated.
|
static String |
LOG_LATENCY_CONNECT
Deprecated.
|
static String |
LOG_LATENCY_FINISH
Deprecated.
|
static String |
LOG_LATENCY_START
Deprecated.
|
static String |
LOG_PATH
Deprecated.
|
static String |
LOG_PORT
Deprecated.
|
static String |
LOG_PROXY_HOST
Deprecated.
|
static String |
LOG_PROXY_PORT
Deprecated.
|
static String |
LOG_PROXY_TYPE
Deprecated.
|
static String |
LOG_QUERY_PARAM_PREFIX
Deprecated.
|
static String |
LOG_READ_TIMEOUT_PREFIX
Deprecated.
|
static String |
LOG_RESPONSE_HEADER_PREFIX
Deprecated.
|
static String |
LOG_SCHEME
Deprecated.
|
static String |
LOG_STATUS
Deprecated.
|
static String |
LOG_URI
Deprecated.
|
protected boolean |
useCertificate
Deprecated.
Whether to use certificates
|
protected static String |
YCA_HTTP_HEADER
Deprecated.
|
Constructor and Description |
---|
HTTPSearcher(com.yahoo.component.ComponentId componentId,
List<Connection> connections,
HTTPParameters parameters,
com.yahoo.statistics.Statistics statistics)
Deprecated.
|
HTTPSearcher(com.yahoo.component.ComponentId componentId,
List<Connection> connections,
HTTPParameters parameters,
com.yahoo.statistics.Statistics statistics,
com.yahoo.jdisc.http.CertificateStore certificateStore)
Deprecated.
Creates a http searcher
|
HTTPSearcher(com.yahoo.component.ComponentId componentId,
List<Connection> connections,
String path,
com.yahoo.statistics.Statistics statistics)
Deprecated.
|
HTTPSearcher(com.yahoo.component.ComponentId componentId,
List<Connection> connections,
String path,
com.yahoo.statistics.Statistics statistics,
com.yahoo.jdisc.http.CertificateStore certificateStore)
Deprecated.
Creates a http searcher with default connection and read timeouts (currently 2 and 5s respectively)
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkPing(org.apache.http.HttpResponse response,
Pong pong)
Deprecated.
Checks if the response is valid.
|
protected void |
cleanupHttpEntity(org.apache.http.HttpEntity entity)
Deprecated.
|
protected org.apache.http.client.HttpClient |
createClient(org.apache.http.params.HttpParams params)
Deprecated.
Creates a http client for one request.
|
protected ErrorMessage |
createMalformedUrlError(Query query,
Exception e)
Deprecated.
Utility method for creating error messages when a url is incorrect
|
protected org.apache.http.client.methods.HttpUriRequest |
createRequest(String method,
URI uri)
Deprecated.
Creates a HttpRequest.
|
protected org.apache.http.client.methods.HttpUriRequest |
createRequest(String method,
URI uri,
org.apache.http.HttpEntity entity)
Deprecated.
Creates a HttpRequest.
|
protected Hit |
createRequestMeta()
Deprecated.
Creates a meta hit dedicated to holding logging information.
|
protected org.apache.http.conn.ClientConnectionManager |
getConnectionManager(org.apache.http.params.HttpParams params)
Deprecated.
Get a connection manager which may be used safely from this thread
|
protected org.apache.http.HttpEntity |
getEntity(URI uri,
Hit requestMeta,
Query query)
Deprecated.
Gets the HTTP entity that holds the response contents.
|
protected org.apache.http.HttpEntity |
getEntity(URI uri,
Query query)
Deprecated.
Same a
getEntity(uri, null) . |
HTTPParameters |
getParameters()
Deprecated.
Returns the HTTP parameters used in this.
|
protected String |
getPath()
Deprecated.
Called by getURI() to get the path of the URI for the external service.
|
protected String |
getPingPath()
Deprecated.
Called by getPingURI() to get the path of the URI for pinging the
external service.
|
protected URI |
getPingURI(Connection connection)
Deprecated.
The URI that is used to check if the provider is up or down.
|
Map<String,String> |
getQueryMap(Query query)
Deprecated.
Returns the key-value pairs that should be added as properties to the request url sent to the service.
|
protected org.apache.http.HttpEntity |
getRequestEntity(Query query,
Hit requestMeta)
Deprecated.
Returns the HTTP request entity to use when making the request for this query.
|
protected Map<String,String> |
getRequestHeaders(Query query,
Hit requestMeta)
Deprecated.
Returns the set of headers to be passed in the http request to provider backend.
|
protected org.apache.http.HttpResponse |
getResponse(URI uri,
Hit requestMeta,
int connectionTimeout,
int readTimeout)
Deprecated.
Executes an HTTP request and gets the response.
|
protected org.apache.http.HttpResponse |
getResponse(URI uri,
Hit requestMeta,
Query query)
Deprecated.
Executes an HTTP request and gets the response.
|
protected org.apache.http.HttpResponse |
getResponse(URI uri,
org.apache.http.HttpEntity reqEntity,
Map<String,String> reqHeaders,
Hit requestMeta,
int connectionTimeout,
int readTimeout)
Deprecated.
Executes an HTTP request and gets the response.
|
protected org.apache.http.HttpResponse |
getResponse(URI uri,
Query query)
Deprecated.
Same as
getResponse(uri, null) . |
protected URI |
getURI(Query query,
Connection connection)
Deprecated.
Same a
getURI(query, offset, hits, null) . |
protected URI |
getURI(Query query,
Hit requestMeta,
Connection connection)
Deprecated.
Creates the URI for a query.
|
protected void |
logResponseLatency(long latency)
Deprecated.
|
Pong |
ping(Ping ping,
Connection connection)
Deprecated.
Pinging in HTTPBackend is done by creating a PING uri from http://host:port/path.
|
void |
shutdownConnectionManagers()
Deprecated.
Only for testing.
|
deconstruct, failed, fill, fill, getFirstConnection, getHasher, getMonitor, log, ping, robustSearch, search, search, search, shouldRetry, 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
protected static final String YCA_HTTP_HEADER
public static final String LOG_PATH
public static final String LOG_PORT
public static final String LOG_HOST
public static final String LOG_IP_ADDRESS
public static final String IP_ADDRESS_UNKNOWN
public static final String LOG_SCHEME
public static final String LOG_URI
public static final String LOG_PROXY_PORT
public static final String LOG_PROXY_HOST
public static final String LOG_PROXY_TYPE
public static final String LOG_STATUS
public static final String LOG_LATENCY_FINISH
public static final String LOG_LATENCY_START
public static final String LOG_LATENCY_CONNECT
public static final String LOG_QUERY_PARAM_PREFIX
public static final String LOG_HEADER_PREFIX
public static final String LOG_RESPONSE_HEADER_PREFIX
public static final String LOG_HITCOUNT
public static final String LOG_CONNECT_TIMEOUT_PREFIX
public static final String LOG_READ_TIMEOUT_PREFIX
protected final Logger log
protected boolean useCertificate
protected org.apache.http.HttpHost certificateProxy
public HTTPSearcher(com.yahoo.component.ComponentId componentId, List<Connection> connections, String path, com.yahoo.statistics.Statistics statistics)
public HTTPSearcher(com.yahoo.component.ComponentId componentId, List<Connection> connections, String path, com.yahoo.statistics.Statistics statistics, com.yahoo.jdisc.http.CertificateStore certificateStore)
public HTTPSearcher(com.yahoo.component.ComponentId componentId, List<Connection> connections, HTTPParameters parameters, com.yahoo.statistics.Statistics statistics)
@Inject public HTTPSearcher(com.yahoo.component.ComponentId componentId, List<Connection> connections, HTTPParameters parameters, com.yahoo.statistics.Statistics statistics, com.yahoo.jdisc.http.CertificateStore certificateStore)
componentId
- the id of this instanceconnections
- the connections to establish to the backend nodesparameters
- the http parameters to use. This object will be frozen if it isn't alreadypublic HTTPParameters getParameters()
public Map<String,String> getQueryMap(Query query)
getURI(com.yahoo.search.Query, com.yahoo.search.federation.http.Connection)
(from which this is called) is overridden.
This default implementation returns an empty LinkedHashMap.
protected URI getURI(Query query, Connection connection) throws MalformedURLException, URISyntaxException
getURI(query, offset, hits, null)
.MalformedURLException
URISyntaxException
getURI(Query, Hit, Connection)
protected URI getURI(Query query, Hit requestMeta, Connection connection) throws MalformedURLException, URISyntaxException
requestMeta
meta hit with the created URI HTTP properties.requestMeta
- a meta hit that holds logging information about this request (may be null
).MalformedURLException
URISyntaxException
protected String getPath()
protected URI getPingURI(Connection connection) throws MalformedURLException, URISyntaxException
protected String getPingPath()
protected void checkPing(org.apache.http.HttpResponse response, Pong pong)
response
- The response from the ping requestpong
- The pong result to return back to the calling method. This method
will add an error to the pong result (using addError) if the status of the HTTP response is 300 or above.public Pong ping(Ping ping, Connection connection)
ping
in class ClusterSearcher<Connection>
protected org.apache.http.HttpEntity getEntity(URI uri, Query query) throws IOException
getEntity(uri, null)
.uri
- resource to fetchquery
- the originating queryTimeoutException
- If query.timeLeft() equal to or lower than 0IOException
protected org.apache.http.HttpEntity getEntity(URI uri, Hit requestMeta, Query query) throws IOException
uri
- the request URI.requestMeta
- a meta hit that holds logging information about this request (may be null
).query
- the originating queryIOException
- Whenever HTTP status code is in the 300 or higher range.TimeoutException
- If query.timeLeft() equal to or lower than 0protected Hit createRequestMeta()
protected void cleanupHttpEntity(org.apache.http.HttpEntity entity)
protected org.apache.http.HttpResponse getResponse(URI uri, Query query) throws IOException
getResponse(uri, null)
.IOException
protected org.apache.http.HttpResponse getResponse(URI uri, Hit requestMeta, Query query) throws IOException
uri
- the request URI.requestMeta
- a meta hit that holds logging information about this request (may be null
).query
- the originating query, used to calculate timeoutsIOException
protected Map<String,String> getRequestHeaders(Query query, Hit requestMeta)
protected org.apache.http.HttpEntity getRequestEntity(Query query, Hit requestMeta)
Do return a repeatable entity if HTTP retry is active.
protected org.apache.http.HttpResponse getResponse(URI uri, Hit requestMeta, int connectionTimeout, int readTimeout) throws IOException
uri
- the request URI.requestMeta
- a meta hit that holds logging information about this request (may be null
).connectionTimeout
- how long to wait for getting a connectionreadTimeout
- timeout for reading HTTP dataIOException
protected org.apache.http.HttpResponse getResponse(URI uri, org.apache.http.HttpEntity reqEntity, Map<String,String> reqHeaders, Hit requestMeta, int connectionTimeout, int readTimeout) throws IOException
uri
- the request URI.requestMeta
- a meta hit that holds logging information about this request (may be null
).connectionTimeout
- how long to wait for getting a connectionreadTimeout
- timeout for reading HTTP dataIOException
protected void logResponseLatency(long latency)
protected org.apache.http.client.HttpClient createClient(org.apache.http.params.HttpParams params)
return new SearcherHttpClient(getConnectionManager(params), params);
protected org.apache.http.client.methods.HttpUriRequest createRequest(String method, URI uri)
return new HttpRequest(method,uri);
protected org.apache.http.client.methods.HttpUriRequest createRequest(String method, URI uri, org.apache.http.HttpEntity entity)
return new HttpRequest(method,uri);
protected org.apache.http.conn.ClientConnectionManager getConnectionManager(org.apache.http.params.HttpParams params)
protected ErrorMessage createMalformedUrlError(Query query, Exception e)
public void shutdownConnectionManagers()
Copyright © 2018. All rights reserved.