public class AsyncDruidWebServiceImpl extends Object implements DruidWebService
Modifier and Type | Field and Description |
---|---|
static Function<org.asynchttpclient.Response,com.fasterxml.jackson.databind.JsonNode> |
DEFAULT_JSON_NODE_BUILDER_STRATEGY
The default JSON builder puts only response body in the JSON response.
|
static String |
DRUID_QUERY_ALL_TIMER |
static String |
DRUID_QUERY_MAX_TIMER |
static String |
DRUID_QUERY_TIMER |
static String |
DRUID_SEGMENT_METADATA_TIMER |
static String |
DRUID_TIMER |
static String |
DRUID_WEIGHTED_QUERY_TIMER |
Constructor and Description |
---|
AsyncDruidWebServiceImpl(DruidServiceConfig config,
org.asynchttpclient.AsyncHttpClient asyncHttpClient,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Deprecated.
We now require a header supplier parameter.
Use
AsyncDruidWebServiceImpl(DruidServiceConfig, AsyncHttpClient, ObjectMapper, Supplier, Function) |
AsyncDruidWebServiceImpl(DruidServiceConfig config,
org.asynchttpclient.AsyncHttpClient asyncHttpClient,
com.fasterxml.jackson.databind.ObjectMapper mapper,
Supplier<Map<String,String>> headersToAppend)
IOC constructor.
|
AsyncDruidWebServiceImpl(DruidServiceConfig config,
org.asynchttpclient.AsyncHttpClient asyncHttpClient,
com.fasterxml.jackson.databind.ObjectMapper mapper,
Supplier<Map<String,String>> headersToAppend,
Function<org.asynchttpclient.Response,com.fasterxml.jackson.databind.JsonNode> jsonNodeBuilderStrategy)
IOC constructor.
|
AsyncDruidWebServiceImpl(DruidServiceConfig serviceConfig,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Deprecated.
We now require a header supplier parameter.
Use
AsyncDruidWebServiceImpl(DruidServiceConfig, AsyncHttpClient, ObjectMapper, Supplier, Function) |
AsyncDruidWebServiceImpl(DruidServiceConfig serviceConfig,
com.fasterxml.jackson.databind.ObjectMapper mapper,
Supplier<Map<String,String>> headersToAppend)
Friendly non-DI constructor useful for manual tests.
|
AsyncDruidWebServiceImpl(DruidServiceConfig serviceConfig,
com.fasterxml.jackson.databind.ObjectMapper mapper,
Supplier<Map<String,String>> headersToAppend,
Function<org.asynchttpclient.Response,com.fasterxml.jackson.databind.JsonNode> jsonNodeBuilderStrategy)
Friendly non-DI constructor useful for manual tests.
|
Modifier and Type | Method and Description |
---|---|
protected DruidServiceConfig |
getDruidServiceConfig() |
protected com.codahale.metrics.Meter |
getExceptionMeter() |
protected com.codahale.metrics.Meter |
getHttpErrorMeter() |
Future<org.asynchttpclient.Response> |
getJsonObject(SuccessCallback success,
HttpErrorCallback error,
FailureCallback failure,
String resourcePath)
Invokes GET on the druid broker with a callback expecting a JSON Object on success.
|
DruidServiceConfig |
getServiceConfig()
Returns the service configuration object for this web service.
|
Integer |
getTimeout()
Returns the timeout configured on this web service.
|
protected boolean |
hasError(javax.ws.rs.core.Response.Status status)
Return true if response status code indicates an error.
|
Future<org.asynchttpclient.Response> |
postDruidQuery(RequestContext context,
SuccessCallback success,
HttpErrorCallback error,
FailureCallback failure,
DruidQuery<?> druidQuery)
Serializes the provided query and invokes POST on the druid broker.
|
protected Future<org.asynchttpclient.Response> |
sendRequest(SuccessCallback success,
HttpErrorCallback error,
FailureCallback failure,
org.asynchttpclient.BoundRequestBuilder requestBuilder,
String timerName,
AtomicLong outstanding)
Serializes the provided query and invokes a request on the druid broker.
|
public static final String DRUID_TIMER
public static final String DRUID_QUERY_TIMER
public static final String DRUID_QUERY_ALL_TIMER
public static final String DRUID_QUERY_MAX_TIMER
public static final String DRUID_WEIGHTED_QUERY_TIMER
public static final String DRUID_SEGMENT_METADATA_TIMER
public static final Function<org.asynchttpclient.Response,com.fasterxml.jackson.databind.JsonNode> DEFAULT_JSON_NODE_BUILDER_STRATEGY
@Deprecated public AsyncDruidWebServiceImpl(DruidServiceConfig serviceConfig, com.fasterxml.jackson.databind.ObjectMapper mapper)
AsyncDruidWebServiceImpl(DruidServiceConfig, AsyncHttpClient, ObjectMapper, Supplier, Function)
serviceConfig
- Configuration for the Druid Servicemapper
- A shared jackson object mapper resource@Deprecated public AsyncDruidWebServiceImpl(DruidServiceConfig config, org.asynchttpclient.AsyncHttpClient asyncHttpClient, com.fasterxml.jackson.databind.ObjectMapper mapper)
AsyncDruidWebServiceImpl(DruidServiceConfig, AsyncHttpClient, ObjectMapper, Supplier, Function)
config
- the configuration for this druid serviceasyncHttpClient
- the HTTP clientmapper
- A shared jackson object mapper resourcepublic AsyncDruidWebServiceImpl(DruidServiceConfig serviceConfig, com.fasterxml.jackson.databind.ObjectMapper mapper, Supplier<Map<String,String>> headersToAppend)
This constructor uses default JSON builder, which only uses response body to build the JSON response.
serviceConfig
- Configuration for the Druid Servicemapper
- A shared jackson object mapper resourceheadersToAppend
- Supplier for map of headers for Druid requestspublic AsyncDruidWebServiceImpl(DruidServiceConfig serviceConfig, com.fasterxml.jackson.databind.ObjectMapper mapper, Supplier<Map<String,String>> headersToAppend, Function<org.asynchttpclient.Response,com.fasterxml.jackson.databind.JsonNode> jsonNodeBuilderStrategy)
serviceConfig
- Configuration for the Druid Servicemapper
- A shared jackson object mapper resourceheadersToAppend
- Supplier for map of headers for Druid requestsjsonNodeBuilderStrategy
- A function to build JSON nodes from the responsepublic AsyncDruidWebServiceImpl(DruidServiceConfig config, org.asynchttpclient.AsyncHttpClient asyncHttpClient, com.fasterxml.jackson.databind.ObjectMapper mapper, Supplier<Map<String,String>> headersToAppend)
This constructor uses default JSON builder, which only uses response body to build the JSON response.
config
- the configuration for this druid serviceasyncHttpClient
- the HTTP clientmapper
- A shared jackson object mapper resourceheadersToAppend
- Supplier for map of headers for Druid requestspublic AsyncDruidWebServiceImpl(DruidServiceConfig config, org.asynchttpclient.AsyncHttpClient asyncHttpClient, com.fasterxml.jackson.databind.ObjectMapper mapper, Supplier<Map<String,String>> headersToAppend, Function<org.asynchttpclient.Response,com.fasterxml.jackson.databind.JsonNode> jsonNodeBuilderStrategy)
config
- the configuration for this druid serviceasyncHttpClient
- the HTTP clientmapper
- A shared jackson object mapper resourceheadersToAppend
- Supplier for map of headers for Druid requestsjsonNodeBuilderStrategy
- A function to build JSON nodes from the responseprotected Future<org.asynchttpclient.Response> sendRequest(SuccessCallback success, HttpErrorCallback error, FailureCallback failure, org.asynchttpclient.BoundRequestBuilder requestBuilder, String timerName, AtomicLong outstanding)
success
- callback for handling successful requests.error
- callback for handling http errors.failure
- callback for handling exception failures.requestBuilder
- The bound request builder for the request to be sent.timerName
- The name that distinguishes this request as part of a druid query or segment metadata requestoutstanding
- The counter that keeps track of the outstanding (in flight) requests for the top level querypublic Future<org.asynchttpclient.Response> getJsonObject(SuccessCallback success, HttpErrorCallback error, FailureCallback failure, String resourcePath)
DruidWebService
getJsonObject
in interface DruidWebService
success
- callback for handling successful requests.error
- callback for handling http errors.failure
- callback for handling exception failures.resourcePath
- The url suffix for the remote resource. The prefix should be the shared Broker endpoint url.public Future<org.asynchttpclient.Response> postDruidQuery(RequestContext context, SuccessCallback success, HttpErrorCallback error, FailureCallback failure, DruidQuery<?> druidQuery)
DruidWebService
postDruidQuery
in interface DruidWebService
context
- The context for the Request.success
- callback for handling successful requests.error
- callback for handling http errors.failure
- callback for handling exception failures.druidQuery
- The druid query object to serialize.public Integer getTimeout()
DruidWebService
getTimeout
in interface DruidWebService
public DruidServiceConfig getServiceConfig()
DruidWebService
getServiceConfig
in interface DruidWebService
protected com.codahale.metrics.Meter getHttpErrorMeter()
protected com.codahale.metrics.Meter getExceptionMeter()
protected DruidServiceConfig getDruidServiceConfig()
protected boolean hasError(javax.ws.rs.core.Response.Status status)
If etag cache is enabled, no error on 200 OK and 304 NOT-MODIFIED. Otherwise, no error only on 200 OK.
status
- The Status object that contains status code to be checkedCopyright © 2016–2018 Yahoo! Inc.. All rights reserved.