Skip to content

Druidry as a Client

Gagan Gupta edited this page Apr 2, 2018 · 1 revision

DruidJerseyClient uses Jersey behind the scenes as the name suggests. It maintains a pool of connection to the druid broker.

Druidry handles connection with Druid Broker, serializing POJO for the request and deserializing response to required POJO.

DruidConfiguration config =  DruidConfiguration
               .builder()
               .host("druid.io")
               .endpoint("druid/v2/")
               .build();

DruidClient client = new DruidJerseyClient(druidConfiguration)
try {
    client.connect();
    List<DruidResponse> responses = client.query(query, DruidResponse.class);
} finally {
    client.close();
}

Druidry also offers the flexibility to get the response as String.

String responseAsString = client.query(query);

Druidry asks for Gzipped response by default

Druid Configuration

DruidConfiguration supports these properties:

  • protocol: Druid Broker is accessible by which Protocol. Supports HTTP and HTTPS.
  • host: Address of Druid Broker instance.
  • port: Port at which broker is listening.
  • endpoint: Querying endpoint of druid broker.
  • concurrentConnectionsRequired: Number of connections required in a pool. Will not be considered if custom jersey config is passed.

Default values

  • protocol: HTTP
  • host: No default value
  • port: 8082 if protocol is HTTP, 8282 if protocol is HTTPS
  • endpoint: No default value
  • concurrentConnectionsRequired: 5

Config values can be overridden. Example:

DruidConfiguration configuration = DruidConfiguration
                .builder()
                .protocol(DruidQueryProtocol.HTTP)
                .host("localhost")
                .port(8080)
                .endpoint("druid/v2")
                .concurrentConnectionsRequired(8)
                .build();

Client can be created with Custom Jersey Config. Example:

DruidClient client = new DruidJerseyClient(druidConfiguration, customJerseyConfig);
Clone this wiki locally