Search in sources :

Example 1 with TDClientBuilder

use of com.treasuredata.client.TDClientBuilder in project fluency by komamitsu.

the class TreasureDataSender method buildClient.

@VisibleForTesting
protected TDClient buildClient() {
    URI uri;
    try {
        uri = new URI(config.getEndpoint());
    } catch (URISyntaxException e) {
        throw new NonRetryableException(String.format("Invalid endpoint. %s", config.getEndpoint()), e);
    }
    String host = uri.getHost() != null ? uri.getHost() : config.getEndpoint();
    TDClientBuilder builder = new TDClientBuilder(false).setEndpoint(host).setApiKey(config.getApikey()).setRetryLimit(config.getRetryMax()).setRetryInitialIntervalMillis(config.getRetryIntervalMs()).setRetryMaxIntervalMillis(config.getMaxRetryIntervalMs()).setRetryMultiplier(config.getRetryFactor());
    if (uri.getScheme() != null && uri.getScheme().equals("http")) {
        builder.setUseSSL(false);
    }
    if (uri.getPort() > 0) {
        builder.setPort(uri.getPort());
    }
    return builder.build();
}
Also used : NonRetryableException(org.komamitsu.fluency.NonRetryableException) TDClientBuilder(com.treasuredata.client.TDClientBuilder) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 TDClientBuilder (com.treasuredata.client.TDClientBuilder)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 NonRetryableException (org.komamitsu.fluency.NonRetryableException)1