Search in sources :

Example 1 with HttpClientConfig

use of com.facebook.airlift.http.client.HttpClientConfig in project presto by prestodb.

the class QueryStatsClientModuleProvider method getModule.

@Override
public Module getModule(Configuration configuration) {
    return new PrivateModule() {

        @Override
        protected void configure() {
            bind(ObjectMapper.class).toProvider(JsonObjectMapperProvider.class);
        }

        @Inject
        @Provides
        @Exposed
        QueryStatsClient getQueryStatsClient(ObjectMapper objectMapper, @Named("databases.presto.server_address") String serverAddress) {
            // @Singleton does not work due: https://github.com/prestodb/tempto/issues/94
            if (httpQueryStatsClient == null) {
                HttpClientConfig httpClientConfig = new HttpClientConfig();
                httpClientConfig.setKeyStorePath(configuration.getString("databases.presto.https_keystore_path").orElse(null));
                httpClientConfig.setKeyStorePassword(configuration.getString("databases.presto.https_keystore_password").orElse(null));
                httpQueryStatsClient = new HttpQueryStatsClient(new JettyHttpClient(httpClientConfig), objectMapper, URI.create(serverAddress));
            }
            return httpQueryStatsClient;
        }
    };
}
Also used : Named(javax.inject.Named) HttpClientConfig(com.facebook.airlift.http.client.HttpClientConfig) JettyHttpClient(com.facebook.airlift.http.client.jetty.JettyHttpClient) PrivateModule(com.google.inject.PrivateModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

HttpClientConfig (com.facebook.airlift.http.client.HttpClientConfig)1 JettyHttpClient (com.facebook.airlift.http.client.jetty.JettyHttpClient)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 PrivateModule (com.google.inject.PrivateModule)1 Named (javax.inject.Named)1